:root {
  /* Kymograph palette — graphite drum-liner ground + cadmium red ink */
  --bg: #0e0c0a;                 /* dark graphite drum ground */
  --bg-2: #14110d;               /* recessed plate well */
  --plate: #1a1613;              /* raised instrument plate */
  --plate-hi: #211c17;           /* plate highlight */
  --fg: #eee5d1;                 /* aged bone (like uninked paper) */
  --muted: #8a7c68;              /* faded ink annotation */
  --dim: #4a4238;                /* fully spent ink */
  --ink: #c62526;                /* cadmium red — primary data trace */
  --ink-2: #7a4a2a;              /* ferric brown — secondary annotation */
  --brass: #b58a3a;              /* brass hairline rule */
  --brass-hi: #d9b878;           /* brass highlight edge */
  --grid: rgba(180, 150, 100, 0.10);   /* engraved sepia grid */
  --grid-strong: rgba(180, 150, 100, 0.22);
  --line: rgba(181, 138, 58, 0.14);    /* brass at rest */
  --line-2: rgba(181, 138, 58, 0.28);  /* brass on emphasis */
  --pilot: #ff3020;              /* pilot lamp red */
  --danger: #ff3020;

  /* Inter — hyper-legible UI face. JetBrains Mono only for measured numerals. */
  --font-display: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --font-label: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", ui-sans-serif, system-ui, sans-serif;
}

body { font-feature-settings: "cv11", "ss01", "ss03"; }
/* Tabular figures for data + numeric readouts */
#stats .stat .v, .milestone .m-v, .big-stat .num, .bar-val, .np-v, .np-cal-mark,
.pct, .otd-year, .tb-pill, .otd-tags, #legend, .persona-meta,
.wrapped-card .wc-stat .v, .wrapped-card .wc-row .plays, .wrapped-card .wc-row .n {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum", "cv11";
}

* { box-sizing: border-box; }

.yg-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.yg-chips .chip { font-size: 10px; padding: 3px 8px; }

.cmp-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin: 8px 0; }
.cmp-col { background: rgba(122, 74, 42, 0.10); border: 1px solid var(--line); padding: 8px 10px; border-radius: 3px; }
.cmp-k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }
.cmp-v { font-family: var(--font-mono); font-size: 22px; color: var(--fg); font-variant-numeric: tabular-nums; }
.cmp-v .sub { display: block; font-size: 10px; color: var(--muted); font-family: var(--font-body); font-weight: 500; margin-top: 2px; }

.hl-marker { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); box-shadow: 0 0 4px var(--ink); }

.sig-row { padding: 6px 0; border-bottom: 1px solid var(--line); }
.sig-row:last-child { border-bottom: 0; }
.sig-head { display: flex; align-items: baseline; gap: 8px; }
.sig-len { color: var(--ink); font-family: var(--font-mono); font-size: 14px; font-variant-numeric: tabular-nums; min-width: 32px; }
.sig-artist { color: var(--fg); font-weight: 600; flex: 1; }
.sig-date { color: var(--muted); font-family: var(--font-mono); }
.sig-top { color: var(--muted); margin-left: 40px; }

.dv-row { display: grid; grid-template-columns: 1fr 60px 32px; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); }
.dv-row:last-child { border-bottom: 0; }
.dv-pair { display: grid; grid-template-columns: 1fr 14px 1fr; gap: 6px; align-items: center; font-size: 11px; }
.dv-a, .dv-b { color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dv-arr { color: var(--ink); font-family: var(--font-mono); text-align: center; }
.dv-track { height: 4px; background: rgba(122,74,42,0.15); border-radius: 2px; overflow: hidden; }
.dv-fill { display: block; height: 100%; background: var(--ink); }
.dv-n { color: var(--muted); font-family: var(--font-mono); font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; }

/* ============ Action dropdowns (bottom bar) ============ */
.actions-menus {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin: 28px 0 18px;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(24, 20, 16, 0.55), rgba(14, 12, 10, 0.55));
  border: 1px solid rgba(217, 184, 120, 0.14);
  border-radius: 14px;
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
}
.dd { position: relative; }
.dd-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  font-family: var(--font-body); font-size: 13px; font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--fg);
  background: rgba(38, 32, 26, 0.7);
  border: 1px solid rgba(217, 184, 120, 0.18);
  border-radius: 10px;
  cursor: pointer;
  transition: background 180ms cubic-bezier(0.32, 0.72, 0.24, 1),
              border-color 180ms, transform 180ms cubic-bezier(0.32, 0.72, 0.24, 1);
}
.dd-trigger:hover { background: rgba(48, 40, 32, 0.85); border-color: rgba(217, 184, 120, 0.28); }
.dd-trigger:active { transform: scale(0.97); }
.dd-trigger.cta {
  background: linear-gradient(180deg, rgba(198, 37, 38, 0.85), rgba(154, 28, 30, 0.85));
  border-color: rgba(198, 37, 38, 0.6);
  color: var(--fg);
  box-shadow: 0 2px 8px -2px rgba(198, 37, 38, 0.4), inset 0 1px 0 rgba(255,255,255,0.1);
}
.dd-trigger.cta:hover { background: linear-gradient(180deg, rgba(220, 50, 52, 0.9), rgba(180, 34, 36, 0.9)); }
.dd-caret {
  font-size: 9px; color: var(--brass-hi); opacity: 0.75;
  transition: transform 220ms cubic-bezier(0.32, 0.72, 0.24, 1);
}
.dd.open .dd-caret { transform: rotate(180deg); }
.dd-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0;
  min-width: 200px;
  background: rgba(24, 20, 16, 0.92);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid rgba(217, 184, 120, 0.18);
  border-radius: 12px;
  padding: 6px;
  box-shadow:
    0 20px 50px -20px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  opacity: 0; pointer-events: none;
  transform: translateY(6px) scale(0.98);
  transform-origin: bottom left;
  transition: opacity 200ms cubic-bezier(0.32, 0.72, 0.24, 1),
              transform 220ms cubic-bezier(0.32, 0.72, 0.24, 1);
  z-index: 8000;
}
.dd.open .dd-menu { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }
.dd-section-title {
  font-family: var(--font-label); font-size: 9.5px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted);
  padding: 8px 10px 4px;
  font-weight: 600;
}
.dd-section-title:first-child { padding-top: 4px; }
.dd-section-title.dd-section-danger { color: rgba(255, 80, 60, 0.65); }
.dd-item {
  display: block; width: 100%;
  padding: 8px 12px; margin: 1px 0;
  font-family: var(--font-body); font-size: 13px; font-weight: 450;
  letter-spacing: -0.005em;
  color: var(--fg); text-align: left;
  background: transparent; border: 0; cursor: pointer;
  border-radius: 7px;
  transition: background 160ms cubic-bezier(0.32, 0.72, 0.24, 1), color 160ms;
}
.dd-item:hover { background: rgba(217, 184, 120, 0.10); }
.dd-item:active { background: rgba(217, 184, 120, 0.18); }
.dd-item.dd-danger { color: rgba(255, 120, 100, 0.9); }
.dd-item.dd-danger:hover { background: rgba(198, 37, 38, 0.16); color: var(--fg); }

.dp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.dp-quad { background: rgba(122, 74, 42, 0.08); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.dp-head { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--fg); font-weight: 600; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: baseline; }
.dp-sub { color: var(--muted); font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.08em; font-weight: 400; }
.dp-row { display: grid; grid-template-columns: 70px 1fr 32px; gap: 6px; align-items: center; padding: 2px 0; font-size: 11px; }
.dp-name { text-transform: capitalize; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-track { height: 4px; background: rgba(122,74,42,0.15); border-radius: 2px; overflow: hidden; }
.dp-fill { display: block; height: 100%; }
.dp-val { font-family: var(--font-mono); font-size: 10px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.focus-dial { text-align: center; padding: 6px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.focus-num { font-family: var(--font-mono); font-size: 38px; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1; }
.focus-unit { font-size: 18px; color: var(--muted); margin-left: 2px; }
.focus-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--fg); margin-top: 2px; }
.focus-sub { color: var(--muted); }
.focus-bar { display: grid; grid-template-columns: 60px 1fr 70px; gap: 8px; align-items: center; padding: 4px 0; }
.fb-k { font-size: 11px; color: var(--fg); }
.fb-track { height: 5px; background: rgba(122,74,42,0.15); border-radius: 3px; overflow: hidden; }
.fb-fill { display: block; height: 100%; }
.fb-v { font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.cmd-panel { max-width: 620px; width: 92vw; padding: 12px; }
.cmd-panel input {
  width: 100%; padding: 12px 14px; background: rgba(20, 17, 13, 0.9); border: 1px solid var(--brass);
  color: var(--fg); font-family: var(--font-body); font-size: 15px; border-radius: 3px; outline: none;
}
.cmd-panel input:focus { border-color: var(--brass-hi); box-shadow: 0 0 0 2px rgba(217,184,120,0.15); }
.cmd-list { max-height: 46vh; overflow-y: auto; margin: 10px 0 6px; }
.cmd-item {
  display: grid; grid-template-columns: 74px 1fr; gap: 10px; align-items: center;
  padding: 6px 10px; border-radius: 2px; cursor: pointer; font-size: 13px;
}
.cmd-item:hover, .cmd-item.active { background: rgba(198,37,38,0.14); }
.cmd-cat { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--brass); }
.cmd-label { color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-empty { padding: 20px; text-align: center; color: var(--muted); }
.cmd-foot { color: var(--muted); text-align: right; padding: 2px 4px 0; }

.tb-machine input[type="range"] {
  flex: 1; min-width: 200px; height: 4px; background: rgba(122,74,42,0.3);
  appearance: none; -webkit-appearance: none; outline: none; border-radius: 2px;
}
.tb-machine input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 14px; height: 14px; background: var(--ink);
  border: 1px solid var(--brass-hi); border-radius: 50%; cursor: pointer;
  box-shadow: 0 0 6px rgba(198,37,38,0.6);
}
.tb-machine input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; background: var(--ink); border: 1px solid var(--brass-hi); border-radius: 50%; cursor: pointer;
}
.tb-machine-label { min-width: 130px; color: var(--brass-hi); font-family: var(--font-mono); }

@media print {
  body, .paper-fiber, body::before { background: #ffffff !important; color: #0a0a0a !important; }
  .paper-fiber, body::before { display: none !important; }
  .toolbar, .time-tb, .actions, footer, .modal, #legend, #sync-status, .np-help,
  #ins-map, #ins-snapshots, #ins-age, #ins-onthisday, .np-eyeplate .np-pilot {
    display: none !important;
  }
  main { max-width: 100% !important; padding: 12mm !important; }
  .glass, .ins-panel {
    background: #ffffff !important; box-shadow: none !important;
    border: 0.5pt solid #333 !important; break-inside: avoid;
    color: #0a0a0a !important;
  }
  .nameplate h1, .nameplate .tag, .np-k, .np-v, .np-cal-mark,
  .ins-title, .stat .k, .stat .v, .stat .sub, .bar-name, .bar-val,
  .milestone .m-k, .milestone .m-v { color: #0a0a0a !important; }
  #chart .cell { stroke: #000 !important; stroke-width: 0.3 !important; }
  #chart .cell[fill^="hsl(2"], #chart .cell[fill^="rgb(198"] { fill: #0a0a0a !important; }
  #chart text, .hour-bar { fill: #333 !important; }
  .bar-fill-el { background: #333 !important; }
  .insights-grid { display: block !important; }
  .ins-panel { margin-bottom: 8mm; }
  #chart-wrap svg { max-width: 160mm; }
  a { color: #333 !important; border-bottom: 0 !important; }
}
body.printing #chart-wrap { background: #ffffff; }

#medals-body { display: flex; flex-wrap: wrap; gap: 10px; }
.medal-pip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 10px; border: 1px solid var(--brass); border-radius: 24px;
  background: linear-gradient(180deg, rgba(181,138,58,0.14), rgba(122,74,42,0.08));
  font-size: 11px; color: var(--fg);
}
.medal-ring { font-size: 12px; color: var(--brass); line-height: 1; }
.medal-pip.tier-2 { border-color: var(--brass-hi); background: linear-gradient(180deg, rgba(217,184,120,0.20), rgba(181,138,58,0.10)); }
.medal-pip.tier-2 .medal-ring { color: var(--brass-hi); }
.medal-pip.tier-3 { border-color: var(--ink); background: linear-gradient(180deg, rgba(198,37,38,0.22), rgba(122,74,42,0.14)); }
.medal-pip.tier-3 .medal-ring { color: var(--ink); text-shadow: 0 0 6px var(--ink); }
.medal-label { font-weight: 600; letter-spacing: 0.02em; }
.medal-sub { color: var(--muted); font-family: var(--font-mono); }

.nov-sess { padding: 8px 0; border-bottom: 1px solid var(--line); }
.nov-sess:last-child { border-bottom: 0; }
.nov-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.nov-badge { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.14em; padding: 2px 6px; border: 1px solid; border-radius: 2px; }
.nov-num { font-family: var(--font-mono); font-size: 20px; color: var(--fg); font-variant-numeric: tabular-nums; }
.nov-artists { color: var(--muted); margin-top: 4px; }

.gem-row { display: grid; grid-template-columns: 1fr auto; row-gap: 2px; column-gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.gem-row:last-child { border-bottom: 0; }
.gem-track { color: var(--fg); font-size: 12px; }
.gem-artist { color: var(--brass); grid-column: 1; }
.gem-meta { grid-column: 2; grid-row: 1 / span 2; text-align: right; align-self: center; }
.gem-plays { font-family: var(--font-mono); color: var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; }
.gem-share { display: block; color: var(--muted); font-family: var(--font-mono); }

/* ============ Retro terminal mode — P1 phosphor CRT override, press T ============ */
body.terminal {
  --fg: #b7ffb0;
  --muted: #4f9c4a;
  --brass: #4f9c4a;
  --brass-hi: #b7ffb0;
  --ink: #6bff6b;
  --ink-2: #2f7a2a;
  --pilot: #6bff6b;
  --grid: rgba(107, 255, 107, 0.10);
  --grid-strong: rgba(107, 255, 107, 0.22);
  --line: rgba(107, 255, 107, 0.14);
  --line-2: rgba(107, 255, 107, 0.28);
  color: var(--fg) !important;
}
body.terminal::before {
  background:
    radial-gradient(60vw 60vw at 12% 8%, rgba(107, 255, 107, 0.10) 0%, transparent 60%),
    radial-gradient(50vw 50vw at 88% 30%, rgba(47, 122, 42, 0.14) 0%, transparent 55%),
    linear-gradient(180deg, #030a03 0%, #010401 100%) !important;
}
body.terminal .paper-fiber { opacity: 0.12; mix-blend-mode: screen; }
body.terminal::after {
  content: "";
  position: fixed; inset: 0; z-index: 9998; pointer-events: none;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.25) 2px,
    rgba(0, 0, 0, 0.25) 3px
  );
  mix-blend-mode: multiply;
}
body.terminal, body.terminal .stat .v, body.terminal .np-v,
body.terminal .persona-badge, body.terminal .m-v, body.terminal .cmp-v,
body.terminal .focus-num, body.terminal h1, body.terminal h3, body.terminal h4 {
  text-shadow: 0 0 4px rgba(107, 255, 107, 0.6);
}
body.terminal #chart .cell { filter: drop-shadow(0 0 3px rgba(107, 255, 107, 0.55)); }
body.terminal #chart .cell[fill^="hsl(2"], body.terminal #chart .cell[fill^="rgb(198"] {
  fill: #6bff6b !important;
}
body.terminal .ins-panel, body.terminal .glass {
  background: rgba(2, 15, 2, 0.72) !important;
  border-color: rgba(107, 255, 107, 0.35) !important;
  box-shadow: 0 0 24px rgba(107, 255, 107, 0.08) inset !important;
}
body.terminal .cta, body.terminal .ghost {
  color: #b7ffb0 !important; border-color: #4f9c4a !important;
  background: rgba(107, 255, 107, 0.06) !important;
}
body.terminal a { color: #b7ffb0 !important; border-bottom-color: #4f9c4a !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
body { overflow-x: clip; }

/* Paper-fiber noise ground — SVG-based, fixed, subtle */
.paper-fiber {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.28;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.4 0 0 0 0 0.32 0 0 0 0 0.22 0 0 0 0.55 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 240px 240px;
}
/* Ambient warmth beneath — gives the liquid glass something to soak */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(60vw 60vw at 12% 8%, rgba(198, 37, 38, 0.18) 0%, transparent 60%),
    radial-gradient(50vw 50vw at 88% 30%, rgba(122, 74, 42, 0.22) 0%, transparent 55%),
    radial-gradient(70vw 70vw at 50% 110%, rgba(181, 138, 58, 0.10) 0%, transparent 60%),
    linear-gradient(180deg, #0f0d0b 0%, #0a0908 100%);
}

a {
  color: var(--brass-hi);
  text-decoration: none;
  border-bottom: 1px solid var(--brass);
  padding-bottom: 1px;
  transition: color 120ms, border-color 120ms;
}
a:hover { color: var(--fg); border-bottom-color: var(--brass-hi); }

main {
  max-width: 1240px;
  margin: 0 auto 0 250px;
  padding: 48px 24px 96px;
  position: relative;
  z-index: 1;
}
@media (max-width: 1100px) { main { margin-left: 0; max-width: 100%; } }
body.sn-collapsed main { margin-left: 60px; }

/* Pre-fingerprint 2-column layout — form left, info cards right filling the empty space */
.pre-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 20px;
  margin-bottom: 24px;
  align-items: start;
}
@media (max-width: 960px) { .pre-grid { grid-template-columns: 1fr; } }
.pre-grid #form-panel { margin-bottom: 0; }
.pre-info { display: flex; flex-direction: column; gap: 14px; }
.info-card {
  padding: 16px 18px;
  border-radius: 3px;
}
.info-title {
  font-family: var(--font-display); font-size: 14px; font-weight: 600;
  color: var(--fg); padding-bottom: 8px; margin-bottom: 10px;
  border-bottom: 1px solid rgba(217, 184, 120, 0.12);
  display: flex; align-items: center; gap: 8px;
}
.info-badge {
  margin-left: auto;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.14em;
  color: var(--ink); border: 1px solid var(--ink); padding: 2px 6px; border-radius: 2px;
  background: rgba(198, 37, 38, 0.08);
}
.info-list, .info-steps {
  margin: 0; padding-left: 18px;
  font-size: 12px; color: var(--fg); line-height: 1.6;
}
.info-list li, .info-steps li { padding: 2px 0; color: var(--muted); }
.info-list li b { color: var(--fg); font-weight: 600; }
.info-list code {
  font-family: var(--font-mono); font-size: 11px; color: var(--brass-hi);
  background: rgba(0, 0, 0, 0.3); padding: 1px 5px; border-radius: 2px;
}
.info-kbd { font-size: 12px; color: var(--muted); }
.info-kbd > div { padding: 3px 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.info-kbd kbd {
  font-family: var(--font-mono); font-size: 10px;
  padding: 1px 6px; border: 1px solid var(--brass);
  background: rgba(0, 0, 0, 0.3); color: var(--brass-hi); border-radius: 2px;
}

/* Hide info cards once fingerprint rendered — modern browsers via :has(), fallback via body class */
body:has(#result:not(.hidden)) .pre-info,
body.result-active .pre-info { display: none; }
body:has(#result:not(.hidden)) .pre-grid,
body.result-active .pre-grid { grid-template-columns: 1fr; }

/* ============ Fixed side navigation — Apple-sleek ============ */
.side-nav {
  position: fixed !important;
  top: 14px; left: 14px; bottom: 14px;
  width: 236px; height: calc(100vh - 28px);
  z-index: 9000;
  background: linear-gradient(180deg, rgba(24, 20, 16, 0.72), rgba(14, 12, 10, 0.72));
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid rgba(217, 184, 120, 0.16);
  border-radius: 18px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 20px 50px -20px rgba(0, 0, 0, 0.75),
    0 0 0 1px rgba(0, 0, 0, 0.35);
  display: flex !important; flex-direction: column;
  transition: width 340ms cubic-bezier(0.32, 0.72, 0.24, 1),
              transform 340ms cubic-bezier(0.32, 0.72, 0.24, 1),
              border-radius 240ms ease;
  overflow: visible;
  visibility: visible !important;
  opacity: 1;
}
#sn-mobile-toggle { z-index: 9001 !important; }
.sn-body, .sn-head { overflow: hidden; }
body.sn-collapsed .side-nav { width: 58px; }
body.sn-collapsed .side-nav .sn-title,
body.sn-collapsed .side-nav .sn-group-title,
body.sn-collapsed .side-nav .sn-body a,
body.sn-collapsed .side-nav .sn-body button {
  opacity: 0; pointer-events: none;
  transform: translateX(-4px);
}
body.sn-collapsed .sn-title { display: none; }
.sn-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(217, 184, 120, 0.10);
  min-height: 58px;
  position: relative;
}
.sn-logo {
  font-family: var(--font-mono); font-weight: 700;
  color: var(--fg); font-size: 12px; letter-spacing: 0.08em;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(198, 37, 38, 0.85), rgba(122, 74, 42, 0.85));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 2px 8px -2px rgba(198, 37, 38, 0.5);
  flex-shrink: 0;
}
.sn-title {
  color: var(--fg); font-size: 12.5px; letter-spacing: 0.02em;
  font-weight: 600; flex: 1;
  transition: opacity 200ms;
  text-transform: none;
}
/* Drawer handle — floating pill on right edge */
.sn-toggle {
  position: absolute;
  top: 22px;
  right: -12px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(38, 32, 26, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(217, 184, 120, 0.24);
  color: var(--brass-hi);
  cursor: pointer;
  font-family: var(--font-body); font-size: 11px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  z-index: 9002;
  box-shadow:
    0 4px 12px -2px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 340ms cubic-bezier(0.32, 0.72, 0.24, 1),
              background 180ms, color 180ms, border-color 180ms;
}
.sn-toggle:hover {
  background: rgba(198, 37, 38, 0.85);
  color: var(--fg);
  border-color: rgba(198, 37, 38, 0.9);
}
body.sn-collapsed .sn-toggle { transform: rotate(180deg); }
.sn-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(181, 138, 58, 0.2) transparent;
  mask-image: linear-gradient(180deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
}
.sn-body::-webkit-scrollbar { width: 4px; }
.sn-body::-webkit-scrollbar-track { background: transparent; }
.sn-body::-webkit-scrollbar-thumb {
  background: rgba(181, 138, 58, 0.18);
  border-radius: 2px;
}
.sn-body::-webkit-scrollbar-thumb:hover { background: rgba(181, 138, 58, 0.32); }
.sn-group { padding: 8px 4px 6px; }
.sn-group + .sn-group {
  margin-top: 4px;
  border-top: 1px solid rgba(217, 184, 120, 0.06);
  padding-top: 12px;
}
.sn-group-title {
  font-family: var(--font-label); font-size: 10px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); padding: 4px 10px 6px;
  transition: opacity 200ms;
  font-weight: 600;
}
.sn-body a, .sn-body button {
  display: flex; align-items: center; width: 100%;
  padding: 7px 12px; margin: 1px 0;
  color: var(--fg); font-size: 13px; text-align: left;
  border: 0; background: transparent; cursor: pointer;
  border-radius: 8px; border-bottom: 0 !important;
  font-family: var(--font-body); letter-spacing: -0.005em;
  font-weight: 450;
  line-height: 1.25;
  transition: background 200ms cubic-bezier(0.32, 0.72, 0.24, 1),
              color 180ms, transform 200ms cubic-bezier(0.32, 0.72, 0.24, 1);
  text-decoration: none;
  position: relative;
  will-change: background;
}
.sn-body a:hover, .sn-body button:hover {
  background: rgba(217, 184, 120, 0.08);
  color: var(--fg);
}
.sn-body a:active, .sn-body button:active {
  transform: scale(0.98);
  background: rgba(217, 184, 120, 0.14);
}
.sn-body a.active {
  background: linear-gradient(180deg, rgba(198, 37, 38, 0.22), rgba(198, 37, 38, 0.14));
  color: var(--fg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 1px 6px -2px rgba(198, 37, 38, 0.5);
}
.sn-body a.active::before {
  content: "";
  position: absolute;
  left: -4px; top: 50%;
  width: 3px; height: 16px;
  background: var(--ink);
  border-radius: 0 2px 2px 0;
  transform: translateY(-50%);
  box-shadow: 0 0 6px rgba(198, 37, 38, 0.5);
}
.sn-actions button {
  color: var(--brass-hi);
  font-family: var(--font-body);
  font-size: 12.5px;
  letter-spacing: -0.005em;
  font-weight: 450;
}
.sn-actions button:hover {
  background: rgba(217, 184, 120, 0.1);
  color: var(--fg);
}
@media (max-width: 1100px) {
  .side-nav {
    top: 0; left: 0; bottom: 0;
    height: 100vh;
    border-radius: 0;
    border-left: 0; border-top: 0; border-bottom: 0;
    transform: translateX(-100%);
  }
  body.sn-open .side-nav { transform: translateX(0); }
}
#sn-mobile-toggle {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 41;
  background: rgba(38, 32, 26, 0.72);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(217, 184, 120, 0.2);
  color: var(--fg);
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
  font-family: var(--font-body); font-size: 17px; font-weight: 500;
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.4);
  transition: background 180ms, transform 200ms;
}
#sn-mobile-toggle:hover { background: rgba(198, 37, 38, 0.75); }
#sn-mobile-toggle:active { transform: scale(0.96); }
@media (max-width: 1100px) { #sn-mobile-toggle { display: block; } }

/* ============ Nameplate header ============ */
.nameplate { margin: 0 0 40px; }
.nameplate-inner {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: flex-start;
  padding: 8px 4px 24px;
  position: relative;
}

.np-eyeplate {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 4px 10px;
  border: 1px solid rgba(217, 184, 120, 0.24);
  background: rgba(38, 32, 26, 0.32);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 999px;
  margin-bottom: 14px;
}
.np-pilot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ff6a4a 0%, var(--pilot) 45%, #6a0d08 100%);
  box-shadow: 0 0 6px var(--pilot), inset 0 -1px 1px rgba(0,0,0,0.6);
  animation: pilot-blink 3.4s ease-in-out infinite;
}
@keyframes pilot-blink {
  0%, 60%, 100% { opacity: 1; }
  62%, 66% { opacity: 0.4; }
  70% { opacity: 1; }
}
.np-cal-mark {
  font-family: var(--font-label);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--brass-hi);
  text-transform: uppercase;
}

h1 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: clamp(34px, 7vw, 68px);
  line-height: 0.95;
  margin: 0;
  color: var(--fg);
  text-transform: uppercase;
}
.np-sep {
  color: var(--ink);
  padding: 0 6px;
  font-weight: 400;
}
.tag {
  color: var(--fg);
  margin: 14px 0 0;
  font-family: var(--font-label);
  font-size: 15px;
  letter-spacing: 0.02em;
  max-width: 640px;
  opacity: 0.72;
}

.np-right { align-self: stretch; display: flex; align-items: flex-start; }
.np-meta {
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px 24px;
  padding: 16px 20px;
  border: 1px solid rgba(217, 184, 120, 0.14);
  border-radius: 14px;
  background: rgba(38, 32, 26, 0.42);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  box-shadow:
    inset 0 1px 0 rgba(255, 245, 220, 0.08),
    0 8px 24px -12px rgba(0, 0, 0, 0.5);
  font-family: var(--font-label);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.np-row { display: contents; }
.np-k { color: var(--muted); }
.np-v { color: var(--brass-hi); text-align: right; }

@media (max-width: 720px) {
  .nameplate-inner { grid-template-columns: 1fr; }
  .np-right { justify-content: flex-start; }
}

/* Liquid glass — translucent plate, backdrop blur, specular hairline */
.glass {
  position: relative;
  background:
    linear-gradient(180deg, rgba(38, 32, 26, 0.62) 0%, rgba(22, 18, 15, 0.52) 100%);
  border: 1px solid rgba(217, 184, 120, 0.12);
  border-radius: 18px;
  backdrop-filter: blur(28px) saturate(1.35);
  -webkit-backdrop-filter: blur(28px) saturate(1.35);
  box-shadow:
    inset 0 1px 0 rgba(255, 245, 220, 0.10),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35),
    0 1px 2px rgba(0, 0, 0, 0.35),
    0 24px 48px -20px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  isolation: isolate;
}
/* Specular sweep across the top — the "wet" highlight of liquid glass */
.glass::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 60%;
  background: linear-gradient(180deg, rgba(255, 245, 220, 0.06) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
  border-radius: inherit;
}
.glass > * { position: relative; z-index: 1; }

.panel { padding: 28px 28px 24px; margin-bottom: 20px; }

.row {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr;
  gap: 20px;
  margin-bottom: 22px;
}
@media (max-width: 720px) { .row { grid-template-columns: 1fr; } }

/* Field label — sentence case, calm */
label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--fg);
  letter-spacing: 0;
  font-weight: 500;
  position: relative;
}

/* Glass input field */
input, select {
  background: rgba(20, 17, 13, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(217, 184, 120, 0.18);
  color: var(--fg);
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 15px;
  font-family: var(--font-body);
  letter-spacing: 0.01em;
  transition: box-shadow 200ms, border-color 200ms, background 200ms;
  box-shadow:
    inset 0 1px 0 rgba(255, 245, 220, 0.06),
    0 1px 2px rgba(0, 0, 0, 0.25);
}
input::placeholder { color: var(--muted); }
input:hover, select:hover { border-color: rgba(217, 184, 120, 0.32); }
input:focus, select:focus {
  outline: none;
  border-color: rgba(217, 184, 120, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 245, 220, 0.08),
    0 0 0 3px rgba(217, 184, 120, 0.18);
}
select {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--brass-hi) 50%),
    linear-gradient(-45deg, transparent 50%, var(--brass-hi) 50%);
  background-position:
    calc(100% - 18px) 22px,
    calc(100% - 12px) 22px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

small { color: var(--muted); font-family: var(--font-body); font-size: 12px; letter-spacing: 0; margin-top: 6px; font-weight: 400; }

button {
  font-family: var(--font-display);
}
/* Primary — cadmium ink lozenge, capsule radius, subtle inner highlight */
button.cta {
  position: relative;
  background: linear-gradient(180deg, #d93028 0%, #b1201f 100%);
  color: #fff5ee;
  border: 1px solid rgba(255, 200, 190, 0.22);
  padding: 14px 28px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
  text-transform: none;
  cursor: pointer;
  transition: transform 120ms cubic-bezier(0.22, 1, 0.36, 1), filter 140ms, box-shadow 200ms;
  box-shadow:
    inset 0 1px 0 rgba(255, 220, 210, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25),
    0 1px 2px rgba(0, 0, 0, 0.3),
    0 12px 28px -8px rgba(198, 37, 38, 0.55);
}
button.cta:hover { filter: brightness(1.05); transform: translateY(-1px); }
button.cta:active { transform: translateY(0); filter: brightness(0.96); }
button.cta:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.35); transform: none; }

/* Secondary — glass lozenge, no fill until hover */
.ghost {
  background: rgba(38, 32, 26, 0.32);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  color: var(--fg);
  border: 1px solid rgba(217, 184, 120, 0.20);
  padding: 12px 22px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: none;
  cursor: pointer;
  transition: color 120ms, background 160ms, transform 120ms cubic-bezier(0.22, 1, 0.36, 1), border-color 160ms;
  box-shadow:
    inset 0 1px 0 rgba(255, 245, 220, 0.08),
    0 1px 2px rgba(0, 0, 0, 0.3);
}
.ghost:hover { background: rgba(58, 48, 40, 0.5); border-color: rgba(217, 184, 120, 0.36); transform: translateY(-1px); }
.ghost:active { transform: translateY(0); }

.hint {
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  margin: 16px 0 0;
  font-weight: 400;
}
.hidden { display: none !important; }

/* Loading */
.loading-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--fg);
}
.pct { font-family: var(--font-mono); color: var(--brass-hi); font-weight: 500; letter-spacing: 0.06em; }

/* Pen-trace progress bar — a mechanical drum roll */
.bar {
  height: 6px;
  background:
    repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 8px),
    linear-gradient(180deg, #060403 0%, #0a0705 100%);
  border-radius: 0;
  overflow: hidden;
  border: 1px solid var(--brass);
  margin: 10px 0 12px;
  position: relative;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
}
#bar-fill {
  height: 100%;
  width: 0%;
  background: var(--ink);
  transition: width 200ms cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: 0 0 4px rgba(198, 37, 38, 0.6);
}
/* Ink pen tip on the leading edge */
#bar-fill::after {
  content: "";
  position: absolute;
  right: -3px;
  top: -3px;
  width: 6px;
  height: 12px;
  background: linear-gradient(180deg, var(--brass-hi), var(--brass) 60%, #4a3818 100%);
  border-radius: 1px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.tiny { color: var(--muted); font-family: var(--font-body); font-size: 13px; letter-spacing: 0; margin: 6px 0 0; font-weight: 400; }

/* Toolbar = control console strip */
.toolbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.tool-group {
  display: flex;
  align-items: center;
  gap: 12px;
}
.tool-group.grow { flex: 1; min-width: 200px; }
.tool-group.grow input {
  padding: 10px 12px;
  font-size: 12px;
  flex: 1;
}
.tlabel {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0;
  color: var(--muted);
  font-weight: 500;
  text-transform: none;
}
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
/* Glass pill segmented control */
.chip {
  position: relative;
  background: rgba(38, 32, 26, 0.28);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(217, 184, 120, 0.14);
  color: var(--fg);
  padding: 8px 14px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: none;
  cursor: pointer;
  transition: color 140ms, background 140ms, border-color 140ms, transform 120ms;
}
.chip:hover { background: rgba(58, 48, 40, 0.48); border-color: rgba(217, 184, 120, 0.28); }
.chip.active {
  color: #fff5ee;
  background: linear-gradient(180deg, #d93028 0%, #b1201f 100%);
  border-color: rgba(255, 200, 190, 0.24);
  box-shadow:
    inset 0 1px 0 rgba(255, 220, 210, 0.28),
    0 6px 16px -4px rgba(198, 37, 38, 0.5);
}

.sync-pill {
  padding: 6px 12px;
  border-radius: 1px;
  font-size: 10px;
  font-family: var(--font-label);
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  background: transparent;
  color: var(--brass-hi);
  border: 1px solid var(--brass);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 200ms;
}
.sync-pill::before {
  content: "";
  width: 6px; height: 6px;
  background: var(--brass-hi);
  border-radius: 50%;
  box-shadow: 0 0 4px currentColor;
}
.sync-pill.syncing { color: var(--ink); border-color: var(--ink); }
.sync-pill.syncing::before { background: var(--ink); animation: pilot-blink 1.4s ease-in-out infinite; }
.sync-pill.ok { color: var(--brass-hi); border-color: var(--brass); }
.sync-pill.err { background: rgba(255, 77, 94, 0.1); color: var(--danger); border-color: rgba(255, 77, 94, 0.3); }
.sync-pill .spin {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
  animation: pulse 1.4s ease-in-out infinite;
}

/* Result grid */
.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 960px) { .result-grid { grid-template-columns: 1fr; } }

#chart-wrap {
  padding: 28px;
  position: relative;
  overflow: hidden;
}
#chart { width: 100%; height: auto; display: block; position: relative; }

#legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 20px 6px 4px;
  font-size: 12px;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  position: relative;
  font-family: var(--font-display);
}
#legend .swatch { display: inline-flex; align-items: center; gap: 6px; }
#legend .dot {
  width: 9px; height: 9px; border-radius: 999px; display: inline-block;
  box-shadow: 0 0 10px currentColor;
}

/* Side panel */
#side-panel { display: flex; flex-direction: column; gap: 20px; }
#stats, #detail {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: fadeUp 400ms cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
/* Cal-mark side stat rail */
#stats .stat {
  display: grid;
  grid-template-columns: 8px 1fr;
  align-items: baseline;
  gap: 3px 12px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line);
  position: relative;
}
#stats .stat::before {
  content: "";
  align-self: center;
  height: 10px;
  width: 4px;
  background: var(--brass);
  grid-row: span 3;
  grid-column: 1;
  border-radius: 1px;
  opacity: 0.6;
}
#stats .stat > * { grid-column: 2; }
#stats .stat:last-child { border-bottom: none; }
#stats .stat .k {
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 500;
}
#stats .stat .v {
  font-size: 30px;
  font-weight: 700;
  color: var(--fg);
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
#stats .stat .sub { font-size: 12px; color: var(--muted); font-family: var(--font-body); letter-spacing: 0; }

/* Detail panel */
#detail .detail-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
#detail .detail-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--fg);
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}
#detail .detail-sub {
  font-size: 10px;
  color: var(--brass);
  font-family: var(--font-label);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  margin-bottom: 14px;
}
#detail .close-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
}
#detail .close-btn:hover { color: var(--fg); }

#detail h4 {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.32em;
  color: var(--brass);
  font-family: var(--font-label);
  font-weight: 400;
  margin: 16px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

#detail .bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 0;
  font-size: 11px;
  font-family: var(--font-label);
}
#detail .bar-row .bar-name {
  flex-shrink: 0;
  width: 42%;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
}
#detail .bar-row .bar-track {
  flex: 1;
  height: 3px;
  background: repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 6px);
  border-bottom: 1px solid var(--grid-strong);
}
#detail .bar-row .bar-fill-el {
  height: 100%;
  background: var(--ink);
  transition: width 400ms cubic-bezier(0.4, 0, 0.2, 1);
}
#detail .bar-row .bar-val {
  color: var(--brass-hi);
  font-family: var(--font-mono);
  font-size: 11px;
  min-width: 30px;
  text-align: right;
}

#detail .tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
#detail .tag-cloud .t {
  background: transparent;
  border: 1px solid var(--brass);
  color: var(--brass-hi);
  padding: 3px 10px;
  border-radius: 2px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-family: var(--font-label);
}

/* Insights grid — dense flow so wide panels tuck in without gaps */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-flow: dense;
  grid-auto-rows: minmax(260px, auto);
  gap: 16px;
  margin-bottom: 20px;
}
@media (min-width: 1500px) { .insights-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 960px) { .insights-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .insights-grid { grid-template-columns: 1fr; } }

.ins-panel {
  padding: 24px 26px 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 260px;
  cursor: pointer;
  animation: fadeUp 500ms cubic-bezier(0.4, 0, 0.2, 1) backwards;
  transition:
    transform 320ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 320ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 200ms;
}
.ins-panel:hover {
  transform: translateY(-2px);
  border-color: rgba(217, 184, 120, 0.22);
  box-shadow:
    inset 0 1px 0 rgba(255, 245, 220, 0.14),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35),
    0 1px 2px rgba(0, 0, 0, 0.35),
    0 32px 60px -20px rgba(0, 0, 0, 0.7);
}
.ins-panel:focus-visible {
  outline: none;
  border-color: rgba(217, 184, 120, 0.5);
  box-shadow:
    inset 0 1px 0 rgba(255, 245, 220, 0.14),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35),
    0 0 0 3px rgba(217, 184, 120, 0.18),
    0 24px 48px -20px rgba(0, 0, 0, 0.55);
}
/* Expand chevron — anchored top-right of title */
.ins-title .expand-mark {
  margin-left: auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brass-hi);
  opacity: 0.55;
  transition: opacity 160ms, background 160ms, transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
  flex-shrink: 0;
}
.ins-title .src + .expand-mark { margin-left: 8px; }
.ins-panel:hover .ins-title .expand-mark { opacity: 1; background: rgba(217, 184, 120, 0.10); }
.ins-panel.expanded .ins-title .expand-mark { transform: rotate(45deg); opacity: 1; background: rgba(217, 184, 120, 0.14); }
.ins-title .expand-mark svg { width: 12px; height: 12px; }

/* Expanded state — panel takes full row and lifts */
.ins-panel.expanded {
  grid-column: 1 / -1;
  min-height: 520px;
  padding: 32px 36px 36px;
  cursor: default;
  border-color: rgba(217, 184, 120, 0.28);
  box-shadow:
    inset 0 1px 0 rgba(255, 245, 220, 0.14),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35),
    0 2px 6px rgba(0, 0, 0, 0.4),
    0 48px 80px -20px rgba(0, 0, 0, 0.75);
}
.ins-panel.expanded .ins-title {
  font-size: 22px;
  padding-bottom: 18px;
  margin-bottom: 20px;
}
.ins-panel.expanded svg { min-height: 340px; }
.insights-grid.has-expanded .ins-panel:not(.expanded) {
  opacity: 0.35;
  filter: saturate(0.7);
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .ins-panel, .ins-panel:hover, .ins-title .expand-mark { transition: none; }
}
#ins-weekly svg, #ins-hourly svg, #ins-discovery svg {
  min-height: 200px;
  height: 100%;
  flex: 1;
}
#ins-weekly, #ins-hourly, #ins-discovery { min-height: 300px; }
.ins-panel:nth-child(1) { animation-delay: 40ms; }
.ins-panel:nth-child(2) { animation-delay: 80ms; }
.ins-panel:nth-child(3) { animation-delay: 120ms; }
.ins-panel:nth-child(4) { animation-delay: 160ms; }
.ins-panel:nth-child(5) { animation-delay: 200ms; }
.ins-panel:nth-child(6) { animation-delay: 240ms; }
.ins-panel:nth-child(7) { animation-delay: 280ms; }
.ins-panel:nth-child(8) { animation-delay: 320ms; }
.ins-panel:nth-child(9) { animation-delay: 360ms; }
.ins-panel:nth-child(10) { animation-delay: 400ms; }
.ins-panel:nth-child(11) { animation-delay: 440ms; }
.ins-panel:nth-child(12) { animation-delay: 480ms; }

/* Panel title — sentence case, premium, no ornament */
.ins-title {
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--fg);
  font-weight: 600;
  padding: 2px 0 14px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(217, 184, 120, 0.08);
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}
.ins-title .src {
  color: var(--muted);
  font-family: var(--font-label);
  font-size: 10px;
  margin-left: auto;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
}

.ins-caption {
  color: var(--brass);
  font-size: 12px;
  font-family: var(--font-label);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  font-weight: 500;
  margin-top: 8px;
}

.ins-panel svg { width: 100%; height: auto; display: block; }
/* Wide panels span 2 columns by default (denser masonry-like layout).
   Full-width only on the true long-form panels that need every pixel. */
.ins-panel.wide { grid-column: span 2; min-height: 300px; }
#ins-dna, #ins-yeargrid, #ins-heartbeat, #ins-onthisday, #ins-map,
#ins-genremigration, #ins-medals, #ins-debut { grid-column: 1 / -1; }
@media (max-width: 960px) { .ins-panel.wide, #ins-dna, #ins-yeargrid, #ins-heartbeat,
  #ins-onthisday, #ins-map, #ins-genremigration, #ins-medals, #ins-debut { grid-column: 1 / -1; } }
.ins-panel { padding: 18px 20px 20px; min-height: 240px; gap: 8px; scroll-margin-top: 20px; }
.sn-flash { animation: snFlash 900ms cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes snFlash {
  0% { box-shadow: 0 0 0 0 rgba(198, 37, 38, 0.6), inset 0 0 0 0 rgba(198, 37, 38, 0); }
  40% { box-shadow: 0 0 0 4px rgba(198, 37, 38, 0.35), inset 0 0 24px rgba(198, 37, 38, 0.15); }
  100% { box-shadow: 0 0 0 0 rgba(198, 37, 38, 0), inset 0 0 0 rgba(198, 37, 38, 0); }
}
.ghost.small { padding: 8px 14px; font-size: 12px; }
.mb-hint { color: var(--muted); font-size: 12px; margin: 0 0 12px; }

#map-svg { background: rgba(0, 0, 0, 0.3); border: 1px solid var(--brass); border-radius: 1px; }
#map-svg .country { fill: rgba(181, 138, 58, 0.06); stroke: rgba(181, 138, 58, 0.16); stroke-width: 0.4; }
#map-svg .country.has { fill: rgba(122, 74, 42, 0.20); }
#map-svg .dot { fill: var(--ink); fill-opacity: 0.85; stroke: #0e0c0a; stroke-width: 0.6; transition: fill-opacity 200ms; }
#map-svg .dot:hover { fill-opacity: 1; }
#map-svg .dot.hot { fill: var(--brass-hi); }

.map-legend {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
.map-legend .country-item { display: flex; align-items: center; gap: 6px; }
.map-legend .country-item .cn { color: var(--fg); }
.map-legend .country-item .cv { color: var(--ink); font-family: var(--font-mono); }
.map-progress { color: var(--muted); font-size: 12px; font-family: var(--font-mono); margin-top: 8px; }

/* ============ Embed mode ============ */
body.embed { padding: 0; background: transparent; }
body.embed .bg-orb { display: none; }
body.embed main { padding: 12px; max-width: none; }
body.embed header,
body.embed #form-panel,
body.embed .toolbar,
body.embed .time-tb,
body.embed .insights-grid,
body.embed .actions,
body.embed footer,
body.embed #side-panel,
body.embed #embed-modal { display: none !important; }
body.embed #loading { max-width: 400px; margin: 40px auto; }
body.embed .result-grid { display: block; }
body.embed .paper-fiber { opacity: 0.4; }
body.embed #chart-wrap { padding: 14px; border-radius: 3px; }
body.embed #chart-wrap svg { max-height: 96vh; }
body.embed #legend { font-size: 10px; }

/* ============ Modal — flat plate under a shade ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-panel {
  max-width: 640px;
  width: 100%;
  padding: 36px 32px 30px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-panel h3 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 24px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--fg);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 10px;
}
.modal-close:hover { color: var(--fg); }
.embed-label {
  display: block;
  margin: 18px 0 6px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-family: var(--font-mono);
}
.embed-label textarea {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 12px;
  resize: vertical;
  line-height: 1.45;
}
.embed-preview-label { margin-top: 20px; color: var(--muted); }

.detail-yoy {
  margin-top: 6px;
  color: var(--muted);
  font-family: var(--font-mono);
}
.detail-yoy b { color: var(--fg); font-weight: 500; }

.snap-controls {
  display: flex;
  gap: 8px;
  margin: 10px 0 8px;
}
.snap-controls input {
  flex: 1;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 12px;
}
.snap-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line-2);
}
.snap-row:first-child { border-top: 0; }
.snap-name { font-family: var(--font-mono); font-size: 13px; color: var(--fg); }
.snap-sub { color: var(--muted); }
.snap-actions { display: flex; gap: 6px; flex-shrink: 0; }

.np-help {
  margin-left: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--brass, #b58a3a);
  color: var(--brass, #b58a3a);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.np-help:hover { color: var(--fg); border-color: var(--fg); }

.kbd-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 10px;
}
.kbd-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg);
}
.kbd-list kbd {
  display: inline-block;
  padding: 2px 8px;
  min-width: 28px;
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--brass, #b58a3a);
}
.kbd-list li span { color: var(--muted); }

.ascii-preview {
  margin: 10px 0 4px;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.15;
  letter-spacing: 0;
  overflow-x: auto;
  white-space: pre;
}

/* ============ Print — instrument-plate report ============ */
@media print {
  html, body {
    background: #fdfaf2 !important;
    color: #1a1410 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .paper-fiber, .nameplate .np-pilot, footer,
  #form-panel, #loading, .toolbar, #time-toolbar, .actions,
  .modal, #detail, #sync-status, .expand-mark {
    display: none !important;
  }
  .glass, .panel, .ins-panel {
    background: #fdfaf2 !important;
    border: 1px solid #7a4a2a !important;
    box-shadow: none !important;
    color: #1a1410 !important;
    break-inside: avoid;
  }
  .nameplate h1, .nameplate .tag, .ins-title, .m-k, .m-v, .persona-badge, .persona-quote { color: #1a1410 !important; }
  .cell { stroke: #1a1410 !important; }
  .chart-wrap svg text, #chart text { fill: #1a1410 !important; }
  .insights-grid {
    display: block !important;
  }
  .ins-panel { page-break-inside: avoid; margin: 6mm 0; }
  #chart-wrap { page-break-after: always; }
  @page { margin: 12mm; }
}

/* Cal-mark bar rows — thin ink stroke over a tick grid */
.ins-panel .bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 0;
  font-size: 13px;
  font-family: var(--font-label);
}
.ins-panel .bar-row .bar-name {
  flex-shrink: 0;
  width: 42%;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.04em;
}
.ins-panel .bar-row .bar-track {
  flex: 1;
  height: 4px;
  background: repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 8px);
  border-bottom: 1px solid var(--grid-strong);
  position: relative;
}
.ins-panel .bar-row .bar-fill-el {
  height: 100%;
  background: var(--ink) !important;
  transition: width 500ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 0 rgba(198, 37, 38, 0);
}
.ins-panel .bar-row .bar-val {
  color: var(--brass-hi);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  min-width: 34px;
  text-align: right;
}

/* Persona — display badge */
.persona-badge {
  display: inline-block;
  padding: 0 0 4px;
  color: var(--fg);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.02em;
  text-transform: none;
  margin-bottom: 10px;
}
.persona-quote {
  font-size: 15px;
  color: var(--fg);
  line-height: 1.55;
  font-family: var(--font-body);
  letter-spacing: 0;
}
.persona-quote em { color: var(--ink); font-style: normal; font-weight: 600; font-family: var(--font-display); font-size: 1.05em; }
.persona-meta {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  font-family: var(--font-display);
  text-transform: none;
  letter-spacing: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-weight: 500;
}

/* Milestone rows — annotation ledger */
.milestone {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(217, 184, 120, 0.08);
  font-size: 14px;
  font-family: var(--font-display);
}
.milestone:last-child { border-bottom: none; }
.milestone .m-k { color: var(--muted); text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 500; }
.milestone .m-v { color: var(--fg); font-family: var(--font-display); font-weight: 600; text-align: right; letter-spacing: 0; font-size: 14px; }
.milestone .m-v .sub { display: block; color: var(--muted); font-size: 12px; font-weight: 400; font-family: var(--font-body); letter-spacing: 0; text-transform: none; margin-top: 2px; }

/* Big number — engraved display readout */
.big-stat {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 12px 0;
}
.big-stat .num {
  font-size: 48px;
  font-weight: 800;
  color: var(--ink);
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  line-height: 1;
}
.big-stat .lbl {
  color: var(--brass);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

/* SVG chart shared — instrument trace */
.chart-bar { transition: fill 200ms, opacity 200ms; cursor: default; }
.chart-bar:hover { opacity: 0.75; }
.chart-axis text {
  fill: var(--muted);
  font-size: 11px;
  font-family: var(--font-display);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
.chart-line { fill: none; stroke: var(--ink); stroke-width: 1.6; }
.chart-area { fill: url(#areaGrad); opacity: 0.7; }
.chart-dot { fill: var(--ink); }

/* Actions */
.actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 24px 0 8px;
  border-top: 1px solid rgba(217, 184, 120, 0.08);
  margin-top: 12px;
}

footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid rgba(217, 184, 120, 0.08);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
}

/* Chart cell polish — pen ink settles rather than bounces */
.cell {
  transition: opacity 200ms, transform 300ms cubic-bezier(0.22, 1, 0.36, 1);
  cursor: pointer;
  transform-origin: center;
  transform-box: fill-box;
}
.cell:hover { opacity: 0.75; }
.cell.dim { opacity: 0.12; }
.cell.hi { opacity: 1; }
.cell.cursor {
  stroke: var(--brass, #b58a3a);
  stroke-width: 2;
  filter: drop-shadow(0 0 6px rgba(217, 184, 120, 0.55));
}
.axis text {
  fill: var(--brass-hi);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-family: var(--font-label);
  font-weight: 400;
}
.axis text.hot { fill: var(--ink); }
.center-label { fill: var(--fg); text-anchor: middle; }
.center-label .big {
  font-size: 46px;
  font-weight: 400;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}
.center-label .small {
  font-size: 10px;
  fill: var(--brass);
  text-transform: uppercase;
  letter-spacing: 0.32em;
  font-family: var(--font-label);
  font-weight: 400;
}
.center-label .artist {
  font-size: 13px;
  fill: var(--ink);
  font-weight: 400;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}

.spoke, .ring {
  stroke: rgba(181, 138, 58, 0.10);
  stroke-width: 1;
  fill: none;
  pointer-events: none;
}

/* Hour bars outer — ink strokes */
.hour-bar { fill: rgba(181, 138, 58, 0.18); transition: fill 200ms; }
.hour-bar.hot { fill: var(--ink); }

/* Tooltip — annotation label on the plate */
#tt {
  position: fixed;
  pointer-events: none;
  background: var(--plate);
  border: 1px solid var(--brass);
  border-radius: 1px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--fg);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 140ms, transform 140ms;
  z-index: 100;
  max-width: 280px;
  box-shadow:
    inset 0 1px 0 rgba(217, 184, 120, 0.22),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 8px 18px rgba(0, 0, 0, 0.55);
}
#tt.on { opacity: 1; transform: translateY(0); }
#tt .t {
  color: var(--fg);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 15px;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}
#tt .m {
  color: var(--brass-hi);
  font-size: 10px;
  font-family: var(--font-label);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Chart-tooltip variant — dense k/v rows */
#tt.chart { max-width: 320px; padding: 10px 12px; }
#tt.chart .ct-head {
  color: var(--fg); font-size: 13px; font-weight: 600;
  padding-bottom: 6px; margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
#tt.chart .ct-row {
  display: grid; grid-template-columns: 92px 1fr; gap: 8px;
  font-size: 11px; padding: 2px 0;
}
#tt.chart .ct-k { color: var(--brass); font-family: var(--font-label); font-size: 10px; letter-spacing: 0.10em; text-transform: uppercase; }
#tt.chart .ct-v { color: var(--fg); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
#tt.chart .ct-v.hot { color: var(--ink); }
#tt.chart .ct-note { color: var(--muted); font-size: 10px; margin-top: 6px; font-style: italic; }
#tt.chart .ct-list { margin-top: 6px; font-size: 11px; color: var(--fg); }
#tt.chart .ct-list .row { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
#tt.chart .ct-list .row span:last-child { color: var(--muted); font-family: var(--font-mono); }

/* Chart hover cursor + subtle highlight — SVG shapes inside insight panels */
.ins-panel svg rect.hoverable,
.ins-panel svg circle.hoverable,
.ins-panel svg path.hoverable {
  cursor: crosshair; transition: filter 100ms, opacity 100ms;
}
.ins-panel svg rect.hoverable:hover,
.ins-panel svg circle.hoverable:hover,
.ins-panel svg path.hoverable:hover {
  filter: drop-shadow(0 0 4px currentColor) brightness(1.2);
}
.chart-crosshair { stroke: rgba(217, 184, 120, 0.5); stroke-width: 0.8; stroke-dasharray: 2 2; pointer-events: none; }

.error {
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 12px 16px;
  border-radius: 1px;
  background: rgba(198, 37, 38, 0.08);
  margin-top: 12px;
  font-size: 11px;
  font-family: var(--font-label);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Cell drawn-in animation */
@keyframes cellIn {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: scale(1); }
}
.cells .cell { animation: cellIn 500ms cubic-bezier(0.22, 1, 0.36, 1) backwards; }

/* ============ Year Card (wrapped-style poster) ============ */
.wrapped-off {
  position: fixed;
  left: -20000px;
  top: 0;
  pointer-events: none;
}
.wrapped-card {
  width: 1080px;
  padding: 72px 72px 64px;
  background:
    /* Faint ink halo from center */
    radial-gradient(ellipse at 50% 40%, rgba(198, 37, 38, 0.10), transparent 60%),
    /* Engraved 60px grid */
    repeating-linear-gradient(0deg, rgba(180, 150, 100, 0.055) 0 1px, transparent 1px 60px),
    repeating-linear-gradient(90deg, rgba(180, 150, 100, 0.055) 0 1px, transparent 1px 60px),
    linear-gradient(180deg, #14110d 0%, #0e0c0a 100%);
  color: var(--fg);
  font-family: var(--font-label);
  border: 2px solid var(--brass);
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  gap: 42px;
  box-shadow: inset 0 2px 0 rgba(217, 184, 120, 0.35), inset 0 -2px 0 rgba(0, 0, 0, 0.5);
}
.wrapped-card .wc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 1px solid var(--brass);
  padding-bottom: 24px;
}
.wrapped-card .wc-brand {
  font-family: var(--font-label);
  font-size: 12px;
  letter-spacing: 0.36em;
  color: var(--brass-hi);
  text-transform: uppercase;
}
.wrapped-card .wc-user {
  font-size: 18px;
  color: var(--brass);
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
}
.wrapped-card .wc-title {
  font-size: 84px;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 0.95;
  margin: 0;
  color: var(--fg);
  font-family: var(--font-display);
  text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6);
}
.wrapped-card .wc-persona {
  font-size: 18px;
  color: var(--fg);
  margin-top: 12px;
  font-family: var(--font-label);
  letter-spacing: 0.02em;
}
.wrapped-card .wc-persona em { color: var(--ink); font-style: normal; font-weight: 400; font-family: var(--font-display); font-size: 1.15em; }
.wrapped-card .wc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}
.wrapped-card .wc-heat { display: flex; align-items: center; justify-content: center; }
.wrapped-card .wc-heat svg { width: 100%; max-width: 480px; height: auto; }
.wrapped-card .wc-stats { display: flex; flex-direction: column; gap: 22px; }
.wrapped-card .wc-stat {
  display: flex;
  flex-direction: column;
  padding: 18px 0;
  background: transparent;
  border-top: 1px solid var(--brass);
  border-bottom: 1px solid var(--brass);
}
.wrapped-card .wc-stat + .wc-stat { border-top: none; }
.wrapped-card .wc-stat .k {
  font-size: 10px;
  letter-spacing: 0.30em;
  text-transform: uppercase;
  color: var(--brass);
  font-family: var(--font-label);
  margin-bottom: 8px;
}
.wrapped-card .wc-stat .v {
  font-size: 42px;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--fg);
  font-family: var(--font-display);
}
.wrapped-card .wc-stat .v.small { font-size: 26px; }
.wrapped-card .wc-stat .sub {
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
  font-family: var(--font-label);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.wrapped-card .wc-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.wrapped-card .wc-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wrapped-card .wc-list .lh {
  font-family: var(--font-label);
  color: var(--brass-hi);
  font-size: 10px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--brass);
}
.wrapped-card .wc-row {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 14px;
  align-items: baseline;
  font-size: 18px;
}
.wrapped-card .wc-row .n {
  font-family: var(--font-mono);
  color: var(--brass);
  font-size: 13px;
  letter-spacing: 0.04em;
}
.wrapped-card .wc-row .name {
  color: var(--fg);
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wrapped-card .wc-row .plays {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
}
.wrapped-card .wc-genre-bar {
  display: flex;
  height: 14px;
  border: 1px solid var(--brass);
  overflow: hidden;
  margin-top: 6px;
}
.wrapped-card .wc-genre-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 12px;
  font-family: var(--font-label);
  font-size: 10px;
  color: var(--brass);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.wrapped-card .wc-genre-legend .sw {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 0;
  margin-right: 6px;
  vertical-align: middle;
}
.wrapped-card .wc-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--brass);
  padding-top: 20px;
  font-family: var(--font-label);
  font-size: 10px;
  color: var(--brass);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.wrapped-card .wc-footer .site { color: var(--brass-hi); }

/* ============ Time toolbar ============ */
.time-tb {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 22px 16px;
  margin-bottom: 20px;
}
.time-tb .tb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.time-tb .tb-row .tlabel { min-width: 110px; }
.time-tb .chip { position: relative; padding: 8px 12px 7px; }
.time-tb .chip-count {
  margin-left: 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--brass);
  letter-spacing: 0.04em;
  opacity: 0.9;
}
.time-tb .chip.active .chip-count { color: var(--brass-hi); }
.time-tb .chip.empty {
  opacity: 0.3;
  cursor: not-allowed;
}
.time-tb .chip.empty:hover {
  color: var(--brass);
  background: linear-gradient(180deg, var(--plate-hi) 0%, var(--plate) 100%);
}
.time-tb .month-chip { min-width: 60px; text-align: left; }

.tb-custom input[type="date"] {
  background: linear-gradient(180deg, #060403 0%, #0a0705 100%);
  color: var(--fg);
  border: 1px solid var(--brass);
  padding: 8px 10px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color-scheme: dark;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
}
.tb-custom input[type="date"]:focus { outline: none; border-color: var(--brass-hi); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6), 0 0 0 2px rgba(217, 184, 120, 0.14); }
.tb-custom .tb-dash { color: var(--brass); font-family: var(--font-label); letter-spacing: 0.14em; }

.tb-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  margin-top: 4px;
}
.tb-pill {
  padding: 5px 12px 4px;
  border-radius: 1px;
  background: transparent;
  color: var(--fg);
  font-family: var(--font-label);
  font-size: 10px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  border: 1px solid var(--brass);
}
.tb-pill b { color: var(--ink); font-weight: 400; font-family: var(--font-display); font-size: 11px; letter-spacing: 0.04em; margin-right: 4px; text-transform: none; }
.tb-empty {
  padding: 10px 14px;
  color: var(--ink);
  font-family: var(--font-label);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: rgba(198, 37, 38, 0.08);
  border: 1px solid var(--ink);
  border-radius: 1px;
}
.mono { font-family: var(--font-mono); }
@media (max-width: 640px) {
  .time-tb .tb-row .tlabel { min-width: 60px; }
}

/* ============ On This Day — printer strip archive ============ */
#ins-onthisday .ins-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.otd-source-pill {
  margin-left: auto;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(38, 32, 26, 0.4);
  color: var(--muted);
  border: 1px solid rgba(217, 184, 120, 0.16);
  font-weight: 500;
}
.otd-source-pill.otd-spot {
  color: #fff5ee;
  border-color: rgba(255, 200, 190, 0.24);
  background: linear-gradient(180deg, #d93028 0%, #b1201f 100%);
}
.otd-summary { margin: 6px 0 16px; color: var(--muted); font-family: var(--font-body); font-size: 13px; letter-spacing: 0; text-transform: none; }
.otd-list { display: flex; flex-direction: column; gap: 6px; max-height: 460px; overflow-y: auto; padding-right: 4px; }
.otd-row {
  display: grid;
  grid-template-columns: 78px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  background: rgba(38, 32, 26, 0.28);
  border: 1px solid rgba(217, 184, 120, 0.08);
  border-radius: 12px;
  transition: background 160ms, border-color 160ms;
  position: relative;
}
.otd-row:hover {
  background: rgba(58, 48, 40, 0.42);
  border-color: rgba(217, 184, 120, 0.20);
}
.otd-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.otd-year {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.02em;
  line-height: 1;
}
.otd-ago {
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  margin-top: 3px;
  font-weight: 500;
}
.otd-info { min-width: 0; }
.otd-track {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--fg);
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.otd-artist {
  color: var(--fg);
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  margin-top: 3px;
  opacity: 0.72;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.otd-tags {
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  margin-top: 4px;
}
.otd-player { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 44px; }
/* Play — glass circular button */
.otd-play {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(38, 32, 26, 0.42);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--fg);
  border: 1px solid rgba(217, 184, 120, 0.20);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  display: flex; align-items: center; justify-content: center;
  transition: color 140ms, background 160ms, transform 120ms cubic-bezier(0.22, 1, 0.36, 1), border-color 160ms;
}
.otd-play:hover { background: rgba(58, 48, 40, 0.6); border-color: rgba(217, 184, 120, 0.36); transform: scale(1.06); }
.otd-play.playing {
  color: #fff5ee;
  background: linear-gradient(180deg, #d93028 0%, #b1201f 100%);
  border-color: rgba(255, 200, 190, 0.24);
  box-shadow: 0 6px 16px -4px rgba(198, 37, 38, 0.5);
}
.otd-play.loading { opacity: 0.6; cursor: wait; }
.otd-embed { width: 340px; max-width: 60vw; margin-top: 6px; }
.otd-embed:empty { display: none; }
.otd-embed iframe { border-radius: 2px; border: 1px solid var(--brass); display: block; }

.otd-controls {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.otd-controls input {
  flex: 1 1 260px;
  min-width: 220px;
  padding: 10px 12px;
  font-size: 11px;
  border-radius: 2px;
}
@media (max-width: 640px) {
  .otd-row { grid-template-columns: 60px 1fr auto; }
  .otd-embed { width: 100%; max-width: none; grid-column: 1 / -1; }
  .otd-player { flex-direction: row; }
}
