:root {
  /* bright kindergarten palette */
  --bg: #fffaf0;
  --bg-2: #fff5e6;
  --panel: #ffffff;
  --ink: #262b3d;
  --ink-2: #4b5470;
  --muted: #7d87a3;
  --line: #f0e4d3;
  --line-2: #faf2e7;
  --accent: #d94f4f;
  --accent-ink: #b93a3a;
  --accent-soft: #ffe9e6;
  --sun: #ffb703;
  --sun-soft: #fff3d1;
  --mint: #2ec4b6;
  --mint-soft: #e0f8f4;
  --sky: #4cc9f0;
  --sky-soft: #e4f6fe;
  --grape: #9b5de5;
  --grape-soft: #f1e8ff;
  --leaf: #43aa8b;
  --leaf-soft: #e6f7ef;
  --peach: #ff8a5b;
  --peach-soft: #ffeee5;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 2px 0 rgba(240, 228, 211, .9), 0 12px 30px -18px rgba(90, 70, 40, .35);
  --shadow-lg: 0 20px 45px -28px rgba(90, 70, 40, .45);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Nunito", system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "PingFang TC",
          "Microsoft JhengHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; color: var(--ink);
  font: 15.5px/1.65 var(--sans);
  background:
    radial-gradient(1200px 420px at 8% -140px, #ffe9c9 0%, transparent 70%),
    radial-gradient(900px 380px at 92% -120px, #d9f6f1 0%, transparent 70%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.22; margin: 0; letter-spacing: -.015em; }
h1 { font-size: clamp(26px, 3.6vw, 42px); font-weight: 900; }
h2 { font-size: 17.5px; font-weight: 800; }
h3 { font-size: 15px; font-weight: 800; }
p { margin: 0; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { width: min(1180px, 100% - 40px); margin-inline: auto; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 10px; z-index: 99; background: var(--panel); padding: 8px 12px; border-radius: 10px; }

/* ---------------- top bar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--line);
}
.topbar-in { display: flex; align-items: center; gap: 16px; height: 68px; }
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 13px; flex: 0 0 auto;
  background: linear-gradient(145deg, #ffb703, #ff8a5b 40%, #ef6f6c 70%, #9b5de5);
  color: #fff; font-weight: 900; display: grid; place-items: center; font-size: 19px;
  box-shadow: 0 6px 14px -6px rgba(255, 138, 91, .8);
  transform: rotate(-4deg);
}
.brand-txt { display: flex; flex-direction: column; line-height: 1.1; }
.brand-txt strong { font-size: 15.5px; font-weight: 850; letter-spacing: -.01em; }
.brand-txt small { color: var(--muted); font-size: 11px; margin-top: 3px; }
.nav { display: flex; gap: 4px; margin-left: 10px; }
.nav a {
  padding: 8px 14px; border-radius: 999px; color: var(--ink-2);
  font-weight: 750; font-size: 14px;
}
.nav a:hover { background: var(--line-2); text-decoration: none; }
.nav a.active { background: var(--mint-soft); color: #0d7f76; }
.tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search { position: relative; }
.search svg { width: 17px; height: 17px; fill: var(--muted); position: absolute; left: 13px; top: 50%; transform: translateY(-50%); }
.search input {
  width: 310px; height: 42px; padding: 0 62px 0 38px;
  border: 2px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink);
  font: inherit; font-size: 14px; outline: none;
}
.search input::placeholder { color: #a9b1c6; }
.search input:focus { border-color: var(--mint); box-shadow: 0 0 0 4px var(--mint-soft); }
.search kbd {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font: 11px var(--mono); color: var(--muted); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 6px; background: var(--bg);
}
.lang {
  height: 42px; min-width: 52px; border-radius: 999px; border: 2px solid var(--line);
  background: #fff; color: var(--ink); font: 800 13px var(--sans); cursor: pointer;
}
.lang:hover { border-color: var(--sun); color: #a86a00; background: var(--sun-soft); }

/* suggestions */
.suggest {
  position: absolute; top: 50px; right: 0; width: min(470px, 86vw); max-height: 62vh; overflow: auto;
  background: #fff; border: 2px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg);
  padding: 8px; z-index: 50;
}
.suggest button {
  display: block; width: 100%; text-align: left; border: 0; background: none; cursor: pointer;
  padding: 10px 12px; border-radius: 12px; color: var(--ink); font: inherit; height: auto;
}
.suggest button:hover, .suggest button[aria-selected="true"] { background: var(--mint-soft); }
.suggest .s-name, .suggest .s-meta { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .s-name { font-weight: 800; font-size: 14px; }
.suggest .s-meta { color: var(--muted); font-size: 12px; margin-top: 1px; }
.suggest .s-empty { padding: 16px; color: var(--muted); font-size: 13px; }

/* ---------------- hero ---------------- */
.hero {
  position: relative; overflow: hidden;
  padding: 52px 0 40px;
  background:
    radial-gradient(680px 300px at 6% 0%, #ffe6b3 0%, transparent 65%),
    radial-gradient(620px 320px at 92% 10%, #ccf3ee 0%, transparent 65%),
    linear-gradient(180deg, #fff8ec, #fffaf0);
  border-bottom: 2px solid var(--line);
}
.hero::before, .hero::after {
  content: ""; position: absolute; border-radius: 50%; pointer-events: none; filter: blur(1px);
}
.hero::before {
  width: 180px; height: 180px; right: 6%; top: -50px;
  background: radial-gradient(circle at 35% 35%, #ffe0a3, #ffd07a);
  opacity: .55;
}
.hero::after {
  width: 240px; height: 240px; left: -70px; bottom: -130px;
  background: radial-gradient(circle at 40% 40%, #d5f6f1, #b9efe8);
  opacity: .7;
}
.hero .wrap { position: relative; z-index: 1; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  color: #0d7f76; background: var(--mint-soft); border-radius: 999px;
  padding: 5px 13px; font-weight: 800; font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
}
.hero h1 { margin-top: 14px; }
.lede { color: var(--ink-2); margin-top: 10px; max-width: 62ch; font-size: 16px; }
.hero-search { display: flex; gap: 9px; margin-top: 24px; max-width: 660px; position: relative; }
.hero-search input {
  flex: 1; height: 54px; border-radius: 999px; border: 2px solid #fff; background: #fff;
  color: var(--ink); padding: 0 20px; font: inherit; font-size: 15.5px;
  box-shadow: var(--shadow-lg); outline: none;
}
.hero-search input:focus { border-color: var(--mint); box-shadow: 0 0 0 4px var(--mint-soft); }
.hero-search > button {
  height: 54px; padding: 0 26px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font: 800 15px var(--sans); flex: 0 0 auto;
  box-shadow: 0 10px 20px -12px rgba(217, 79, 79, .9);
}
.hero-search > button:hover { background: var(--accent-ink); }
.hero-search .suggest { top: 62px; left: 0; right: auto; width: 100%; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.hero-tags button {
  border: 2px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 999px; padding: 5px 13px; font: 700 12.5px var(--sans); cursor: pointer;
}
.hero-tags button:hover { border-color: var(--sun); background: var(--sun-soft); color: #a86a00; }

/* ---------------- cards / grid ---------------- */
main { padding-bottom: 70px; }
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-top: 26px; }
.kpi {
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 14px; background: #fff; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.kpi:nth-child(1) { background: var(--mint-soft); border-color: #c9efe9; }
.kpi:nth-child(2) { background: var(--sun-soft); border-color: #ffe6ad; }
.kpi:nth-child(3) { background: var(--sky-soft); border-color: #c7ecfa; }
.kpi:nth-child(4) { background: var(--peach-soft); border-color: #ffd9c7; }
.kpi:nth-child(5) { background: var(--grape-soft); border-color: #e3d3fb; }
.kpi:nth-child(6) { background: var(--leaf-soft); border-color: #c9ecdc; }
.kpi .k-label { font-size: 12px; color: var(--ink-2); font-weight: 800; letter-spacing: .01em; }
.kpi .k-val { font-size: 24px; font-weight: 900; letter-spacing: -.02em; margin-top: 5px; }
.kpi .k-val small { font-size: 13px; font-weight: 800; color: var(--muted); margin-left: 3px; }
.kpi .k-sub { font-size: 12px; color: var(--ink-2); margin-top: 3px; opacity: .85; }

.grid { display: grid; gap: 18px; margin-top: 18px; }
.grid.two { grid-template-columns: 1fr 1fr; align-items: start; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.card {
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); margin: 0;
}
.card + .card, .grid + .card { margin-top: 18px; }
figcaption { margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.muted { color: var(--muted); }
.chart { width: 100%; min-height: 160px; }
.chart.tall { min-height: 320px; }
.donut-wrap { display: grid; place-items: center; height: 220px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 10px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; border-radius: 4px; display: inline-block; }

.insight {
  background: #fff; border: 2px solid var(--line); border-radius: 18px; padding: 16px 18px;
  box-shadow: var(--shadow); border-top: 5px solid var(--mint);
}
.insight:nth-child(2) { border-top-color: var(--sun); }
.insight:nth-child(3) { border-top-color: var(--sky); }
.insight:nth-child(4) { border-top-color: var(--peach); }
.insight:nth-child(5) { border-top-color: var(--grape); }
.insight:nth-child(6) { border-top-color: var(--leaf); }
.insight h3 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.insight p { margin-top: 7px; font-size: 14.5px; }
.insight b { font-weight: 900; }

/* ---------------- page head / filters ---------------- */
.page-head { padding: 36px 0 6px; }
.page-head .lede { margin-top: 6px; }
.filters {
  display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end; margin-top: 20px;
}
.filters label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 800; }
.filters select, .filters input[type="range"] {
  height: 40px; border: 2px solid var(--line); border-radius: 12px; background: #fff;
  color: var(--ink); font: inherit; font-size: 13.5px; padding: 0 10px; min-width: 132px;
}
.filters select:focus { outline: none; border-color: var(--mint); box-shadow: 0 0 0 3px var(--mint-soft); }
.filters input[type="range"] { padding: 0; accent-color: var(--accent); border: 0; height: auto; }
.filters .range { display: flex; align-items: center; gap: 9px; }
.filters output { font-variant-numeric: tabular-nums; color: var(--ink); font-size: 12.5px; font-weight: 700; }
.filters .chk { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.filters .chk input { accent-color: var(--mint); width: 17px; height: 17px; }
button.ghost {
  height: 40px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--line);
  background: #fff; color: var(--ink-2); font: 750 13px var(--sans); cursor: pointer;
}
button.ghost:hover { border-color: var(--mint); color: #0d7f76; background: var(--mint-soft); }
.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; background: #fff; }
.seg button {
  border: 0; background: none; color: var(--ink-2); padding: 8px 14px; font: 750 13px var(--sans); cursor: pointer;
  border-right: 1px solid var(--line-2);
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--line-2); }
.seg button.on { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------------- tables ---------------- */
.table-wrap { overflow: auto; border-radius: 14px; }
table.dt { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.dt th, table.dt td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.dt th {
  position: sticky; top: 0; background: #fff; z-index: 1;
  font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  cursor: pointer; user-select: none; font-weight: 800;
}
table.dt th[data-sort]::after { content: "↕"; margin-left: 5px; opacity: .35; font-size: 10px; }
table.dt th.asc::after { content: "↑"; opacity: .9; }
table.dt th.desc::after { content: "↓"; opacity: .9; }
table.dt tbody tr:hover { background: var(--line-2); cursor: pointer; }
table.dt td.num, table.dt th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.dt td.name { white-space: normal; min-width: 250px; }
table.dt td.name .en { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.pager button { min-width: 36px; height: 34px; border-radius: 999px; border: 2px solid var(--line); background: #fff; color: var(--ink-2); cursor: pointer; font: 750 13px var(--sans); }
.pager button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.pager button:disabled { opacity: .45; cursor: default; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 800;
  background: var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.badge.np { background: var(--mint-soft); color: #0d7f76; }
.badge.pi { background: var(--sun-soft); color: #9a6200; }
.badge.join { background: var(--mint-soft); color: #0d7f76; }
.badge.nojoin { background: #f2f4f8; color: var(--muted); }
.badge.pending { background: var(--accent-soft); color: var(--accent-ink); }
.badge.free { background: var(--leaf-soft); color: #23795c; }

/* ---------------- school detail ---------------- */
.back { margin: 26px 0 6px; height: 38px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--line); background: #fff; color: var(--ink-2); cursor: pointer; font: 750 13px var(--sans); }
.back:hover { border-color: var(--mint); color: #0d7f76; }
.sd-head { padding: 10px 0 18px; border-bottom: 2px solid var(--line); }
.sd-head h1 { font-size: clamp(24px, 3vw, 34px); }
.sd-head .alt { color: var(--muted); margin-top: 5px; font-size: 14px; }
.sd-badges { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 12px; }
.sd-facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 18px; }
.sd-fact { border: 2px solid var(--line); border-radius: 16px; padding: 12px 14px; background: var(--mint-soft); }
.sd-fact:nth-child(2) { background: var(--sun-soft); border-color: #ffe6ad; }
.sd-fact:nth-child(3) { background: var(--sky-soft); border-color: #c7ecfa; }
.sd-fact:nth-child(4) { background: var(--peach-soft); border-color: #ffd9c7; }
.sd-fact .l { font-size: 11.5px; color: var(--ink-2); font-weight: 800; }
.sd-fact .v { font-size: 18px; font-weight: 850; margin-top: 2px; word-break: break-word; }
.sd-fact .v.small { font-size: 13.5px; font-weight: 700; }
.sd-sec { margin-top: 18px; }
.sd-sec h2 { font-size: 15.5px; display: flex; align-items: center; gap: 9px; }
.sd-sec h2::before { content: ""; width: 5px; height: 16px; border-radius: 3px; background: var(--sun); }
.sd-sec table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13.5px; }
.sd-sec th, .sd-sec td { text-align: left; vertical-align: top; padding: 9px 10px; border-bottom: 1px solid var(--line-2); }
.sd-sec th { width: 34%; color: var(--muted); font-weight: 800; font-size: 12.5px; }
.sd-sec td { color: var(--ink); white-space: pre-line; }
.sd-sec td.num { font-variant-numeric: tabular-nums; }
.sd-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; }

/* ---------------- about ---------------- */
.prose { max-width: 840px; padding-top: 36px; }
.prose h1 { font-size: 30px; }
.prose h2 { margin-top: 28px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.prose h2::before { content: ""; width: 5px; height: 15px; border-radius: 3px; background: var(--mint); }
.prose p, .prose li { color: var(--ink-2); margin-top: 8px; }
.prose ul { padding-left: 20px; }
.prose code { font: 12.5px var(--mono); background: var(--line-2); padding: 1px 6px; border-radius: 6px; }
.prose table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13.5px; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.prose th { color: var(--muted); font-size: 12px; width: 38%; }
.prose a { font-weight: 700; }

/* ---------------- footer ---------------- */
.foot { border-top: 2px solid var(--line); padding: 24px 0 36px; color: var(--muted); font-size: 12.5px; background: var(--bg-2); }
.foot p + p { margin-top: 4px; }

/* ---------------- svg chart bits ---------------- */
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .ax { stroke: #eadfd0; stroke-width: 1; }
.chart text { fill: var(--muted); font: 11px var(--sans); }
.chart text.val { fill: var(--ink); font-weight: 850; font-size: 11px; }
.chart .bar { transition: opacity .15s ease; }
.chart .bar:hover { opacity: .78; }
.chart .gl { stroke: #f3ebdf; stroke-dasharray: 3 4; }
.donut-center { font: 900 21px var(--sans); fill: var(--ink); }
.donut-center-sub { font: 11px var(--sans); fill: var(--muted); }

@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .search input { width: 220px; }
}
@media (max-width: 860px) {
  .topbar-in { height: auto; padding: 10px 0; flex-wrap: wrap; row-gap: 8px; }
  .nav { order: 3; width: 100%; overflow: auto; }
  .tools { order: 2; flex: 1 1 200px; justify-content: flex-end; }
  .search { flex: 1; }
  .search input { width: 100%; }
  .brand-txt small { display: none; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .sd-facts { grid-template-columns: repeat(2, 1fr); }
  .hero { padding: 34px 0 28px; }
  .wrap { width: min(1180px, 100% - 28px); }
}
@media (max-width: 700px) {
  #schoolTable th:nth-child(2), #schoolTable td:nth-child(2),
  #schoolTable th:nth-child(3), #schoolTable td:nth-child(3),
  #schoolTable th:nth-child(4), #schoolTable td:nth-child(4),
  #schoolTable th:nth-child(7), #schoolTable td:nth-child(7),
  #schoolTable th:nth-child(8), #schoolTable td:nth-child(8),
  #schoolTable th:nth-child(9), #schoolTable td:nth-child(9) { display: none; }
  #schoolTable th, #schoolTable td { padding: 9px 8px; }
  #schoolTable td.name { min-width: 200px; }
  #districtTable th:nth-child(4), #districtTable td:nth-child(4),
  #districtTable th:nth-child(5), #districtTable td:nth-child(5),
  #districtTable th:nth-child(9), #districtTable td:nth-child(9) { display: none; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .brand { flex: 1; }
  .tools { flex: 1 1 100%; order: 2; }
  .search { flex: 1; }
  .search kbd { display: none; }
  .hero-search { flex-wrap: wrap; }
  .hero-search > button { width: 100%; }
  .sd-facts { grid-template-columns: 1fr 1fr; }
  .sd-sec th { width: 42%; }
  .filters select { min-width: 100%; }
}
@media print {
  .topbar, .filters, .pager, .back, .foot, .hero-search, .hero-tags { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ddd; }
}
