/* 基本樣式：變數、版面、掣、卡片、對話框。全部同源，冇外部字體。 */
:root {
  --primary: #2563eb;
  --accent: #f59e0b;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --on-primary: #ffffff;
  --on-accent: #111111;
  --on-bg: #111827;
  --on-surface: #111827;
  --good: #15803d;
  --bad: #b91c1c;
  --radius: 18px;
  --font: -apple-system, "PingFang HK", "Microsoft JhengHei", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--on-bg);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.5;
  overflow-x: hidden;
}
h1, h2, h3, p, ul { margin: 0 0 12px; }
ul { padding-left: 1.2em; }
a { color: inherit; }
[hidden] { display: none !important; }

.app { max-width: 560px; margin: 0 auto; padding: 12px 16px calc(28px + env(safe-area-inset-bottom)); }
.wide-app { max-width: 760px; }
.screen { padding-bottom: 12px; }
.screen-title { font-size: 26px; margin: 8px 0 12px; }
.muted { opacity: 0.75; }
.tip { font-size: 18px; opacity: 0.85; margin-bottom: 8px; }

/* ---------- 掣 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 8px 20px;
  font: inherit; font-size: 20px; font-weight: 700; line-height: 1.25; text-align: center; text-decoration: none;
  color: var(--on-surface); background: var(--surface);
  border: 2px solid rgba(127, 127, 127, 0.35); border-radius: 16px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
  cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  max-width: 100%; overflow-wrap: anywhere;
}
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn:focus-visible, .tile:focus-visible, .chip:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 4px solid var(--accent); outline-offset: 2px;
}
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.btn-ghost { background: transparent; box-shadow: none; color: var(--on-bg); }
.btn-good { background: var(--good); color: #fff; border-color: transparent; }
.btn-bad { background: var(--bad); color: #fff; border-color: transparent; }
.btn-small { font-size: 17px; padding: 6px 14px; }
.btn-big { font-size: 26px; min-height: 68px; padding: 10px 40px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.actions > .btn { flex: 1 1 140px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface); color: var(--on-surface);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12); border: 1px solid rgba(127, 127, 127, 0.2);
}

/* ---------- 表單 ---------- */
label.field { display: block; margin-bottom: 14px; font-weight: 700; }
label.field > span { display: block; margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="file"], select, textarea {
  width: 100%; min-height: 56px; padding: 10px 14px;
  font: inherit; font-size: 20px; color: var(--on-surface); background: var(--surface);
  border: 2px solid rgba(127, 127, 127, 0.5); border-radius: 14px;
}
textarea { min-height: 160px; font-size: 17px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
input[type="checkbox"] { width: 28px; height: 28px; vertical-align: middle; margin-right: 8px; }

/* ---------- 對話框、提示 ---------- */
.dialog-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.dialog { background: var(--surface); color: var(--on-surface); border-radius: 20px; padding: 20px; width: min(420px, 100%); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); }
.dialog-title { font-size: 24px; }
.dialog-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.dialog-actions .btn { flex: 1 1 120px; }
/* 提示放喺頂欄之下（流內），唔會擋住題目 */
.toast-area { display: flex; flex-direction: column; gap: 8px; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: 14px; font-size: 16px; margin-bottom: 8px; }

.notice { border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; border: 2px solid transparent; }
.notice-error { background: #fee2e2; color: #7f1d1d; border-color: #fca5a5; }
.notice-warn { background: #fef3c7; color: #78350f; border-color: #fcd34d; }
.notice-ok { background: #dcfce7; color: #14532d; border-color: #86efac; }
.notice ul { margin: 6px 0 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
