/* 音樂教學輔助平台 — 深色主題 */
:root {
  --bg: #0a0d16;
  --card: #10141f;
  --card2: #161b29;
  --border: #232b3d;
  --text: #e8e6e0;
  --muted: #8b93a7;
  --accent: #e8a13d;
  --accent-dim: #b57a20;
  --good: #22c55e;
  --high: #f97316;
  --low: #3b82f6;
  --danger: #dc2626;
  --amber: #f59e0b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}
.hidden { display: none !important; }

/* ── 頂欄 ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; position: sticky; top: 0; z-index: 10;
  background: rgba(10,13,22,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon {
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(135deg, #2a1f10, #171c2a);
  border: 1px solid var(--accent-dim); color: var(--accent);
  display: grid; place-items: center;
}
.brand h1 { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: #3a4358; transition: background .3s, box-shadow .3s;
}
.dot.on { background: #22c55e; box-shadow: 0 0 8px #22c55e88; }
.dot.err { background: var(--danger); }

/* ── 按鈕 ── */
.btn {
  border: 1px solid var(--border); background: var(--card2); color: var(--text);
  padding: 10px 18px; border-radius: 12px; font-size: 15px; cursor: pointer;
  font-family: inherit; transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-start { background: #14532d; border-color: #1f7a44; color: #d9fbe6; font-weight: 700; }
.btn-danger { background: var(--danger); border-color: #ef4444; color: #fff; font-weight: 700; padding: 10px 22px; }
.btn-ref { color: var(--accent); border-color: var(--accent-dim); background: rgba(232,161,61,.08); font-weight: 600; }

main { max-width: 780px; margin: 0 auto; padding: 16px 14px 40px; display: grid; gap: 16px; }

/* ── 卡片 ── */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; padding: 18px;
}
.card-title { font-size: 16px; color: var(--accent); font-weight: 700; margin-bottom: 14px; }

/* ── 分頁 ── */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.tab {
  padding: 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card2); color: var(--muted); font-size: 16px; cursor: pointer; font-family: inherit;
}
.tab.active { background: #241a0c; color: var(--accent); border-color: var(--accent-dim); font-weight: 700; }

/* ── 目標列 ── */
.target-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.row-label { color: var(--muted); font-size: 14px; white-space: nowrap; }
.target-info { flex: 1; min-width: 0; }
.target-title { font-size: 22px; font-weight: 800; word-break: break-all; }
.target-meta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.select {
  background: var(--card2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; font-size: 14px; font-family: inherit;
}
.select.small { max-width: 110px; }
.select.grow { flex: 1; }

.ref-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.now-singing { color: var(--muted); font-size: 15px; }
.now-singing b { color: var(--text); font-size: 17px; }

/* ── 表盤 ── */
.gauge-wrap { text-align: center; padding: 6px 0 2px; }
.gauge { width: min(320px, 80vw); }
.gauge-text { font-size: 26px; font-weight: 800; margin-top: -46px; }
.gauge-text.good { color: var(--good); }
.gauge-text.high { color: var(--high); }
.gauge-text.low { color: var(--low); }
.gauge-sub { color: var(--muted); font-size: 15px; margin: 6px 0 18px; min-height: 22px; }

/* ── 鍵盤 ── */
.keyboard {
  position: relative; height: 92px; border-radius: 10px; overflow: hidden;
  background: #11151f; border: 1px solid var(--border); user-select: none;
}
.wkey {
  position: absolute; top: 0; bottom: 0;
  background: #f5f2ea; border: 1px solid #c9c4b8; border-radius: 0 0 4px 4px;
  display: flex; align-items: flex-end; justify-content: center;
  font-size: 9px; color: #555; padding-bottom: 2px; transition: background .1s;
}
.bkey {
  position: absolute; top: 0; height: 60%; z-index: 2;
  background: #17181d; border: 1px solid #000; border-radius: 0 0 3px 3px;
  transition: background .1s;
}
.wkey.target, .bkey.target { background: var(--amber); animation: pulse 1s infinite; }
.wkey.good { background: var(--good); } .bkey.good { background: #16a34a; }
.wkey.high { background: var(--high); } .bkey.high { background: #c2570a; }
.wkey.low { background: var(--low); }  .bkey.low { background: #2563eb; }
@keyframes pulse { 50% { filter: brightness(1.35); } }

/* ── 曲線圖 ── */
.chart { width: 100%; height: 240px; margin-top: 14px; border-radius: 10px; background: #0d1119; border: 1px solid var(--border); }

.legend { display: flex; gap: 18px; margin: 10px 4px 4px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 22px; height: 7px; border-radius: 4px; display: inline-block; }
.sw-target { background: #14532d; border: 1px solid var(--good); }
.sw-good { background: var(--good); }
.sw-high { background: var(--high); }
.sw-low { background: var(--low); }

/* ── 句/音按鈕 ── */
.note-btns { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.note-btn {
  min-width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card2); color: var(--muted); font-size: 17px; font-weight: 700;
  cursor: pointer; font-family: inherit; position: relative;
}
.note-btn.current { color: var(--accent); border-color: var(--accent); background: rgba(232,161,61,.12); }
.note-btn.done-good { color: var(--good); border-color: var(--good); }
.note-btn.done-high { color: var(--high); border-color: var(--high); }
.note-btn.done-low { color: var(--low); border-color: var(--low); }
.hint { color: var(--muted); font-size: 13.5px; margin-top: 12px; line-height: 1.6; }
.hint b { color: var(--high); }

/* ── 設定 ── */
.setting-block { margin-bottom: 18px; }
.setting-label { font-size: 16px; font-weight: 700; }
.setting-desc { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.speed-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.speed.active { background: #7a4a10; border-color: var(--accent); color: #ffe9c8; font-weight: 700; }
.tip {
  margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; color: var(--muted); font-size: 13.5px; background: var(--card2);
}
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 0; border-top: 1px solid var(--border); cursor: pointer;
}
.switch-row input { display: none; }
.switch {
  width: 52px; height: 30px; border-radius: 20px; background: #39435c;
  position: relative; transition: background .2s; flex-shrink: 0;
}
.switch::after {
  content: ""; position: absolute; top: 4px; left: 4px; width: 22px; height: 22px;
  border-radius: 50%; background: #aab3c8; transition: transform .2s, background .2s;
}
.switch-row input:checked + .switch { background: rgba(232,161,61,.35); border: 1px solid var(--accent-dim); }
.switch-row input:checked + .switch::after { transform: translateX(22px); background: var(--accent); }
.volume-row { display: flex; align-items: center; gap: 14px; padding: 14px 0 2px; border-top: 1px solid var(--border); }
.volume-row input[type=range] { flex: 1; accent-color: var(--accent); }

/* ── 統計 ── */
.stat-big { font-size: 56px; font-weight: 800; color: var(--accent); line-height: 1; }
.stat-big small { font-size: 16px; color: var(--text); font-weight: 400; margin-left: 6px; }
.stat-msg { color: #f0965a; font-weight: 700; margin: 12px 0 16px; min-height: 22px; }
.stat-bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 44px 1fr 48px; align-items: center; gap: 10px; font-size: 14px; }
.bar-row b { text-align: right; color: var(--muted); font-weight: 400; }
.bar { height: 10px; border-radius: 6px; background: #1a2030; overflow: hidden; }
.fill { display: block; height: 100%; border-radius: 6px; transition: width .3s; }
.fill-good { background: var(--good); }
.fill-high { background: #b91c1c; }
.fill-low { background: #1d4ed8; }
.fill-rhythm { background: var(--accent); }
.score-box {
  margin-top: 16px; padding: 12px; text-align: center; border-radius: 12px;
  border: 1px solid #14532d; background: rgba(20,83,45,.15); font-size: 16px;
}
.score-box b { font-size: 24px; color: var(--good); }
.trend-box { margin-top: 14px; }
.trend-title { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.trend-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; height: 60px; }
.trend-bar { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.trend-bar i { display: block; border-radius: 6px 6px 0 0; background: #b91c1c; }
.trend-bar span { text-align: center; color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ── 說明 ── */
.help-list { list-style: none; display: grid; gap: 10px; color: #c8cede; font-size: 14.5px; line-height: 1.6; }
.help-list li::before { content: "● "; color: var(--accent); font-size: 10px; vertical-align: 2px; }
.c-good { color: var(--good); } .c-high { color: var(--high); } .c-amber { color: var(--amber); }

.foot { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; padding: 4px 6px; }
.foot a { color: var(--accent); text-decoration: none; }

@media (max-width: 480px) {
  .target-title { font-size: 18px; }
  .gauge-text { font-size: 22px; }
  .chart { height: 200px; }
}

/* ── 後台管理 ── */
.login-box { max-width: 360px; margin: 40px auto; text-align: center; }
.login-box input {
  width: 100%; padding: 12px; margin: 14px 0; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card2); color: var(--text);
  font-size: 16px; font-family: inherit;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.form-grid label.full { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea {
  padding: 9px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card2); color: var(--text); font-size: 14px; font-family: inherit;
}
.form-grid textarea { min-height: 130px; line-height: 1.7; }
.form-actions { display: flex; gap: 10px; margin-top: 14px; align-items: center; flex-wrap: wrap; }
.form-msg { font-size: 13.5px; }
.form-msg.ok { color: var(--good); }
.form-msg.err { color: var(--danger); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); }
table.data th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
table.data td.num, table.data th.num { text-align: right; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-sm.danger { color: #fca5a5; border-color: #7f1d1d; }
.muted { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin: 8px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.upload-status { font-size: 13px; color: var(--accent); }
