:root {
  --bg: #ffffff;
  --panel: #fafaf7;
  --text: #1f2328;
  --muted: #646d76;
  --line: #e3e3dc;
  --accent: #1f6f5c;
  --accent-soft: #e3f1ec;
  --warn: #9a5b00;
  --warn-soft: #fff4e0;
  --es: #1f6f5c;
  --jh: #3b5bab;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.6;
}
a { color: var(--accent); }

.layout { display: flex; height: 100%; }
.panel {
  width: 400px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}
#map { flex: 1; }

h1 { font-size: 22px; margin: 0; }
.sub { margin: 2px 0 0; color: var(--muted); }

form { display: flex; gap: 8px; }
input[type=search] {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
input[type=search]:focus { outline: 2px solid var(--accent); border-color: transparent; }
button {
  font-size: 16px;
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.suggest {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: -8px;
  overflow: hidden;
}
.suggest button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  color: var(--text);
  border-radius: 0;
  padding: 8px 12px;
  font-size: 15px;
}
.suggest button:hover, .suggest button:focus { background: var(--accent-soft); }

.hint ul { margin: 4px 0 0; padding-left: 20px; }
.hint p { margin: 0; color: var(--muted); }

.addr { font-size: 17px; font-weight: 600; margin: 0; }
.meta { color: var(--muted); margin: 2px 0 10px; font-size: 14px; }
.note {
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  margin: 8px 0;
}
.error { color: #b42318; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.card h2 {
  font-size: 13px;
  margin: 0 0 6px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .05em;
}
.school { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.school + .school { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.school-name { font-size: 18px; font-weight: 700; cursor: pointer; }
.school-name:hover { text-decoration: underline; }
.tag {
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
}
.tag.shared { background: var(--warn-soft); color: var(--warn); }
.school-info { width: 100%; font-size: 13px; color: var(--muted); }

.road-list { margin: 0; padding: 0; list-style: none; }
.road-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.road-list li:last-child { border-bottom: 0; }

.layers { display: flex; gap: 12px; align-items: center; font-size: 14px; flex-wrap: wrap; }
.layers span { color: var(--muted); }

footer { margin-top: auto; font-size: 12px; color: var(--muted); }
footer p { margin: 6px 0; }

.loading { color: var(--muted); }

.legend {
  background: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.8;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.legend i { display: inline-block; width: 14px; height: 10px; margin-right: 6px; vertical-align: middle; border: 2px solid; }

@media (max-width: 760px) {
  .layout { flex-direction: column-reverse; }
  #map { height: 45vh; flex: none; }
  .panel { width: 100%; flex: 1; border-right: 0; border-top: 1px solid var(--line); padding: 16px; }
  h1 { font-size: 19px; }
}

/* ---------- 分頁 ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1;
  background: none;
  color: var(--muted);
  border-radius: 8px 8px 0 0;
  padding: 8px 4px;
  font-size: 15px;
  border-bottom: 3px solid transparent;
}
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.tab-panel { display: flex; flex-direction: column; gap: 12px; }
.tab-panel[hidden] { display: none; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; align-self: flex-start; }
.seg button { background: #fff; color: var(--text); border-radius: 0; padding: 6px 18px; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }

.small-btn {
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
}
.tag.full { background: #fde8e8; color: #b42318; }
.tag.muted { background: #eee; color: var(--muted); }

/* ---------- 額滿學校清單 ---------- */
.full-intro { font-size: 14px; color: var(--muted); margin: 0; }
.full-group h3 { font-size: 14px; margin: 14px 0 6px; color: var(--muted); }
.full-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line); }
.full-row:last-child { border-bottom: 0; }
.full-row .school-name { font-size: 16px; }
.full-row .meta-line { width: 100%; font-size: 13px; color: var(--muted); }
.full-row .actions { margin-left: auto; display: flex; gap: 6px; }

/* ---------- 設籍試算 ---------- */
.calc-form { display: flex; flex-direction: column; gap: 10px; }
.calc-form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; }
.calc-form input, .calc-form select {
  font-size: 16px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.privacy { font-size: 12px; color: var(--muted); margin: 0; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before {
  content: "";
  position: absolute;
  left: 4px; top: 7px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline li::after {
  content: "";
  position: absolute;
  left: 8px; top: 18px; bottom: 0;
  width: 2px;
  background: var(--line);
}
.timeline li:last-child::after { display: none; }
.timeline li.past::before { background: #bbb; }
.timeline li.key::before { background: #d9480f; }
.tl-date { font-weight: 700; }
.tl-left { font-size: 12px; margin-left: 6px; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.past .tl-left { background: #eee; color: var(--muted); }
.tl-desc { font-size: 14px; color: var(--text); }
.tl-desc small { color: var(--muted); }

table.hist { width: 100%; border-collapse: collapse; font-size: 13px; }
table.hist th, table.hist td { text-align: left; padding: 5px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.hist th { color: var(--muted); font-weight: 600; }
.big { font-size: 20px; font-weight: 700; color: #d9480f; }

/* ---------- 首頁常見問題 ---------- */
.faq-home h2 { font-size: 15px; margin: 8px 0 6px; }
.faq-home details { border-top: 1px solid var(--line); padding: 8px 0; font-size: 14px; }
.faq-home summary { cursor: pointer; font-weight: 600; }
.faq-home p { margin: 6px 0 0; color: var(--muted); }

/* ---------- 學區房價 ---------- */
.range-row { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; margin-bottom: -6px; }
.range-row output { color: var(--accent); }
.dual { position: relative; height: 28px; }
.dual input[type=range] { position: absolute; left: 0; right: 0; width: 100%; pointer-events: none; background: none; -webkit-appearance: none; appearance: none; height: 28px; margin: 0; }
.dual input[type=range]::-webkit-slider-thumb { pointer-events: auto; }
.dual input[type=range]::-moz-range-thumb { pointer-events: auto; }
.dual::before { content: ""; position: absolute; left: 0; right: 0; top: 12px; height: 4px; border-radius: 2px; background: var(--line); }
input[type=range] { accent-color: var(--accent); width: 100%; }
.checks { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; }
.checks legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
.checks label { flex-direction: row; font-weight: 400; align-items: center; gap: 4px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { background: var(--panel); border-radius: 8px; padding: 8px 10px; }
.stat b { display: block; font-size: 20px; color: var(--text); }
.stat span { font-size: 12px; color: var(--muted); }
.trade-list { list-style: none; margin: 0; padding: 0; }
.trade-list li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; cursor: pointer; }
.trade-list li:hover { background: var(--accent-soft); }
.trade-list .price { float: right; text-align: right; font-weight: 700; }
.trade-list .price small { display: block; font-weight: 400; color: var(--muted); }
.trade-list .sub { color: var(--muted); font-size: 12px; }
.price-legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.price-legend i { flex: 1; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #2b8a3e, #f59f00, #d9480f, #862e9c); }

/* ---------- 觀察清單 ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint-inline { font-weight: 400; color: var(--muted); font-size: 12px; }
.watch-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.watch-card h3 { margin: 0 0 4px; font-size: 16px; display: flex; gap: 8px; align-items: baseline; }
.watch-card .num { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; background: #3b5bab; color: #fff; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
.watch-card .row { font-size: 14px; margin: 4px 0; }
.watch-card .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.watch-card .del { background: #fde8e8; color: #b42318; }
.diff-up { color: #b42318; font-weight: 700; }
.diff-down { color: #2b8a3e; font-weight: 700; }
.comps { font-size: 13px; color: var(--muted); margin: 6px 0 0; padding-left: 18px; }
.compare-wrap { overflow-x: auto; }
table.compare { border-collapse: collapse; font-size: 13px; min-width: 100%; background: #fff; }
table.compare th, table.compare td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; white-space: nowrap; }
table.compare th { background: var(--panel); color: var(--muted); font-weight: 600; }
@media (max-width: 760px) {
  .tabs button { font-size: 13px; padding: 8px 2px; }
}
.tabs button { white-space: nowrap; font-size: 14px; padding: 8px 2px; }
.grid2 input { width: 100%; min-width: 0; }
.grid2 label { min-width: 0; }

/* ---------- 依預算找學區 ---------- */
.calc-form[hidden], #trade-result[hidden] { display: none; }
.pay-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pay-table th, .pay-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: right; }
.pay-table th:first-child, .pay-table td:first-child { text-align: left; color: var(--muted); font-weight: 400; }
.pay-table thead th { color: var(--muted); font-weight: 600; }
.zone-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; }
.zone-card.dim { opacity: .65; }
.zone-card h3 { margin: 0; font-size: 16px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.zone-card .rank { color: var(--hot, #d9480f); font-weight: 700; }
.zone-card .big-ping { font-size: 18px; font-weight: 700; color: var(--accent); }
.zone-card .row { font-size: 13px; color: var(--muted); margin-top: 4px; }
.zone-card .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.highlight-card { background: var(--warn-soft); border-color: #f5d9a8; }
.highlight-card p { margin: 6px 0; font-size: 14px; }

/* ---------- CoRich 導流卡 ---------- */
.promo-card { display: block; text-decoration: none; color: var(--text); background: #f4f7fb; border: 1px solid #dfe6f0; border-radius: 10px; padding: 10px 14px; margin: 4px 0 10px; }
.promo-card:hover { border-color: #3b5bab; }
.promo-title { display: block; font-weight: 700; font-size: 14px; }
.promo-body { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.promo-cta { display: block; font-size: 13px; color: #3b5bab; margin-top: 4px; font-weight: 600; }
