:root {
  --bg: #0e1116;
  --card: #161b22;
  --card2: #1d232c;
  --line: #2a313c;
  --text: #e8ecf1;
  --muted: #8b95a3;
  --accent: #7cc4ff;
  --good: #6fd19a;
  --warn: #ffc163;
  --bad: #ff7a7a;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f9; --card: #ffffff; --card2: #eef1f5; --line: #dde2e9;
    --text: #141a22; --muted: #66707e; --accent: #0b6bcb; --good: #138a4e; --warn: #a76400; --bad: #c62828;
    color-scheme: light;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  padding: calc(var(--safe-t) + 8px) 16px calc(84px + var(--safe-b));
  min-height: 100vh;
}
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.top { display: flex; align-items: flex-end; justify-content: space-between; padding: 12px 2px 14px; }
.top h1 { margin: 0; font-size: 28px; letter-spacing: .5px; }
.top p { margin: 2px 0 0; font-size: 12px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; cursor: pointer; }
.icon-btn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 6px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabs button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 6px 0; min-height: 48px; cursor: pointer; }
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.on { color: var(--accent); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.card h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .5px; }
.section-title { font-size: 13px; color: var(--muted); margin: 18px 4px 8px; font-weight: 600; }

.hero { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, var(--card)), var(--card)); }
.hero .label { font-size: 12px; color: var(--accent); font-weight: 600; letter-spacing: .5px; }
.hero .name { font-size: 22px; font-weight: 700; margin: 4px 0 2px; }
.hero .meta { color: var(--muted); font-size: 14px; }

.cls { display: grid; grid-template-columns: 62px 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.cls:first-of-type { border-top: 0; }
.cls .time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); line-height: 1.35; }
.cls .time b { display: block; color: var(--text); font-size: 15px; font-weight: 600; }
.cls .what { font-weight: 600; }
.cls .where { font-size: 13px; color: var(--muted); }
.cls.now { position: relative; }
.cls.now::before { content: ""; position: absolute; left: -16px; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--accent); }
.cls.past { opacity: .45; }

.daypick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.daypick button { flex: 1 0 auto; min-width: 48px; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
.daypick button.on { background: var(--accent); color: #06121e; border-color: var(--accent); font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card2); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.bad b { color: var(--bad); }

.list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }
.list-row .l { min-width: 0; }
.list-row .l div:first-child { font-weight: 600; }
.list-row .sub { font-size: 12px; color: var(--muted); }
.score { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.score small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
.score.fail { color: var(--bad); }
.score.pending { color: var(--muted); font-weight: 400; }

details.card { padding: 0; }
details.card > summary { list-style: none; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; min-height: 48px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "›"; color: var(--muted); font-size: 22px; transition: transform .2s; }
details.card[open] > summary::after { transform: rotate(90deg); }
details.card .body { padding: 0 16px 12px; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--card2); color: var(--muted); margin-left: 6px; }
.pills { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; margin-left: auto; padding-left: 8px; max-width: 60%; }
.pills .pill { margin-left: 0; }
details.card > summary { gap: 6px; }
.pill.warn { color: var(--warn); }
.pill.bad { color: var(--bad); }
.detail { font-size: 13px; color: var(--muted); margin: 6px 0 0; padding-left: 14px; }
.detail li { margin: 2px 0; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.cta { margin-top: 16px; }

.primary, .ghost { min-height: 48px; border-radius: 12px; padding: 0 18px; font-weight: 600; cursor: pointer; }
.primary { background: var(--accent); color: #06121e; border: 0; }
.primary:disabled { opacity: .6; }
.ghost { background: transparent; border: 1px solid var(--line); }

.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; }
.sheet.hidden { display: none; }
.sheet-card { width: 100%; background: var(--card); border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + var(--safe-b)); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-card h2 { margin: 0 0 4px; font-size: 20px; }
.sheet-card label { display: block; font-size: 13px; color: var(--muted); margin-top: 12px; }
.sheet-card input:not([type=checkbox]) { display: block; width: 100%; margin-top: 4px; min-height: 48px; font-size: 17px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.sheet-card input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.sheet-card label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; min-height: 44px; }
.sheet-card label.check input { width: 20px; height: 20px; }
.captcha-row { display: grid; grid-template-columns: 1fr 130px; gap: 8px; align-items: stretch; margin-top: 4px; }
.captcha-row input { margin-top: 0 !important; }
.captcha { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 0; overflow: hidden; display: grid; place-items: center; cursor: pointer; min-height: 48px; }
.captcha img { width: 100%; height: 48px; object-fit: contain; image-rendering: pixelated; display: none; }
.captcha span { color: #555; font-size: 12px; }
.row { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 14px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin: 8px 0 0; white-space: pre-wrap; word-break: break-all; max-height: 30vh; overflow: auto; -webkit-user-select: text; user-select: text; }

.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 30; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
