/* Composer: one layout, three style directions (deploy/composer-DESIGN.md). data-style on <html> picks one. */
:root, :root[data-style="a"] {
  --ground: #EDF0F3; --surface: #FFFFFF; --ink: #131A23; --muted: #5D6876; --accent: #2246D3; --line: #CDD5DE;
  --on-accent: #FFFFFF; --soft: #E1E6EC; --sec1: #DCE3F7; --sec2: #E9EDF2; --good: #1F7A4D; --bad: #B4232C;
  --display: "Bricolage Grotesque", "Atkinson Hyperlegible", system-ui, sans-serif; --display-w: 760; --display-stretch: 100%;
  --body: "Atkinson Hyperlegible", system-ui, sans-serif; --r-sm: 6px; --r-lg: 8px; --r-btn: 6px; --track: 1px;
  color-scheme: light;
}
:root[data-style="b"] {
  --ground: #0F1A2B; --surface: #16253C; --ink: #E7EDF5; --muted: #8D9DB3; --accent: #F4B545; --line: #24364F;
  --on-accent: #1A1406; --soft: #1C2D47; --sec1: #233A5C; --sec2: #1A2B44; --good: #5CCB97; --bad: #FF7A70;
  --display: "Archivo", system-ui, sans-serif; --display-w: 800; --display-stretch: 112%;
  --body: "Archivo", system-ui, sans-serif; --r-sm: 8px; --r-lg: 12px; --r-btn: 10px; --track: 0px;
  color-scheme: dark;
}
:root[data-style="c"] {
  --ground: #FFE4D4; --surface: #FFF5EE; --ink: #2A1636; --muted: #7B5A77; --accent: #FF4A1C; --line: #F2C6B0;
  --on-accent: #FFFFFF; --soft: #FFD3BD; --sec1: #FFC9AE; --sec2: #FFDCC9; --good: #1D7F57; --bad: #C2182B;
  --display: "Gabarito", "Figtree", system-ui, sans-serif; --display-w: 800; --display-stretch: 100%;
  --body: "Figtree", system-ui, sans-serif; --r-sm: 14px; --r-lg: 20px; --r-btn: 999px; --track: 0px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--ground); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
  --bar-h: 64px; --lane-h: 0px;
}
body.lane-open { --lane-h: 104px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.fill { fill: currentColor; stroke: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--r-btn); background: var(--surface); color: var(--ink);
  font-weight: 650; font-size: 15px; cursor: pointer; touch-action: manipulation; user-select: none;
  transition: transform 120ms ease-out, background-color 150ms ease-out, border-color 150ms ease-out;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.round { width: 44px; min-height: 44px; padding: 0; border-radius: 999px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
@media (hover: hover) and (pointer: fine) { .btn:hover { border-color: var(--accent); } }
@media (prefers-reduced-motion: reduce) { .btn { transition: background-color 150ms, border-color 150ms; } .btn:active { transform: none; } }

/* ---------- shell ---------- */
.top {
  position: sticky; top: 0; z-index: 20; background: var(--ground);
  padding: max(10px, env(safe-area-inset-top)) 16px 0; border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; gap: 10px; max-width: 1400px; margin: 0 auto; }
.brand { font-family: var(--display); font-weight: var(--display-w); font-stretch: var(--display-stretch); font-size: 20px; letter-spacing: -.02em; color: var(--ink); text-decoration: none; }
.brand small { font-family: var(--body); font-weight: 500; font-size: 13px; color: var(--muted); letter-spacing: 0; margin-left: 6px; }
.grow { flex: 1; }
.styles { display: flex; gap: 4px; align-items: center; font-size: 12px; color: var(--muted); }
.styles button { width: 32px; height: 32px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700; font-size: 13px; }
.styles button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.tabs { display: flex; gap: 4px; max-width: 1400px; margin: 8px auto 0; }
.tab {
  position: relative; border: 0; background: none; padding: 10px 12px 12px; font-weight: 700; font-size: 16px;
  color: var(--muted); cursor: pointer; touch-action: manipulation;
}
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px; background: var(--accent); border-radius: 3px 3px 0 0; }

.layout { max-width: 1400px; margin: 0 auto; padding: 12px 16px calc(var(--bar-h) + var(--lane-h) + env(safe-area-inset-bottom, 0px) + 24px); }
.view[hidden] { display: none; }
h1, h2, h3 { font-family: var(--display); font-weight: var(--display-w); font-stretch: var(--display-stretch); letter-spacing: -.02em; line-height: 1.1; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Listen: library ---------- */
.search { position: relative; margin: 4px 0 10px; }
.search input {
  width: 100%; height: 46px; padding: 0 14px 0 42px; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); font-size: 16px; /* 16px keeps iOS from zooming */
}
.search .icon { position: absolute; left: 13px; top: 12px; color: var(--muted); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font-size: 14px; font-weight: 650; cursor: pointer; white-space: nowrap; touch-action: manipulation; transition: transform 120ms ease-out;
}
.chip:active { transform: scale(.96); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--ground); border-color: var(--ink); }
.group { border-top: 1px solid var(--line); }
.group-head {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 54px; padding: 0 2px; border: 0; background: none;
  cursor: pointer; text-align: left; touch-action: manipulation;
}
.group-head h2 { font-size: 20px; flex: 1; }
.group-head .count { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.pm { width: 30px; height: 30px; border-radius: var(--r-sm); border: 1px solid var(--line); display: grid; place-items: center; background: var(--surface); flex: none; }
.pm .icon { width: 16px; height: 16px; }
.group-body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 200ms ease-out; }
.group[aria-expanded="false"] .group-body { grid-template-rows: 0fr; }
.group-body > div { overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .group-body { transition: none; } }
.song {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; width: 100%; min-height: 56px;
  padding: 6px 4px; border: 0; border-radius: var(--r-sm); background: none; text-align: left; cursor: pointer; touch-action: manipulation;
  content-visibility: auto; contain-intrinsic-size: auto 56px;
}
.song + .song { box-shadow: 0 -1px 0 color-mix(in srgb, var(--line) 60%, transparent); }
.song .t { font-weight: 700; font-size: 16px; display: block; }
.song .m { color: var(--muted); font-size: 13px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song .d { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.song .n { color: var(--muted); font-size: 13px; text-align: center; font-variant-numeric: tabular-nums; }
.song[aria-current="true"] { background: var(--soft); }
.song[aria-current="true"] .t { color: var(--accent); }
@media (hover: hover) and (pointer: fine) { .song:hover { background: var(--soft); } }
.empty { padding: 24px 4px; color: var(--muted); }
.eq { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; }
.eq i { width: 3px; background: var(--accent); border-radius: 1px; height: 30%; }
body.playing .eq i { animation: eq 900ms ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -300ms !important; } .eq i:nth-child(3) { animation-delay: -600ms !important; }
@keyframes eq { 0%, 100% { height: 30%; } 50% { height: 100%; } }
@media (prefers-reduced-motion: reduce) { body.playing .eq i { animation: none; height: 70%; } }
details.about { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 12px; }
details.about summary { cursor: pointer; font-weight: 700; }
details.about ul { padding-left: 18px; color: var(--muted); font-size: 14px; }

/* ---------- Now playing (desktop column, phone sheet) ---------- */
.np { background: var(--surface); }
.np .grabber { display: none; }
.np-inner { padding: 18px; }
.np h2.np-title { font-size: 30px; }
.np .np-sub { color: var(--muted); margin-top: 4px; }
.np .np-mood { margin-top: 12px; font-size: 15px; }
.np .np-brief { margin-top: 8px; color: var(--muted); font-size: 14px; }
.np .np-controls { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 18px 0 10px; }
.np .np-controls .btn.primary.round { width: 64px; min-height: 64px; }
.np .np-controls .btn.primary.round .icon { width: 28px; height: 28px; }
.np .np-time { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.np .np-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.np .np-ens { margin-top: 14px; font-size: 14px; color: var(--muted); }
.np .np-ens b { color: var(--ink); }
.np .lane { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--r-lg); }

.votes { display: none; gap: 8px; margin-top: 12px; }
body.votes-on .votes { display: flex; }
.votes .btn { min-width: 72px; font-variant-numeric: tabular-nums; }
.votes .btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.rank { font-size: 12px; color: var(--accent); font-weight: 800; margin-left: 6px; }

/* ---------- seek bar with sections ---------- */
.seek { position: relative; height: 22px; touch-action: none; }
.seek .segs { position: absolute; left: 0; right: 0; top: 8px; height: 6px; display: flex; border-radius: 3px; overflow: hidden; background: var(--sec2); }
.seek .segs span { height: 100%; }
.seek .segs span:nth-child(odd) { background: var(--sec1); }
.seek .segs span:nth-child(even) { background: var(--sec2); }
.seek .fill { position: absolute; left: 0; top: 8px; height: 6px; background: var(--accent); border-radius: 3px; width: 0; pointer-events: none; }
.seek input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seek .knob { position: absolute; top: 4px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--accent); pointer-events: none; left: 0; }
.seclabels { display: flex; font-size: 11px; color: var(--muted); height: 14px; overflow: hidden; }
.seclabels span { overflow: hidden; white-space: nowrap; text-overflow: clip; padding-left: 2px; }

/* ---------- chord lane ---------- */
.lane { position: relative; height: 104px; overflow: hidden; touch-action: pan-y; user-select: none; background: var(--surface); }
.lane .now { position: absolute; left: 12px; top: 8px; z-index: 2; display: flex; gap: 12px; align-items: baseline; pointer-events: none; }
.lane .now b { font-family: var(--display); font-weight: var(--display-w); font-stretch: var(--display-stretch); font-size: 26px; letter-spacing: -.02em; }
.lane .now span { font-size: 13px; color: var(--muted); }
.lane .track { position: absolute; left: 0; top: 50px; height: 44px; will-change: transform; }
.lane .blk {
  position: absolute; top: 0; height: 40px; padding: 0 6px; display: flex; align-items: center; border-left: 2px solid var(--line);
  font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; color: var(--muted); cursor: pointer;
}
.lane .blk.on { color: var(--accent); border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.lane .sec { position: absolute; top: -14px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.lane .head { position: absolute; left: 50%; top: 46px; bottom: 6px; width: 2px; background: var(--accent); z-index: 2; pointer-events: none; }

/* ---------- player bar ---------- */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bar .lane { height: 0; border-bottom: 1px solid transparent; transition: height 240ms cubic-bezier(.32,.72,0,1); }
body.lane-open .bar .lane { height: var(--lane-h); border-bottom-color: var(--line); }
@media (prefers-reduced-motion: reduce) { .bar .lane { transition: none; } }
.bar .seek { margin: -11px 0 -6px; }
.bar-row { display: flex; align-items: center; gap: 6px; height: var(--bar-h); padding: 0 10px; max-width: 1400px; margin: 0 auto; }
.bar-title { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 6px 4px; cursor: pointer; display: flex; flex-direction: column; justify-content: center; min-height: 48px; }
.bar-title b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-title span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; display: none; min-width: 92px; text-align: right; }
.bar .chords-btn { font-size: 13px; min-height: 36px; padding: 0 10px; }
.bar .prev { display: none; }

/* ---------- Mix ---------- */
.mix-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.mix-head h2 { font-size: 24px; flex: 1 1 200px; }
.status { font-size: 13px; color: var(--muted); min-height: 18px; }
.pgroups { margin-top: 6px; }
.pgroup { border-top: 1px solid var(--line); }
.pgroup .group-head h2 { font-size: 17px; }
.pgroup .chipset { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 12px; }
.chip.preset[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.parts { width: 100%; border-collapse: collapse; margin-top: 10px; }
.parts td { padding: 8px 4px; border-top: 1px solid var(--line); vertical-align: middle; }
.parts td.role { width: 92px; }
.parts td.role b { display: block; font-size: 15px; }
.parts td.role span { font-size: 12px; color: var(--muted); }
.parts select { width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); padding: 0 8px; font-size: 16px; }
.parts .ctl { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.parts .ctl select { width: auto; min-height: 36px; font-size: 14px; }
.parts .ctl input[type=range] { flex: 1 1 90px; min-width: 80px; accent-color: var(--accent); }
.mini { min-width: 36px; min-height: 36px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); font-weight: 800; font-size: 13px; cursor: pointer; touch-action: manipulation; }
.mini[aria-pressed="true"].m { background: var(--bad); color: #fff; border-color: var(--bad); }
.mini[aria-pressed="true"].s { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.st { font-size: 12px; color: var(--muted); }
.st.load { color: var(--accent); }
.mix-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.keys { font-size: 13px; color: var(--muted); margin-top: 10px; display: none; }
kbd { border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 12px; background: var(--surface); }

/* ---------- Compose (styles for compose.js markup) ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; margin-top: 4px; }
.card h2 { font-size: 22px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cx select, .cx input[type=text], .cx textarea, .cx input[type=number] { width: 100%; min-height: 42px; background: var(--ground); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; font-size: 16px; }
.cx textarea { min-height: 84px; resize: vertical; }
.cx label.f { display: block; font-size: 14px; font-weight: 700; margin: 12px 0 4px; }
.cx .hint { color: var(--muted); font-size: 13px; font-weight: 400; margin-top: 3px; }
.cx .g2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.cx .g3 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.cx .opts { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; font-size: 15px; }
.cx .opts label { display: flex; gap: 6px; align-items: center; min-height: 32px; }
.cx .roles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 12px; margin-top: 6px; font-size: 13px; }
.cx .roles b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.cx details { margin-top: 12px; } .cx summary { cursor: pointer; color: var(--muted); font-size: 14px; min-height: 32px; }
.cx pre { background: var(--ground); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px; font-size: 12px; max-height: 240px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 6px 0 0; }
.cx .warn { color: var(--bad); font-size: 13px; min-height: 16px; margin-top: 8px; }
.cx .hide, .hide { display: none !important; }
.cx .light { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.cx .light.on { background: var(--good); } .cx .light.off { background: var(--bad); }
.cx .lighttext { font-size: 13px; color: var(--muted); margin-right: 8px; }
.cx .forkbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 14px; border: 1px solid var(--accent); border-radius: var(--r-sm); padding: 6px 10px; margin-top: 8px; }
.cx .forkbar span { flex: 1 1 240px; }
.cx #cx-chordtypes { display: grid; grid-template-columns: 1fr; gap: 6px 14px; }
.cx #cx-chordtypes label { align-items: flex-start; }
.cx #cx-chordtypes b { font-weight: 700; }
.cx .btn.main { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.jobs { display: flex; flex-direction: column; gap: 8px; }
.job { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; background: var(--ground); }
.job .top { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.job .t { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.pill { font-size: 12px; border-radius: 999px; padding: 1px 8px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.queued, .pill.composing, .pill.publishing { color: var(--accent); border-color: var(--accent); }
.pill.done { color: var(--good); border-color: var(--good); } .pill.failed { color: var(--bad); border-color: var(--bad); }
.job .ev { font-size: 13px; color: var(--muted); margin-top: 6px; max-height: 160px; overflow: auto; }
.job .ev div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job .res { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.job .res .r { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.job .res audio { height: 36px; flex: 1 1 220px; max-width: 100%; }
.job .err { color: var(--bad); font-size: 13px; margin-top: 6px; white-space: pre-wrap; }

/* ---------- phones: the now-playing panel is a sheet ---------- */
@media (max-width: 1023px) {
  .np {
    position: fixed; left: 0; right: 0; bottom: 0; top: max(8px, env(safe-area-inset-top)); z-index: 40;
    border-radius: var(--r-lg) var(--r-lg) 0 0; border: 1px solid var(--line); border-bottom: 0;
    transform: translateY(105%); transition: transform 220ms cubic-bezier(.32,.72,0,1); visibility: hidden;
    display: flex; flex-direction: column; box-shadow: 0 -12px 40px rgba(0,0,0,.18);
  }
  body.sheet-open .np { transform: translateY(0); visibility: visible; transition-duration: 280ms; }
  .np .grabber { display: block; position: relative; height: 34px; width: 100%; border: 0; background: none; cursor: grab; flex: none; touch-action: none; }
  .np .grabber::before { content: ""; position: absolute; left: 50%; top: 12px; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: var(--line); }
  .np-inner { overflow-y: auto; flex: 1; padding: 0 18px calc(24px + env(safe-area-inset-bottom, 0px)); overscroll-behavior: contain; }
  .scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity 220ms ease-out; }
  body.sheet-open .scrim { opacity: 1; pointer-events: auto; }
  @media (prefers-reduced-motion: reduce) { .np { transition: opacity 200ms; transform: none; opacity: 0; } body.sheet-open .np { opacity: 1; } }
}

/* ---------- desktop: docked bar, now-playing column ---------- */
@media (min-width: 1024px) {
  body { --bar-h: 76px; }
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
  .np { position: sticky; top: 120px; border: 1px solid var(--line); border-radius: var(--r-lg); max-height: calc(100vh - 140px - var(--bar-h) - var(--lane-h)); overflow-y: auto; }
  .scrim { display: none; }
  .bar .time { display: block; }
  .bar .prev { display: inline-flex; }
  .np .lane { display: none; }   /* the docked bar carries the chord lane on desktop */
  .bar-title { cursor: default; }
  .keys { display: block; }
  .cx .g2 { grid-template-columns: 1fr 1fr; } .cx .g3 { grid-template-columns: repeat(3, 1fr); }
  .cx #cx-chordtypes { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}
@media (min-width: 1024px) and (max-width: 1199px) { .layout { grid-template-columns: minmax(0, 1fr) 320px; } }

/* view switch */
@supports (view-transition-name: none) {
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 200ms; }
}
@media (prefers-reduced-motion: reduce) { ::view-transition-old(root), ::view-transition-new(root) { animation: none; } }

/* ---------- How it works (about.js) ---------- */
.about-btn { min-height: 36px; padding: 0 10px; font-size: 14px; }
@media (max-width: 420px) { .about-btn span { display: none; } .about-btn { width: 36px; padding: 0; border-radius: 999px; } }
dialog.about {
  border: 0; padding: 0; background: transparent; color: var(--ink); max-width: none; max-height: none;
  width: 100%; height: 100%; margin: 0; inset: 0; overflow: hidden;
}
dialog.about::backdrop { background: rgba(10, 14, 20, .55); animation: ab-fade 200ms ease-out; }
dialog.about.closing::backdrop { opacity: 0; transition: opacity 180ms ease-in; }
html.about-open { overflow: hidden; }
.about-box {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; border: 1px solid var(--line); border-bottom: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px); animation: ab-up 280ms cubic-bezier(.32,.72,0,1);
  box-shadow: 0 -20px 60px rgba(0,0,0,.25);
}
dialog.about.closing .about-box { transform: translateY(105%); transition: transform 200ms cubic-bezier(.32,.72,0,1); }
@keyframes ab-up { from { transform: translateY(100%); } }
@keyframes ab-fade { from { opacity: 0; } }
.about-top { display: flex; align-items: center; gap: 8px; padding: 14px 14px 4px 20px; }
.about-top h2 { flex: 1; font-size: 15px; font-family: var(--body); font-weight: 700; color: var(--muted); letter-spacing: 0; }
.about-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; flex: 1; min-height: 0; outline: none; }
.about-track::-webkit-scrollbar { display: none; }
.about-slide { flex: 0 0 100%; scroll-snap-align: start; scroll-snap-stop: always; overflow-y: auto; padding: 4px 20px 8px; }
.about-text { padding-top: 14px; }
.about-n { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.about-text h3 { font-size: 28px; margin-top: 4px; }
.about-lead { font-size: 17px; font-weight: 700; color: var(--accent); margin: 8px 0 0; }
.about-p { font-size: 16px; line-height: 1.55; margin: 8px 0 0; }
.about-compose { margin-top: 14px; }
.about-nav { display: flex; align-items: center; gap: 10px; padding: 10px 20px 14px; border-top: 1px solid var(--line); }
.about-nav .btn { min-width: 84px; }
.about-dots { flex: 1; display: flex; justify-content: center; gap: 2px; }
.about-dot { width: 28px; height: 28px; border: 0; background: none; cursor: pointer; position: relative; }
.about-dot::before { content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 4px; background: var(--line); transition: width 200ms ease-out, margin 200ms ease-out, background-color 200ms; }
.about-dot[aria-current="step"]::before { width: 22px; margin-left: -11px; background: var(--accent); }
@media (min-width: 760px) {
  .about-box { left: 50%; top: 50%; bottom: auto; width: min(760px, calc(100% - 48px)); max-height: min(720px, calc(100dvh - 48px));
    transform: translate(-50%, -50%); border-radius: var(--r-lg); border-bottom: 1px solid var(--line); animation: ab-pop 240ms cubic-bezier(.32,.72,0,1); padding-bottom: 0; }
  @keyframes ab-pop { from { opacity: 0; transform: translate(-50%, -46%) scale(.98); } }
  dialog.about.closing .about-box { transform: translate(-50%, -48%) scale(.98); opacity: 0; transition: transform 180ms ease-in, opacity 180ms ease-in; }
  .about-slide { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: center; padding: 8px 28px 16px; }
  .about-text { padding-top: 0; }
  .art { height: 260px !important; }
}

/* illustrations: they animate only on the visible step */
.art { position: relative; height: 190px; border-radius: var(--r-lg); background: var(--ground); border: 1px solid var(--line); overflow: hidden; padding: 12px; }
.about-slide:not(.on) .art * { animation-play-state: paused !important; }
/* 1. the chart */
.chart-head { font-size: 12px; color: var(--muted); font-weight: 700; }
.chart-bars { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 8px; border-left: 2px solid var(--ink); }
.chart-bar { position: relative; padding: 10px 8px; border-right: 2px solid var(--ink); border-bottom: 1px solid var(--line); font-family: var(--display); font-weight: var(--display-w); font-size: 20px; letter-spacing: -.02em; opacity: 0; animation: ab-in 300ms ease-out forwards, bar-on 4.8s linear infinite; animation-delay: calc(var(--i) * 120ms), calc(1s + var(--i) * 600ms); }
@keyframes ab-in { to { opacity: 1; } }
@keyframes bar-on { 0%, 12.4% { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); } 12.5%, 100% { background: transparent; color: var(--ink); } }
.chart-mel { position: absolute; left: 12px; right: 12px; bottom: 12px; height: 42px; }
.chart-mel i { position: absolute; left: calc(var(--i) * 8%); bottom: calc(var(--y) * 5px); width: 9px; height: 7px; border-radius: 50%; background: var(--accent); transform: rotate(-20deg) scale(0); animation: dot-in 240ms ease-out forwards; animation-delay: calc(400ms + var(--i) * 90ms); }
@keyframes dot-in { to { transform: rotate(-20deg) scale(1); } }
/* 2. the ears */
.ears { display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.ear-row { display: grid; grid-template-columns: 1fr auto 70px 38px; gap: 8px; align-items: center; font-size: 13px; }
.ear-k { font-weight: 700; } .ear-t { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.ear-m { height: 6px; border-radius: 3px; background: var(--soft); overflow: hidden; }
.ear-m i { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); animation: ear-fill 6s ease-out infinite; animation-delay: calc(var(--i) * 280ms); }
@keyframes ear-fill { 0% { transform: scaleX(0); } 18%, 92% { transform: scaleX(1); } 100% { transform: scaleX(1); opacity: 0; } }
.ear-ok { color: var(--good); font-size: 12px; opacity: 0; animation: ear-ok 6s ease-out infinite; animation-delay: calc(var(--i) * 280ms); }
@keyframes ear-ok { 0%, 17% { opacity: 0; transform: translateX(-4px); } 22%, 92% { opacity: 1; transform: none; } 100% { opacity: 0; } }
/* 3. the picks */
.picks { display: flex; flex-wrap: wrap; align-content: safe center; gap: 6px; padding-top: 14px; }
.pick { display: inline-flex; gap: 6px; align-items: center; padding: 6px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 700; opacity: 0; transform: scale(.8); animation: pick-in 6s ease-out infinite; animation-delay: calc(var(--i) * 260ms); }
.pick b { color: var(--good); }
.pick.no { animation-name: pick-no; } .pick.no b { color: var(--bad); }
@keyframes pick-in { 0% { opacity: 0; transform: scale(.8); } 6%, 90% { opacity: 1; transform: none; } 100% { opacity: 0; } }
@keyframes pick-no { 0% { opacity: 0; transform: scale(.8); } 6%, 18% { opacity: 1; transform: none; } 26%, 90% { opacity: .35; transform: scale(.96); text-decoration: line-through; } 100% { opacity: 0; } }
/* 4. the live roll */
.roll { display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 12px 0; }
.lane-row { display: grid; grid-template-columns: 112px 1fr; align-items: center; height: 30px; }
.lane-lab { padding-left: 12px; font-size: 12px; line-height: 1.2; }
.lane-lab b { display: block; }
.lane-swap { position: relative; display: block; height: 15px; color: var(--accent); font-weight: 700; }
.lane-swap em { position: absolute; left: 0; font-style: normal; opacity: 0; animation: swap 9s infinite; animation-delay: calc(var(--j) * 3s + var(--k) * 400ms); white-space: nowrap; }
@keyframes swap { 0% { opacity: 0; transform: translateY(5px); } 4%, 30% { opacity: 1; transform: none; } 34%, 100% { opacity: 0; transform: translateY(-5px); } }
.lane-notes { position: relative; height: 100%; width: 200%; animation: roll 8s linear infinite; }
.lane-notes i { position: absolute; top: 6px; bottom: 6px; border-radius: 3px; background: var(--accent); opacity: .8; }
.lane-row:nth-child(2) .lane-notes i { opacity: .5; } .lane-row:nth-child(3) .lane-notes i { opacity: .65; } .lane-row:nth-child(4) .lane-notes i { opacity: .4; top: 10px; bottom: 10px; }
@keyframes roll { to { transform: translateX(-50%); } }
.lane-row { overflow: hidden; }
.roll-head { position: absolute; top: 10px; bottom: 10px; left: calc(112px + (100% - 112px) / 2); width: 2px; background: var(--ink); opacity: .7; }
/* 5. compose */
.gen { display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.gen-q { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; font-size: 14px; overflow: hidden; }
.gen-type { display: block; white-space: nowrap; overflow: hidden; text-overflow: clip; clip-path: inset(0 100% 0 0); animation: type 8s steps(48) infinite; }
@keyframes type { 0% { clip-path: inset(0 100% 0 0); } 30%, 95% { clip-path: inset(0 0 0 0); } 100% { clip-path: inset(0 0 0 0); opacity: 0; } }
.gen-steps { display: flex; gap: 6px; flex-wrap: wrap; }
.gen-steps span { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); animation: step-on 8s infinite; animation-delay: calc(2.6s + var(--i) * 700ms); }
@keyframes step-on { 0% { background: transparent; color: var(--muted); } 3%, 60% { background: var(--accent); color: var(--on-accent); border-color: var(--accent); } 70%, 100% { background: transparent; color: var(--muted); } }
.gen-card { align-self: flex-start; display: flex; flex-direction: column; padding: 10px 14px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--accent); opacity: 0; transform: translateY(8px); animation: card-in 8s ease-out infinite; animation-delay: 5.4s; }
.gen-card b { font-size: 16px; } .gen-card span { font-size: 12px; color: var(--muted); }
@keyframes card-in { 0% { opacity: 0; transform: translateY(8px); } 5%, 30% { opacity: 1; transform: none; } 36%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .about-box, dialog.about::backdrop { animation: none; }
  .art *, .art *::before { animation: none !important; opacity: 1 !important; transform: none !important; clip-path: none !important; }
  .lane-swap em:not(:first-child) { display: none; }
  .pick.no { opacity: .4 !important; text-decoration: line-through; }
}
@media (max-width: 420px) {
  .styles > span, .brand small { display: none; }
  .top-row { gap: 8px; }
}
