/* 顏色由 config/brand.json 在載入時覆寫，這裡是預設值 */
:root {
  --primary: #C0392B;
  --primary-ink: #FFFFFF;
  --primary-soft: #FBEAE7;
  --ink: #1B2A41;
  --muted: #5B6676;
  --bg: #F7F4EE;
  --card: #FFFFFF;
  --line: #E6E0D4;
  --ok: #2E7D5B;
  --ok-soft: #E6F3EC;
  --warn: #9A5B00;
  --warn-soft: #FFF4DE;
  --radius: 14px;
  --tabbar-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
a { color: var(--primary); }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- 頂部 ---------- */
.top {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.top-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo { width: 32px; height: 32px; border-radius: 8px; flex: none; }
.brand-name { font-size: 17px; margin: 0; line-height: 1.3; }
.badge-unofficial { display: inline-block; vertical-align: 2px; font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; line-height: 1.5; }
.badge-unofficial:empty { display: none; }
.brand-tagline { font-size: 13px; margin: 0; color: var(--muted); line-height: 1.3; }

main { max-width: 560px; margin: 0 auto; padding: 16px; }
.loading { padding: 48px 0; min-height: 70vh; text-align: center; color: var(--muted); }

/* ---------- 共用元件 ---------- */
h2 { font-size: 22px; line-height: 1.35; margin: 4px 0 8px; }
h3 { font-size: 17px; margin: 28px 0 10px; }
.lead { color: var(--muted); margin: 0 0 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card { margin-top: 10px; }
.small { font-size: 13px; color: var(--muted); }
.tag {
  display: inline-block;
  font-size: 12px;
  line-height: 1;
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-weight: 600;
  vertical-align: 2px;
  white-space: nowrap;
}
.tag.sponsor { background: #EEF1F5; color: var(--muted); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 12px;
  border: 0;
  background: var(--primary);
  color: var(--primary-ink);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
}
.btn.ghost { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn.quiet { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 500; min-height: 40px; width: auto; }
.btn:active { transform: translateY(1px); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--primary); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.notice {
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 14px;
  margin: 12px 0;
}
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.sources { font-size: 13px; color: var(--muted); }
.sources ul { padding-left: 18px; margin: 6px 0; }
.sources a { color: var(--muted); word-break: break-all; }

/* ---------- 看懂新制 ---------- */
.countdown {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 8px;
  background: var(--primary);
  color: var(--primary-ink);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.countdown span { white-space: nowrap; }
.countdown b { margin-right: 6px; font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li {
  position: relative;
  padding: 0 0 18px 48px;
  counter-increment: step;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 0;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
  display: grid;
  place-items: center;
}
.steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 16px; top: 38px; bottom: 4px;
  border-left: 2px dashed var(--line);
}
.steps strong { display: block; font-size: 16px; line-height: 1.4; padding-top: 5px; }
.steps p { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.rules { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.rules .card { margin: 0; padding: 14px; }
.rules strong { display: block; font-size: 15px; }
.rules p { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.formula { font-variant-numeric: tabular-nums; }
.formula p { margin: 4px 0; }
.fails { list-style: none; padding: 0; margin: 0; }
.fails li {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.fails strong { display: block; }
.fails span { color: var(--muted); font-size: 14px; }
.cta-row { display: grid; gap: 10px; margin-top: 20px; }
.feedback { margin-top: 18px; border-color: var(--primary); background: var(--primary-soft); }
.faq { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.faq details { border-top: 1px solid var(--line); }
.faq details:first-child { border-top: 0; }
.faq summary { cursor: pointer; padding: 14px 40px 14px 16px; font-weight: 600; position: relative; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 16px; top: 12px; font-size: 20px; color: var(--muted); }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 0 16px 10px; font-size: 15px; }
.faq details p.small { margin-bottom: 14px; }

/* ---------- 檢查清單 ---------- */
.progress {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: 8px 0 12px;
}
.progress-top { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .25s; }
.group { margin-top: 18px; }
.group-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.group-head h3 { margin: 0; }
.group-head span { font-size: 13px; color: var(--muted); }
.items {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.item { display: flex; gap: 12px; padding: 14px 14px; border-top: 1px dashed var(--line); }
.item:first-child { border-top: 0; }
.item input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 26px; height: 26px;
  margin: 0;
  border: 2px solid #B9B2A4;
  border-radius: 8px;
  background: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.item input:checked { background: var(--ok); border-color: var(--ok); }
.item input:checked::after {
  content: "";
  width: 7px; height: 13px;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  transform: translateY(-2px) rotate(45deg);
}
.item input:focus-visible { outline: 3px solid var(--primary-soft); outline-offset: 2px; }
.item label { flex: 1; cursor: pointer; }
.item .t { display: block; font-weight: 600; line-height: 1.45; }
.item .d { display: block; font-size: 14px; color: var(--muted); margin-top: 2px; }
.item .act { display: inline-block; margin-top: 6px; font-size: 14px; }
.item.done .t { color: var(--muted); text-decoration: line-through; text-decoration-color: #B9B2A4; }
.reset-row { text-align: center; margin-top: 22px; }

/* ---------- 查業者 ---------- */
.search {
  width: 100%;
  min-height: 50px;
  padding: 0 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font-size: 16px; /* 16px 以上 iPhone 才不會自動放大 */
}
.search:focus { outline: none; border-color: var(--primary); }
.result-meta { font-size: 13px; color: var(--muted); margin: 10px 2px; }
.op h4 { margin: 0 0 2px; font-size: 17px; }
.op .kind { font-size: 12px; color: var(--muted); }
.op dl { margin: 10px 0 0; display: grid; grid-template-columns: 4.5em 1fr; gap: 6px 10px; font-size: 14px; }
.op dt { color: var(--muted); }
.op dd { margin: 0; }
.op .via { margin-top: 10px; padding: 10px 12px; background: var(--primary-soft); border-radius: 10px; font-size: 14px; }
.op .src { margin-top: 10px; font-size: 12px; color: var(--muted); }
.op .src a { color: var(--muted); }
.ask {
  font-size: 15px;
  background: var(--card);
  border: 1px dashed var(--muted);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 8px;
}
.ask .jp { font-size: 18px; font-weight: 700; display: block; }

/* ---------- 出境提醒 ---------- */
.form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.field input, .field select {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  min-width: 0;
  background: var(--card);
  font-size: 16px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.preview { font-size: 14px; }
.preview ol { margin: 6px 0 0; padding-left: 20px; }
.preview li { margin-bottom: 4px; }
.done-panel h3 { margin-top: 0; }
.done-panel ol { padding-left: 20px; margin: 6px 0; }

/* ---------- 頁尾 ---------- */
.foot { margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.foot p { margin: 4px 0; }
.foot details { margin: 6px 0; }
.foot summary { cursor: pointer; color: var(--ink); font-weight: 600; }

/* ---------- 底部分頁列 ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--muted);
  font-size: 12px;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--primary); font-weight: 700; }
.tabbar a[aria-current="page"] svg { stroke-width: 2.3; }

@media (min-width: 600px) {
  .tabbar { max-width: 560px; margin: 0 auto; border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; }
}
