/* =========================================================
   RealityIDEAS — Base design tokens & components
   ========================================================= */
:root {
  --bg: #f7f6f2;
  --bg-elev: #ffffff;
  --bg-sunken: #efede6;
  --ink: #17151f;
  --ink-2: #4a4757;
  --ink-3: #8a8797;
  --line: #e4e1d8;
  --line-strong: #d3cfc3;

  --brand: #5b3df5;
  --brand-ink: #ffffff;
  --brand-soft: #ece8ff;
  --brand-2: #ff8a3d;          /* "spark" — ideas */
  --brand-2-soft: #fff0e5;

  --ok: #13a36e;   --ok-soft: #e2f6ee;
  --warn: #d98a00; --warn-soft: #fff4dc;
  --bad: #e0434b;  --bad-soft: #fde8e9;
  --info: #2b7fff; --info-soft: #e5efff;

  --radius-s: 8px;
  --radius: 14px;
  --radius-l: 22px;
  --shadow-s: 0 1px 2px rgba(23, 21, 31, .06);
  --shadow: 0 4px 18px rgba(23, 21, 31, .07), 0 1px 3px rgba(23, 21, 31, .05);
  --shadow-l: 0 20px 50px rgba(23, 21, 31, .14);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Instrument Serif", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111017; --bg-elev: #1a1922; --bg-sunken: #0c0b11;
    --ink: #f2f0fa; --ink-2: #bdb9cc; --ink-3: #7f7b90;
    --line: #2a2835; --line-strong: #3a3747;
    --brand: #8b74ff; --brand-soft: #262046;
    --brand-2: #ff9e5c; --brand-2-soft: #33231a;
    --ok-soft: #0f2a20; --warn-soft: #2e2410; --bad-soft: #321619; --info-soft: #14223a;
    --shadow: 0 4px 18px rgba(0,0,0,.35); --shadow-l: 0 20px 50px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --bg: #111017; --bg-elev: #1a1922; --bg-sunken: #0c0b11;
  --ink: #f2f0fa; --ink-2: #bdb9cc; --ink-3: #7f7b90;
  --line: #2a2835; --line-strong: #3a3747;
  --brand: #8b74ff; --brand-soft: #262046;
  --brand-2: #ff9e5c; --brand-2-soft: #33231a;
  --ok-soft: #0f2a20; --warn-soft: #2e2410; --bad-soft: #321619; --info-soft: #14223a;
  --shadow: 0 4px 18px rgba(0,0,0,.35); --shadow-l: 0 20px 50px rgba(0,0,0,.5);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; letter-spacing: -.02em; }
p { margin: 0; }
.serif { font-family: var(--font-display); font-weight: 400; letter-spacing: -.01em; }
.muted { color: var(--ink-2); }
.subtle { color: var(--ink-3); }
.mono { font-family: var(--font-mono); }
.hidden { display: none !important; }

/* Lucide icons sizing */
[data-lucide], .lucide { width: 18px; height: 18px; stroke-width: 1.9; flex-shrink: 0; }

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 10px; position: relative;
  background: linear-gradient(135deg, var(--brand), #9b5cff 60%, var(--brand-2));
  display: grid; place-items: center; color: #fff; box-shadow: 0 4px 12px rgba(91,61,245,.35);
}
.logo-mark::after {
  content: ""; width: 10px; height: 10px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,.35);
}
.logo b { color: var(--brand); font-weight: 800; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: transform .12s ease, background .15s, box-shadow .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 6px 16px rgba(91,61,245,.28); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-dark { background: var(--ink); color: var(--bg); }
.btn-ghost { background: transparent; border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--bg-sunken); }
.btn-soft { background: var(--brand-soft); color: var(--brand); }
.btn-soft:hover { filter: brightness(.97); }
.btn-lg { height: 50px; padding: 0 24px; font-size: 15px; border-radius: 12px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }

/* ---------- Badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px;
  border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg-sunken); color: var(--ink-2);
}
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.badge.spark { background: var(--brand-2-soft); color: var(--brand-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge [data-lucide], .badge .lucide { width: 13px; height: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: currentColor; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--bg-elev);
  font-size: 13px; font-weight: 500; cursor: pointer; color: var(--ink-2);
}
.chip:hover { border-color: var(--ink-3); }
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-s);
}
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 16px 20px; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--bg-elev); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.input-icon { position: relative; }
.input-icon > [data-lucide], .input-icon > .lucide { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.input-icon .input { padding-left: 38px; }

/* ---------- Avatars ---------- */
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
  background: var(--brand); border: 2px solid var(--bg-elev);
}
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }
.avatar.xl { width: 72px; height: 72px; font-size: 22px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar + .avatar { margin-left: -8px; }
.av-1 { background: #5b3df5; } .av-2 { background: #ff8a3d; } .av-3 { background: #13a36e; }
.av-4 { background: #2b7fff; } .av-5 { background: #e0434b; } .av-6 { background: #b04de0; }

/* ---------- Progress ---------- */
.progress { height: 8px; border-radius: 99px; background: var(--bg-sunken); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.progress.ok > span { background: var(--ok); }
.progress.warn > span { background: var(--warn); }
.progress.bad > span { background: var(--bad); }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 300; display: grid; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow-l); font-size: 14px; font-weight: 500;
  animation: toastIn .25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200; background: rgba(12, 11, 17, .5); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-backdrop.open { display: flex; animation: fade .2s ease; }
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--bg-elev); border-radius: var(--radius-l); box-shadow: var(--shadow-l); border: 1px solid var(--line);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 22px; display: grid; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }

/* ---------- Utility grid ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: grid; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
