:root {
  --bg: #0d0f14;
  --panel: #161a22;
  --line: #262c38;
  --text: #e8ebf1;
  --muted: #8b93a5;
  --accent: #4fd1c5;
  --good: #3ddc84;
  --warn: #f5c542;
  --bad: #ff5d5d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }

main { display: grid; grid-template-columns: 1fr 320px; height: 100vh; }
.stage-wrap { position: relative; display: flex; flex-direction: column; min-width: 0; background: #000; }
#stage { flex: 1; width: 100%; min-height: 0; object-fit: contain; }
#timeline { width: 100%; height: 140px; border-top: 1px solid var(--line); background: var(--bg); }
.placeholder { position: absolute; inset: 0 0 140px 0; display: grid; place-content: center; text-align: center; color: var(--muted); padding: 16px; }
.placeholder h1 { color: var(--text); margin: 0 0 8px; font-size: 32px; letter-spacing: -0.02em; }

aside { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 12px 16px 24px; }
.group { border-bottom: 1px solid var(--line); padding: 12px 0; }
.group:last-child { border-bottom: 0; }
h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
label { display: block; color: var(--muted); margin-bottom: 10px; font-size: 12px; }
select, input[type=number] { display: block; width: 100%; margin-top: 4px; padding: 6px 8px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; font: inherit; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.row { display: flex; gap: 8px; margin-bottom: 8px; }
button, .button { flex: 1; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; text-align: center; margin: 0; }
button:hover, .button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #031614; border-color: var(--accent); font-weight: 600; }
button.on { border-color: var(--accent); color: var(--accent); }
.status { color: var(--muted); font-size: 12px; margin: 4px 0 0; min-height: 1.4em; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.stats .label { display: block; font-size: 12px; color: var(--muted); }
.big { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.unit { color: var(--muted); margin-left: 4px; }
.meter { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; margin: 10px 0 8px; }
.meter div { height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { font-size: 11px; color: var(--muted); font-weight: 500; text-align: right; padding: 4px; }
td { text-align: right; padding: 6px 4px; border-top: 1px solid var(--line); }
td:first-child, th:first-child { text-align: left; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.empty td { color: var(--muted); text-align: left; }

@media (max-width: 800px) {
  main { grid-template-columns: 1fr; height: auto; }
  .stage-wrap { height: 70vh; }
  aside { border-left: 0; border-top: 1px solid var(--line); }
}

[hidden] { display: none !important; }
code { font-size: 11px; color: var(--text); }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 10px; }
button.small { flex: 0 0 auto; padding: 4px 8px; font-size: 12px; }
.button.primary { background: var(--accent); color: #031614; border-color: var(--accent); font-weight: 600; }
.tabs { display: flex; gap: 0; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.tabs button { border: 0; border-radius: 0; background: transparent; color: var(--muted); }
.tabs button.on { background: var(--line); color: var(--text); }

.review { position: absolute; inset: 0; z-index: 5; background: var(--bg); overflow-y: auto; padding: 16px; }
.review-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.review-head h2 { margin: 0; flex: 1; font-size: 13px; color: var(--text); }
.downbeat { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
#reviewCanvas { width: 100%; display: block; cursor: pointer; border-radius: 6px; }
.detail { margin: 10px 0; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.detail > div { margin-top: 4px; }
.detail-head { display: flex; align-items: center; gap: 10px; }
.music-summary { color: var(--muted); font-size: 12px; margin: 6px 0 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin: 0 0 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
#reviewList h3 { font-size: 14px; margin: 16px 0 6px; }
#reviewList h3 small { color: var(--muted); font-weight: 400; margin-left: 8px; }
#reviewList ul { margin: 0; padding-left: 0; list-style: none; }
#reviewList li { padding: 6px 10px; margin: 4px 0; border-left: 3px solid var(--line); background: var(--panel); border-radius: 0 6px 6px 0; font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#reviewList li.late, #reviewList li.break { border-left-color: var(--bad); }
#reviewList li.early { border-left-color: #7cc4ff; }
#reviewList li.scattered, #reviewList li.accents { border-left-color: #f5a524; }
#reviewList li.under, #reviewList li.over { border-left-color: #b48cff; }
#reviewList li button { margin-left: auto; }
#reviewList .ok, #reviewList .profile { color: var(--muted); font-size: 12px; margin: 4px 0; }

.ai { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); max-width: 900px; }
.ai-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.ai input, .ai textarea { display: block; width: 100%; margin-top: 4px; padding: 6px 8px; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.ai select { background: var(--panel); }
.ai-answer { white-space: pre-wrap; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; font-size: 14px; line-height: 1.55; }
@media (max-width: 800px) { .ai-row { grid-template-columns: 1fr; } }

/* Online version: accounts, plans, history */
body:not(.cloud) .cloud-only { display: none !important; }
body.cloud .local-only { display: none !important; }
.acct-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; margin-bottom: 4px; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--muted); }
.badge[data-plan='coach'] { background: rgba(79, 209, 197, 0.15); color: var(--accent); }
.badge[data-plan='studio'] { background: var(--accent); color: #031614; }
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(5, 7, 10, 0.78); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px; width: 100%; max-width: 380px; }
.modal-box.wide { max-width: 880px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { margin: 0; color: var(--text); font-size: 14px; }
.auth-box h1 { margin: 0 0 4px; font-size: 26px; }
.auth-box input { display: block; width: 100%; margin-top: 4px; padding: 8px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.auth-box button[type=submit] { width: 100%; margin-top: 4px; }
.linkish { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 4px 0; font-size: 12px; }
.fine { color: var(--muted); font-size: 11px; margin: 12px 0 0; }
.plan-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.plan-card { border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.plan-card.current { border-color: var(--accent); }
.plan-card h3 { margin: 0; font-size: 15px; }
.plan-card .price { font-size: 24px; font-weight: 700; }
.plan-card .price small { font-size: 12px; color: var(--muted); font-weight: 400; }
.plan-card ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; flex: 1; }
.plan-card button { flex: 0 0 auto; }
table.hist td, table.hist th { text-align: left; vertical-align: top; }
#historyBody h3 { font-size: 14px; margin: 16px 0 6px; }
#historyBody h3 small { color: var(--muted); font-weight: 400; }
#historyBody small { color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; background: var(--panel); border: 1px solid var(--accent); color: var(--text); padding: 10px 16px; border-radius: 8px; font-size: 13px; }
@media (max-width: 800px) { .plan-cards { grid-template-columns: 1fr; } }
