:root {
  --bg: #0e1116;
  --card: #181d25;
  --line: #2c3442;
  --text: #f3f5f8;
  --muted: #b7c0cc;
  --bad: #ff6b6b;
  --bad-bg: #3a1518;
  --ok: #4ade80;
  --ok-bg: #12301f;
  --info: #93c5fd;
  --accent: #fbbf24;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 18px; line-height: 1.5;
}
.wrap { max-width: 640px; margin: 0 auto; padding: 12px 12px 48px; }
.wrap.narrow { max-width: 420px; padding-top: 40px; }
h1 { font-size: 24px; margin: 4px 0; }
h2 { font-size: 22px; margin: 0 0 12px; }
h3 { font-size: 19px; margin: 20px 0 8px; color: var(--muted); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 14px 0; }
.muted { color: var(--muted); margin: 4px 0; }
.hidden { display: none !important; }

.rank-time { font-size: 18px; padding: 8px 10px; border-radius: 8px; background: #11151b; }
.rank-time.stale { background: var(--bad-bg); color: var(--bad); font-weight: 700; }
.bigrow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.big { background: #11151b; border-radius: 10px; padding: 10px; text-align: center; }
.big .label { color: var(--muted); font-size: 18px; }
.big .num { font-size: 48px; font-weight: 800; line-height: 1.15; word-break: keep-all; }
.big .num.small { font-size: 26px; padding: 10px 0; }
.auto-state { font-size: 26px; font-weight: 800; text-align: center; padding: 10px; border-radius: 10px; }
.auto-state.on, .switch.on { background: var(--ok-bg); color: var(--ok); }
.auto-state.off, .switch.off { background: var(--bad-bg); color: var(--bad); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 14px 0 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; text-align: right; }

.notes { list-style: none; padding: 0; margin: 0; }
.notes li { padding: 8px 10px; border-radius: 8px; margin: 6px 0; background: #11151b; }
.notes li.bad { background: var(--bad-bg); color: var(--bad); font-weight: 700; }
.notes li.ok { background: var(--ok-bg); color: var(--ok); }
.notes li.info { color: var(--info); }

.btn {
  min-height: 52px; font-size: 19px; font-weight: 700; border-radius: 10px; border: 2px solid var(--line);
  background: #232a35; color: var(--text); padding: 8px 16px; cursor: pointer; font-family: inherit;
}
.btn:disabled { opacity: .55; cursor: wait; }
.btn:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn.primary { width: 100%; background: var(--accent); color: #111; border-color: var(--accent); margin-top: 16px; }
.btn.ghost { background: transparent; }
.btn.switch { width: 100%; font-size: 24px; min-height: 64px; }
.btn.switch.on { border-color: var(--ok); }
.btn.switch.off { border-color: var(--bad); }
.switch-row { margin-bottom: 8px; }

.field { display: block; margin: 12px 0 0; font-weight: 700; }
input[type=text], input[type=password], input[type=time] {
  display: block; width: 100%; min-height: 52px; margin-top: 6px; font-size: 22px; font-family: inherit;
  background: #0b0e12; color: var(--text); border: 2px solid var(--line); border-radius: 10px; padding: 8px 12px;
}
input.invalid { border-color: var(--bad); }
input.dirty { border-color: var(--accent); }
.note { color: var(--accent); margin: 6px 0 0; font-size: 17px; }

.sched { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 10px 0; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 52px;
  border: 2px solid var(--line); border-radius: 8px; font-weight: 700; cursor: pointer; user-select: none; }
.day input { width: 22px; height: 22px; margin: 0; }
.day.checked { border-color: var(--accent); color: var(--accent); }
.sched-line { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; margin-top: 8px; }
.sched-line label { font-size: 16px; color: var(--muted); min-width: 0; }
.sched-line input { min-width: 0; }
.sched-line .btn { grid-column: 1 / -1; }
@media (min-width: 560px) {
  .sched-line { grid-template-columns: 1fr 1fr auto; }
  .sched-line .btn { grid-column: auto; min-width: 72px; }
}

.alert { padding: 10px 12px; border-radius: 10px; margin: 12px 0; font-weight: 700; }
ul.alert { padding-left: 30px; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.info { background: #13233a; color: var(--info); }

.chart { width: 100%; height: auto; background: #11151b; border-radius: 10px; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .line-rank { stroke: var(--info); stroke-width: 2.5; fill: none; }
.chart .line-bid { stroke: var(--accent); stroke-width: 2.5; fill: none; }
.chart .target { stroke: var(--ok); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart text { fill: var(--muted); font-size: 12px; }
.scroll { max-height: 360px; overflow-y: auto; margin-top: 12px; border-radius: 10px; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 8px; border-bottom: 1px solid var(--line); text-align: right; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl thead th { position: sticky; top: 0; background: var(--card); }
.log { list-style: none; padding: 0; margin: 0; }
.log li { border-bottom: 1px solid var(--line); padding: 10px 0; }
.log .meta { color: var(--muted); font-size: 16px; }
.log .res-ok { color: var(--ok); font-weight: 700; }
.log .res-bad { color: var(--bad); font-weight: 700; }

dialog { background: var(--card); color: var(--text); border: 2px solid var(--line); border-radius: 14px;
  width: min(92vw, 520px); padding: 18px; }
dialog::backdrop { background: rgba(0, 0, 0, .7); }
.changes { padding-left: 22px; }
.changes li { margin: 8px 0; }
.changes .arrow { color: var(--accent); font-weight: 800; }
.dialog-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.dialog-btns .btn.primary { margin-top: 0; }
@media (max-width: 380px) {
  .big .num { font-size: 48px; }
  .kv { grid-template-columns: 1fr; }
  .kv dd { text-align: left; margin-bottom: 6px; }
}
