:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e6e9f0;
  --brand: #ff8a3d;
  --brand-ink: #d96a1e;
  --teal: #2fbf9b;
  --warn: #f0b429;
  --danger: #ef5b5b;
  --shadow: 0 10px 30px rgba(31, 36, 48, .08);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.screen { min-height: 100vh; }

/* ================= 首页 ================= */
.home {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 15% -10%, #ffe7d1 0%, rgba(255, 231, 209, 0) 60%),
    radial-gradient(800px 500px at 95% 110%, #d8f3ec 0%, rgba(216, 243, 236, 0) 60%),
    var(--bg);
}

.home-card {
  width: 100%;
  max-width: 460px;
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
  text-align: center;
}

.brand {
  color: var(--muted);
  font-size: 15px;
  letter-spacing: .5px;
  margin-bottom: 10px;
}

.home-clock {
  font-size: 76px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(120deg, var(--brand-ink), var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.home-date { color: var(--muted); margin-top: 8px; font-size: 15px; }
.next-tip { margin: 14px 0 22px; color: var(--brand-ink); font-size: 14px; }

.btn-primary {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(120deg, #ff9f4d, #ff7a3d);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 12px 28px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(255, 138, 61, .32);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary.big { width: 100%; padding: 18px; font-size: 20px; letter-spacing: 2px; }

.home-actions { margin-top: 14px; display: flex; gap: 10px; justify-content: center; }

.btn-ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
}
.btn-ghost:hover { border-color: #cfd6e4; }

.home-mic { margin-top: 12px; font-size: 13px; color: var(--muted); }
.home-mic.ok { color: var(--teal); }
.home-mic.off { color: #9aa2b1; }
.home-mic.bad { color: #c9302c; }

.home-rem {
  margin-top: 22px;
  text-align: left;
  border-top: 1px dashed var(--line);
  padding-top: 16px;
}
.hr-row { display: flex; gap: 12px; padding: 6px 0; font-size: 14px; color: var(--ink); }
.hr-row.off { color: #b3bac7; text-decoration: line-through; }
.hr-rep {
  flex: none; font-size: 12px; color: var(--brand-ink);
  background: #fff2e6; border-radius: 6px; padding: 1px 6px;
}
.hr-time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--brand-ink); min-width: 46px; }
.hr-row.off .hr-time { color: #b3bac7; }
.hr-text { color: var(--muted); }
.home-meta { margin-top: 12px; font-size: 13px; color: #9aa2b1; }

/* ================= 自习大屏 ================= */
.stage {
  display: flex;
  flex-direction: column;
  padding: 22px 30px 26px;
  background:
    radial-gradient(900px 600px at 50% -20%, #fff4e8 0%, rgba(255, 244, 232, 0) 65%),
    radial-gradient(800px 500px at 50% 120%, #e7f7f2 0%, rgba(231, 247, 242, 0) 60%),
    #fbfcfe;
}

.stage-top { display: flex; align-items: center; justify-content: space-between; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 15px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.stage-tools { display: flex; gap: 8px; }
.tool {
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 18px;
  cursor: pointer;
  color: var(--ink);
}
.tool:hover { border-color: #cfd6e4; }
.tool.danger:hover { background: #fff1f1; border-color: #f6c9c9; }

.stage-middle {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.stage-clock {
  font-size: clamp(80px, 17vw, 220px);
  line-height: 1;
  font-weight: 800;
  letter-spacing: 4px;
  font-variant-numeric: tabular-nums;
  color: #22293a;
}
.stage-date { margin-top: 10px; color: var(--muted); font-size: 18px; }
.stage-enc {
  margin-top: 34px;
  font-size: clamp(20px, 3vw, 34px);
  font-weight: 600;
  color: var(--brand-ink);
  background: #fff;
  border-radius: 18px;
  padding: 14px 30px;
  box-shadow: var(--shadow);
  cursor: pointer;
  max-width: 90%;
}
.stage-enc:empty { display: none; }

.stage-bottom { margin-top: 10px; }
.meter { max-width: 720px; margin: 0 auto; }
.meter.disabled { opacity: .45; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.meter-title { font-size: 15px; color: var(--muted); }
.meter-state { font-size: 15px; font-weight: 600; }
.meter-state.quiet { color: var(--teal); }
.meter-state.warn { color: var(--warn); }
.meter-state.loud { color: var(--danger); }
.meter-state.err { color: #c9302c; font-weight: 700; line-height: 1.4; }
.mic-retry { margin-top: 10px; display: block; }

.mic-perm { font-size: 13px; line-height: 1.7; color: var(--muted); margin-bottom: 10px; }
.mic-perm.bad { color: #c9302c; }

.diag {
  margin-top: 10px; padding: 12px 14px;
  background: #f8fafc; border: 1px dashed var(--line); border-radius: 12px;
  font-size: 13px; line-height: 1.9;
}
.diag-row.ok { color: #1e7d63; }
.diag-row.bad { color: #c9302c; background: #fff5f5; border-radius: 6px; padding: 2px 6px; }
.diag-row b { font-weight: 600; }

.meter-bar {
  position: relative;
  height: 18px;
  background: #eef1f6;
  border-radius: 999px;
  overflow: hidden;
}
.meter-bar .fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  transition: width .12s linear, background .2s linear;
}
.meter-bar .fill.quiet { background: linear-gradient(90deg, #7fdcc3, #2fbf9b); }
.meter-bar .fill.warn { background: linear-gradient(90deg, #ffd782, #f0b429); }
.meter-bar .fill.loud { background: linear-gradient(90deg, #ff9c9c, #ef5b5b); }
.meter-bar .th {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: rgba(239, 91, 91, .8);
}
.meter-num { margin-top: 8px; font-size: 14px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.meter-num b { font-size: 20px; color: var(--ink); }
.meter-hint { font-size: 12px; color: #a7aeba; }

/* toast */
.toast-wrap {
  position: fixed;
  top: 84px; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none;
  z-index: 40;
}
.toast {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand);
  border-radius: 14px;
  padding: 14px 22px;
  font-size: 18px;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: drop .28s ease;
  max-width: 80vw;
}
.toast.remind { border-left-color: var(--brand); }
.toast.noise { border-left-color: var(--danger); color: #c93c3c; }
.toast.warn { border-left-color: var(--warn); }
.toast.info { border-left-color: var(--teal); }
.toast.out { opacity: 0; transform: translateY(-8px); transition: .35s ease; }
@keyframes drop { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }

/* 噪音闪烁提示 */
.noise-flash {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, rgba(239, 91, 91, 0) 55%, rgba(239, 91, 91, .18) 100%);
}
.noise-flash.show { animation: pulse 2.2s ease; }
.nf-card {
  background: rgba(255, 255, 255, .96);
  border: 3px solid var(--danger);
  color: var(--danger);
  border-radius: 26px;
  padding: 28px 46px;
  font-size: 40px;
  font-weight: 800;
  text-align: center;
  line-height: 1.4;
  box-shadow: 0 20px 50px rgba(239, 91, 91, .25);
}
@keyframes pulse {
  0% { opacity: 0; transform: scale(.9); }
  12% { opacity: 1; transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.02); }
}

/* ================= 弹层 ================= */
.overlay {
  position: fixed; inset: 0;
  background: rgba(24, 28, 38, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px;
  overflow: auto;
  z-index: 60;
}
.panel {
  width: 100%; max-width: 620px;
  background: #fff;
  border-radius: 20px;
  padding: 22px 24px 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .2);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel h2 { margin: 0 0 4px; font-size: 20px; }
.panel h3 { margin: 0 0 6px; font-size: 16px; }
.panel section { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 16px; }
.tip { color: var(--muted); font-size: 13px; margin: 0 0 10px; }

.rem-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.sw-mini { display: flex; }
.rem-time {
  width: 96px; padding: 9px 8px;
  border: 1px solid var(--line); border-radius: 10px; font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.rem-rep {
  width: 58px; flex: none; padding: 9px 4px;
  border: 1px solid var(--line); border-radius: 10px; font-size: 14px;
  background: #fff; color: var(--ink); cursor: pointer;
}
.rem-text {
  flex: 1; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px; font-size: 14px; min-width: 0;
}
.rem-del {
  width: 34px; height: 34px; flex: none;
  border: 1px solid var(--line); background: #fff; border-radius: 10px; cursor: pointer; color: #98a1b0;
}
.rem-del:hover { color: var(--danger); border-color: #f3c4c4; }

.row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.row label { width: 96px; flex: none; font-size: 14px; color: var(--muted); }
.row input[type=range] { flex: 1; accent-color: var(--brand); }
.row b { width: 66px; text-align: right; font-size: 14px; font-variant-numeric: tabular-nums; }
.row input[type=text] {
  flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px;
}
/* 开关行不换行（大屏与鼓励语那两个选项要并排） */
.row.switches { flex-wrap: nowrap; gap: 18px; overflow: hidden; }
.sw { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; white-space: nowrap; }
.sw input { accent-color: var(--brand); width: 16px; height: 16px; }

.btn-mini {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 8px 14px; font-size: 13px; cursor: pointer; color: var(--ink);
}
.btn-mini:hover { border-color: #cfd6e4; }

.mic-test {
  background: #f8fafc; border: 1px dashed var(--line); border-radius: 14px;
  padding: 14px; margin-bottom: 12px;
}
.mic-live { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 6px 0; }
.mic-track { height: 12px; background: #e9edf4; border-radius: 999px; overflow: hidden; }
.mic-bar { display: block; height: 100%; width: 0; transition: width .12s linear; }
.mic-bar.quiet { background: var(--teal); }
.mic-bar.warn { background: var(--warn); }
.mic-bar.loud { background: var(--danger); }
.mic-test .tip { margin: 8px 0 0; }

textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font-size: 14px; font-family: inherit; resize: vertical;
}

.panel-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }

.rp-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; margin-bottom: 8px;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 12px;
  font-size: 15px; cursor: pointer;
}
.rp-item:hover { border-color: var(--brand); background: #fff7f0; }
.rp-item b { font-variant-numeric: tabular-nums; color: var(--brand-ink); flex: none; min-width: 48px; }
.rp-text { flex: 1; color: var(--muted); min-width: 0; }
.rp-item.off { opacity: .55; }

.done { max-width: 420px; text-align: center; }
.done h2 { margin-bottom: 18px; }
.done-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 22px; }
.done-grid div {
  background: #f8fafc; border-radius: 14px; padding: 14px 8px;
}
.done-grid span { display: block; font-size: 22px; font-weight: 700; color: var(--brand-ink); }
.done-grid label { font-size: 12px; color: var(--muted); }

@media (max-width: 520px) {
  .home-clock { font-size: 56px; }
  .row label { width: 76px; }
  .rem-time { width: 84px; }
  .rem-rep { width: 52px; }
  .stage { padding: 16px 16px 20px; }
}
