/* Second Brain OS — Rewrite Minds
   Light, minimal, Notion-adjacent. Mobile-first. */

:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --surface-2: #f7f7f5;
  --surface-3: #f1f1ee;
  --border: #e9e9e6;
  --border-strong: #dcdcd7;
  --text: #37352f;
  --text-2: #5b5a55;
  --text-3: #6e6d68;
  --accent: #2f5d50;
  --accent-soft: #e9f1ed;
  --accent-ink: #ffffff;
  --danger: #b4342a;
  --danger-soft: #fdeceb;
  --warn: #a4720f;
  --warn-soft: #fdf4e3;
  --ok: #2c7a51;
  --shadow-sm: 0 1px 2px rgba(20, 20, 18, .05);
  --shadow: 0 1px 2px rgba(20, 20, 18, .05), 0 6px 18px rgba(20, 20, 18, .06);
  --shadow-lg: 0 18px 50px rgba(20, 20, 18, .16), 0 2px 8px rgba(20, 20, 18, .06);
  --shadow-float: 0 2px 6px rgba(20,20,18,.05), 0 14px 34px rgba(20,20,18,.10);
  --r-sm: 6px;
  --r: 9px;
  --r-lg: 14px;
  --r-xl: 20px;
  --sidebar-w: 238px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* motion */
  --ease: cubic-bezier(.32, .72, 0, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.42, .64, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --dur-1: 110ms;
  --dur-2: 200ms;
  --dur-3: 340ms;

  /* material */
  --glass: rgba(255, 255, 255, .90);
  --glass-brd: rgba(255, 255, 255, .85);
  --glass-dark: rgba(30, 29, 27, .55);
  --ring: 0 0 0 3px var(--accent-soft);
  --topbar-bg: rgba(251, 251, 250, .86);
  --bottomnav-bg: rgba(251, 251, 250, .82);
  --overlay-bg: rgba(28, 27, 25, .30);
}

/* ---------------------------------------------------------------- dark theme variables */

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141413;
  --surface: #1e1e1c;
  --surface-2: #262623;
  --surface-3: #2e2d29;
  --border: #33322d;
  --border-strong: #44423c;
  --text: #edece8;
  --text-2: #a8a7a1;
  --text-3: #96958f;
  --glass: rgba(30, 30, 28, 0.88);
  --glass-brd: rgba(60, 58, 54, 0.6);
  --glass-dark: rgba(15, 15, 14, 0.8);
  --accent: #3e8470;
  --accent-soft: rgba(62, 132, 112, 0.22);
  --accent-ink: #0b1210;
  --danger: #e05d52;
  --danger-soft: rgba(224, 93, 82, 0.2);
  --warn: #e5a43b;
  --warn-soft: rgba(229, 164, 59, 0.2);
  --ok: #48b87d;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow: 0 2px 5px rgba(0, 0, 0, .45), 0 8px 24px rgba(0, 0, 0, .4);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, .65), 0 4px 12px rgba(0, 0, 0, .45);
  --shadow-float: 0 4px 12px rgba(0, 0, 0, .4), 0 16px 36px rgba(0, 0, 0, .55);
  --ring: 0 0 0 3px rgba(62, 132, 112, 0.35);
  --topbar-bg: rgba(20, 20, 19, 0.88);
  --bottomnav-bg: rgba(20, 20, 19, 0.88);
  --overlay-bg: rgba(0, 0, 0, 0.65);
}

@media all {
  .theme-dark,
  .theme-dark {
    color-scheme: dark;
    --bg: #141413;
    --surface: #1e1e1c;
    --surface-2: #262623;
    --surface-3: #2e2d29;
    --border: #33322d;
    --border-strong: #44423c;
    --text: #edece8;
    --text-2: #a8a7a1;
    --text-3: #96958f;
    --glass: rgba(30, 30, 28, 0.88);
    --glass-brd: rgba(60, 58, 54, 0.6);
    --glass-dark: rgba(15, 15, 14, 0.8);
    --accent: #3e8470;
    --accent-soft: rgba(62, 132, 112, 0.22);
    --accent-ink: #0b1210;
    --danger: #e05d52;
    --danger-soft: rgba(224, 93, 82, 0.2);
    --warn: #e5a43b;
    --warn-soft: rgba(229, 164, 59, 0.2);
    --ok: #48b87d;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow: 0 2px 5px rgba(0, 0, 0, .45), 0 8px 24px rgba(0, 0, 0, .4);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, .65), 0 4px 12px rgba(0, 0, 0, .45);
    --shadow-float: 0 4px 12px rgba(0, 0, 0, .4), 0 16px 36px rgba(0, 0, 0, .55);
    --ring: 0 0 0 3px rgba(62, 132, 112, 0.35);
    --topbar-bg: rgba(20, 20, 19, 0.88);
    --bottomnav-bg: rgba(20, 20, 19, 0.88);
    --overlay-bg: rgba(0, 0, 0, 0.65);
  }
}

[data-density="compact"] { --row-pad: 7px 10px; --gap: 12px; }
:root { --row-pad: 10px 12px; --gap: 18px; }

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 620px at 6% -12%, rgba(47, 93, 80, .085), transparent 62%),
    radial-gradient(820px 520px at 102% -6%, rgba(226, 146, 100, .10), transparent 58%),
    radial-gradient(980px 720px at 88% 108%, rgba(86, 116, 168, .07), transparent 62%);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

/* Inverted ambient glow for dark mode */
[data-theme="dark"] body,
body[data-theme="dark"] {
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 620px at 6% -12%, rgba(62, 132, 112, .14), transparent 62%),
    radial-gradient(820px 520px at 102% -6%, rgba(226, 146, 100, .10), transparent 58%),
    radial-gradient(980px 720px at 88% 108%, rgba(86, 116, 168, .11), transparent 62%);
}

@media all {
  .theme-dark body,
  .theme-dark body {
    background-color: var(--bg);
    background-image:
      radial-gradient(900px 620px at 6% -12%, rgba(62, 132, 112, .14), transparent 62%),
      radial-gradient(820px 520px at 102% -6%, rgba(226, 146, 100, .10), transparent 58%),
      radial-gradient(980px 720px at 88% 108%, rgba(86, 116, 168, .11), transparent 62%);
  }
}

::selection { background: var(--accent-soft); color: var(--text); }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.015em; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14.5px; }
p { margin: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, textarea, select { font: inherit; color: inherit; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--surface); padding: 10px 14px; border-radius: var(--r);
}
.skip:focus { left: 12px; top: 12px; }

/* Base icon box. Every SVG in this app inherits it; components override the size. */
.ico {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  display: block;
  stroke-width: 1.7;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
/* Accent-filled controls need a ring that can't disappear into their own fill. */
.btn-primary:focus-visible,
.onb-next:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

/* ---------------------------------------------------------------- shell */

#app { display: flex; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  padding: 14px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  z-index: 40;
}

.brand {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px 14px; margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
/* Brand mark: chrome brain on a graphite tile (inline SVG in app.js). */
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  display: grid; place-items: center; flex: 0 0 auto;
  background: radial-gradient(115% 115% at 28% 12%, #2b343a 0%, #151b20 48%, #090d10 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .12),
    inset 0 -9px 14px -11px rgba(255, 156, 120, .85),
    0 6px 16px -10px rgba(0, 0, 0, .75);
}
.brand-mark svg { width: 76%; height: 76%; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-size: 13px; font-weight: 600; letter-spacing: -.01em; }
.brand-sub { font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; }

.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-3); font-weight: 600;
  padding: 14px 8px 5px;
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  cursor: pointer; border: 0; background: transparent; text-align: left; width: 100%;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease-out);
  position: relative;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item:active { transform: scale(.985); }
.nav-item[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.nav-item[aria-current="page"]::before {
  content: ''; position: absolute; left: 0; top: 50%; width: 3px; height: 16px;
  margin-top: -8px; border-radius: 0 3px 3px 0; background: var(--accent);
  animation: nav-bar .3s var(--ease-spring);
}
@keyframes nav-bar { from { height: 2px; opacity: 0; } }
.nav-item .ico { width: 16px; height: 16px; flex: 0 0 16px; opacity: .75; transition: transform var(--dur-2) var(--ease-spring); }
.nav-item:hover .ico { transform: scale(1.08); }
.nav-item[aria-current="page"] .ico { opacity: 1; color: var(--accent); }
.nav-item .count {
  margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums;
  color: var(--text-3); background: var(--surface-3); border-radius: 20px; padding: 1px 7px;
}
.nav-item[aria-current="page"] .count { background: var(--accent-soft); color: var(--accent); }

.sidebar-foot { margin-top: auto; padding: 12px 4px 2px; border-top: 1px solid var(--border); }
.storage-note { font-size: 10.5px; color: var(--text-3); padding: 6px 8px; line-height: 1.4; }
.storage-note b { color: var(--text-2); font-weight: 600; }

/* ---------------------------------------------------------------- main */

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 26px;
  background: var(--topbar-bg, rgba(251, 251, 250, .86));
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  min-height: 54px;
}
.topbar-title { font-size: 14px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-sub { font-size: 12px; color: var(--text-3); margin-left: 9px; font-weight: 400; letter-spacing: 0; }
.topbar-spacer { flex: 1 1 auto; }

.menu-btn {
  display: none; background: transparent; border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); width: 34px; height: 34px; place-items: center; cursor: pointer;
}

.searchbar {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r); padding: 0 9px; height: 32px;
  min-width: 210px; color: var(--text-3);
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.searchbar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.searchbar input { border: 0; background: transparent; outline: 0; width: 100%; font-size: 13px; color: var(--text); }
.searchbar input::placeholder { color: var(--text-3); }
.kbd {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-3);
  border: 1px solid var(--border-strong); border-radius: 4px;
  padding: 1px 5px; background: var(--surface-2); white-space: nowrap;
}

.content {
  flex: 1 1 auto;
  width: 100%; max-width: 900px;
  margin: 0 auto;
  padding: 28px 26px 90px;
}

/* ---------------------------------------------------------------- primitives */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 33px; padding: 0 12px;
  border-radius: var(--r-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease),
              transform var(--dur-1) var(--ease-spring), box-shadow var(--dur-2) var(--ease-out);
  will-change: transform;
  position: relative;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.965); }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600;
  box-shadow: 0 1px 2px rgba(20, 20, 18, .12), 0 6px 16px -8px var(--accent);
}
.btn-primary:hover { background: var(--accent); filter: brightness(1.06); box-shadow: 0 2px 4px rgba(20,20,18,.14), 0 10px 22px -10px var(--accent); }
.btn-secondary,
.banner .btn,
.warn-banner .btn {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
  font-weight: 600;
  box-shadow: none;
}
.btn-secondary:hover,
.banner .btn:hover,
.warn-banner .btn:hover {
  background: var(--accent);
  color: var(--accent-ink);
  filter: none;
}
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { color: var(--danger); border-color: #eccac7; background: var(--danger-soft); }
.btn-danger:hover { background: #fbe0de; }
.btn-sm { height: 27px; padding: 0 9px; font-size: 12px; }
.btn-icon { width: 33px; padding: 0; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 16px 18px; }

.page-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 22px; }
.page-head-text { flex: 1 1 auto; min-width: 0; }
.page-title { font-size: 21px; letter-spacing: -.02em; }
.page-sub { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex: 0 0 auto; }

.section { margin-bottom: 26px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); }
.section-line { flex: 1 1 auto; height: 1px; background: var(--border); }

.empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: 26px 22px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  background: var(--surface-2);
}
.empty b { display: block; color: var(--text); font-size: 14px; margin-bottom: 4px; font-weight: 600; }

/* ---------------------------------------------------------------- capture */

.capture {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 4px 4px 4px 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.capture:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.capture input { flex: 1 1 auto; border: 0; outline: 0; background: transparent; font-size: 14.5px; padding: 10px 0; color: var(--text); }
.capture input::placeholder { color: var(--text-3); }
.capture-hint { display: flex; gap: 6px; align-items: center; padding-right: 4px; }
.capture .btn,
.capture .btn-primary,
.capture button[type="submit"] {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
  font-weight: 600;
  box-shadow: none;
}
.capture .btn:hover,
.capture .btn-primary:hover,
.capture button[type="submit"]:hover {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 1px 3px rgba(20, 20, 18, .12);
  filter: none;
}
.capture .btn:active,
.capture .btn-primary:active,
.capture button[type="submit"]:active {
  transform: scale(.96);
}

/* ---------------------------------------------------------------- stat grid */

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px 14px;
}
.stat-num { font-size: 22px; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; margin-top: 3px; font-weight: 600; }
.stat.hot .stat-num { color: var(--accent); }
.stat[role="button"], button.stat {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  display: block;
  width: 100%;
}
.stat[role="button"]:hover, button.stat:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stat[role="button"]:active, button.stat:active {
  transform: translateY(0) scale(.985);
}
.stat[role="button"]:focus-visible, button.stat:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- rows */

.rows { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: var(--row-pad);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  transition: background var(--dur-2) var(--ease), opacity var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease-out), transform var(--dur-1) var(--ease-out);
  position: relative;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row:active { transform: scale(.997); }
.row-main { flex: 1 1 auto; min-width: 0; }
.row-title {
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
  transition: color var(--dur-2) var(--ease), opacity var(--dur-2) var(--ease), text-decoration-color var(--dur-2) var(--ease);
}
.row-meta {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 3px; font-size: 11.5px; color: var(--text-3);
  transition: opacity var(--dur-2) var(--ease);
}
.row-actions { display: flex; gap: 2px; opacity: 0; transition: opacity var(--dur-1) var(--ease); flex: 0 0 auto; }
.row:hover .row-actions, .row:focus-within .row-actions { opacity: 1; }
.row.done {
  opacity: .72;
}
.row.done:hover {
  opacity: 1;
}
.row.done .row-title {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  text-decoration-color: var(--text-3);
  color: var(--text-3);
}
.row.done .row-meta {
  opacity: .7;
}

@keyframes row-complete {
  0%   { background: var(--accent-soft); transform: scale(1.006); }
  50%  { background: var(--accent-soft); }
  100% { background: var(--surface); transform: scale(1); }
}
.row.just-done { animation: row-complete .75s var(--ease-out); }

@keyframes row-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

@media (hover: none) { .row-actions { opacity: 1; } }

.check {
  flex: 0 0 auto; width: 17px; height: 17px; margin-top: 2px;
  border: 1.5px solid var(--border-strong); border-radius: 5px;
  background: var(--surface); cursor: pointer; padding: 0;
  display: grid; place-items: center; color: transparent;
  transition: background var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out), transform var(--dur-1) var(--ease-spring);
  position: relative;
}
.check:hover { border-color: var(--accent); transform: scale(1.08); }
.check:active { transform: scale(.9); }
.check svg { width: 11px; height: 11px; }
.check svg path { stroke-dasharray: 22; stroke-dashoffset: 22; transition: stroke-dashoffset var(--dur-2) var(--ease-out) 40ms; }
.row.done .check, .check[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.row.done .check svg path, .check[aria-checked="true"] svg path { stroke-dashoffset: 0; }

@keyframes check-bounce {
  0%   { transform: scale(1); }
  28%  { transform: scale(0.8); }
  56%  { transform: scale(1.26); }
  78%  { transform: scale(0.94); }
  100% { transform: scale(1); }
}
.row.done .check,
.check[aria-checked="true"],
.check.pop {
  animation: check-bounce .36s var(--ease-spring);
}

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
  padding: 1.5px 7px; border-radius: 20px;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.p1 .dot { background: var(--danger); }
.p2 .dot { background: var(--warn); }
.p3 .dot { background: var(--text-3); }

/* ---------------------------------------------------------------- tabs */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: transparent; color: var(--text-3);
  font-size: 13px; font-weight: 500; padding: 8px 11px 9px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }
.tab .n { font-size: 11px; color: var(--text-3); margin-left: 4px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- projects */

.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }

.project-card { padding: 14px 15px; cursor: pointer; transition: box-shadow .14s var(--ease), transform .1s var(--ease); }
.project-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.project-top { display: flex; align-items: flex-start; gap: 8px; }
.project-name { font-size: 14px; font-weight: 600; flex: 1 1 auto; }
.project-outcome { font-size: 12px; color: var(--text-3); margin-top: 3px; line-height: 1.4; }
.progress { height: 4px; border-radius: 4px; background: var(--surface-3); margin-top: 11px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s var(--ease); }
@keyframes bar-grow { from { width: 0; } }
.content.enter .progress span { animation: bar-grow .8s var(--ease-out) both; animation-delay: .18s; }
.project-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 11.5px; color: var(--text-3); }

/* ---------------------------------------------------------------- notes */

.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.note-card { padding: 13px 14px; cursor: pointer; transition: box-shadow .14s var(--ease), transform .1s var(--ease); min-height: 104px; display: flex; flex-direction: column; }
.note-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.note-title { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.note-body { font-size: 12.5px; color: var(--text-2); line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.note-foot { margin-top: auto; padding-top: 9px; font-size: 10.5px; color: var(--text-3); display: flex; gap: 5px; flex-wrap: wrap; }

.editor-title {
  width: 100%; border: 0; background: transparent; outline: 0;
  font-size: 26px; font-weight: 600; letter-spacing: -.025em; padding: 0;
  margin-bottom: 12px; color: var(--text);
}
.editor-title::placeholder { color: var(--text-3); }
.editor-body {
  width: 100%; border: 0; background: transparent; outline: 0; resize: none;
  font-size: 15px; line-height: 1.7; min-height: 52vh; color: var(--text);
  font-family: var(--font);
}
.editor-body::placeholder { color: var(--text-3); }
.editor-meta { display: flex; gap: 8px; align-items: center; padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-3); flex-wrap: wrap; }

.tag-input { border: 0; background: var(--surface-2); border-radius: 20px; padding: 3px 9px; font-size: 11.5px; outline: 0; width: 110px; color: var(--text-2); }

/* ---------------------------------------------------------------- journal */

.journal-entry { padding: 15px 17px; margin-bottom: 12px; }
.journal-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.journal-date { font-size: 12.5px; font-weight: 600; }
.journal-body { font-size: 13.5px; line-height: 1.65; color: var(--text-2); white-space: pre-wrap; }
.mood { display: flex; gap: 5px; }
.mood-btn {
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border-strong);
  background: var(--surface); cursor: pointer; font-size: 14px; line-height: 1;
  display: grid; place-items: center; transition: all .12s var(--ease); padding: 0;
}
.mood-btn:hover { border-color: var(--accent); }
.mood-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); transform: scale(1.06); }

/* ---------------------------------------------------------------- review */

.review-step { padding: 20px 22px; }
.review-q { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.review-help { font-size: 12.5px; color: var(--text-3); margin-bottom: 12px; }
.review-input {
  width: 100%; border: 1px solid var(--border-strong); border-radius: var(--r);
  padding: 10px 12px; font-size: 14px; background: var(--surface); outline: 0;
  min-height: 96px; resize: vertical; line-height: 1.6;
}
.review-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.review-nav { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.steps { display: flex; gap: 5px; margin-bottom: 18px; }
.step-dot { flex: 1 1 0; height: 3px; border-radius: 3px; background: var(--surface-3); transition: background .2s var(--ease); }
.step-dot.on { background: var(--accent); }

/* ---------------------------------------------------------------- modal */

.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: var(--overlay-bg, rgba(28, 27, 25, .30));
  backdrop-filter: blur(8px) saturate(130%);
  -webkit-backdrop-filter: blur(8px) saturate(130%);
  display: grid; place-items: center;
  padding: 18px;
  animation: fade var(--dur-2) var(--ease-out);
  overscroll-behavior: contain;
}
.overlay.closing { animation: fade-out var(--dur-2) var(--ease) forwards; }
.overlay.closing .modal { animation: pop-out var(--dur-2) var(--ease) forwards; }

@keyframes fade { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop-out { to { opacity: 0; transform: translateY(6px) scale(.985); } }
@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
}
@keyframes sheet-up {
  from { opacity: 0; transform: translateY(28px); }
}

.modal {
  width: 100%; max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--glass-brd);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  animation: pop var(--dur-3) var(--ease-spring);
  max-height: calc(100dvh - 36px);
  display: flex; flex-direction: column;
  overflow: hidden;
  will-change: transform, opacity;
}
.modal-wide { max-width: 620px; }
.modal-head { padding: 18px 20px 0; }
.modal-title { font-size: 16px; font-weight: 600; letter-spacing: -.015em; }
.modal-sub { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.modal-body { padding: 14px 20px; overflow-y: auto; }
.modal-foot { padding: 12px 20px 16px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--border); background: var(--surface-2); }

.field { margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 11.5px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .05em; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding: 8px 10px; font-size: 13.5px; background: var(--surface); outline: 0;
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { min-height: 74px; resize: vertical; line-height: 1.55; }
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1 1 0; min-width: 0; }

/* ---------------------------------------------------------------- palette (legacy + modern) */

.palette {
  max-width: 560px; align-self: start; margin-top: 8vh;
  background: var(--glass);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--glass-brd);
  box-shadow: 0 24px 60px -12px rgba(20, 20, 18, .28), 0 0 0 1px rgba(20,20,18,.04);
}
.palette.closing { animation: pop-out var(--dur-2) var(--ease) forwards; }
.palette-input {
  width: 100%; border: 0; border-bottom: 1px solid var(--border); outline: 0;
  padding: 17px 20px; font-size: 15.5px; background: transparent; color: var(--text);
}
.palette-input::placeholder { color: var(--text-3); }
.palette-list { overflow-y: auto; max-height: 52vh; padding: 6px; }
.palette-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border: 0; background: transparent; border-radius: var(--r-sm);
  cursor: pointer; text-align: left; font-size: 13.5px; color: var(--text-2);
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease-out);
}
.palette-item:hover, .palette-item.sel { background: var(--accent-soft); color: var(--text); }
.palette-item.sel { transform: translateX(2px); }
.palette-item .ico { opacity: .65; width: 15px; height: 15px; }
.palette-item .hint { margin-left: auto; font-size: 10.5px; color: var(--text-3); }
.palette-empty { padding: 20px; text-align: center; color: var(--text-3); font-size: 13px; }

/* Modern Command Palette */
.cmd-palette-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: start center;
  padding: clamp(32px, 10vh, 120px) 16px 24px;
  background: var(--overlay-bg, rgba(20, 20, 18, 0.42));
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  animation: cmd-fade-in 180ms cubic-bezier(.16, 1, .3, 1) both;
  overscroll-behavior: contain;
}
.cmd-palette-backdrop.is-closing {
  animation: cmd-fade-out 140ms var(--ease) forwards;
}

.cmd-palette-modal {
  position: relative;
  width: 100%;
  max-width: 580px;
  background: var(--glass);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--glass-brd);
  border-radius: var(--r-xl);
  box-shadow: 0 24px 64px -12px rgba(20, 20, 18, .32), 0 2px 8px rgba(20, 20, 18, .06), 0 0 0 1px var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: cmd-pop-in 240ms cubic-bezier(.34, 1.36, .64, 1) both;
  will-change: transform, opacity;
}
.cmd-palette-backdrop.is-closing .cmd-palette-modal {
  animation: cmd-pop-out 140ms var(--ease) forwards;
}

.cmd-palette-header {
  position: relative;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.cmd-palette-header .ico {
  position: absolute;
  left: 16px;
  color: var(--text-3);
  pointer-events: none;
}

.cmd-palette-input {
  width: 100%;
  height: 52px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  padding: 0 18px 0 44px;
  font-size: 15px;
  color: var(--text);
  outline: 0;
  line-height: 52px;
}
.cmd-palette-modal > .cmd-palette-input:first-child {
  padding-left: 18px;
}
.cmd-palette-input::placeholder {
  color: var(--text-3);
}

.cmd-palette-list {
  max-height: clamp(240px, 48vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cmd-palette-group-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 8px 10px 4px;
}

.cmd-palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
  color: var(--text-2);
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease-out);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.cmd-palette-item .ico {
  width: 16px;
  height: 16px;
  color: var(--text-3);
  flex-shrink: 0;
  transition: color var(--dur-1) var(--ease);
}
.cmd-palette-item-text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd-palette-item:hover,
.cmd-palette-item.is-selected,
.cmd-palette-item[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--text);
  transform: translateX(2px);
}
.cmd-palette-item:hover .ico,
.cmd-palette-item.is-selected .ico,
.cmd-palette-item[aria-selected="true"] .ico {
  color: var(--accent);
}

.cmd-palette-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 1.5px 6px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--text-3);
  flex-shrink: 0;
  transition: all var(--dur-1) var(--ease);
}
.cmd-palette-item.is-selected .cmd-palette-badge,
.cmd-palette-item:hover .cmd-palette-badge {
  background: rgba(0, 0, 0, .07);
  color: var(--text-2);
}

.cmd-palette-shortcut {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--surface-2);
  white-space: nowrap;
  flex-shrink: 0;
}

.cmd-palette-empty {
  padding: 28px 18px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

.cmd-palette-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 11px;
  color: var(--text-3);
}

@keyframes cmd-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes cmd-fade-out {
  to   { opacity: 0; }
}
@keyframes cmd-pop-in {
  from { opacity: 0; transform: translateY(-10px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes cmd-pop-out {
  to   { opacity: 0; transform: translateY(6px) scale(.98); }
}

@media (max-width: 640px) {
  .cmd-palette-backdrop {
    padding: 12px;
    align-items: start;
  }
  .cmd-palette-modal {
    max-width: 100%;
    border-radius: var(--r-lg);
  }
  .cmd-palette-input {
    height: 48px;
    font-size: 16px;
    padding-left: 14px;
  }
  .cmd-palette-header .ico {
    display: none;
  }
  .cmd-palette-footer {
    display: none;
  }
}

/* ---------------------------------------------------------------- toast */

#toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: rgba(43, 42, 39, .93);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  color: #f7f6f3;
  padding: 10px 17px; border-radius: 22px;
  font-size: 12.5px; font-weight: 500;
  box-shadow: var(--shadow-float);
  animation: toast-in .42s var(--ease-spring);
  max-width: min(92vw, 460px); text-align: center;
  will-change: transform, opacity;
}
.toast.ok { background: rgba(47, 93, 80, .95); }
.toast.err { background: rgba(180, 52, 42, .95); }
.toast.out { animation: toast-out var(--dur-2) var(--ease) forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px) scale(.94); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px) scale(.96); }
}

/* ---------------------------------------------------------------- misc */

.muted { color: var(--text-3); }
.small { font-size: 12px; }
.hstack { display: flex; align-items: center; gap: 8px; }
.vstack { display: flex; flex-direction: column; gap: 8px; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }
.nowrap { white-space: nowrap; }
.hr { height: 1px; background: var(--border); margin: 18px 0; border: 0; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-size: inherit; cursor: pointer; font-weight: 500; }
.link-btn:hover { text-decoration: underline; }
.danger-zone { border: 1px solid #f0d5d2; background: #fffbfa; border-radius: var(--r); padding: 14px 16px; }

.bottom-nav { display: none; }

.warn-banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--danger-soft);
  border-bottom: 1px solid #f0d5d2;
  color: #8a2a22;
  font-size: 12.5px;
  line-height: 1.5;
  padding: 10px 26px;
}
.warn-banner .ico { margin-top: 2px; color: var(--danger); }
.warn-banner b { font-weight: 600; }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 880px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-102%);
    transition: transform var(--dur-3) var(--ease-out);
    box-shadow: var(--shadow-lg);
    width: min(292px, 84vw); flex-basis: auto;
    padding-top: calc(14px + env(safe-area-inset-top));
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    will-change: transform;
  }
  #app[data-sidebar="open"] .sidebar { transform: translateX(0); }
  .menu-btn { display: grid; }
  .topbar {
    padding: 10px 14px;
    padding-top: calc(10px + env(safe-area-inset-top));
    gap: 9px;
  }
  .searchbar { min-width: 0; flex: 1 1 auto; height: 36px; }
  .searchbar .kbd { display: none; }
  .content { padding: 18px 15px calc(104px + env(safe-area-inset-bottom)); }
  .page-title { font-size: 19px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .notes-grid { grid-template-columns: 1fr; }
  .page-head { flex-wrap: wrap; }
  .editor-title { font-size: 22px; }
  .nav-item { padding: 10px 10px; font-size: 14.5px; }

  /* inbox actions drop below the text instead of squeezing it */
  .inbox-row { flex-direction: column; align-items: stretch; gap: 9px; }
  .inbox-row .row-actions { width: 100%; }
  .inbox-row .row-actions .btn { flex: 1 1 0; }
  .inbox-row .row-actions .btn-icon { flex: 0 0 40px; }

  /* thumb-sized controls */
  .btn { height: 40px; padding: 0 15px; font-size: 13.5px; }
  .btn-sm { height: 34px; padding: 0 12px; }
  .btn-icon { width: 40px; }
  .check { width: 21px; height: 21px; border-radius: 6px; }
  .check svg { width: 13px; height: 13px; }
  .input, .select, .textarea, .review-input { font-size: 16px; } /* stops iOS focus zoom */
  .capture input, .palette-input, .searchbar input, .editor-body { font-size: 16px; }
  .tag-input { font-size: 16px; }

  /* modals become bottom sheets */
  .overlay { align-items: end; padding: 0; }
  .modal {
    max-width: none;
    border-radius: 22px 22px 0 0;
    max-height: 92dvh;
    animation: sheet-up var(--dur-3) var(--ease-out);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .overlay.closing .modal { animation: sheet-down var(--dur-2) var(--ease) forwards; }
  .modal-body { padding: 12px 18px 16px; }
  .modal-head { padding: 16px 18px 0; }
  .modal-foot { padding: 12px 18px 14px; }
  .modal-foot .btn { flex: 1 1 0; }
  .palette { max-width: none; margin-top: 0; align-self: start; border-radius: 0 0 22px 22px; }
  .overlay:has(.palette) { align-items: start; }
  .overlay:has(.palette).closing .modal { animation: pop-out var(--dur-2) var(--ease) forwards; }

  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 35;
    background: var(--bottomnav-bg, rgba(251, 251, 250, .82));
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--border);
    padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 24px -12px rgba(20, 20, 18, .18);
  }
  .bottom-nav button {
    flex: 1 1 0; background: transparent; border: 0; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 2px 5px; min-height: 52px; color: var(--text-3); font-size: 10px; font-weight: 600;
    border-radius: 12px; position: relative;
    transition: color var(--dur-2) var(--ease-out), transform var(--dur-1) var(--ease-out);
    -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav button:active { transform: scale(.94); }
  .bottom-nav button[aria-current="page"] { color: var(--accent); }
  .bottom-nav button[aria-current="page"]::before {
    content: ''; position: absolute; top: 3px; left: 50%; width: 26px; height: 26px;
    margin-left: -13px; border-radius: 10px; background: var(--accent-soft);
    animation: nav-pill .34s var(--ease-spring); z-index: -1;
  }
  @keyframes nav-pill { from { transform: scale(.5); opacity: 0; } }
  .bottom-nav .ico { width: 21px; height: 21px; transition: transform var(--dur-2) var(--ease-spring); }
  .bottom-nav button[aria-current="page"] .ico { transform: translateY(-1px) scale(1.06); }
  .sidebar-scrim {
    position: fixed; inset: 0; background: rgba(28,27,25,.34);
    backdrop-filter: blur(2px);
    z-index: 39; animation: fade var(--dur-2) var(--ease-out);
  }
}

@keyframes sheet-down { to { opacity: 0; transform: translateY(40px); } }

@media (max-width: 640px) {
  .view-sub,
  .topbar-sub {
    display: none !important;
  }
  .topbar {
    gap: 8px;
    padding: 9px 12px;
    padding-top: calc(9px + env(safe-area-inset-top));
    min-height: 50px;
    flex-wrap: nowrap;
  }
  .topbar-title {
    font-size: 14.5px;
    flex-shrink: 0;
    max-width: 48%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar-spacer {
    flex: 1 1 4px;
    min-width: 4px;
  }
  .searchbar {
    min-width: 120px;
    flex: 1 1 auto;
    height: 34px;
  }
}

@media (max-width: 420px) {
  .stat-num { font-size: 19px; }
  .view-sub,
  .topbar-sub { display: none !important; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
}

@media (hover: none) {
  .row-actions { opacity: 1; }
  .project-card:hover, .note-card:hover { box-shadow: none; transform: none; }
}

@media print {
  .sidebar, .topbar, .bottom-nav, .row-actions { display: none !important; }
  .content { max-width: none; padding: 0; }
}

/* ---------------------------------------------------------------- motion layer */

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
@keyframes rise-sm {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}
@keyframes scale-in {
  from { opacity: 0; transform: scale(.94); }
}
@keyframes slide-from-right { from { opacity: 0; transform: translateX(14px); } }
@keyframes slide-from-left  { from { opacity: 0; transform: translateX(-14px); } }

/* View entrance: only applied on navigation, never on patch renders. */
.content.enter > * {
  animation: rise var(--dur-3) var(--ease-out) both;
}
.content.enter > *:nth-child(1) { animation-delay: 0ms; }
.content.enter > *:nth-child(2) { animation-delay: 40ms; }
.content.enter > *:nth-child(3) { animation-delay: 80ms; }
.content.enter > *:nth-child(4) { animation-delay: 120ms; }
.content.enter > *:nth-child(5) { animation-delay: 160ms; }
.content.enter > *:nth-child(6) { animation-delay: 200ms; }
.content.enter > *:nth-child(n+7) { animation-delay: 230ms; }

.content.enter.forward > * { animation-name: slide-from-right; }
.content.enter.back > * { animation-name: slide-from-left; }

/* List stagger — JS stamps --i on each row/card, only animates on arrival. */
.content.enter [data-stag] {
  animation: rise-sm .38s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 26ms);
}

.stat { transition: transform var(--dur-2) var(--ease-spring), box-shadow var(--dur-2) var(--ease-out); }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-float); }
.stat-num { display: block; }

.card,
.project-card,
.note-card { transition: box-shadow var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out); }

.project-card:active,
.note-card:active { transform: scale(.985); }
.project-card:hover,
.note-card:hover { border-color: var(--border-strong); }

.mood-btn:active { transform: scale(.9); }

.capture { transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-spring); }
.capture:focus-within { transform: translateY(-1px); box-shadow: var(--shadow-float), var(--ring); }
.capture.pulse { animation: capture-pulse .5s var(--ease-out); }
@keyframes capture-pulse {
  0% { box-shadow: 0 0 0 0 var(--accent-soft); }
  100% { box-shadow: 0 0 0 14px transparent; }
}

/* nav count bump when it changes */
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.28); } 100% { transform: scale(1); } }
.count.bump { animation: bump .4s var(--ease-spring); }

/* ---------------------------------------------------------------- onboarding */

.onb {
  position: fixed; inset: 0; z-index: 140;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(250, 250, 248, .94);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.onb.out { animation: fade-out var(--dur-3) var(--ease) forwards; }

.onb-panel {
  width: 100%; max-width: 860px;
  margin: auto;
  display: flex; flex-direction: column;
  /* fixed height → the footer never moves between steps */
  height: min(880px, calc(100dvh - 48px));
  position: relative;
}

.onb-top { display: flex; align-items: center; gap: 10px; margin-bottom: clamp(28px, 7vh, 64px); }
.onb-brand { display: flex; align-items: center; gap: 10px; }
.onb-mark {
  width: 34px; height: 34px; border-radius: 10px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .12),
    inset 0 -10px 16px -12px rgba(255, 156, 120, .85),
    0 8px 20px -10px rgba(0, 0, 0, .55);
}
.onb-brand-t { display: flex; flex-direction: column; line-height: 1.1; }
.onb-brand-n { font-size: 13px; font-weight: 650; letter-spacing: -.01em; }
.onb-brand-s { font-size: 9.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--text-3); font-weight: 600; }
.onb-skip {
  margin-left: auto; background: none; border: 0; color: var(--text-3);
  font-size: 12.5px; cursor: pointer; padding: 8px 10px; border-radius: 8px;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.onb-skip:hover { background: rgba(0,0,0,.04); color: var(--text); }

.onb-body {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  /* The step transition slides ±18px. Without an explicit hidden x-axis the
     browser promotes overflow-x to auto and a scrollbar flashes for 150ms. */
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
}
/* auto margins centre the step when there is room, and collapse to 0 when the
   content is taller than the body — so nothing is ever clipped at the top */
.onb-body > .onb-step { margin-block: auto; }

.onb-eyebrow {
  font-size: 10.5px; font-weight: 700; letter-spacing: .16em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 14px;
}
.onb-huge {
  font-size: clamp(32px, 5.6vw, 58px);
  line-height: 1.0;
  letter-spacing: -.045em;
  font-weight: 650;
  margin: 0 0 16px;
  max-width: 15ch;
  text-wrap: balance;
}
.onb-huge em { font-style: normal; color: var(--accent); }
.onb-lede {
  font-size: clamp(14px, 1.5vw, 16px);
  line-height: 1.6;
  color: var(--text-2);
  max-width: 46ch;
}

/* hero composition */
.onb-step.poster { position: relative; display: flex; flex-direction: column; }

.poster-stage {
  position: relative;
  height: clamp(180px, 30vh, 300px);
  display: grid; place-items: center;
  margin-bottom: 10px;
}

.poster-ghost {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(42px, 7.6vw, 104px);
  line-height: .84;
  letter-spacing: -.055em;
  font-weight: 800;
  white-space: nowrap;
  color: rgba(255, 255, 255, .13);
  pointer-events: none; user-select: none;
  z-index: 0;
  animation: ghost-in 1.1s var(--ease-out) both;
}
@keyframes ghost-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
}

.poster-art {
  position: relative; z-index: 1;
  width: min(100%, 900px);
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: 26px;
  overflow: hidden;
  background:
    radial-gradient(72% 96% at 50% 40%, #202a3a 0%, #101620 52%, #070a0f 100%);
  box-shadow:
    0 30px 70px -38px rgba(12, 16, 22, .7),
    inset 0 0 0 1px rgba(255, 255, 255, .07);
}
.poster-copy { position: relative; z-index: 1; max-width: 620px; }

.poster-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 22px; }
.chip {
  font-size: 11.5px; font-weight: 600; letter-spacing: -.005em;
  padding: 6px 12px; border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .7);
  color: var(--text-3);
  transition: all var(--dur-2) var(--ease);
}
.chip.on {
  background: var(--text); border-color: var(--text); color: #fff;
  box-shadow: 0 6px 14px -8px rgba(20,20,18,.6);
}

/* the object — a glass brain, drawn inline so it ships with the page */
.art { position: relative; display: grid; place-items: center; z-index: 1; }
.art .brain { display: block; width: 100%; height: auto; }
/* soft aura so the sculpture sits in front of the giant type instead of in it */
.art::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 130%; height: 130%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(251, 251, 250, .95), rgba(251, 251, 250, .62) 46%, rgba(251, 251, 250, 0) 74%);
  z-index: -1;
  pointer-events: none;
}
.art::after {
  content: ''; position: absolute; left: 50%; bottom: 1%;
  width: 62%; height: 7%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(20, 20, 18, .22), rgba(20, 20, 18, 0));
  filter: blur(6px);
  z-index: -1;
}

/* While the WebGL model loads (or if WebGL is off) the host must not be a hole:
   a soft pool of light reads as the sculpture arriving, then it leaves. */
.art-fallback {
  position: absolute;
  inset: 18% 12%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 48%,
    rgba(126, 148, 180, .20) 0%,
    rgba(86, 106, 138, .10) 46%,
    rgba(10, 14, 20, 0) 74%);
  filter: blur(7px);
  opacity: .9;
  pointer-events: none;
  animation: fallback-breathe 3.2s ease-in-out infinite;
  transition: opacity .5s var(--ease);
}
/* The keyframes must not touch opacity: an animation outranks a plain
   declaration, which is why the "egg" used to stay welded over the brain. */
.has-brain > .art-fallback,
.brain-failed > .art-fallback {
  opacity: 0;
  animation: none;
}
@keyframes fallback-breathe {
  0%, 100% { transform: scale(.98); }
  50% { transform: scale(1.02); }
}
@media (prefers-reduced-motion: reduce) {
  .art-fallback { animation: none; }
}

.poster-art .art {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: art-in 1.05s var(--ease-spring) both;
}
@keyframes art-in {
  from { opacity: 0; transform: scale(.86); }
}

/* contact shadow lives on .art::after — see above */

.mini {
  position: absolute;
  background: rgba(255, 255, 255, .96);
  border: 1px solid rgba(255, 255, 255, .95);
  border-radius: 14px;
  box-shadow: 0 24px 46px -24px rgba(20, 20, 18, .32), 0 2px 6px rgba(20, 20, 18, .05);
  padding: 13px 15px;
  transform: rotate(var(--rot, 0deg));
  animation:
    mini-in .72s var(--ease-out) both,
    floaty 7s ease-in-out infinite;
  animation-delay: var(--d, 0s), calc(1.1s + var(--d, 0s));
}
.mini-a { top: 26%; left: 18px; width: 262px; --rot: -1.9deg; --d: .28s; }
.mini-b { bottom: 14%; right: 18px; width: 276px; --rot: 1.6deg; --d: .40s; }

/* Under ~900px the panel is too narrow for two cards plus the sculpture.
   Cards clipped by the panel's rounded corner looked like a bug, not a bleed. */
@media (max-width: 900px) {
  .poster-art .mini,
  .poster-art .mini-toast { display: none; }
}

@keyframes mini-in {
  from { opacity: 0; transform: translateY(18px) scale(.965) rotate(var(--rot, 0deg)); }
}
@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(var(--rot, 0deg)); }
  50%      { transform: translateY(-7px) rotate(var(--rot, 0deg)); }
}

.mini-row { display: flex; align-items: center; gap: 9px; }
.mini-check {
  width: 15px; height: 15px; border-radius: 4px; flex: 0 0 auto;
  border: 1.5px solid var(--border-strong); background: #fff;
}
.mini-t { font-size: 12.5px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.mini-meta { display: flex; align-items: center; gap: 7px; margin-top: 7px; font-size: 10.5px; color: var(--text-3); }
.mini-pill {
  background: var(--accent-soft); color: var(--accent);
  font-size: 9.5px; font-weight: 700; letter-spacing: .03em;
  padding: 1px 7px; border-radius: 20px;
}
.mini-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--border-strong); }
.mini-bar { height: 4px; border-radius: 4px; background: var(--surface-3); margin-top: 10px; overflow: hidden; }
.mini-bar i { display: block; height: 100%; width: 64%; background: var(--accent); border-radius: 4px; }
.mini-body { font-size: 11.5px; line-height: 1.55; color: var(--text-2); margin-top: 5px; }
.mini-toast {
  position: absolute; top: 27%; left: 64%;
  background: rgba(43, 42, 39, .92); color: #f7f6f3;
  font-size: 10.5px; font-weight: 600; padding: 6px 12px; border-radius: 18px;
  box-shadow: var(--shadow-float);
  animation: mini-in .6s var(--ease-spring) .7s both;
}

.onb-step { animation: onb-step-in 420ms var(--ease-spring) both; }
.onb-step.static { animation: none; }
.onb-step.dir-back { animation-name: onb-step-in-back; }
@keyframes onb-step-in {
  from { opacity: 0; transform: translate3d(18px, 7px, 0) scale(.986); }
}
@keyframes onb-step-in-back {
  from { opacity: 0; transform: translate3d(-18px, 7px, 0) scale(.986); }
}
.onb-step.out-fwd { animation: onb-step-out 150ms var(--ease) forwards; }
.onb-step.out-back { animation: onb-step-out-back 150ms var(--ease) forwards; }
@keyframes onb-step-out {
  to { opacity: 0; transform: translate3d(-16px, -6px, 0) scale(.99); }
}
@keyframes onb-step-out-back {
  to { opacity: 0; transform: translate3d(16px, -6px, 0) scale(.99); }
}

.onb-rules { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 30px; }
.onb-rule {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, .72);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  animation: rise var(--dur-3) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 65ms + 40ms);
}
.onb-rule-n {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.onb-rule-t { font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; }
.onb-rule-d { font-size: 12.5px; color: var(--text-2); line-height: 1.5; margin-top: 2px; }

.onb-field { margin-top: 24px; max-width: 380px; }
.onb-label {
  display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 7px;
}
.onb-input {
  width: 100%; height: 46px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--r);
  background: rgba(255,255,255,.85); font-size: 15px; outline: 0;
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease-out);
}
.onb-input:focus { border-color: var(--accent); box-shadow: var(--ring); }

.onb-swatches { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.onb-swatch {
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; background-clip: content-box; padding: 3px;
  transition: transform var(--dur-2) var(--ease-spring), border-color var(--dur-2) var(--ease);
  position: relative;
}
.onb-swatch:hover { transform: scale(1.08); }
.onb-swatch[aria-pressed="true"] { border-color: var(--text); }

/* personalisation: form left, live preview right */
.onb-personalise { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: center; }
.onb-personalise .onb-field { max-width: none; }
.onb-preview { position: relative; }

.pv {
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(255, 255, 255, .95);
  border-radius: 18px;
  box-shadow: 0 26px 50px -26px rgba(20, 20, 18, .34), 0 2px 6px rgba(20, 20, 18, .05);
  padding: 16px 18px 18px;
  animation: mini-in .7s var(--ease-out) .1s both;
}
.pv-top { display: flex; gap: 4px; margin-bottom: 14px; }
.pv-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); }
.pv-greet { font-size: 17px; font-weight: 650; letter-spacing: -.02em; }
.pv-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.pv-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 12px; }
.pv-stat { background: var(--surface-2); border-radius: 9px; padding: 8px 10px; }
.pv-stat b { display: block; font-size: 17px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.pv-stat span { font-size: 8.5px; letter-spacing: .07em; color: var(--text-3); font-weight: 700; }
.pv-capture {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 7px 7px 7px 11px; font-size: 11.5px; color: var(--text-3);
}
.pv-capture i {
  margin-left: auto; font-style: normal; background: var(--accent); color: #fff;
  font-size: 10.5px; font-weight: 600; padding: 4px 10px; border-radius: 7px;
}

.onb-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 26px; }
.onb-choice {
  text-align: left; cursor: pointer;
  padding: 18px 18px 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border-strong);
  background: rgba(255,255,255,.7);
  transition: transform var(--dur-2) var(--ease-spring), border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease-out), background var(--dur-2) var(--ease);
}
.onb-choice:hover { transform: translateY(-2px); box-shadow: var(--shadow-float); background: #fff; }
.onb-choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: #fff; }
.onb-choice-t { font-size: 14px; font-weight: 650; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.onb-choice-d { font-size: 12.5px; color: var(--text-2); line-height: 1.5; margin-top: 5px; }
.onb-choice .tick { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--border-strong); display: grid; place-items: center; color: transparent; flex: 0 0 auto; transition: all var(--dur-2) var(--ease-spring); }
.onb-choice[aria-pressed="true"] .tick { background: var(--accent); border-color: var(--accent); color: #fff; }
.onb-choice .tick svg { width: 10px; height: 10px; }

.onb-foot {
  display: grid;
  grid-template-columns: 1fr minmax(0, 440px) 1fr;
  align-items: center; gap: 14px;
  margin-top: clamp(26px, 5vh, 44px);
}
/* flattened on desktop so back · rail · next share one row without nesting,
   and the rail stays optically centred whatever the button labels are */
.onb-foot-row { display: contents; }
.onb-back { order: 1; justify-self: start; }
.onb-next { order: 3; justify-self: end; margin-left: 0; }
/* progress rail — four named nodes, fills as you move */
.onb-rail {
  display: flex; align-items: flex-start;
  order: 2; margin: 0; padding: 0; list-style: none;
  width: 100%; max-width: none;
}
.onb-node {
  position: relative;
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.onb-node::before {
  content: ''; position: absolute; top: 9px; left: 50%;
  width: 100%; height: 1.5px;
  background: var(--border-strong);
  transition: background var(--dur-3) var(--ease);
}
.onb-node:last-child::before { display: none; }
.onb-node.done::before { background: var(--accent); }

.onb-node-d {
  position: relative; z-index: 1; flex: 0 0 auto;
  width: 19px; height: 19px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 1.5px solid var(--border-strong);
  color: var(--text-3);
  font-size: 9.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: all var(--dur-3) var(--ease-spring);
}
.onb-node-n {
  font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1;
  transition: opacity var(--dur-2) var(--ease);
}
.onb-node-ck {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  opacity: 0; transform: scale(.5);
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease-spring);
}
.onb-node-ck svg { width: 10px; height: 10px; }
.onb-node.done .onb-node-n { opacity: 0; }
.onb-node.done .onb-node-ck { opacity: 1; transform: scale(1); }
.onb-node.done .onb-node-d { background: var(--accent); border-color: var(--accent); color: #fff; }
.onb-node.cur .onb-node-d {
  border-color: var(--accent); color: var(--accent); background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.onb-node-t {
  font-size: 10px; font-weight: 650; letter-spacing: .02em;
  color: var(--text-3); white-space: nowrap; text-align: center;
  transition: color var(--dur-2) var(--ease);
}
.onb-node.cur .onb-node-t { color: var(--text); }
.onb-node.done .onb-node-t { color: var(--text-2); }
.onb-back {
  flex: 0 0 auto;
  background: rgba(255, 255, 255, .5); border: 1px solid var(--border-strong); border-radius: var(--r);
  height: 40px; padding: 0 15px; font-size: 13px; cursor: pointer; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 6px;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease),
              transform var(--dur-1) var(--ease-spring), box-shadow var(--dur-2) var(--ease-out);
}
.onb-back:hover { background: #fff; color: var(--text); box-shadow: 0 2px 6px rgba(20, 20, 18, .07); }
.onb-back:active { transform: translateY(1px) scale(.97); box-shadow: inset 0 1px 3px rgba(20, 20, 18, .12); }
/* keep the box, hide the paint — the row must not jump when Back appears */
.onb-back[hidden] { display: inline-flex; visibility: hidden; pointer-events: none; }

.onb-next {
  margin-left: auto; height: 46px; padding: 0 22px;
  border-radius: var(--r); border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  font-size: 14px; font-weight: 600; letter-spacing: -.01em;
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 4px rgba(20, 20, 18, .14), 0 12px 26px -12px var(--accent);
  transition: transform var(--dur-2) var(--ease-spring), filter var(--dur-2) var(--ease),
              box-shadow var(--dur-2) var(--ease-out);
}
@media (hover: hover) {
  .onb-next:hover {
    filter: brightness(1.07); transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(20, 20, 18, .16), 0 16px 30px -12px var(--accent);
  }
  .onb-next:hover .ico { transform: translateX(3px); }
}
/* the press: dip in fast, then spring back */
.onb-next:active {
  transform: translateY(1px) scale(.955);
  filter: brightness(.93);
  box-shadow: 0 1px 2px rgba(20, 20, 18, .22), 0 4px 10px -6px var(--accent);
  transition-duration: 55ms;
}
.onb-next .ico { transition: transform var(--dur-2) var(--ease-spring); }

.onb-hint { font-size: 11.5px; color: var(--text-3); margin-top: 14px; }
.onb-hint .kbd { margin: 0 2px; }

@media (max-width: 680px) {
  .onb { padding: 0; align-items: stretch; }
  .onb-panel {
    height: 100dvh; max-height: none; max-width: none;
    padding: calc(18px + env(safe-area-inset-top)) 20px calc(14px + env(safe-area-inset-bottom));
  }
  .onb-top { margin-bottom: 18px; }
  .onb-body { padding-top: 0; }
  .onb-eyebrow { margin-bottom: 10px; }
  .onb-huge {
    font-size: clamp(29px, 8.4vw, 38px);
    line-height: 1.06;
    letter-spacing: -.038em;
    max-width: none;
    margin-bottom: 14px;
  }
  .onb-lede { font-size: 14.5px; line-height: 1.58; }

  /* poster: art on top, then the copy — never an empty slide */
  .poster-stage { height: 208px; margin-bottom: 12px; }
  .poster-ghost { font-size: 12.4vw; letter-spacing: -.05em; }
  .poster-art .art { width: 100%; height: 100%; aspect-ratio: auto; }
  .poster-art .mini { display: none; }
  .poster-art .mini-toast { display: none; }
  .poster-copy { max-width: none; }
  .poster-chips { margin-top: 16px; gap: 6px; }
  .chip { font-size: 11px; padding: 5px 10px; }

  .onb-rules { grid-template-columns: 1fr; margin-top: 20px; gap: 8px; }
  .onb-rule { padding: 12px 13px; gap: 11px; }
  .onb-personalise { grid-template-columns: 1fr; gap: 20px; }
  .onb-preview { display: none; }
  .onb-choices { grid-template-columns: 1fr; margin-top: 20px; gap: 10px; }
  .onb-choice { padding: 15px 15px 14px; }

  .onb-foot {
    display: flex; flex-direction: column; align-items: stretch;
    margin-top: auto; padding-top: 20px; gap: 14px;
  }
  .onb-foot-row { display: flex; align-items: center; gap: 10px; }
  .onb-rail { order: 0; width: 100%; max-width: none; margin: 0; align-self: stretch; }
  .onb-node { padding-right: 0; flex: 1 1 0; }
  .onb-node::before { width: 100%; }
  .onb-node-t { display: none; }
  .onb-back { height: 44px; padding: 0; width: 46px; justify-content: center; }
  .onb-back-t { display: none; }
  .onb-next { flex: 1 1 auto; justify-content: center; height: 48px; padding: 0 16px; gap: 6px; font-size: 14px; margin-left: 0; }
  .onb-input { font-size: 16px; height: 48px; }

  .intro-word { font-size: 10.2vw; }
  .intro-stack { height: clamp(170px, 32vh, 240px); }
  .intro-art { width: clamp(260px, 74vw, 340px); height: clamp(200px, 58vw, 266px); aspect-ratio: 460 / 360; }
  .intro-tag { margin-top: 22px; font-size: 9.5px; }
}

/* settings extras */
.set-toggle {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}
.set-toggle-t { font-size: 13px; font-weight: 600; letter-spacing: -.01em; }
.set-toggle-d { font-size: 12px; color: var(--text-3); margin-top: 2px; line-height: 1.45; }
.set-toggle-ctl { margin-left: auto; display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

.switch { position: relative; width: 38px; height: 22px; flex: 0 0 auto; cursor: pointer; display: inline-block; }
.switch input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; opacity: 0; cursor: pointer;
}
.switch span {
  position: absolute; inset: 0; border-radius: 20px;
  background: var(--border-strong);
  transition: background var(--dur-2) var(--ease);
}
.switch span::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(20, 20, 18, .28);
  transition: transform var(--dur-2) var(--ease-spring);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* intro specifics */
.intro-art {
  position: absolute; left: 50%; top: 50%;
  width: clamp(320px, 54vmin, 640px);
  height: clamp(250px, 42vmin, 500px);
  aspect-ratio: 460 / 360;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  animation: intro-art-in 1.15s var(--ease-spring) .14s both;
}
@keyframes intro-art-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.7); }
}

/* ---------------------------------------------------------------- intro */

.intro {
  position: fixed; inset: 0; z-index: 150;
  display: grid; place-items: center;
  background:
    radial-gradient(118% 120% at 50% 40%, #1a2432 0%, #0d1219 44%, #06080c 100%);
  overflow: hidden;
}
.intro::before {
  content: ''; position: absolute; inset: -25%;
  background:
    radial-gradient(46% 42% at 50% 46%, rgba(62, 132, 112, .26), transparent 68%),
    radial-gradient(38% 34% at 76% 24%, rgba(226, 146, 100, .30), transparent 70%),
    radial-gradient(42% 40% at 20% 78%, rgba(86, 116, 168, .22), transparent 72%);
  animation: intro-wash 1.6s var(--ease-out) both;
}
.intro.out { animation: intro-out .28s var(--ease) forwards; }
@keyframes intro-out { to { opacity: 0; transform: scale(1.02); } }
@keyframes intro-wash {
  from { opacity: 0; transform: scale(.9); }
  to   { opacity: 1; transform: scale(1); }
}

.intro-inner {
  position: relative;
  display: grid; justify-items: center;
  padding: 24px;
}

.intro-stack {
  position: relative;
  width: min(94vw, 1160px);
  height: clamp(200px, 38vh, 360px);
  display: grid; place-items: center;
}

.intro-word {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  line-height: .84;
  letter-spacing: -.055em;
  font-weight: 800;
  font-size: clamp(34px, 10.4vw, 150px);
  white-space: nowrap;
  color: rgba(255, 255, 255, .13);
  text-align: center;
  user-select: none;
}
.intro-word span { display: block; overflow: hidden; padding: 0 .04em; }
.intro-word i {
  display: block; font-style: normal;
  animation: word-rise 1s var(--ease-out) both;
}
@keyframes word-rise {
  from { transform: translateY(105%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}


.intro-tag {
  margin-top: clamp(18px, 4vh, 40px);
  font-size: 10.5px; font-weight: 700; letter-spacing: .34em;
  text-transform: uppercase; color: rgba(255, 255, 255, .52); text-indent: .34em;
  animation: rise .7s var(--ease-out) .75s both;
}
.intro-bar {
  margin-top: 16px; width: 132px; height: 2px;
  border-radius: 2px; background: rgba(255, 255, 255, .14); overflow: hidden;
  animation: rise .5s var(--ease-out) .85s both;
}
.intro-bar i {
  display: block; height: 100%; width: 100%;
  background: var(--accent); border-radius: 2px;
  transform-origin: left center;
  animation: bar-fill 1.15s var(--ease-in-out) .35s both;
}
@keyframes bar-fill { from { transform: scaleX(0); } }

/* ---------------------------------------------------------------- utility */

.glass {
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid var(--glass-brd);
}
.display {
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1;
  letter-spacing: -.04em;
  font-weight: 650;
}

/* ---------------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-delay: 0ms !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .content.enter > *, .content.enter [data-stag], .onb-rule { animation: none !important; opacity: 1 !important; transform: none !important; }
}

/* ---------------------------------------------------------------- dark theme component refinements */

@media all {
  .theme-dark select option,
  .theme-dark select option {
    background: var(--surface);
    color: var(--text);
  }
}

@media all {
  .theme-dark .danger-zone,
  .theme-dark .danger-zone {
    border-color: rgba(224, 93, 82, 0.35);
    background: rgba(224, 93, 82, 0.08);
  }
}

@media all {
  .theme-dark .btn-danger,
  .theme-dark .btn-danger {
    color: var(--danger);
    border-color: rgba(224, 93, 82, 0.35);
    background: var(--danger-soft);
  }
  .theme-dark .btn-danger:hover,
  .theme-dark .btn-danger:hover {
    background: rgba(224, 93, 82, 0.3);
  }
}

@media all {
  .theme-dark .warn-banner,
  .theme-dark .warn-banner {
    border-bottom-color: rgba(224, 93, 82, 0.35);
    color: #fca5a5;
  }
}

@media all {
  .theme-dark .cmd-palette-item.is-selected .cmd-palette-badge,
  .theme-dark .cmd-palette-item:hover .cmd-palette-badge,
  .theme-dark .cmd-palette-item.is-selected .cmd-palette-badge,
  .theme-dark .cmd-palette-item:hover .cmd-palette-badge {
    background: rgba(255, 255, 255, .12);
    color: var(--text);
  }
}

@media all {
  .theme-dark .onb,
  .theme-dark .onb {
    background: rgba(20, 20, 19, 0.96);
  }
  .theme-dark .onb-rule,
  .theme-dark .onb-rule {
    background: var(--surface);
  }
  .theme-dark .onb-choice,
  .theme-dark .onb-choice {
    background: var(--surface);
  }
  .theme-dark .onb-choice:hover,
  .theme-dark .onb-choice:hover {
    background: var(--surface-2);
  }
  .theme-dark .onb-choice[aria-pressed="true"],
  .theme-dark .onb-choice[aria-pressed="true"] {
    background: var(--surface-2);
  }
  .theme-dark .onb-input,
  .theme-dark .onb-input {
    background: var(--surface-2);
    color: var(--text);
  }
  .theme-dark .onb-back,
  .theme-dark .onb-back {
    background: var(--surface-2);
    color: var(--text-2);
  }
  .theme-dark .onb-back:hover,
  .theme-dark .onb-back:hover {
    background: var(--surface-3);
    color: var(--text);
  }
  .theme-dark .pv,
  .theme-dark .pv {
    background: var(--surface);
    border-color: var(--border);
  }
  .theme-dark .mini,
  .theme-dark .mini {
    background: var(--surface-2);
    border-color: var(--border);
  }
  .theme-dark .chip,
  .theme-dark .chip {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text-2);
  }
  .theme-dark .art::before,
  .theme-dark .art::before {
    background: radial-gradient(closest-side, rgba(158, 186, 224, .10), rgba(158, 186, 224, 0) 72%);
  }
}


/* Intro & Onboarding 3D Brain Canvas — one shared canvas element, re-parented. */
.brain-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  z-index: 0;
  opacity: 0;
  transition: opacity 420ms var(--ease);
  pointer-events: none;
  touch-action: pan-y;
}
.has-brain > .brain-canvas {
  opacity: 1;
}

/* The 3D hosts are dark by design (dark splash, dark poster window), so the
   old paper-white aura behind the sculpture is wrong on both. Give them a cool
   halo instead and drop the fake contact shadow. */
.intro-art::before,
.poster-art .art::before {
  background: radial-gradient(closest-side, rgba(158, 186, 224, .12), rgba(158, 186, 224, 0) 72%);
}
.intro-art::after,
.poster-art .art::after {
  opacity: 0;
}
.brain-canvas[data-mode="hero"] {
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
}
.brain-canvas[data-mode="hero"]:active,
.brain-canvas.is-dragging {
  cursor: grabbing;
}
.brain-canvas[data-mode="intro"] {
  cursor: grab;
  pointer-events: auto;
  touch-action: pan-y;
}

/* Fallback when WebGL is unavailable: no empty hole, no spinner forever. */
[data-brain-host].brain-failed::after {
  content: '';
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 30% 28%, rgba(255, 255, 255, .95), transparent 55%),
    radial-gradient(ellipse at 72% 74%, rgba(255, 160, 130, .55), transparent 62%),
    linear-gradient(150deg, #eef1f6, #c9ced8 55%, #aab1bd);
  filter: blur(.3px);
  opacity: .85;
  pointer-events: none;
}



/* --- Pro Upgrade & Gating Styles --- */
.pill-pro {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(224, 159, 62, .18);
  color: #e09f3e;
  border: 1px solid rgba(224, 159, 62, .35);
  margin-left: auto;
}
.theme-dark .pill-pro {
  background: rgba(243, 182, 100, .15);
  color: #f3b664;
  border-color: rgba(243, 182, 100, .3);
}

.btn-upgrade {
  background: linear-gradient(135deg, #2f5d50, #1b3830);
  color: #ffffff !important;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, .15);
  box-shadow: 0 2px 8px rgba(47, 93, 80, .3);
  transition: all .2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-upgrade:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(47, 93, 80, .45);
  background: linear-gradient(135deg, #386f60, #22473d);
}

.pro-teaser {
  max-width: 620px;
  margin: 20px auto 40px auto;
  padding: 32px 28px;
  text-align: center;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-2);
}
.pro-teaser-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px auto;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(47, 93, 80, .12);
  color: var(--accent);
}
.pro-teaser-icon svg {
  width: 28px;
  height: 28px;
}
.pro-teaser-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: 8px;
  color: var(--text-1);
}
.pro-teaser-sub {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text-2);
  margin-bottom: 24px;
}
.pro-benefit-list {
  text-align: left;
  margin: 20px auto 28px auto;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pro-benefit-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text-1);
}
.pro-benefit-item svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}
.pro-teaser-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.pro-guarantee {
  font-size: 12px;
  color: var(--text-3);
}
