:root {
  --bg: #04070f;
  --panel: rgba(9, 15, 30, 0.78);
  --line: rgba(122, 152, 220, 0.22);
  --text: #eaf0fc;
  --muted: #97a5c4;
  --accent: #ff7a45;
  --cyan: #5ac2ff;
  --gold: #ffd479;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
.school-logo { width: 46px; height: 46px; object-fit: contain; }
.brand small { display: block; font-size: 11px; letter-spacing: 0; color: var(--muted); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }
.p-hero .visual { display: block; min-width: 0; border: 1px solid var(--line); border-radius: 16px; padding: 12px; background: var(--panel); }
#planetViewer { width: 100%; height: 350px; border-radius: 12px; overflow: hidden; }
#planetViewer canvas { display: block; touch-action: none; }
#viewerHelp, #viewerStatus { font-size: 12px; color: var(--muted); line-height: 1.7; margin: 8px 0; }
.viewer-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.viewer-tools .ctl-btn { min-height: 44px; display: inline-flex; align-items: center; }
.visual.expanded { position: fixed; inset: 12px; z-index: 100; background: var(--bg); display: flex; flex-direction: column; margin: 0; }
.visual.expanded #planetViewer { flex: 1; min-height: 0; height: auto; }
.viewer-open { overflow: hidden; }
@media (max-width: 640px) {
  .school-logo { width: 38px; height: 38px; }
  .brand small { font-size: 10px; }
  .topbar .nav { width: 100%; }
  .page { padding-top: 128px; }
  #planetViewer { height: 300px; }
  .p-hero .info { order: -2; }
  .visual.expanded { inset: 6px; }
  .controls { top: 110px; }
}
@media (prefers-reduced-motion: reduce) { .p-hero .visual img { animation: none; } }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px;
  background: linear-gradient(180deg, rgba(4,7,15,.85), rgba(4,7,15,0));
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: 1px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffd479, #ff8a3d 60%, #b34700);
  box-shadow: 0 0 14px rgba(255, 170, 60, .55);
}
.nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.nav a {
  color: var(--muted); font-size: 14px; padding: 7px 12px; border-radius: 8px;
  border: 1px solid transparent;
}
.nav a:hover { color: var(--text); border-color: var(--line); text-decoration: none; }
.nav a.active { color: var(--text); border-color: var(--line); background: var(--panel); }

/* ---------- home scene ---------- */
#scene { position: fixed; inset: 0; z-index: 0; }
#scene canvas { display: block; }
#labels { position: fixed; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
.p-label {
  position: absolute; transform: translate(-50%, -140%);
  font-size: 12px; color: rgba(234,240,252,.92); letter-spacing: 1px;
  padding: 2px 8px; border-radius: 6px; white-space: nowrap;
  background: rgba(6,10,22,.55); border: 1px solid rgba(122,152,220,.25);
  transition: opacity .2s;
}
.p-label.hot { color: var(--gold); border-color: rgba(255,212,121,.5); }

.hero {
  position: fixed; z-index: 10; left: 34px; top: 50%; transform: translateY(-52%);
  max-width: 400px; pointer-events: none;
}
.hero h1 { font-size: clamp(28px, 3.6vw, 46px); line-height: 1.25; font-weight: 900; text-shadow: 0 2px 18px rgba(0,0,0,.8); }
.hero p.sub { margin-top: 14px; color: var(--muted); font-size: 15px; line-height: 1.7; }
.hero .cta {
  pointer-events: auto; display: inline-block; margin-top: 22px;
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 13px 26px; font-size: 16px; font-weight: 700; letter-spacing: 1px;
}
.hero .cta:hover { background: #ff8f63; }
.hero .hints { margin-top: 18px; display: flex; gap: 14px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.hero .hints span { display: inline-flex; align-items: center; gap: 5px; }
.hero .note { margin-top: 14px; font-size: 11.5px; color: rgba(151,165,196,.75); }

/* controls */
.controls {
  position: fixed; z-index: 10; top: 74px; right: 26px;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
}
.controls .row { display: flex; gap: 8px; }
.ctl-btn {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 14px; font-size: 13px; letter-spacing: 1px;
  backdrop-filter: blur(6px);
}
.ctl-btn:hover { border-color: var(--cyan); }
.ctl-btn.on { color: var(--cyan); border-color: rgba(90,194,255,.55); }
.speed-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 14px; font-size: 12.5px; color: var(--muted);
  display: flex; align-items: center; gap: 10px; backdrop-filter: blur(6px);
}
.speed-box input[type=range] { width: 130px; accent-color: var(--cyan); }
.speed-box b { color: var(--text); min-width: 38px; text-align: right; }

/* bottom planet strip */
.strip {
  position: fixed; z-index: 10; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 10px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  backdrop-filter: blur(8px); max-width: 94vw; overflow-x: auto;
}
.strip .cap { writing-mode: vertical-lr; font-size: 11px; color: var(--muted); letter-spacing: 3px; align-self: center; padding-right: 4px; }
.strip button {
  background: none; border: 1px solid transparent; border-radius: 12px;
  padding: 7px 9px 6px; display: flex; flex-direction: column; align-items: center; gap: 5px;
  color: var(--muted); font-size: 12px; letter-spacing: 1px; min-width: 62px;
}
.strip button img { width: 40px; height: 40px; object-fit: contain; }
.strip button:hover { border-color: var(--line); color: var(--text); background: rgba(90,194,255,.06); }

/* loading */
#loading {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; flex-direction: column; gap: 16px; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px; letter-spacing: 2px; transition: opacity .6s;
}
#loading .orb { width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--gold); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- detail page ---------- */
.page { position: relative; z-index: 1; max-width: 1080px; margin: 0 auto; padding: 96px 26px 40px; }
.p-hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 30px; align-items: center; margin-bottom: 34px; }
.p-hero .info .kicker { color: var(--muted); font-size: 13px; letter-spacing: 3px; }
.p-hero h1 { font-size: clamp(38px, 5vw, 60px); font-weight: 900; margin: 6px 0 2px; }
.p-hero .en { color: var(--muted); font-size: 18px; letter-spacing: 2px; }
.badge {
  display: inline-block; margin-top: 12px; padding: 5px 14px; border-radius: 999px;
  font-size: 13px; border: 1px solid var(--line); color: var(--gold); background: var(--panel);
}
.p-hero .tagline { margin-top: 14px; font-size: 17px; font-weight: 700; }
.p-hero .intro { margin-top: 12px; color: var(--muted); line-height: 1.9; font-size: 15px; }
.p-hero .visual { display: block; }
.p-hero .visual.expanded { display: flex; }
.p-hero .visual img {
  width: min(360px, 80%); filter: drop-shadow(0 0 40px rgba(90,140,255,.25));
  animation: float 7s ease-in-out infinite;
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-16px); } }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 34px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
}
.stat .k { color: var(--muted); font-size: 12.5px; letter-spacing: 1px; margin-bottom: 6px; }
.stat .v { font-size: 15px; font-weight: 700; line-height: 1.5; overflow-wrap: anywhere; }

.section { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px; margin-bottom: 16px; }
.section h2 { font-size: 19px; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.section h2 .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--cyan); }
.section p { color: var(--muted); line-height: 1.95; font-size: 14.5px; }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.fact {
  border: 1px solid var(--line); border-radius: 12px; padding: 15px 17px;
  background: rgba(90,194,255,.04); font-size: 14px; line-height: 1.75; color: var(--text);
}
.fact b { color: var(--gold); margin-right: 8px; }

.pager { display: flex; justify-content: space-between; gap: 12px; margin: 30px 0 10px; }
.pager a {
  flex: 1; display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; color: var(--text);
}
.pager a:hover { border-color: var(--cyan); text-decoration: none; }
.pager a.next { justify-content: flex-end; text-align: right; }
.pager img { width: 42px; height: 42px; object-fit: contain; }
.pager .t small { display: block; color: var(--muted); font-size: 11.5px; letter-spacing: 1px; }
.pager .t span { font-weight: 700; }

.footer { text-align: center; color: rgba(151,165,196,.7); font-size: 12.5px; padding: 26px 0 34px; line-height: 1.9; }

/* starfield for detail pages */
#bgstars { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

@media (max-width: 860px) {
  .hero { left: 20px; right: 20px; top: auto; bottom: 120px; transform: none; max-width: none; }
  .hero h1 { font-size: 26px; }
  .hero p.sub, .hero .hints, .hero .note { display: none; }
  .hero .cta { margin-top: 12px; padding: 10px 20px; font-size: 14px; }
  .controls { top: 66px; right: 14px; }
  .speed-box input[type=range] { width: 80px; }
  .p-hero { grid-template-columns: 1fr; }
  .p-hero .visual { order: -1; }
  .p-hero .visual img { width: min(240px, 60%); }
  .nav a { padding: 6px 8px; font-size: 12.5px; }
}

/* ---------- phone: detail page reading comfort ---------- */
@media (max-width: 640px) {
  .topbar {
    padding: 10px 14px; gap: 4px 10px; flex-wrap: wrap;
    background: rgba(4, 7, 15, .92); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
  }
  .brand { font-size: 16px; }
  .brand .logo { width: 28px; height: 28px; }
  .nav { gap: 2px; }
  .nav a { padding: 6px 8px; font-size: 12px; }

  .page { padding: 112px 16px 28px; }
  .p-hero { gap: 18px; margin-bottom: 24px; }
  .p-hero .visual img { width: min(210px, 55%); }
  .p-hero .info .kicker { font-size: 12px; letter-spacing: 2px; }
  .p-hero .en { font-size: 15px; }
  .p-hero .tagline { font-size: 16px; margin-top: 12px; }
  .p-hero .intro { font-size: 15px; line-height: 1.9; }

  /* 2-column compact stats; long values span full width */
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 24px; }
  .stat { padding: 11px 12px; border-radius: 10px; }
  .stat .k { font-size: 11px; margin-bottom: 4px; letter-spacing: .5px; }
  .stat .v { font-size: 13px; line-height: 1.55; }
  .stat:nth-child(7), .stat:nth-child(8), .stat:nth-child(9) { grid-column: 1 / -1; }

  .section { padding: 18px 16px; border-radius: 12px; margin-bottom: 12px; }
  .section h2 { font-size: 17px; margin-bottom: 10px; }
  .section p { font-size: 15px; line-height: 1.9; }

  .facts { grid-template-columns: 1fr; gap: 8px; }
  .fact { padding: 13px 14px; font-size: 14px; line-height: 1.8; }

  .pager { flex-direction: column; gap: 8px; margin: 22px 0 6px; }
  .pager a { padding: 12px 14px; }
  .pager img { width: 36px; height: 36px; }

  .footer { font-size: 11.5px; padding: 20px 16px 28px; }
  .controls { top: 116px; }
  .page { padding-top: 128px; }
}