/* 投票頁樣式：低飽和度莫蘭迪色系，手機優先 */
:root {
  --bg: #efece6;
  --card: #fbfaf7;
  --text: #4a4744;
  --muted: #8a867f;
  --line: #ded9d0;
  --accent: #7f9183;          /* 鼠尾草綠 */
  --accent-strong: #667a6b;
  --accent-text: #ffffff;
  --accent-soft: #e4ebe5;
  --rose: #b08a85;            /* 灰玫瑰 */
  --rose-soft: #f1e6e3;
  --sand: #c9b79c;
  --disabled: #b9b4ab;
  --shadow: 0 1px 2px rgba(60, 50, 40, .08), 0 4px 16px rgba(60, 50, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #2b2a28; --card: #353330; --text: #e6e1d8; --muted: #a39e94; --line: #4a4743;
    --accent: #8fa293; --accent-strong: #a3b5a7; --accent-text: #1f2420; --accent-soft: #3c453e;
    --rose: #c9a39e; --rose-soft: #433a38; --disabled: #6f6a62;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); line-height: 1.55;
  font-family: system-ui, -apple-system, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 17px;
}
[hidden] { display: none !important; }

.screen { max-width: 640px; margin: 0 auto; padding: 20px 16px 120px; }
.screen.centered { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding-bottom: 40px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 22px 20px;
}
.brand { text-align: center; color: var(--muted); font-size: .95rem; margin: 0 0 6px; }
h1 { font-size: 1.45rem; margin: 0 0 6px; text-align: center; }
h2 { font-size: 1.2rem; margin: 0 0 8px; }
.lead { color: var(--muted); margin: 0 0 18px; text-align: center; }

label.field { display: block; font-weight: 600; margin-bottom: 8px; }
.key-input {
  width: 100%; font-size: 1.6rem; letter-spacing: .12em; text-align: center; padding: 14px 12px;
  border: 2px solid var(--line); border-radius: 12px; background: transparent; color: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.key-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

button { font: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 22px; border-radius: 12px; border: 2px solid transparent;
  background: var(--accent); color: var(--accent-text); font-weight: 600;
}
.btn:hover:not(:disabled) { background: var(--accent-strong); }
.btn:disabled { background: var(--disabled); cursor: not-allowed; opacity: .75; }
.btn.block { width: 100%; margin-top: 14px; }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--line); }
.btn.secondary:hover:not(:disabled) { background: var(--accent-soft); }
.btn.link { background: none; color: var(--accent-strong); border: 0; min-height: 36px; padding: 4px 8px; text-decoration: underline; font-weight: 500; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.kiosk-note { margin: 16px 0 0; padding-top: 12px; border-top: 1px dashed var(--line); text-align: center; color: var(--muted); font-size: .92rem; }
.notice { margin: 14px 0 0; padding: 12px 14px; border-radius: 10px; font-size: .98rem; }
.notice.error { background: var(--rose-soft); color: var(--rose); border: 1px solid var(--rose); }
.notice.info { background: var(--accent-soft); color: var(--accent-strong); border: 1px solid var(--accent); }

/* 選票 */
.ballot-head { text-align: center; margin-bottom: 14px; }
.ballot-head .org { color: var(--muted); font-size: .95rem; }
.ballot-head .position { font-size: 1.7rem; font-weight: 700; margin: 2px 0; }
.ballot-head .round { display: inline-block; background: var(--accent-soft); color: var(--accent-strong); border-radius: 999px; padding: 2px 12px; font-size: .9rem; font-weight: 600; }
.hint { text-align: center; color: var(--muted); margin: 10px 0 14px; }

.search { width: 100%; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); color: inherit; font: inherit; margin-bottom: 12px; }
.search:focus { outline: none; border-color: var(--accent); }

.list { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.cand {
  display: flex; align-items: stretch; background: var(--card); border: 2px solid var(--line);
  border-radius: 12px; overflow: hidden; transition: border-color .15s, background .15s;
}
.cand.selected { border-color: var(--accent); background: var(--accent-soft); }
.cand.flash { border-color: var(--sand); box-shadow: 0 0 0 4px rgba(201, 183, 156, .35); }
.cand.disabled { background: transparent; border-style: dashed; opacity: .75; }
.cand label { flex: 1; display: flex; align-items: center; gap: 14px; padding: 12px 14px; min-height: 64px; cursor: pointer; }
.cand.disabled label, .cand.maxed label { cursor: not-allowed; }
.cand.maxed:not(.selected) { opacity: .55; }
.cand input[type=checkbox], .blank input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--accent-strong); flex: none; }
.cand .info { display: flex; flex-direction: column; min-width: 0; }
.cand .name { font-size: 1.15rem; font-weight: 600; word-break: break-word; }
.cand .unit { color: var(--muted); font-size: .92rem; }
.cand .tag { display: inline-block; font-size: .78rem; border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; margin-left: 6px; color: var(--muted); vertical-align: middle; }
.cand .code { display: inline-block; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; color: var(--accent-strong); background: var(--accent-soft); border-radius: 6px; padding: 0 6px; }
.cand .why { color: var(--rose); font-weight: 600; font-size: .95rem; }
.cand .detail { border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--accent-strong); padding: 0 14px; min-width: 64px; font-weight: 600; }
.cand .detail:hover { background: var(--accent-soft); }

.blank { margin-top: 14px; display: flex; background: transparent; border: 2px dashed var(--sand); border-radius: 12px; }
.blank.selected { background: var(--accent-soft); border-style: solid; border-color: var(--accent); }
.blank label { flex: 1; display: flex; align-items: center; gap: 14px; padding: 14px; min-height: 64px; cursor: pointer; }
.blank .name { font-weight: 600; }
.blank .unit { color: var(--muted); font-size: .92rem; display: block; }
.empty { text-align: center; color: var(--muted); padding: 18px 0; }

.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -4px 16px rgba(60, 50, 40, .08);
}
.actionbar .inner { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 14px; }
.actionbar .summary { flex: 1; min-width: 0; font-size: .95rem; color: var(--muted); }
.actionbar .summary strong { color: var(--text); }
.actionbar .btn { flex: none; min-width: 140px; }

/* 彈出視窗 */
.overlay { position: fixed; inset: 0; background: rgba(40, 34, 30, .55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--card); border-radius: 16px; max-width: 520px; width: 100%; max-height: 90vh; overflow: auto; padding: 22px 20px; box-shadow: var(--shadow); }
.modal h2 { text-align: center; }
.modal .photo { display: block; width: 140px; height: 140px; object-fit: cover; border-radius: 50%; margin: 0 auto 12px; border: 3px solid var(--accent-soft); background: var(--accent-soft); }
.modal .meta { text-align: center; color: var(--muted); margin: 0 0 12px; }
.modal .bio { white-space: pre-wrap; word-break: break-word; margin: 0 0 16px; }
.modal .bio.none { color: var(--muted); text-align: center; }
.modal .actions { display: flex; gap: 10px; margin-top: 16px; }
.modal .actions .btn { flex: 1; }
.confirm-list { margin: 10px 0 6px; padding: 12px 14px; background: var(--accent-soft); border-radius: 10px; font-weight: 600; font-size: 1.1rem; text-align: center; word-break: break-word; }
.warn { color: var(--rose); text-align: center; margin: 8px 0 0; font-size: .95rem; }

/* 完成與提示畫面 */
.big-icon { font-size: 3.4rem; text-align: center; margin-bottom: 6px; line-height: 1; }
.big-icon.ok { color: var(--accent-strong); }
.big-icon.wait { color: var(--sand); }
.big-icon.warn { color: var(--rose); }
.center { text-align: center; }
.countdown { font-size: 1.1rem; color: var(--muted); margin-top: 14px; text-align: center; }
.countdown strong { font-size: 1.5rem; color: var(--text); }
.noscript { padding: 24px; text-align: center; }

@media (min-width: 700px) {
  .screen { padding-top: 40px; }
  .cand label, .blank label { min-height: 72px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
