/* Layout: a working desk. Header band with a stitched paj ntaub edge, then two lyric sheets side by side, then the word-by-word breakdown and rule settings. */
:root {
  --bg: #F4F5FA;
  --surface: #FFFFFF;
  --ink: #1B1F3B;
  --muted: #5A6082;
  --line: #D9DCEA;
  --accent: #B3123F;
  --accent-ink: #FFFFFF;
  --accent-soft: #F8E5EB;
  --ok: #1D7656;
  --warn: #9A5600;
  --warn-soft: #FBF0DF;
  --stitch-a: #B3123F;
  --stitch-b: #1B1F3B;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10121E; --surface: #181B2B; --ink: #E9EBF5; --muted: #9AA0BE; --line: #2B2F46;
    --accent: #FF5C84; --accent-ink: #1C0710; --accent-soft: #3A1A26; --ok: #4FC99C;
    --warn: #E9A84E; --warn-soft: #3A2C17; --stitch-a: #FF5C84; --stitch-b: #E9EBF5;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #10121E; --surface: #181B2B; --ink: #E9EBF5; --muted: #9AA0BE; --line: #2B2F46;
  --accent: #FF5C84; --accent-ink: #1C0710; --accent-soft: #3A1A26; --ok: #4FC99C;
  --warn: #E9A84E; --warn-soft: #3A2C17; --stitch-a: #FF5C84; --stitch-b: #E9EBF5;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.55;
}
.wrap {
  max-width: 1180px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
header { padding-block: 28px 0; }
.brand { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; }
h1 {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(1.7rem, 4vw, 2.5rem);
  letter-spacing: -0.02em; line-height: 1.1; margin: 0; text-wrap: balance;
}
h1 em { font-style: normal; color: var(--accent); }
.byline { color: var(--muted); font-size: 0.9rem; }
.tagline { margin: 8px 0 0; color: var(--muted); max-width: 62ch; font-size: 1.05rem; }
.stitch {
  height: 10px; margin-top: 22px; opacity: 0.85;
  background:
    linear-gradient(135deg, var(--stitch-a) 25%, transparent 25%) 0 0 / 20px 10px,
    linear-gradient(225deg, var(--stitch-a) 25%, transparent 25%) 0 0 / 20px 10px,
    linear-gradient(315deg, var(--stitch-b) 25%, transparent 25%) 10px 0 / 20px 10px,
    linear-gradient(45deg, var(--stitch-b) 25%, transparent 25%) 10px 0 / 20px 10px;
}

main { padding-block: 24px 48px; display: grid; gap: 28px; }
.sheets { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 820px) { .sheets { grid-template-columns: 1fr; } }
.sheet {
  min-width: 0; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.sheet-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.sheet-head label, .label {
  font-family: var(--font-display); font-weight: 600; font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}
.sheet.out .sheet-head label { color: var(--accent); }
.tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
textarea {
  width: 100%; min-height: 380px; flex: 1; resize: vertical; border: 0; outline: none;
  background: transparent; color: var(--ink); padding: 16px;
  font-family: var(--font-body); font-size: 1.08rem; line-height: 1.75;
}
textarea:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); border-radius: 0 0 var(--radius) var(--radius); }
.badge {
  font-size: 0.75rem; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.badge.warn { background: var(--warn-soft); color: var(--warn); }

button, .btn {
  font: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 6px 12px; border-radius: 8px;
}
button:hover { border-color: var(--muted); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
  font-family: var(--font-display); font-size: 1.05rem; padding: 12px 26px; letter-spacing: 0.01em;
}
button.primary:hover { filter: brightness(1.07); }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.status { font-size: 0.95rem; color: var(--muted); min-height: 1.5em; }
.status.error { color: var(--accent); font-weight: 700; }
.status.ok { color: var(--ok); font-weight: 700; }

.confirm {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  background: var(--warn-soft); color: var(--ink); border: 1px solid var(--warn);
  border-radius: var(--radius); padding: 12px 14px;
}
.confirm p { margin: 0; flex: 1 1 280px; }

.stats { display: flex; flex-wrap: wrap; gap: 8px; font-size: 0.9rem; }
.chip {
  display: inline-flex; gap: 6px; align-items: baseline; padding: 4px 10px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-variant-numeric: tabular-nums;
}
.chip b { font-family: var(--font-mono); font-weight: 500; }
.chip.warn { border-color: var(--warn); color: var(--warn); }

section h2 {
  font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; margin: 0 0 4px;
  letter-spacing: -0.01em; text-wrap: balance;
}
section .lede { margin: 0 0 14px; color: var(--muted); max-width: 70ch; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.table-scroll { overflow-x: auto; max-height: 460px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface); font-family: var(--font-display); font-weight: 600;
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); z-index: 1; }
td.mono, .mono { font-family: var(--font-mono); }
td.out { font-weight: 700; color: var(--accent); font-size: 1rem; }
.parts span { padding: 1px 5px; border-radius: 4px; background: var(--bg); margin-right: 2px; }
.parts .tone { color: var(--muted); }
.tone-name { color: var(--muted); font-family: var(--font-body); font-size: 0.82rem; margin-left: 6px; }
.kind { font-size: 0.75rem; font-weight: 700; padding: 2px 7px; border-radius: 4px; }
.kind.rule { color: var(--muted); }
.kind.exception, .kind.custom { background: var(--accent-soft); color: var(--accent); }
.kind.split { background: var(--warn-soft); color: var(--warn); }
.kind.unknown { background: var(--warn-soft); color: var(--warn); }
td.applied { color: var(--muted); font-family: var(--font-mono); font-size: 0.82rem; white-space: normal; min-width: 150px; }
.fix { display: flex; gap: 6px; }
.fix input {
  width: 120px; font: inherit; font-family: var(--font-mono); padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.empty { padding: 18px; color: var(--muted); }

.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.settings .panel { padding: 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.field { display: grid; gap: 6px; }
.field select, .field input[type="text"] {
  font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink);
}
.check { display: flex; gap: 10px; align-items: center; font-weight: 700; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.hint { color: var(--muted); font-size: 0.88rem; margin: 0; }
.rule-list { display: grid; gap: 4px; font-family: var(--font-mono); font-size: 0.88rem; margin: 0; padding: 0; list-style: none; }
.rule-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.rule-list li:last-child { border-bottom: 0; }
.rule-list .arrow { color: var(--muted); }
.rule-list .to { color: var(--accent); font-weight: 500; }
.rule-list button { padding: 2px 8px; font-size: 0.8rem; }

.wordcount { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.wordcount.over { color: var(--accent); font-weight: 700; }
.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tabs button { border: 0; border-radius: 0; padding: 6px 12px; }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--bg); }
.stacked {
  flex: 1; min-height: 380px; max-height: 640px; overflow-y: auto; padding: 16px;
  display: grid; gap: 14px; align-content: start;
}
.sline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px 12px; min-width: 0; }
.sline.blank { height: 6px; }
.sline.label {
  font-family: var(--font-display); font-weight: 600; font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); padding-top: 6px;
}
.w { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.w .native { font-size: 0.85rem; color: var(--muted); }
.w .suno { font-size: 1.1rem; font-weight: 700; color: var(--ink); }
.w.changed .suno { color: var(--accent); }
.w .punct { color: var(--muted); font-weight: 400; }
.stacked-note { font-size: 0.85rem; color: var(--muted); margin: 0; }
footer { padding-block: 0 40px; color: var(--muted); font-size: 0.85rem; }
footer p { margin: 0 0 4px; max-width: 80ch; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- App additions: account bar, plans, dialogs, songs ---- */
body { margin: 0; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; }
.account { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 0.92rem; }
.account .who { color: var(--muted); max-width: 26ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.credit-pill { font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-variant-numeric: tabular-nums; }
.credit-pill.zero { background: var(--warn-soft); color: var(--warn); }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.notice { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; border-radius: var(--radius); padding: 12px 14px; border: 1px solid var(--line); background: var(--surface); }
.notice.good { border-color: var(--ok); }
.notice.warn { border-color: var(--warn); background: var(--warn-soft); }
.notice p { margin: 0; flex: 1 1 260px; }
.mode-hint { color: var(--muted); font-size: 0.92rem; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.plan { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 8px; align-content: start; min-width: 0; }
.plan.featured { border: 2px solid var(--accent); }
.plan h3 { margin: 0; font-family: var(--font-display); font-size: 1.05rem; }
.plan .price { font-family: var(--font-display); font-weight: 700; font-size: 2rem; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.plan .price small { font-size: 0.9rem; font-weight: 600; color: var(--muted); }
.plan .per { color: var(--muted); font-size: 0.88rem; margin: 0; min-height: 1.4em; }
.plan button { margin-top: 6px; }
.tag { justify-self: start; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 22px; width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 12, 25, 0.55); }
dialog h2 { margin: 0 0 6px; font-family: var(--font-display); }
dialog form { display: grid; gap: 12px; }
dialog input[type="email"] { font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
dialog .row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.songs { list-style: none; margin: 0; padding: 0; display: grid; }
.songs li { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.songs li:last-child { border-bottom: 0; }
.songs .t { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.songs .m { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.songs li.current { background: var(--accent-soft); }
.small { font-size: 0.85rem; color: var(--muted); }
button[disabled] { opacity: 0.55; cursor: not-allowed; }
footer a { color: inherit; }

.steps { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 14px 0 0; padding: 0; font-weight: 700; }
.steps li { display: flex; align-items: center; gap: 8px; }
.steps b { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-family: var(--font-display); font-size: 0.85rem; }
.locked { margin: 0 16px 16px; padding: 18px; border: 2px dashed var(--accent); border-radius: var(--radius); background: var(--accent-soft); display: grid; gap: 10px; text-align: center; justify-items: center; }
.lock-title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; }
.lock-text { margin: 0; max-width: 46ch; }
.lock-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.google-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); padding: 10px 16px; font-size: 1rem; }
.google-btn .g { font-family: var(--font-display); font-weight: 700; color: #4285F4; font-size: 1.1rem; }
.or { text-align: center; margin: 4px 0 0 !important; }
.plans.two { grid-template-columns: repeat(auto-fit, minmax(220px, 320px)); }
.promises { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 8px; max-width: 70ch; }
.promises li { padding-left: 22px; position: relative; }
.promises li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); font-weight: 700; }
.report-btn { font-size: 0.8rem; padding: 3px 9px; }
[hidden] { display: none !important; }
main { grid-template-columns: minmax(0, 1fr); }
.sheets { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 820px) { .sheets { grid-template-columns: minmax(0, 1fr); } }
html, body { overflow-x: hidden; }
.sheets .action-row { grid-column: 1 / -1; order: 3; }
.sheets .sheet.out { order: 2; }
@media (max-width: 820px) { .sheets .action-row { order: 0; } .sheets .sheet.out { order: 0; } }
.sheet.out:has(#lockPanel:not([hidden])) .stacked { min-height: 0; }
