:root {
  --bg: #f4f5f7; --surface: #fff; --ink: #14161a; --muted: #5d6572; --line: #e3e6eb;
  --accent: #1d4ed8; --accent-ink: #fff; --ok: #0f7a3d; --ok-bg: #e4f5ea;
  --warn: #a15c00; --warn-bg: #fff1d6; --bad: #b42318; --bad-bg: #fde8e6;
  --shadow: 0 1px 2px rgba(20,22,26,.06), 0 4px 16px rgba(20,22,26,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013; --surface: #171a1f; --ink: #eceef2; --muted: #98a1b0; --line: #2a2f37;
    --accent: #6c93ff; --accent-ink: #0b1020; --ok: #5ad08a; --ok-bg: #12301f;
    --warn: #f3b44f; --warn-bg: #33270f; --bad: #ff8a80; --bad-bg: #3a1815;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom));
}
#app { max-width: 560px; margin: 0 auto; padding-top: 16px; }
[hidden] { display: none !important; }
h1 { font-size: 20px; margin: 0; letter-spacing: .2px; }
h2 { font-size: 17px; margin: 0 0 4px; }
h3 { margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 14px; margin: 4px 0 14px; }
.center { text-align: center; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.card.narrow { margin-top: 12vh; }
.card.narrow h1 { margin-bottom: 4px; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px 14px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.pill { font-size: 13px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; background: var(--surface); }

label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
input[type=password], input:not([type]), input[type=text] {
  display: block; width: 100%; margin-top: 4px; padding: 11px 12px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label.check { display: flex; gap: 8px; align-items: flex-start; }
label.check input { margin-top: 4px; accent-color: var(--accent); }

.btn {
  font: inherit; font-weight: 600; border-radius: 10px; border: 1px solid transparent;
  padding: 11px 16px; cursor: pointer; min-height: 44px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); width: 100%; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: 14px; font-weight: 500; }
.btn.icon { width: 44px; padding: 0; font-size: 22px; line-height: 1; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.datebar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.date-label {
  flex: 1; font: inherit; font-weight: 600; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; min-height: 44px; cursor: pointer;
}

.lessons { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.lesson {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; box-shadow: var(--shadow); display: grid; gap: 6px;
}
.lesson .row1 { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.lesson .name { font-weight: 650; font-size: 17px; }
.lesson .time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; white-space: nowrap; }
.lesson .meta { color: var(--muted); font-size: 14px; }
.lesson .row3 { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 4px; }
.badge { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 99px; }
.badge.signed { color: var(--ok); background: var(--ok-bg); }
.badge.unsigned { color: var(--warn); background: var(--warn-bg); }
.badge.unknown { color: var(--bad); background: var(--bad-bg); }
.lesson .btn { min-width: 96px; }
.lesson .btn.primary { width: auto; }
.hint { font-size: 13px; color: var(--muted); }

.foot { text-align: center; margin-top: 22px; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; font: inherit; font-size: 13px; cursor: pointer; padding: 8px; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); max-width: 360px; width: calc(100% - 32px); padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
dialog .btn.primary { width: auto; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  max-width: calc(100% - 32px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--bad); color: #fff; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* ---- 多账号管理 ---- */
#app { max-width: 640px; }
.top-actions .btn.primary { width: auto; }
.accounts { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 12px; }
.acc { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.acc.off { opacity: .86; }
.acc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.acc-name { font-weight: 650; font-size: 17px; overflow-wrap: anywhere; }
.acc-num { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.acc-state { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.acc-state.bad { color: var(--bad); }
.plans { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.plans li { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; font-size: 14px; padding: 6px 10px; background: var(--bg); border-radius: 8px; }
.plans .pn { font-weight: 600; overflow-wrap: anywhere; }
.plans .pm { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; text-align: right; white-space: nowrap; }
.pill-s { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; margin-left: 6px; }
.pill-s.signed { color: var(--ok); background: var(--ok-bg); }
.pill-s.pending { color: var(--warn); background: var(--warn-bg); }
.pill-s.failed, .pill-s.unknown { color: var(--bad); background: var(--bad-bg); }
.acc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.acc-actions .btn { min-height: 36px; padding: 4px 12px; font-size: 14px; font-weight: 500; }
.acc-actions .danger { color: var(--bad); }

/* 开关 */
.switch { position: relative; flex: none; width: 52px; height: 30px; border-radius: 99px; border: 0; padding: 0; cursor: pointer; background: var(--line); transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.switch[aria-checked=true] { background: var(--ok); }
.switch[aria-checked=true]::after { transform: translateX(22px); }
.switch:disabled { opacity: .5; }
@media (prefers-reduced-motion: reduce) { .switch, .switch::after { transition: none; } }

.log-card h2 { margin-bottom: 8px; }
.events { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; font-size: 13px; display: grid; gap: 4px; }
.events li { display: grid; grid-template-columns: 62px 1fr; gap: 8px; color: var(--muted); }
.events .t { font-variant-numeric: tabular-nums; }
.events .m { color: var(--ink); overflow-wrap: anywhere; }
.events .a { color: var(--muted); }
.events li.error .m { color: var(--bad); }
.events li.trace .m { color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

dialog.wide { max-width: 560px; max-height: 88vh; overflow: auto; }
.sched-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.err { color: var(--bad); font-size: 13px; overflow-wrap: anywhere; white-space: pre-wrap; }
label .hint { font-size: 12px; }
dialog form label { margin-bottom: 12px; }
