/* Spine — visual system.
   Aesthetic: near-black ground, dithered halftone light, monochrome chrome, one ember spark.
   Depth comes from stacked translucent materials, never from decoration.
   Motion: springs in JS for anything a finger touches; short damped curves for the rest. */

:root {
  color-scheme: dark;

  /* Ground and materials. Surfaces are translucent so the layer beneath shows through —
     that overlap is what makes the stack read as depth rather than as flat boxes. */
  --bg: #050506;
  --bg-2: #0a0a0c;
  --mat-1: rgba(255, 255, 255, 0.034);   /* content plane */
  --mat-2: rgba(255, 255, 255, 0.062);   /* controls sitting on the plane */
  --mat-3: rgba(255, 255, 255, 0.094);   /* pressed / selected */
  --mat-solid: #0f0f11;                  /* where translucency would stack twice */
  --line: rgba(255, 255, 255, 0.11);
  --line-soft: rgba(255, 255, 255, 0.055);
  --edge: rgba(255, 255, 255, 0.16);     /* bright top edge = light catching the material */

  --text: #f4f4f6;
  --text-dim: rgba(244, 244, 246, 0.64);
  --text-faint: rgba(244, 244, 246, 0.38);

  --on-primary: #08080a;
  --primary: #f4f4f6;

  --spark: #e4633a;
  --spark-soft: rgba(228, 99, 58, 0.16);
  --spark-line: rgba(228, 99, 58, 0.45);
  --good: #5fbf7f;
  --warn: #e0b341;
  --bad: #e2564b;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;

  /* Damped, no overshoot. Overshoot is reserved for gestures that carried momentum. */
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --t-press: 100ms;
  --t-fast: 160ms;
  --t-mid: 240ms;

  --sidebar-w: 264px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 1px 2px rgba(0, 0, 0, 0.6), 0 24px 60px -16px rgba(0, 0, 0, 0.9);

  --dots: radial-gradient(rgba(255, 255, 255, 0.5) 0.5px, transparent 0.5px);
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #eeeeef;
  --bg-2: #f7f7f8;
  --mat-1: rgba(255, 255, 255, 0.72);
  --mat-2: rgba(10, 10, 12, 0.045);
  --mat-3: rgba(10, 10, 12, 0.085);
  --mat-solid: #ffffff;
  --line: rgba(10, 10, 12, 0.12);
  --line-soft: rgba(10, 10, 12, 0.07);
  --edge: rgba(255, 255, 255, 0.9);
  --text: #0d0d0f;
  --text-dim: rgba(13, 13, 15, 0.64);
  --text-faint: rgba(13, 13, 15, 0.42);
  --on-primary: #ffffff;
  --primary: #17171a;
  --spark: #c8471d;
  --spark-soft: rgba(200, 71, 29, 0.1);
  --spark-line: rgba(200, 71, 29, 0.32);
  --bad: #c23a2f;
  --shadow-sm: 0 1px 2px rgba(20, 20, 25, 0.08);
  --shadow-lg: 0 1px 2px rgba(20, 20, 25, 0.08), 0 20px 50px -18px rgba(20, 20, 25, 0.28);
  --dots: radial-gradient(rgba(10, 10, 12, 0.5) 0.5px, transparent 0.5px);
}

/* Density: declared after the base so it actually wins. (It did not, before.) */
:root { --row-h: 48px; --pad: 26px; --gap: 16px; }
:root[data-density='compact'] { --row-h: 38px; --pad: 18px; --gap: 12px; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Hanken Grotesk', ui-sans-serif, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* A single dot grid over the whole app, at the density of the reference's halftone.
   It is barely there; it stops large dark fields from reading as dead flat colour. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: var(--dots);
  background-size: 3px 3px;
  opacity: 0.05;
  pointer-events: none;
  z-index: 999;
}

[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { width: 1em; height: 1em; stroke-width: 1.75; flex: none; }
img, video, canvas { display: block; max-width: 100%; }
::selection { background: var(--text); color: var(--bg); }

:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 6px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

kbd {
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  background: var(--mat-2);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 2px 5px;
  line-height: 1;
  white-space: nowrap;
}

/* ── Type scale ─────────────────────────────────────────
   Tracking is size-specific: large text tightens, body sits at zero, small caps opens up. */
h1, h2, h3 { font-weight: 600; }
.t-display { font-size: clamp(26px, 4vw, 34px); line-height: 1.06; letter-spacing: -0.035em; font-weight: 700; }
.t-title   { font-size: 19px; line-height: 1.2; letter-spacing: -0.022em; font-weight: 650; }
.t-section { font-size: 13px; line-height: 1.3; letter-spacing: -0.008em; font-weight: 650; }
.t-eyebrow { font-size: 10.5px; line-height: 1; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 700; }

/* ── Mark & wordmark ────────────────────────────────── */
.wordmark { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 700; letter-spacing: -0.05em; }
.wordmark-sm { font-size: 17px; gap: 9px; }
.mark {
  position: relative;
  width: 18px;
  height: 18px;
  flex: none;
}
.mark::before, .mark::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--text);
}
.mark::before { top: 0; left: 0; }
.mark::after { bottom: 0; right: 0; background: var(--spark); }
.wordmark-sm .mark { width: 15px; height: 15px; }
.wordmark-sm .mark::before, .wordmark-sm .mark::after { width: 7px; height: 7px; }

/* ── Gate ───────────────────────────────────────────── */
.gate {
  position: relative;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 28px;
  overflow: hidden;
  background: var(--bg);
}
.dither {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  pointer-events: none;
  opacity: 0.5;
  animation: dither-in 900ms var(--ease) both;
}
@keyframes dither-in { from { opacity: 0; } to { opacity: 0.5; } }

.gate-panel {
  position: relative;
  width: min(404px, 100%);
  padding: 30px;
  border-radius: var(--radius-lg);
  /* Big surface → thicker material: stronger blur, deeper shadow than a chip gets. */
  background: color-mix(in srgb, var(--bg) 74%, transparent);
  backdrop-filter: blur(34px) saturate(150%);
  -webkit-backdrop-filter: blur(34px) saturate(150%);
  border: 1px solid var(--line);
  border-top-color: var(--edge);
  box-shadow: var(--shadow-lg);
  animation: materialize var(--t-mid) var(--ease) both;
}
/* Glass arrives as a material — blur and scale together, not a plain fade. */
@keyframes materialize {
  from { opacity: 0; transform: scale(0.97); backdrop-filter: blur(0px); }
}
.gate-head { margin-bottom: 22px; }
.gate-head .wordmark { margin-bottom: 12px; }
.gate-tag { color: var(--text-dim); font-size: 14px; max-width: 32ch; }

.gate-fine {
  display: flex;
  gap: 9px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
  line-height: 1.6;
  /* Vibrancy: over a blurred surface, flat grey text dissolves. Weight up, track out slightly. */
  color: var(--text-faint);
  font-weight: 500;
  letter-spacing: 0.01em;
}
.gate-fine svg { margin-top: 3px; }

/* ── Segmented control ──────────────────────────────── */
.seg {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  background: var(--mat-2);
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  margin-bottom: 20px;
}
.seg-btn {
  position: relative;
  z-index: 1;
  padding: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
  border-radius: 8px;
  transition: color var(--t-fast) var(--ease);
}
.seg-btn.is-on { color: var(--text); }
.seg-thumb {
  position: absolute;
  z-index: 0;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: var(--mat-3);
  border: 1px solid var(--line-soft);
  border-top-color: var(--edge);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  /* translated by a spring from JS */
  transform: translate3d(var(--x, 0px), 0, 0);
}

/* ── Fields ─────────────────────────────────────────── */
.field { display: block; position: relative; margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.015em;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field input, .field textarea, .field select, .input {
  width: 100%;
  background: var(--mat-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.field input:focus, .field textarea:focus, .field select:focus, .input:focus {
  outline: none;
  border-color: var(--edge);
  background: var(--mat-3);
}
.field textarea { resize: vertical; min-height: 92px; line-height: 1.6; }
.field-eye {
  position: absolute;
  right: 8px;
  bottom: 7px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--text-faint);
  border-radius: 7px;
  transition: color var(--t-fast) var(--ease);
}
.field-eye:hover { color: var(--text); }

.strength { margin: -4px 0 14px; }
.strength-bar { height: 3px; background: var(--line-soft); border-radius: 99px; overflow: hidden; }
.strength-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--bad);
  transition: width var(--t-mid) var(--ease), background var(--t-mid) var(--ease);
}
.strength-note { font-size: 12px; color: var(--text-faint); margin-top: 6px; }

.msg {
  font-size: 13px;
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  margin-bottom: 14px;
  border: 1px solid transparent;
  animation: rise var(--t-fast) var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.msg[data-kind='error'] { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.msg[data-kind='ok'] { color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); background: color-mix(in srgb, var(--good) 12%, transparent); }

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--mat-2);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  /* Press feedback is driven by --press, set on pointerdown, so it lands on the press. */
  transform: scale(var(--press, 1));
  transition: transform var(--t-press) var(--ease), background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}
.btn:hover { background: var(--mat-3); border-color: var(--edge); }
.btn-primary { background: var(--primary); border-color: transparent; color: var(--on-primary); }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 88%, var(--bg)); border-color: transparent; }
.btn-primary svg { stroke-width: 2.1; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--mat-2); color: var(--text); border-color: transparent; }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: transparent; }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 14%, transparent); border-color: var(--bad); }
.btn-block { width: 100%; height: 44px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; }

.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--text-dim);
  transform: scale(var(--press, 1));
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-press) var(--ease);
}
.icon-btn:hover { background: var(--mat-2); color: var(--text); }
.icon-btn[data-danger]:hover { color: var(--bad); }

/* ── Shell ──────────────────────────────────────────── */
.shell { height: 100%; display: grid; grid-template-columns: var(--sidebar-w) 1fr; background: var(--bg); }

/* Structural region → heavier material than the content it frames. */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 12px;
  background: var(--bg-2);
  border-right: 1px solid var(--line-soft);
  overflow: hidden auto;
  overscroll-behavior: contain;
}
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 0; min-height: 32px; }
.side-close { display: none; }

.search-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--mat-2);
  color: var(--text-faint);
  font-size: 13.5px;
  transform: scale(var(--press, 1));
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-press) var(--ease);
}
.search-trigger:hover { border-color: var(--line); color: var(--text-dim); }
.search-trigger span { flex: 1; text-align: left; }

.nav { position: relative; flex: 1; }
.nav-group { margin-bottom: 18px; }
.nav-group:last-of-type { margin-bottom: 0; }
.nav-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 10px;
  margin-bottom: 6px;
}
.nav-item {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: 9px;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  transition: color var(--t-fast) var(--ease);
}
.nav-item span { flex: 1; }
.nav-item kbd { opacity: 0; transition: opacity var(--t-fast) var(--ease); }
.nav-item:hover { color: var(--text); }
.nav-item:hover kbd { opacity: 1; }
.nav-item[aria-current='page'] { color: var(--text); font-weight: 600; }

.nav-marker {
  position: absolute;
  left: 0;
  width: 100%;
  height: 34px;
  border-radius: 9px;
  background: var(--mat-2);
  border: 1px solid var(--line-soft);
  border-top-color: var(--edge);
  /* y is driven by a spring, so switching sections mid-flight redirects instead of restarting. */
  transform: translate3d(0, var(--y, 0px), 0);
  opacity: 0;
  z-index: 0;
  transition: opacity var(--t-fast) var(--ease);
}
.nav-marker.is-on { opacity: 1; }
.nav-marker::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 10px;
  width: 3px;
  height: 14px;
  border-radius: 0 3px 3px 0;
  background: var(--spark);
}

.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 11px;
  border: 1px solid var(--line-soft);
  background: var(--mat-2);
  text-align: left;
  transform: scale(var(--press, 1));
  transition: border-color var(--t-fast) var(--ease), transform var(--t-press) var(--ease);
}
.side-user:hover { border-color: var(--line); }
.side-user svg { color: var(--text-faint); }
.side-user-meta { flex: 1; min-width: 0; }
.side-user-meta b { display: block; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-meta small { font-size: 10.5px; color: var(--text-faint); }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--mat-3);
  border: 1px solid var(--line-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  flex: none;
}

.side-scrim { display: none; }

/* ── Main ───────────────────────────────────────────── */
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; position: relative; }

/* Floating chrome: content scrolls *under* it. No 1px rule — the scroll edge fades instead. */
.topbar {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 60px;
  padding: 0 var(--pad);
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  flex: none;
  transition: box-shadow var(--t-mid) var(--ease);
}
.topbar.is-stuck { box-shadow: 0 1px 0 var(--line-soft), 0 12px 24px -18px rgba(0, 0, 0, 0.9); }
.topbar h1 { flex: 1; font-size: 18px; font-weight: 650; letter-spacing: -0.03em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.side-open { display: none; }

.view {
  flex: 1;
  overflow: auto;
  overscroll-behavior: contain;
  padding: calc(60px + var(--pad)) var(--pad) 64px;
  /* Content dissolves into the floating bar instead of being clipped by it. */
  -webkit-mask-image: linear-gradient(to bottom, transparent 60px, #000 84px);
  mask-image: linear-gradient(to bottom, transparent 60px, #000 84px);
}
.view > *:not(input) { animation: view-in 260ms var(--ease) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

.wrap { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--gap); }
.wrap-wide { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--gap); }

/* ── Panels, rows, grids ────────────────────────────── */
.panel {
  background: var(--mat-1);
  border: 1px solid var(--line-soft);
  border-top-color: var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  min-height: 46px;
}
.panel-head h2 { flex: 1; font-size: 13px; font-weight: 650; letter-spacing: -0.008em; }
.panel-head p { font-size: 12px; color: var(--text-faint); }
.panel-body { padding: 16px; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--row-h);
  padding: 8px 16px;
  border-bottom: 1px solid var(--line-soft);
  transition: background var(--t-fast) var(--ease);
  cursor: default;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--mat-2); }
.row-main { flex: 1; min-width: 0; }
.row-main b { display: block; font-size: 14px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main small { font-size: 12px; color: var(--text-faint); }
.row-acts { display: flex; gap: 2px; opacity: 0; transition: opacity var(--t-fast) var(--ease); }
.row:hover .row-acts, .row:focus-within .row-acts { opacity: 1; }
@media (hover: none) { .row-acts { opacity: 1; } }
.row-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--mat-2);
  border: 1px solid var(--line-soft);
  color: var(--text-dim);
  font-size: 14px;
  flex: none;
}
.row.is-link { cursor: pointer; }

.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.grid-tiles { grid-template-columns: repeat(auto-fill, minmax(164px, 1fr)); }

.card {
  background: var(--mat-1);
  border: 1px solid var(--line-soft);
  border-top-color: var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transform: scale(var(--press, 1));
  transition: border-color var(--t-fast) var(--ease), transform var(--t-press) var(--ease);
}
.card-head { display: flex; gap: 10px; align-items: center; }
.card-head-main { flex: 1; min-width: 0; }
.card-head-main b { display: block; font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-head-main small { color: var(--text-faint); font-size: 12px; }

/* ── Media tiles ────────────────────────────────────── */
.tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--mat-2);
  border: 1px solid var(--line-soft);
  cursor: zoom-in;
  transform: scale(var(--press, 1));
  transition: border-color var(--t-fast) var(--ease), transform var(--t-press) var(--ease);
}
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile:hover { border-color: var(--edge); }
.tile-spin { position: absolute; inset: 0; margin: auto; }
.tile-x {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  /* A small chip over an image: light material, tight blur. */
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px) saturate(140%);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  opacity: 0;
  transform: scale(var(--press, 1));
  transition: opacity var(--t-fast) var(--ease), transform var(--t-press) var(--ease);
}
.tile:hover .tile-x, .tile:focus-within .tile-x { opacity: 1; }
@media (hover: none) { .tile-x { opacity: 1; } }
.tile-foot {
  position: absolute;
  inset: auto 0 0 0;
  padding: 22px 10px 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.01em;
  text-align: left;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}
.tile-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 17px;
  pointer-events: none;
}

/* ── Audio player ───────────────────────────────────── */
.aud-play {
  width: 36px;
  height: 36px;
  border-radius: 99px;
  display: grid;
  place-items: center;
  background: var(--mat-3);
  border: 1px solid var(--line-soft);
  color: var(--text);
  flex: none;
  transform: scale(var(--press, 1));
  transition: background var(--t-fast) var(--ease), transform var(--t-press) var(--ease);
}
.row.is-playing .aud-play { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.aud-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.aud-name { font-size: 14px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aud-scrub {
  position: relative;
  height: 16px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}
.aud-track { height: 3px; width: 100%; border-radius: 99px; background: var(--mat-3); overflow: hidden; }
.aud-fill { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--text-dim); }
.row.is-playing .aud-fill { background: var(--spark); }
.aud-knob {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 99px;
  background: var(--text);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: scale(var(--knob, 1));
  transition: opacity var(--t-fast) var(--ease), transform var(--t-press) var(--ease);
}
.aud-scrub:hover .aud-knob, .row.is-playing .aud-knob, .aud-scrub.is-drag .aud-knob { opacity: 1; }
.aud-time { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; flex: none; }

/* ── Bits ───────────────────────────────────────────── */
.empty {
  display: grid;
  place-items: center;
  gap: 10px;
  text-align: center;
  padding: 64px 20px;
  color: var(--text-faint);
}
.empty-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  border: 1px solid var(--line-soft);
  background: var(--mat-2);
  color: var(--text-dim);
  font-size: 19px;
}
.empty h3 { font-size: 15px; font-weight: 600; color: var(--text-dim); }
.empty p { font-size: 13px; max-width: 42ch; line-height: 1.6; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--mat-2);
  border: 1px solid var(--line-soft);
  color: var(--text-dim);
  white-space: nowrap;
}
.tag-accent { background: var(--spark-soft); border-color: var(--spark-line); color: var(--spark); }
.tag-good { color: var(--good); border-color: color-mix(in srgb, var(--good) 34%, transparent); background: color-mix(in srgb, var(--good) 10%, transparent); }
.tag-bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 34%, transparent); background: color-mix(in srgb, var(--bad) 10%, transparent); }

.bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bar .input { flex: 1; min-width: 180px; }
.spacer { flex: 1; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; letter-spacing: 0; }
.note { font-size: 12.5px; color: var(--text-faint); line-height: 1.6; }

.kv { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.kv:first-child { padding-top: 0; }
.kv:last-child { border-bottom: 0; padding-bottom: 0; }
.kv > span { color: var(--text-dim); }
.kv > b { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.kv-flat { border-bottom: 0; padding: 5px 0; }

.crumbs { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-faint); flex-wrap: wrap; }
.crumbs button { color: var(--text-dim); font-weight: 600; border-radius: 5px; padding: 2px 4px; transition: color var(--t-fast) var(--ease); }
.crumbs button:hover { color: var(--text); }
.crumbs button:last-of-type { color: var(--text); }

/* ── Notes split ────────────────────────────────────── */
.split { display: grid; grid-template-columns: 268px 1fr; gap: var(--gap); align-items: start; }
.split-list { display: flex; flex-direction: column; gap: 4px; max-height: calc(100vh - 200px); overflow: auto; overscroll-behavior: contain; padding-right: 2px; }
.split-item {
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  transform: scale(var(--press, 1));
  transition: background var(--t-fast) var(--ease), transform var(--t-press) var(--ease);
}
.split-item:hover { background: var(--mat-2); }
.split-item.is-on { background: var(--mat-1); border-color: var(--line-soft); border-top-color: var(--line); }
.split-item b { display: block; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split-item small { font-size: 11.5px; color: var(--text-faint); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor { display: flex; flex-direction: column; gap: 12px; }
.editor input.title { background: none; border: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.032em; padding: 0; }
.editor input.title:focus { outline: none; }
.editor textarea { min-height: 46vh; background: none; border: 0; resize: none; line-height: 1.75; color: var(--text-dim); }
.editor textarea:focus { outline: none; }

/* ── Calendar ───────────────────────────────────────── */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.cal-dow { background: var(--bg-2); padding: 9px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); text-align: center; }
.cal-cell { background: var(--bg); min-height: 104px; padding: 8px; text-align: left; transition: background var(--t-fast) var(--ease); display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.cal-cell:hover { background: var(--mat-2); }
.cal-cell.is-out { opacity: 0.38; }
.cal-day { font-size: 12px; font-weight: 600; color: var(--text-dim); width: 22px; height: 22px; display: grid; place-items: center; border-radius: 7px; flex: none; }
.cal-cell.is-today .cal-day { background: var(--spark); color: #fff; }
.cal-ev { font-size: 11px; font-weight: 550; padding: 3px 6px; border-radius: 6px; background: var(--mat-3); color: var(--text); border: 1px solid var(--line-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; text-align: left; }
.cal-ev:hover { border-color: var(--edge); }

/* ── Tasks ──────────────────────────────────────────── */
.check {
  width: 20px;
  height: 20px;
  border-radius: 7px;
  border: 1.5px solid var(--line);
  display: grid;
  place-items: center;
  color: transparent;
  font-size: 11px;
  flex: none;
  transform: scale(var(--press, 1));
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-press) var(--ease);
}
.check:hover { border-color: var(--text-faint); }
.check.is-on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.row.is-done .row-main b { text-decoration: line-through; color: var(--text-faint); }

/* ── Modal ──────────────────────────────────────────── */
.modal-layer { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; }
/* Dim to focus: a modal is a blocking task, so the ground goes back and down. */
.modal-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(4px); animation: fadein var(--t-fast) var(--ease) both; }
@keyframes fadein { from { opacity: 0; } }
.modal {
  position: relative;
  width: min(480px, 100%);
  max-height: 86vh;
  overflow: auto;
  overscroll-behavior: contain;
  background: color-mix(in srgb, var(--mat-solid) 84%, transparent);
  backdrop-filter: blur(30px) saturate(160%);
  -webkit-backdrop-filter: blur(30px) saturate(160%);
  border: 1px solid var(--line);
  border-top-color: var(--edge);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 22px;
  /* Anchored to whatever opened it (set from JS) so it grows out of its trigger. */
  transform-origin: var(--ox, 50%) var(--oy, 50%);
  animation: materialize var(--t-mid) var(--ease) both;
}
.modal.is-out { animation: dematerialize var(--t-fast) var(--ease) both; }
@keyframes dematerialize { to { opacity: 0; transform: scale(0.97); } }
.modal-lg { width: min(760px, 100%); }
.modal h2 { font-size: 17.5px; font-weight: 650; letter-spacing: -0.022em; margin-bottom: 4px; }
.modal > p.sub { font-size: 13px; color: var(--text-faint); margin-bottom: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ── Palette ────────────────────────────────────────── */
.palette-layer { position: fixed; inset: 0; z-index: 300; display: grid; place-items: start center; padding: 12vh 20px 20px; }
.palette-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); animation: fadein 120ms var(--ease) both; }
.palette {
  position: relative;
  width: min(560px, 100%);
  background: color-mix(in srgb, var(--mat-solid) 82%, transparent);
  backdrop-filter: blur(32px) saturate(170%);
  -webkit-backdrop-filter: blur(32px) saturate(170%);
  border: 1px solid var(--line);
  border-top-color: var(--edge);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: materialize 180ms var(--ease) both;
}
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 15px; border-bottom: 1px solid var(--line-soft); color: var(--text-faint); }
.palette-input input { flex: 1; background: none; border: 0; font-size: 15px; min-width: 0; }
.palette-input input:focus { outline: none; }
.palette-input input::placeholder { color: var(--text-faint); }
.palette-list { list-style: none; max-height: 340px; overflow: auto; overscroll-behavior: contain; padding: 6px; }
.palette-sec { font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); padding: 8px 8px 4px; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 9px; font-size: 14px; cursor: pointer; color: var(--text-dim); }
.palette-item svg { color: var(--text-faint); }
.palette-item b { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item[aria-selected='true'] { background: var(--mat-3); color: var(--text); }
.palette-item[aria-selected='true'] svg { color: var(--text); }
.palette-empty { padding: 28px; text-align: center; color: var(--text-faint); font-size: 13px; }

/* ── Toasts ─────────────────────────────────────────── */
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 400; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--mat-solid) 86%, transparent);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--line);
  border-top-color: var(--edge);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 500;
  max-width: min(380px, calc(100vw - 36px));
  animation: toast-in var(--t-mid) var(--ease) both;
}
.toast span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast.is-out { animation: toast-out var(--t-fast) var(--ease) both; }
.toast[data-kind='error'] svg { color: var(--bad); }
.toast[data-kind='ok'] svg { color: var(--good); }
.toast[data-kind='work'] svg { color: var(--text-faint); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(0.98); } }

/* ── Boot ───────────────────────────────────────────── */
.boot { position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; background: var(--bg); }
.boot-spin {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--text);
  animation: spin 620ms linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    z-index: 150;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    /* x is a spring, so the drawer can be grabbed and reversed mid-flight. */
    transform: translate3d(var(--x, -100%), 0, 0);
    touch-action: pan-y;
  }
  .side-open, .side-close { display: grid; }
  .side-scrim { display: block; position: fixed; inset: 0; z-index: 140; background: rgba(0, 0, 0, 0.5); opacity: var(--o, 1); }
  .split { grid-template-columns: 1fr; }
  .split-list { max-height: 208px; }
  .cal-cell { min-height: 64px; padding: 5px; }
  .cal-ev { font-size: 10px; padding: 2px 4px; }
  .editor textarea { min-height: 40vh; }
}

/* Reduced motion: cross-fade, drop travel and overshoot. Feedback stays. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  .dither { animation: none; }
}
:root[data-motion='off'] *, :root[data-motion='off'] *::before, :root[data-motion='off'] *::after {
  animation-duration: 1ms !important;
  transition-duration: 1ms !important;
}

@media (prefers-reduced-transparency: reduce) {
  .gate-panel, .modal, .palette, .toast, .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg-2); }
  .view { -webkit-mask-image: none; mask-image: none; }
}
@media (prefers-contrast: more) {
  :root { --line: rgba(255, 255, 255, 0.34); --line-soft: rgba(255, 255, 255, 0.2); --text-dim: rgba(244, 244, 246, 0.85); --text-faint: rgba(244, 244, 246, 0.62); }
  .gate-panel, .modal, .palette, .toast { background: var(--bg-2); backdrop-filter: none; }
}
