/* Layout: lead-sheet desk. Left column is the brief you fill in, right column is the sheet that comes back, one tab per platform. */
:root {
  --bg: #eceef3;
  --surface: #ffffff;
  --sunk: #e2e5ec;
  --fg: #1b1f2c;
  --muted: #5b6275;
  --line: #cfd4df;
  --accent: #34507f;
  --accent-fg: #ffffff;
  --candle: #8a5212;
  --candle-soft: #f5e6d1;
  --warn: #a3392f;
  --ok: #2f6b4f;
  --font-display: "Songti SC", "STSong", serif;
  --font-body: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111420; --surface: #191d2b; --sunk: #0d1019; --fg: #e6e8f0; --muted: #9aa0b6; --line: #2b3145;
    --accent: #93acd9; --accent-fg: #0f1320; --candle: #e2a95d; --candle-soft: #33281a; --warn: #f08f84; --ok: #8fcfae;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111420; --surface: #191d2b; --sunk: #0d1019; --fg: #e6e8f0; --muted: #9aa0b6; --line: #2b3145;
  --accent: #93acd9; --accent-fg: #0f1320; --candle: #e2a95d; --candle-soft: #33281a; --warn: #f08f84; --ok: #8fcfae;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.6;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px 48px;
}
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0; font-weight: 700; }
h1 { font-size: 1.6rem; letter-spacing: 0.02em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; font-weight: 500; }
p { margin: 0; }
.wrap { max-width: 1240px; margin: 0 auto; display: grid; gap: 20px; }
header.top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 20px; }
.top .sub { color: var(--muted); font-size: 0.9rem; max-width: 60ch; }
.status { font-size: 0.82rem; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }
.status span::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--line); vertical-align: 1px; }
.status span.on::before { background: var(--ok); }
.status span.off::before { background: var(--warn); }
.desk { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 880px) { .desk { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 16px; min-width: 0; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label, .label { font-size: 0.8rem; color: var(--muted); letter-spacing: 0.04em; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.row > .field { flex: 1 1 140px; }
textarea, input[type="text"], select {
  width: 100%; font: inherit; color: var(--fg); background: var(--sunk); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px;
}
textarea { resize: vertical; min-height: 96px; }
textarea:focus, input:focus, select:focus, button:focus-visible, .dir:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--sunk); border-radius: 8px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 8px; border-radius: 6px; font: inherit; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }
button.primary, button.ghost, button.small {
  font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid transparent;
}
button.primary { background: var(--accent); color: var(--accent-fg); padding: 11px 16px; font-weight: 600; }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--accent); border-color: var(--line); padding: 9px 14px; }
button.small { background: var(--sunk); color: var(--fg); border-color: var(--line); padding: 4px 10px; font-size: 0.8rem; }
.note { font-size: 0.82rem; color: var(--muted); }
.note.warn { color: var(--warn); }
.dirs { display: grid; gap: 6px; max-height: 340px; overflow-y: auto; padding-right: 4px; }
.dir-group { font-size: 0.75rem; color: var(--muted); letter-spacing: 0.06em; padding-top: 6px; }
.dir { text-align: left; font: inherit; color: var(--fg); background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 10px; align-items: baseline; }
.dir[aria-pressed="true"] { border-color: var(--accent); background: var(--sunk); }
.dir .id { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); }
.dir .t { font-size: 0.9rem; min-width: 0; overflow-wrap: anywhere; }
.dir .bpm { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.dir .hk { grid-column: 2 / 4; font-size: 0.8rem; color: var(--candle); }
.dir-detail { background: var(--sunk); border-radius: 8px; padding: 12px; display: grid; gap: 8px; font-size: 0.85rem; }
.sheet-head { display: grid; gap: 6px; }
.sheet-head .meta { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 0.75rem; border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.hook { color: var(--candle); border-color: var(--candle); background: var(--candle-soft); }
.chip.example { color: var(--accent); border-color: var(--accent); }
.brief { font-size: 0.9rem; color: var(--muted); max-width: 70ch; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { font: inherit; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 8px 10px; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.out { display: grid; gap: 14px; }
.box { display: grid; gap: 6px; min-width: 0; }
.box-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.count { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.count.over { color: var(--warn); font-weight: 500; }
pre.text { margin: 0; background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.55; max-height: 420px; overflow-y: auto; }
pre.text.lyrics { font-family: var(--font-body); font-size: 0.9rem; }
.section-label { font-size: 0.75rem; letter-spacing: 0.08em; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-top: 6px; }
dl.settings { margin: 0; display: grid; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.setting { display: grid; grid-template-columns: minmax(7.5em, 34%) minmax(0, 1fr); gap: 4px 12px; padding: 9px 12px; background: var(--surface); }
.setting + .setting { border-top: 1px solid var(--line); }
.setting dt { font-size: 0.85rem; color: var(--muted); font-family: var(--font-mono); }
.setting dd { margin: 0; display: grid; gap: 2px; min-width: 0; }
.setting .val { font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.setting .hint { font-size: 0.78rem; color: var(--muted); }
ol.steps, ul.plain { margin: 0; padding-left: 1.3em; display: grid; gap: 4px; font-size: 0.88rem; }
.src { font-size: 0.78rem; color: var(--muted); }
.src a { color: var(--accent); }
.progress { font-size: 0.85rem; color: var(--muted); font-family: var(--font-mono); white-space: pre-wrap; max-height: 120px; overflow: hidden; }
.edit { display: grid; gap: 12px; border-top: 1px solid var(--line); padding-top: 16px; }
.picked { font-size: 0.85rem; background: var(--candle-soft); color: var(--fg); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 9em; overflow-y: auto; }
.history { display: grid; gap: 6px; }
.history button { text-align: left; font: inherit; background: none; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--fg); cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.history .when { color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { color: var(--muted); font-size: 0.88rem; padding: 12px; border: 1px dashed var(--line); border-radius: 8px; }
.legal { font-size: 0.8rem; color: var(--fg); background: var(--candle-soft); border-radius: 8px; padding: 8px 10px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 0.85rem; }
@media (prefers-reduced-motion: no-preference) { .toast { transition: opacity 0.2s; } }
[hidden] { display: none !important; }
body { margin: 0; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.stack { display: grid; gap: 14px; }
input[type="password"] { width: 100%; font: inherit; color: var(--fg); background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.gate { min-height: 80vh; display: grid; place-items: center; }
.gate-card { width: min(100%, 380px); }
.account { display: inline-flex; gap: 6px; align-items: center; }
.account::before { display: none; }
.ai-grid { display: grid; gap: 6px; }
.ai-row { display: grid; grid-template-columns: minmax(5.5em, auto) minmax(0, 1fr) minmax(0, 1fr); gap: 6px; align-items: start; }
.ai-name { font-size: 0.88rem; padding-top: 7px; }
.ai-name small { display: block; font-size: 0.72rem; color: var(--muted); }
.ai-opt { font: inherit; font-size: 0.82rem; text-align: left; cursor: pointer; border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; background: transparent; color: var(--fg); display: grid; gap: 2px; min-width: 0; }
.ai-opt .tag { font-size: 0.7rem; letter-spacing: 0.04em; color: var(--ok); }
.ai-opt[aria-pressed="true"] { border-color: var(--accent); background: var(--sunk); box-shadow: inset 0 0 0 1px var(--accent); }
.ai-opt:disabled { cursor: not-allowed; color: var(--muted); background: var(--sunk); opacity: 0.6; }
.ai-opt:disabled .tag { color: var(--warn); }
.ai-opt .why { font-size: 0.72rem; color: var(--muted); overflow-wrap: anywhere; }
.ai-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.keys { display: grid; gap: 10px; }
.key-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.key-row .state { font-size: 0.78rem; }
.key-row .state.on { color: var(--ok); }
.key-row .state.off { color: var(--muted); }
@media (max-width: 480px) { .ai-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .ai-name { grid-column: 1 / -1; padding-top: 4px; } }
.ai-opt .why { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
details.ai-why { font-size: 0.8rem; color: var(--muted); }
details.ai-why summary { cursor: pointer; color: var(--accent); }
details.ai-why ul { margin: 6px 0 0; padding-left: 1.2em; display: grid; gap: 4px; }
details.ai-why a { color: var(--accent); }
.pending { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 0.85rem; background: var(--candle-soft); border-radius: 8px; padding: 8px 10px; }
.pending span { overflow-wrap: anywhere; max-height: 6em; overflow-y: auto; }
ol.picks { margin: 0; padding-left: 1.4em; display: grid; gap: 10px; }
.pick { display: grid; gap: 6px; }
.pick-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: start; font-size: 0.85rem; }
.pick-text { overflow-wrap: anywhere; white-space: pre-wrap; max-height: 6em; overflow-y: auto; }
.pick-all { display: flex; gap: 8px; align-items: center; font-size: 0.85rem; cursor: pointer; }
.pick-all input { width: 18px; height: 18px; accent-color: var(--accent); }
