:root {
  --ink: #1d1d1b;
  --lime: #9bc14b;
  --green: #5f8f1f;
  --bg: #eef1ea;
  --surface: #fff;
  --muted: #5d6166;
  --line: #e1e5dc;
  --font-head: "Raleway", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --tabbar-h: 64px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.5;
  overflow-x: hidden;
}
h1 { font-family: var(--font-head); font-size: 1.5rem; margin: 0 0 16px; }
a { color: var(--green); }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

.topbar {
  display: flex; align-items: center; gap: 12px; padding: 8px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none;
  font-family: var(--font-head); font-weight: 700; min-height: 44px; }
.topnav { display: none; }
.who { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.who-name { color: var(--muted); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 30vw; }
.who form { margin: 0; }

.page { padding: 16px 16px calc(var(--tabbar-h) + 24px); max-width: 960px; margin: 0 auto; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.empty { text-align: center; padding: 32px 16px; }
.empty p { margin: 0 0 16px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  padding: 0 20px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  font: 600 1rem var(--font-body); text-decoration: none;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--line); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--tabbar-h); display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 44px; color: var(--muted); text-decoration: none; font-size: 0.85rem; font-weight: 600;
}
.tabbar a[aria-current="page"] { color: var(--green); box-shadow: inset 0 3px 0 var(--lime); }
.tab-icon { font-size: 1.25rem; line-height: 1; }

.login { max-width: 420px; margin: 0 auto; padding: 32px 16px; text-align: center; }
.login img { display: block; margin: 0 auto 8px; }
.form { text-align: left; display: flex; flex-direction: column; gap: 8px; }
.form label { font-weight: 600; }
.form input[type="email"], .form input[type="password"] {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--muted); border-radius: 10px;
  font: inherit; width: 100%; background: #fff; color: var(--ink);
}
.form .btn { margin-top: 8px; }
.error { color: #9b1c1c; font-weight: 600; min-height: 1.5em; }

@media (min-width: 900px) {
  .tabbar { display: none; }
  .page { padding-bottom: 32px; }
  .topnav { display: flex; gap: 4px; margin-left: 24px; }
  .topnav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px;
    border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 600; }
  .topnav a[aria-current="page"] { background: var(--bg); color: var(--green); }
  .who-name { max-width: none; }
}
.error:empty{display:none}

/* ---- Step 3: shared ---- */
h2 { font-family: var(--font-head); font-size: 1.15rem; margin: 0 0 8px; }
h3 { font-size: 1rem; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 4px 0 0; }
.prewrap { white-space: pre-wrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack > * { margin: 0; }
.card + .card, .card + form, form + .card, .song-list + .card, .arc + h2 { margin-top: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.fake-banner { margin: 0; padding: 8px 16px; background: #fff4c2; color: #4a3b00; font-weight: 600;
  text-align: center; border-bottom: 1px solid #e6d27a; }
.btn-small { min-height: 44px; padding: 0 14px; font-size: 0.95rem; }
.btn-block { width: 100%; }
.btn-danger { background: transparent; color: #9b1c1c; border-color: #e5b9b9; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions-row form { margin: 0; }
.end-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.end-actions form { margin: 0; }
.alert { padding: 10px 12px; border-radius: 10px; margin: 0 0 12px; }
.alert-error { background: #fdecec; color: #8a1717; font-weight: 600; }
.alert-info { background: #eaf3dc; color: #2f4a10; }
.note-box { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.note-box ul { margin: 4px 0 0; padding-left: 20px; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field label, .field legend { font-weight: 600; }
.field legend { padding: 0; margin-bottom: 6px; }
input[type="text"], input[type="date"], input[type="search"], select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--muted);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%; max-width: 100%; }
textarea { resize: vertical; line-height: 1.45; }
input[type="file"] { font: inherit; min-height: 44px; max-width: 100%; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; font-weight: 400; cursor: pointer; }
.choice input { width: 20px; height: 20px; margin: 0; accent-color: var(--green); }
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; min-width: 0; }

/* sets list */
.set-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.set-link { display: flex; flex-direction: column; gap: 4px; color: var(--ink); text-decoration: none; min-height: 44px; }
.set-link:hover { border-color: var(--lime); }
.set-date { color: var(--muted); font-size: 0.9rem; }
.set-title { font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; overflow-wrap: anywhere; }
.set-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; color: var(--muted);
  font-size: 0.9rem; margin: 0; }
.status-chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-weight: 600; font-size: 0.85rem; }
.status-draft { background: #fff4c2; color: #4a3b00; }
.status-approved { background: var(--lime); color: var(--ink); }
.status-progress { background: #e3ecf7; color: #1d3a5f; }
.status-error { background: #fdecec; color: #8a1717; }

/* set page */
.set-head { margin-bottom: 16px; }
.set-head h1 { margin: 0 0 6px; overflow-wrap: anywhere; }
.eyebrow { margin: 0 0 2px; color: var(--muted); font-size: 0.9rem; }
.section-title { margin: 20px 0 10px; }
.progress { text-align: center; padding: 32px 16px; }
.progress p { color: var(--muted); margin: 0; }
.spinner { width: 40px; height: 40px; margin: 0 auto 12px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--green); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.bottom-line { font-size: 1.05rem; }
.approved-banner p { margin: 0 0 6px; }

/* tempo arc */
.arc { margin: 0 0 4px; padding: 12px; }
.arc figcaption { font-weight: 600; font-size: 0.9rem; color: var(--muted); }
.arc svg { display: block; width: 100%; height: auto; max-height: 220px; }
.arc-legend { margin: 4px 0 0; font-size: 0.8rem; color: var(--muted); }

/* song cards */
.song-list { list-style: none; margin: 0; padding: 0; }
.song-card { position: relative; display: flex; flex-direction: column; gap: 10px; }
.song-card > p { margin: 0; }
.song-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pos { flex: none; width: 28px; text-align: center; font-weight: 700; color: var(--muted); }
.key-badge { flex: none; width: 60px; height: 60px; border-radius: 14px; background: var(--lime);
  color: var(--ink); display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 700; font-size: 1.5rem; }
.song-title { min-width: 0; }
.song-title h3 { font-family: var(--font-head); font-size: 1.1rem; overflow-wrap: anywhere; }
.artist { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 3px 10px; border-radius: 999px; background: var(--bg); font-size: 0.875rem; font-weight: 600; }
.chip-role { background: var(--ink); color: #fff; }
.chip-warn { background: #fff4c2; color: #4a3b00; border: 1px dashed #b39500; }
.reason { margin: 0; }
.dnote { margin: 0; background: var(--bg); border-radius: 8px; padding: 6px 10px; }
.mt-link { align-self: flex-start; }
.card-tools { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.inline-form label { font-weight: 600; }
.inline-form select { width: auto; flex: 1; min-width: 140px; }
.move-row { display: flex; flex-wrap: wrap; gap: 8px; }
.move-row form { margin: 0; }
.tool > summary { list-style: none; display: inline-flex; }
.tool > summary::-webkit-details-marker { display: none; }
.tool[open] > summary { background: var(--bg); }
.tool > form, .tool > ul, .tool > p { margin-top: 8px; }
.swap-list, .result-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.swap-item, .result { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.swap-item form, .result form { margin: 0; }
.result-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 200px; overflow-wrap: anywhere; }
.mini-key { display: inline-block; min-width: 32px; padding: 0 6px; border-radius: 6px; background: var(--lime);
  font-weight: 700; text-align: center; }
.transition { margin: 6px 0 6px 40px; padding: 6px 12px; border-left: 3px dashed var(--lime);
  color: var(--ink); font-size: 0.925rem; }
.transition .auto { font-weight: 600; color: var(--green); white-space: nowrap; }
.song-item { margin-bottom: 10px; }
.drag-handle { display: none; position: absolute; top: 8px; right: 8px; width: 44px; height: 44px;
  align-items: center; justify-content: center; font-size: 1.4rem; color: var(--muted); cursor: grab;
  touch-action: none; border-radius: 10px; }
.sortable-on .drag-handle { display: flex; }
.sortable-on .song-top { padding-right: 44px; }
.sortable-ghost { opacity: 0.4; }
.collapsible > summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.collapsible h3 { margin-top: 8px; }

/* change proposal */
.proposal { border: 2px solid var(--lime); }
.explanation { font-weight: 600; margin: 0; }
.proposal-grid { display: grid; gap: 12px; }
.mini-list { margin: 6px 0 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.mini-list li { overflow-wrap: anywhere; }
.mini-list .changed { background: #eaf3dc; border-radius: 6px; padding: 2px 6px; }
.tag-new { color: var(--green); font-size: 0.8rem; text-transform: uppercase; }

/* catalog */
.catalog-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

@media (min-width: 900px) {
  .proposal-grid { grid-template-columns: 1fr 1fr; }
  .card-tools { flex-direction: row; flex-wrap: wrap; align-items: flex-start; }
  .catalog-list { grid-template-columns: 1fr 1fr; }
  .end-actions { flex-direction: row; }
  .end-actions > * { flex: 1; }
}

/* ---- Stage view: the only dark screen ---- */
body.stage { background: #0d0f0c; color: #f4f6f0; }
.stage :focus-visible { outline-color: #f4f6f0; }
.stage-page { max-width: 760px; margin: 0 auto; padding: 16px; }
.stage-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.stage-head h1 { font-size: 1.6rem; margin: 0; overflow-wrap: anywhere; }
.stage-back { align-self: flex-start; color: #f4f6f0; border-color: #3a3f37; }
.stage-date, .stage-total { margin: 0; color: #c9cec2; }
.stage-list { list-style: none; margin: 0; padding: 0; }
.stage-song { background: #1a1d18; border: 1px solid #2c3029; border-radius: 16px; padding: 14px; }
.stage-row { display: flex; gap: 14px; align-items: center; min-width: 0; }
.stage-key { flex: none; min-width: 84px; height: 84px; padding: 0 8px; border-radius: 16px; background: var(--lime);
  color: #0d0f0c; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 700; font-size: 2.6rem; }
.stage-info { min-width: 0; }
.stage-info h2 { font-size: 1.35rem; margin: 0; overflow-wrap: anywhere; }
.stage-pos { margin: 0; color: #c9cec2; font-weight: 600; }
.stage-artist { margin: 0; color: #c9cec2; overflow-wrap: anywhere; }
.stage-music { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin: 10px 0 0;
  font-size: 1.15rem; font-weight: 600; }
.stage-bpm { font-family: var(--font-head); font-size: 2rem; color: #fff; }
.stage-bpm small { font-size: 1rem; color: #c9cec2; }
.stage-warn { color: #ffe08a; border: 1px dashed #ffe08a; border-radius: 999px; padding: 0 10px; font-size: 0.95rem; }
.stage-note { margin: 8px 0 0; color: #e8ecdf; }
.stage-transition { margin: 8px 0 8px 16px; padding-left: 12px; border-left: 3px dashed var(--lime);
  color: #dfe5d4; font-size: 1.05rem; }
