/* ============================================================
   CURSOR LAB — Nothing design language, dark (OLED)
   Doto (display) · Space Grotesk (UI) · Space Mono (data/labels)
   No gradients in chrome. No shadows. No blur. No toasts.
   ============================================================ */

:root {
  --black: #000000;
  --surface: #111111;
  --surface-raised: #1A1A1A;
  --border: #222222;
  --border-visible: #333333;
  --text-disabled: #666666;
  --text-secondary: #999999;
  --text-primary: #E8E8E8;
  --text-display: #FFFFFF;

  --accent: #D71921;
  --success: #4A9E5C;
  --warning: #D4A843;
  --interactive: #5B9BF6;

  --font-display: "Doto", "Space Mono", monospace;
  --font-sans: "Space Grotesk", "DM Sans", system-ui, sans-serif;
  --font-mono: "Space Mono", "JetBrains Mono", ui-monospace, monospace;

  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
}

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

body {
  background: var(--black);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input { font: inherit; color: inherit; background: none; border: 0; }
button { cursor: pointer; }
svg { display: block; }
::selection { background: var(--text-display); color: var(--black); }
:focus-visible { outline: 1px solid var(--text-display); outline-offset: 2px; }

/* the one typographic constant: instrument-panel labels */
.lbl {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.doto {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 36px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  color: var(--text-display);
}
.dot-grid {
  background-image: radial-gradient(circle, var(--border-visible) 1px, transparent 1px);
  background-size: 16px 16px;
}

/* ── shell ─────────────────────────────────────────────── */
.app { height: 100dvh; display: grid; grid-template-rows: 56px minmax(0, 1fr); }

.bar {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: var(--space-md);
  padding: 0 var(--space-md);
  border-bottom: 1px solid var(--border);
}
.bar__left { display: flex; align-items: center; gap: 10px; }
.bar__right { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-md); }

/* GitHub pill — the star count is fetched live, and simply stays absent
   if the repo is private, missing, or the API is rate-limited */
.gh {
  display: inline-flex; align-items: center; gap: 7px;
  height: 28px; padding: 0 11px;
  border: 1px solid var(--border-visible); border-radius: 999px;
  color: var(--text-secondary); text-decoration: none;
  transition: color 200ms var(--ease), border-color 200ms var(--ease);
}
.gh:hover { color: var(--text-display); border-color: var(--text-primary); }
.gh svg { width: 14px; height: 14px; flex: none; }
.gh__n {
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.04em; font-variant-numeric: tabular-nums;
}
.gh__n[hidden] { display: none; }
.gh__n::after { content: " ★"; opacity: 0.55; }
/* the mark is an <img>, so it keeps its own aspect and never reflows.
   object-fit keeps a non-square source from stretching. */
.mark {
  width: 22px; height: 22px; flex: none; display: block;
  object-fit: contain;
}

/* ── segmented control (tabs, langs, selects) ──────────── */
.seg {
  display: inline-flex;
  border: 1px solid var(--border-visible);
  border-radius: 4px;
  overflow: hidden;
}
.seg button {
  padding: 7px 16px;
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-secondary);
  background: transparent;
  transition: color 200ms var(--ease), background-color 200ms var(--ease);
  white-space: nowrap;
}
.seg button + button { border-left: 1px solid var(--border-visible); }
.seg button:hover { color: var(--text-primary); }
.seg button[aria-selected="true"] { background: var(--text-display); color: var(--black); }
.seg--tabs button { padding: 8px 22px; }
/* param rows hold 4-5 options inside a 320px column */
.ctl .seg button {
  padding: 6px 5px; letter-spacing: 0.03em;
  overflow: hidden; text-overflow: ellipsis;
}

/* ── buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 34px; padding: 0 18px;
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase;
  border-radius: 999px;
  transition: background-color 200ms var(--ease), color 200ms var(--ease), border-color 200ms var(--ease);
}
.btn--primary { background: var(--text-display); color: var(--black); }
.btn--primary:hover { background: var(--text-primary); }
.btn--secondary { border: 1px solid var(--border-visible); color: var(--text-primary); flex: 1; }
.btn--secondary:hover { border-color: var(--text-primary); }
.btn--ghost { color: var(--text-secondary); padding: 0 14px; }
.btn--ghost:hover { color: var(--text-primary); }

.iconbtn {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center; color: var(--text-secondary);
  border-radius: 4px;
  transition: color 200ms var(--ease), background-color 200ms var(--ease);
}
.iconbtn:hover { color: var(--text-display); background: var(--surface-raised); }
.iconbtn svg { width: 15px; height: 15px; }

/* inline status text — replaces toasts entirely */
.status {
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--success);
  opacity: 0;
  transition: opacity 150ms var(--ease);
  white-space: nowrap;
}
.status.on { opacity: 1; }

/* ── three panes ───────────────────────────────────────── */
.work { display: grid; grid-template-columns: 232px minmax(0, 1fr) 320px; min-height: 0; }

/* ── catalogue ─────────────────────────────────────────── */
.rail {
  display: grid; grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0; border-right: 1px solid var(--border);
}
.nav { overflow-y: auto; overscroll-behavior: contain; }

.railfoot { border-top: 1px solid var(--border); }

.updated {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm);
  padding: 11px var(--space-md) 0;
}
.updated .lbl { color: var(--text-disabled); }
.updated__d {
  padding: 3px 7px; border-radius: 4px;
  background: var(--surface-raised); color: var(--text-primary);
  font-family: var(--font-mono); font-size: 11px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

.credit {
  display: block; padding: 10px var(--space-md) 14px;
  font-size: 12px; color: var(--text-disabled); text-decoration: none;
  transition: color 200ms var(--ease);
}
.credit b { font-weight: 400; color: var(--text-secondary); transition: color 200ms var(--ease); }
.credit:hover { color: var(--text-secondary); }
.credit:hover b { color: var(--text-display); }

.nav__group {
  padding: var(--space-lg) var(--space-md) var(--space-sm);
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-disabled);
}

.item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 11px var(--space-md);
  text-align: left; color: var(--text-secondary);
  border-top: 1px solid var(--border);
  transition: color 200ms var(--ease), background-color 200ms var(--ease);
  opacity: 0;
  animation: fadeIn 220ms var(--ease) forwards;
}
@keyframes fadeIn { to { opacity: 1; } }
.item:hover { color: var(--text-primary); }
.item[aria-current="true"] {
  background: var(--surface-raised);
  color: var(--text-display);
}
.item[aria-current="true"]::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--accent);
}
.item__name { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__idx { font-family: var(--font-mono); font-size: 11px; color: var(--text-disabled); }
.item__ico { flex: none; width: 18px; height: 18px; display: grid; place-items: center; }
.item__ico svg { width: 17px; height: 17px; }
.item__ico[data-pixel="1"] svg { image-rendering: pixelated; }

/* ── stage ─────────────────────────────────────────────── */
.center { position: relative; min-width: 0; min-height: 0; overflow: hidden; }

.stage {
  position: absolute; inset: 0;
  overflow: hidden; isolation: isolate;
  display: grid; place-items: center;
  touch-action: pan-y;
}
.stage[data-hide].is-live,
.stage[data-hide].is-live * { cursor: none; }

.stage__hint {
  position: absolute; left: 50%; bottom: var(--space-lg); transform: translateX(-50%);
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-disabled);
  pointer-events: none; z-index: 8;
  transition: opacity 200ms var(--ease);
}
.stage.is-live .stage__hint { opacity: 0; }

.stage__body {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: var(--space-md);
  text-align: center; padding: var(--space-xl);
  animation: fadeIn 220ms var(--ease) both;
}
.stage__title {
  font-family: var(--font-sans); font-weight: 300;
  font-size: clamp(24px, 3.2vw, 40px); line-height: 1.1;
  letter-spacing: -0.02em; color: var(--text-display);
}
.stage__note {
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-disabled);
}

.ghost-chip {
  padding: 10px 22px;
  border: 1px solid var(--border-visible); border-radius: 999px;
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary);
  transition: border-color 200ms var(--ease), color 200ms var(--ease);
}
.ghost-chip:hover { border-color: var(--text-primary); color: var(--text-display); }

.demo-card {
  width: min(340px, 74vw); padding: var(--space-lg);
  border: 1px solid var(--border-visible); border-radius: 12px;
  display: flex; flex-direction: column; gap: var(--space-xl); text-align: left;
  background: var(--surface);
}
.demo-card b { font-family: var(--font-sans); font-weight: 400; font-size: 17px; line-height: 1.35; color: var(--text-display); }
.demo-card i {
  font-style: normal; font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.08em; color: var(--text-disabled);
}
.demo-pill {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: 999px;
  background: var(--text-display); color: var(--black);
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase;
}

/* design preview */
.dsp { display: grid; place-items: center; gap: var(--space-lg); }
.dsp__art { transition: transform 150ms var(--ease); }
.dsp__art.is-press { transform: scale(0.94); }
.dsp__art svg { width: 128px; height: 128px; }
.dsp__art[data-pixel="1"] svg { image-rendering: pixelated; }

/* ── inspector ─────────────────────────────────────────── */
.insp {
  border-left: 1px solid var(--border);
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
}
.insp__head { padding: var(--space-lg) var(--space-md) var(--space-md); }
.insp__head .lbl { margin-bottom: var(--space-md); }
.insp__head .doto { margin-bottom: var(--space-md); }
.insp__desc { font-size: 13px; line-height: 1.6; color: var(--text-secondary); }

.insp__body { overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--space-md); }
.insp__foot {
  padding: var(--space-md);
  border-top: 1px solid var(--border);
  display: flex; gap: var(--space-sm);
}

/* ── parameter groups (compact, foldable) ──────────────── */
.grp { border-top: 1px solid var(--border); }
.grp__t {
  display: flex; align-items: center; gap: var(--space-sm);
  width: 100%; padding: 11px 0 7px; text-align: left;
  color: var(--text-secondary);
  transition: color 200ms var(--ease);
}
.grp__t:hover { color: var(--text-primary); }
.grp__t .lbl { color: inherit; }
.grp__n {
  margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--text-disabled);
}
.grp__t svg { width: 13px; height: 13px; flex: none; transition: transform 200ms var(--ease); }
.grp.is-folded .grp__t svg { transform: rotate(-90deg); }
.grp.is-folded .grp__b { display: none; }
.grp__b { padding-bottom: 6px; }
.grp .ctl:first-child { border-top: 0; }

.ctl { padding: 9px 0; border-top: 1px solid var(--border); }
.ctl__top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-sm); margin-bottom: 8px; }
.ctl__val {
  font-family: var(--font-mono); font-size: 12px;
  color: var(--text-display); font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ctl__val--sm { font-size: 10px; letter-spacing: .02em; }
.ctl__val em { font-style: normal; font-size: 10px; color: var(--text-secondary); margin-left: 2px; }

/* ── paint: presets + custom stops + gradient ───────────── */
.paint { display: flex; flex-direction: column; gap: 8px; }
.paint__row { display: flex; align-items: center; gap: 6px; }
.stop {
  position: relative; width: 24px; height: 24px; flex: none;
  border-radius: 4px; border: 1px solid var(--border-visible);
  overflow: hidden; cursor: pointer;
  transition: opacity 200ms var(--ease), border-color 200ms var(--ease);
}
.stop:hover { border-color: var(--text-secondary); }
.stop.is-off { opacity: 0.28; }
.stop input {
  position: absolute; inset: -6px; width: 200%; height: 200%;
  padding: 0; border: 0; cursor: pointer; opacity: 0;
}
.stop span { display: block; width: 100%; height: 100%; }
.chip {
  margin-left: auto; padding: 5px 11px;
  border: 1px solid var(--border-visible); border-radius: 999px;
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary);
  transition: color 200ms var(--ease), background-color 200ms var(--ease), border-color 200ms var(--ease);
}
.chip:hover { color: var(--text-primary); }
.chip[aria-pressed="true"] {
  background: var(--text-display); color: var(--black); border-color: var(--text-display);
}

/* signature control: segmented bar. Blocks, 2px gaps, square ends. */
.segbar {
  display: flex; gap: 2px; height: 10px;
  cursor: ew-resize; touch-action: none;
}
.segbar i {
  flex: 1; background: var(--border);
  transition: background-color 150ms var(--ease);
}
.segbar i.on { background: var(--text-display); }
.segbar.anim i { animation: segIn 160ms var(--ease) both; }
@keyframes segIn { from { opacity: 0; } to { opacity: 1; } }

/* toggle */
.sw {
  width: 40px; height: 22px; flex: none; border-radius: 999px;
  border: 1px solid var(--border-visible); position: relative;
  transition: background-color 200ms var(--ease), border-color 200ms var(--ease);
}
.sw::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 14px; height: 14px; border-radius: 50%; background: var(--text-disabled);
  transition: transform 200ms var(--ease), background-color 200ms var(--ease);
}
.sw[aria-pressed="true"] { background: var(--text-display); border-color: var(--text-display); }
.sw[aria-pressed="true"]::after { transform: translateX(18px); background: var(--black); }

/* colour: technical squares, not candy dots */
.swatches { display: flex; gap: 5px; }
.swatch {
  width: 20px; height: 20px; flex: 1 1 0; min-width: 0; max-width: 26px;
  border-radius: 4px;
  border: 1px solid var(--border-visible);
  transition: border-color 200ms var(--ease);
}
.swatch:hover { border-color: var(--text-secondary); }
.swatch[aria-pressed="true"] { border-color: var(--text-display); border-width: 2px; }

/* text field: underline only */
.field {
  width: 100%; padding: 6px 0;
  border-bottom: 1px solid var(--border-visible);
  font-family: var(--font-mono); font-size: 13px; color: var(--text-display);
  transition: border-color 200ms var(--ease);
}
.field:focus { outline: none; border-bottom-color: var(--text-display); }

/* ── source drawer ─────────────────────────────────────── */
.drawer {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
  height: min(58%, 440px);
  display: grid; grid-template-rows: auto minmax(0, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border-visible);
  transform: translateY(100%);
  transition: transform 300ms var(--ease);
}
.drawer.open { transform: none; }
.drawer__head {
  display: flex; align-items: center; gap: var(--space-md);
  padding: 10px var(--space-md);
  border-bottom: 1px solid var(--border);
}
.drawer__head .lbl { margin-right: auto; }
.drawer__body { overflow: auto; padding: var(--space-md) var(--space-md) var(--space-lg); }
.drawer__body pre {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.75;
  color: var(--text-secondary); tab-size: 2;
  white-space: pre-wrap; word-break: break-word;   /* data URIs wrap, never scroll */
}
.tok-key { color: var(--text-display); }
.tok-str { color: var(--text-primary); }
.tok-com { color: var(--text-disabled); }
.tok-fn  { color: var(--text-primary); }
.tok-num { color: var(--text-display); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-visible) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-visible); border: 3px solid var(--black); }

/* ── responsive ────────────────────────────────────────── */
@media (max-width: 1120px) {
  .work { grid-template-columns: 200px minmax(0, 1fr) 288px; }
  .doto { font-size: 30px; }
}
@media (max-width: 900px) {
  .work { grid-template-columns: minmax(0, 1fr) 272px; }
  .rail {
    position: absolute; inset: 56px auto 0 0; width: 232px; z-index: 30;
    background: var(--black); border-right: 1px solid var(--border-visible);
    transform: translateX(-100%);
    transition: transform 250ms var(--ease);
  }
  body.nav-open .rail { transform: none; }
  .navToggle { display: grid !important; }
}
@media (max-width: 640px) {
  .work { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 244px; }
  .insp { border-left: 0; border-top: 1px solid var(--border); }
  .insp__head { padding: var(--space-md) var(--space-md) var(--space-sm); }
  .insp__desc { display: none; }
  .doto { font-size: 24px; margin-bottom: var(--space-sm) !important; }
  .bar__right { display: none; }
  .drawer { height: 74%; }
}
.navToggle { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
  .item, .stage__body { opacity: 1; }
}
