:root {
  color-scheme: light;
  --surface: #E8EFF9;
  --surface-lift: #EEF3FB;
  --ink: #101B31;
  --slate: #475A75;
  --blue: #0054CC;
  --blue-deep: #003F99;
  --green: #117A35;
  --red: #C62828;
  --brand-blue: #0B63FF;
  --brand-green: #1AB34B;
  --brand-red: #FF2D20;
  --shade: #C4CFDF;
  --light: #FFFFFF;
  --up-sm: 4px 4px 10px var(--shade), -4px -4px 10px var(--light);
  --in-sm: inset 4px 4px 10px var(--shade), inset -4px -4px 10px var(--light);
  --in-xs: inset 3px 3px 8px var(--shade), inset -3px -3px 8px var(--light);
  --glow: 8px 8px 20px rgba(11, 99, 255, 0.16), -8px -8px 20px var(--light);
  --glow-lg: 10px 10px 24px rgba(11, 99, 255, 0.16), -10px -10px 24px var(--light);
  --glow-strong: 10px 10px 24px rgba(11, 99, 255, 0.30), -10px -10px 24px var(--light);
  /* ByteLand motion scale: pick by distance travelled; exits run at two thirds. */
  --t-instant: 100ms;
  --t-short: 180ms;
  --t-medium: 260ms;
  --t-long: 340ms;
  --x-instant: 67ms;
  --x-short: 120ms;
  --x-medium: 173ms;
  --x-long: 227ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-accelerate: cubic-bezier(0.3, 0, 1, 1);
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
a { color: var(--blue); }
a:hover { color: var(--blue-deep); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; border-radius: 8px; }
button { font: inherit; color: inherit; cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.grow { flex: 1; min-width: 0; display: flex; }
.muted { color: var(--slate); }

.ic { flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ic-blue { color: var(--blue); }
.ic-green { color: var(--green); }
.ic-muted { color: var(--slate); }

.band { display: flex; height: 5px; }
.band span { flex: 1; }
.band span:nth-child(1) { background: var(--brand-blue); }
.band span:nth-child(2) { background: var(--brand-green); }
.band span:nth-child(3) { background: var(--brand-red); }

/* Header */
.top { max-width: 1120px; margin: 0 auto; padding: 20px 24px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 18px; letter-spacing: -0.2px; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 44px; height: 44px; border-radius: 14px; background: var(--surface-lift); box-shadow: 4px 4px 10px rgba(11, 99, 255, 0.24), -4px -4px 10px var(--light); display: flex; align-items: center; justify-content: center; color: var(--blue); }
.nav { margin-left: auto; display: flex; gap: 14px; }

.btn-round { position: relative; width: 48px; height: 48px; flex: 0 0 auto; border: 0; border-radius: 50%; background: var(--surface); box-shadow: var(--up-sm); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn-round:hover { color: var(--blue); }
.btn-round[aria-pressed="true"] { box-shadow: var(--in-sm); color: var(--blue); }
.btn-round[aria-pressed="true"] .ic { fill: currentColor; }
.btn-round[data-toggle="compare"][aria-pressed="true"] .ic { fill: none; }
.badge { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--red); color: #fff; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.badge[hidden] { display: none; }

main { max-width: 1120px; margin: 0 auto; padding: 0 24px 96px; }
.foot { max-width: 1120px; margin: 0 auto; padding: 24px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--slate); }
.foot-src { display: flex; align-items: center; gap: 6px; }
.tabbar { display: none; }

/* Home */
.home { padding-top: 32px; display: flex; flex-direction: column; align-items: center; gap: 28px; }
.segmented { position: relative; display: flex; gap: 6px; padding: 6px; border-radius: 999px; background: var(--surface); box-shadow: var(--in-sm); }
.segmented button { position: relative; z-index: 1; min-height: 48px; padding: 0 24px; display: flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; background: transparent; color: var(--slate); font-weight: 700; }
.segmented button[aria-selected="true"] { color: var(--blue); }
.seg-thumb { position: absolute; top: 6px; left: 0; height: 48px; width: 0; border-radius: 999px; background: var(--surface); box-shadow: var(--up-sm); }
.segmented:not(.ready) button[aria-selected="true"] { background: var(--surface); box-shadow: var(--up-sm); }
.level-panel { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 28px; }
.level-panel[hidden] { display: none; }
.search-pill { width: 100%; max-width: 760px; display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 26px; border-radius: 999px; background: var(--surface); box-shadow: var(--glow-strong); }
.search-pill input, .search-bar input { flex: 1; min-width: 0; min-height: 52px; border: 0; outline: none; background: transparent; font: inherit; font-size: 19px; color: var(--ink); }
.search-pill input::placeholder, .search-bar input::placeholder { color: var(--slate); }
.btn-go { width: 56px; height: 56px; flex: 0 0 auto; border: 0; border-radius: 50%; background: var(--blue); color: #fff; box-shadow: 4px 4px 10px #A9BCD8, -4px -4px 10px var(--light); display: flex; align-items: center; justify-content: center; }
.btn-go:hover { background: var(--blue-deep); }
.btn-go .ic { stroke-width: 2; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.chip { min-height: 44px; padding: 0 18px 0 14px; display: flex; align-items: center; gap: 8px; border-radius: 999px; background: var(--surface); box-shadow: var(--up-sm); color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 700; }
.chip:hover { color: var(--blue); }
.regions { width: 100%; margin-top: 20px; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 32px; align-items: start; }
.panel { border-radius: 24px; background: var(--surface); box-shadow: var(--glow); }
.region { border-radius: 28px; box-shadow: var(--glow-lg); padding: 24px 26px 14px; }
.region h3 { margin: 0 0 8px; display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 800; }
.region ul { list-style: none; margin: 0; padding: 0; }
.region a { display: flex; align-items: center; justify-content: space-between; min-height: 46px; color: var(--ink); text-decoration: none; }
.region a:hover { color: var(--blue); }
.well { width: 44px; height: 44px; flex: 0 0 auto; border-radius: 50%; background: var(--surface); box-shadow: var(--in-xs); display: inline-flex; align-items: center; justify-content: center; color: var(--blue); }

/* Search */
.page { padding-top: 8px; display: flex; flex-direction: column; gap: 28px; }
.search-bar { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 22px; border-radius: 999px; background: var(--surface); box-shadow: var(--in-sm); }
.search-bar input { font-size: 17px; min-height: 48px; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.title-row h1 { margin: 0; font-size: 30px; font-weight: 800; line-height: 1.25; }
.title-row .btn-round:last-child { margin-left: auto; }
.count { font-size: 20px; color: var(--slate); }
.filters { display: flex; flex-wrap: wrap; gap: 14px; }
.pill-select { position: relative; display: inline-flex; align-items: center; }
.pill-select select { appearance: none; min-height: 44px; padding: 0 38px 0 18px; border: 0; border-radius: 999px; background: var(--surface); box-shadow: var(--up-sm); font: inherit; font-size: 15px; font-weight: 700; color: var(--ink); cursor: pointer; }
.pill-select select.on { box-shadow: var(--in-sm); color: var(--blue); }
.pill-select .ic { position: absolute; right: 14px; pointer-events: none; stroke-width: 2; }
.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 20px; }
.result { padding: 16px 20px 16px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.result .well { width: 52px; height: 52px; }
.result-text { flex: 999 1 380px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.result-text a { font-size: 18px; font-weight: 800; color: var(--ink); text-decoration: none; }
.result-text a:hover { color: var(--blue); }
.result-text span { font-size: 15px; color: var(--slate); }
.result-actions { display: flex; gap: 12px; }
.empty-note { padding: 40px; text-align: center; color: var(--slate); }
.pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.pager a, .pager span { min-width: 44px; height: 44px; padding: 0 12px; border-radius: 22px; background: var(--surface); box-shadow: var(--up-sm); color: var(--ink); text-decoration: none; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.pager [aria-current="page"] { box-shadow: var(--in-sm); color: var(--blue); }
.tray { position: sticky; bottom: 24px; display: flex; justify-content: center; padding: 0 24px; margin-top: -64px; }
.tray[hidden] { display: none; }
.tray a { max-width: 100%; min-height: 56px; padding: 0 10px 0 22px; display: flex; align-items: center; gap: 14px; border-radius: 999px; background: var(--surface); box-shadow: 8px 8px 20px rgba(11, 99, 255, 0.24), -8px -8px 20px var(--light); color: var(--ink); text-decoration: none; font-weight: 700; }
.tray a > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray-go { flex: 0 0 auto; min-height: 40px; padding: 0 18px; border-radius: 999px; background: var(--blue); color: #fff; font-weight: 800; display: flex; align-items: center; }

/* School */
.school-bar { display: flex; align-items: center; gap: 16px; }
.school-head { display: flex; flex-direction: column; gap: 12px; }
.school-head h1 { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 42px; font-weight: 800; line-height: 1.2; }
.other-name { margin: 0; font-size: 17px; color: var(--slate); }
.tags { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 14px; }
.tags li { min-height: 40px; padding: 0 16px 0 12px; display: flex; align-items: center; gap: 8px; border-radius: 999px; background: var(--surface); box-shadow: var(--in-xs); font-size: 15px; font-weight: 700; }
.school-grid { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-start; }
.contact { flex: 1 1 340px; min-width: 0; border-radius: 28px; box-shadow: var(--glow-lg); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.map-well { height: 220px; border-radius: 20px; background: var(--surface); box-shadow: inset 5px 5px 12px var(--shade), inset -5px -5px 12px var(--light); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--blue); text-decoration: none; }
.coords { font-size: 13px; color: var(--slate); }
address { font-style: normal; display: flex; flex-direction: column; padding: 4px 10px; }
address a { min-height: 50px; display: flex; align-items: center; gap: 14px; color: var(--ink); text-decoration: none; }
address a:hover { color: var(--blue); }
address span { overflow-wrap: anywhere; }
.school-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 32px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 24px; }
.fact { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.fact .well { width: 48px; height: 48px; }
.fact dl { margin: 0; display: flex; flex-direction: column-reverse; gap: 2px; }
.fact dt { font-size: 13px; color: var(--slate); }
.fact dd { margin: 0; font-size: clamp(16px, 4.2vw, 19px); font-weight: 800; overflow-wrap: anywhere; }

/* Compare */
.pill-check { min-height: 48px; display: inline-flex; align-items: center; gap: 10px; padding: 0 18px; border-radius: 999px; background: var(--surface); box-shadow: var(--up-sm); font-size: 15px; font-weight: 700; cursor: pointer; }
.pill-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); }
.table-wrap { overflow-x: auto; border-radius: 28px; box-shadow: var(--glow-lg); padding: 12px 16px; }
.table-wrap table { width: 100%; min-width: 760px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.table-wrap th, .table-wrap td { padding: 14px; text-align: left; vertical-align: top; }
.table-wrap thead th { vertical-align: top; }
.table-wrap tbody th { font-size: 14px; font-weight: 500; color: var(--slate); width: 150px; }
.table-wrap tbody th span { display: flex; align-items: center; gap: 8px; }
.table-wrap td.diff { color: var(--blue); font-weight: 800; }
.table-wrap tr.same[data-hide] { display: none; }
.col-head { display: flex; align-items: flex-start; gap: 8px; }
.col-head a { flex: 1; font-size: 18px; font-weight: 800; line-height: 1.4; color: var(--ink); text-decoration: none; }
.col-head .btn-round { width: 36px; height: 36px; }
.add-col { width: 52px; height: 52px; margin: 0 auto; border-radius: 50%; background: var(--surface); box-shadow: var(--in-sm); color: var(--blue); display: flex; align-items: center; justify-content: center; }
.saved h2 { margin: 0 0 20px; display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; }
.saved-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 24px; }
.saved-list .result { flex-wrap: nowrap; }
.saved-list .result-text { flex: 1; }

.empty { align-items: center; text-align: center; padding-top: 80px; }
.btn-primary { display: inline-flex; min-height: 48px; padding: 0 24px; align-items: center; border-radius: 999px; background: var(--blue); color: #fff; text-decoration: none; font-weight: 800; }
.btn-primary:hover { background: var(--blue-deep); color: #fff; }

@media (max-width: 700px) {
  .top { padding: 14px 16px; }
  .nav { display: none; }
  main { padding: 0 16px 120px; }
  .home { padding-top: 12px; gap: 22px; }
  .search-pill { padding-left: 18px; }
  .search-pill input { font-size: 17px; }
  .chips { gap: 10px; }
  .regions { gap: 24px; }
  .school-head h1 { font-size: 30px; }
  .title-row h1 { font-size: 24px; }
  .tray { bottom: 92px; }
  .foot { padding-bottom: 110px; }
  .tabbar { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 10; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 8px; border-radius: 999px; background: var(--surface); box-shadow: 6px 6px 14px rgba(11, 99, 255, 0.20), -6px -6px 14px var(--light); }
  .tabbar a { min-height: 52px; border-radius: 999px; display: flex; align-items: center; justify-content: center; color: var(--slate); }
  .tabbar a[aria-current="page"] { box-shadow: var(--in-xs); color: var(--blue); }
}

@media print {
  .band, .top, .tabbar, .tray, .foot, .title-row .btn-round, .pill-check, .saved { display: none !important; }
  .table-wrap { box-shadow: none; }
}

.center { text-align: center; }

/* ---------- Badges ---------- */
/* Badges are transparent cut-outs. They sit in the same inset well as icons, or on a raised disc. */
.crest { flex: 0 0 auto; width: 52px; height: 52px; border-radius: 50%; background: var(--surface); box-shadow: var(--in-xs); display: inline-flex; align-items: center; justify-content: center; color: var(--blue); }
.crest img { width: 76%; height: 76%; object-fit: contain; filter: drop-shadow(0 1px 1.5px rgba(16, 27, 49, 0.14)); }
.crest-row { display: flex; align-items: center; gap: 24px; }
.head-text { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.crest-lg { width: 120px; height: 120px; box-shadow: var(--glow-lg); }
.crest-lg img { width: 80%; height: 80%; filter: drop-shadow(2px 3px 4px rgba(16, 27, 49, 0.16)); }
.col-head .crest { width: 40px; height: 40px; }
.district { display: inline-flex; align-items: center; gap: 12px; }
.tray-crests { display: flex; flex: 0 0 auto; }
.tray-crests .crest { width: 34px; height: 34px; box-shadow: var(--up-sm); }
.tray-crests .crest + .crest { margin-left: -8px; }
.title-row h1 .ic { vertical-align: -3px; margin-right: 10px; }
@media (max-width: 700px) {
  .crest-row { gap: 16px; }
  .crest-lg { width: 84px; height: 84px; }
}

/* ---------- Motion ---------- */
@view-transition { navigation: auto; }

.band { view-transition-name: band; }
.brand-mark { view-transition-name: brand; }
.tabbar { view-transition-name: tabbar; }
.page.school .crest-lg { view-transition-name: crest; }
.page.school .school-head .name { view-transition-name: school-name; }
.search-pill, .search-bar { view-transition-name: search; }
.level-panel[hidden] .search-pill { view-transition-name: none; }

::view-transition-group(*) { animation-duration: var(--t-medium); animation-timing-function: var(--ease-standard); }
::view-transition-old(root) { animation: var(--x-short) var(--ease-accelerate) both sb-fade-out; }
::view-transition-new(root) { animation: var(--t-short) var(--ease-standard) both sb-rise-in; }
::view-transition-old(band), ::view-transition-new(band),
::view-transition-old(brand), ::view-transition-new(brand),
::view-transition-old(tabbar), ::view-transition-new(tabbar) { animation: none; }
::view-transition-old(crest), ::view-transition-new(crest),
::view-transition-old(school-name), ::view-transition-new(school-name) { height: 100%; object-fit: contain; }

/* In-page list and tab updates: keep the page still and let named items move. */
html[data-vt="list"]::view-transition-old(root), html[data-vt="list"]::view-transition-new(root) { animation: none; }
html[data-vt="tab"]::view-transition-old(root) { animation: var(--x-medium) var(--ease-accelerate) both sb-slide-out; }
html[data-vt="tab"]::view-transition-new(root) { animation: var(--t-medium) var(--ease-standard) both sb-slide-in; }
html[data-vt="list"]::view-transition-new(*):only-child { animation: var(--t-short) var(--ease-standard) both sb-rise-in; }
html[data-vt="list"]::view-transition-old(*):only-child { animation: var(--x-short) var(--ease-accelerate) both sb-fade-out; }

@keyframes sb-fade-out { to { opacity: 0; } }
@keyframes sb-rise-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes sb-slide-out { to { opacity: 0; transform: translateX(calc(var(--vt-dir, 1) * -24px)); } }
@keyframes sb-slide-in { from { opacity: 0; transform: translateX(calc(var(--vt-dir, 1) * 24px)); } }
@keyframes sb-pop { from { transform: scale(0.82); } }
@keyframes sb-bump { 50% { transform: scale(1.18); } }

@media (prefers-reduced-motion: no-preference) {
  .btn-round, .chip, .pill-select select, .btn-go, .pill-check, .pager a, .tray-go, .tabbar a, .result, .region, .fact, .contact, .search-pill, .search-bar, .segmented button {
    transition: box-shadow var(--t-short) var(--ease-standard), transform var(--t-instant) var(--ease-standard), color var(--t-instant) var(--ease-standard), background-color var(--t-instant) var(--ease-standard);
  }
  .chip:hover, .result:hover, .region:hover, .fact:hover, .pager a:hover { transform: translateY(-2px); }
  .result:hover, .region:hover, .fact:hover { box-shadow: 12px 12px 26px rgba(11, 99, 255, 0.22), -10px -10px 22px var(--light); }
  .btn-round:active, .chip:active, .btn-go:active, .pill-check:active, .pager a:active, .tray a:active .tray-go, .tabbar a:active, .pill-select select:active {
    transform: scale(0.96); box-shadow: var(--in-sm);
  }
  .search-pill:focus-within { box-shadow: 14px 14px 30px rgba(11, 99, 255, 0.36), -12px -12px 26px var(--light); }
  .search-bar:focus-within { box-shadow: var(--in-sm), 0 0 0 3px rgba(0, 84, 204, 0.18); }
  .btn-round[aria-pressed="true"] .ic { animation: sb-pop var(--t-short) var(--ease-standard); }
  .badge.bump { animation: sb-bump var(--t-short) var(--ease-standard); }
  .seg-thumb.ready { transition: transform var(--t-medium) var(--ease-standard), width var(--t-medium) var(--ease-standard); }
  .segmented button { transition: color var(--t-medium) var(--ease-standard); }

  /* Entrances: lists and cards rise in sequence, capped so long lists do not wait. */
  .rise { animation: sb-rise-in var(--t-short) var(--ease-standard) both; animation-delay: calc(min(var(--i, 0), 8) * 30ms); }
  .regions > .region, .facts > .fact, .chips > .chip, .tags > li, .contact { animation: sb-rise-in var(--t-short) var(--ease-standard) both; }
  .regions > .region:nth-child(2), .facts > .fact:nth-child(2), .tags > li:nth-child(2) { animation-delay: 40ms; }
  .regions > .region:nth-child(3), .facts > .fact:nth-child(3), .tags > li:nth-child(3) { animation-delay: 80ms; }
  .facts > .fact:nth-child(4), .tags > li:nth-child(4) { animation-delay: 120ms; }
  .contact { animation-delay: 60ms; }

  .tray { transition: transform var(--t-medium) var(--ease-standard), opacity var(--t-medium) var(--ease-standard); }
  .tray.closing { transition-duration: var(--x-medium); transition-timing-function: var(--ease-accelerate); }
}
.tray.closing, .tray.opening { transform: translateY(24px); opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
