:root { --bg: #0b1430; --card: #111c3d; --ink: #e2e8f0; --mute: #94a3b8; --acc: #22c55e; --gold: #facc15; --line: #24345e; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif; }
button { font: inherit; cursor: pointer; }
#scene { position: fixed; inset: 0; }
#scene canvas { display: block; touch-action: none; }

#topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 30; min-height: 52px; display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 6px; padding: 6px 12px; background: rgba(8, 15, 38, .88); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 1.1rem; letter-spacing: .5px; }
#topbar nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#topbar nav button { background: #1e2b55; color: var(--ink); border: 1px solid #334477; border-radius: 999px; padding: 6px 12px; }
#topbar nav button:hover { background: #2a3c75; }
.badge { background: #14532d; border: 1px solid #22c55e; color: #bbf7d0; padding: 4px 10px; border-radius: 999px; font-size: .85rem; }

#dir { position: fixed; z-index: 20; left: 10px; top: 64px; bottom: 10px; width: 256px; display: flex; flex-direction: column; gap: 8px;
  background: rgba(10, 20, 50, .86); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
#dirToggle { display: none; }
#search { width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid #334477; background: #0b1430; color: var(--ink); }
#islandList { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#islandList button { width: 100%; display: flex; gap: 8px; align-items: center; text-align: left; background: transparent; color: var(--ink);
  border: 0; border-left: 4px solid var(--c); border-radius: 8px; padding: 7px 8px; margin-bottom: 4px; }
#islandList button:hover { background: #1b2a55; }
#islandList b { min-width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #0b1430; font-size: .85rem; }
#islandList small { display: block; color: var(--mute); font-size: .78rem; }
.legend { margin: 0; font-size: .78rem; color: var(--mute); line-height: 1.5; }
.tbc { display: inline-block; background: #7c2d12; color: #fed7aa; border: 1px solid #fb923c; border-radius: 6px; padding: 0 6px;
  font-size: .78em; font-weight: 700; white-space: nowrap; vertical-align: 1px; }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 10; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; pointer-events: auto; display: flex; align-items: center; gap: 5px; white-space: nowrap;
  background: rgba(8, 15, 38, .82); color: var(--ink); border: 1px solid var(--c); border-radius: 999px; padding: 3px 10px 3px 3px; font-size: .82rem; }
.lbl b { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #0b1430; font-size: .78rem; }
.lbl.on { background: var(--c); color: #0b1430; font-weight: 700; }

#panel { position: fixed; z-index: 25; right: 10px; top: 64px; bottom: 10px; width: 440px; display: flex; flex-direction: column;
  background: rgba(12, 22, 52, .97); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
#panel.hidden, .hidden { display: none !important; }
.panel-top { position: sticky; top: 0; z-index: 2; background: #0f1a40; border-bottom: 1px solid var(--line); padding: 10px 12px 0; }
.ptop-row { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
#panelHead h2 { margin: 2px 0; font-size: 1.15rem; }
#panelHead p { margin: 0 0 6px; color: var(--mute); font-size: .82rem; }
.pno { display: inline-block; background: var(--c); color: #0b1430; font-weight: 800; border-radius: 999px; padding: 1px 10px; font-size: .8rem; }
.pbtns { display: flex; gap: 6px; flex-shrink: 0; }
.close { background: #facc15; color: #111827; font-weight: 800; border: 0; border-radius: 999px; padding: 7px 12px; }
.mob-only { display: none; }
#btnCollapse { background: #1e2b55; color: var(--ink); border: 1px solid #334477; border-radius: 999px; padding: 7px 10px; }
.tabs { display: flex; gap: 4px; margin-top: 6px; }
.tabs button { flex: 1; background: transparent; color: var(--mute); border: 0; border-bottom: 3px solid transparent; padding: 8px 4px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--acc); font-weight: 700; }
#panelBody { overflow-y: auto; padding: 12px 14px 24px; flex: 1; line-height: 1.7; font-size: .95rem; }
#panelBody h4 { margin: 14px 0 6px; color: var(--gold); }
.points { padding-left: 1.3em; margin: 0; } .points li { margin-bottom: 8px; }
.src { display: inline-block; font-size: .74rem; color: #7dd3fc; background: #0b2540; border-radius: 6px; padding: 0 6px; margin-left: 2px; }
.links a { color: #86efac; word-break: break-all; }
.pending li { margin-bottom: 6px; color: #fde68a; }
.code-card { background: #0a1230; border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 12px; }
.code-card h4 { margin: 0 0 6px; color: var(--ink) !important; }
.code-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.copy { background: #166534; color: #dcfce7; border: 0; border-radius: 8px; padding: 4px 10px; flex-shrink: 0; }
pre { margin: 8px 0; max-height: 360px; overflow: auto; background: #020617; border-radius: 8px; padding: 10px; }
code { font-family: "JetBrains Mono", Consolas, "Courier New", monospace; font-size: .8rem; line-height: 1.5; color: #e2e8f0; white-space: pre; }
.verbatim { margin: 4px 0 0; font-size: .74rem; color: var(--mute); }
.empty, .hint { color: var(--mute); font-size: .85rem; }
.ws-item { background: #0a1230; border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.wtype { display: inline-block; background: #1e3a8a; color: #bfdbfe; border-radius: 6px; padding: 0 6px; font-size: .75rem; }
.wtype.orig { background: #14532d; color: #bbf7d0; }
.ws-item textarea { width: 100%; margin-top: 6px; border-radius: 8px; border: 1px solid #334477; background: #020617; color: var(--ink); padding: 8px; font: inherit; resize: vertical; }
.done { display: inline-flex; gap: 6px; align-items: center; font-size: .85rem; color: var(--mute); margin-top: 4px; }
.ws-actions button { background: #1d4ed8; color: #fff; border: 0; border-radius: 10px; padding: 8px 14px; }
#nogl { position: fixed; left: 50%; top: 45%; transform: translate(-50%, -50%); z-index: 15; background: var(--card); padding: 16px; border-radius: 12px; max-width: 80vw; }

@media (max-width: 800px) {
  .brand { font-size: 1rem; }
  #topbar nav button { padding: 5px 9px; font-size: .85rem; }
  #dir { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 60vh; border-radius: 16px 16px 0 0; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  #dirToggle { display: block; background: #1e2b55; color: var(--ink); border: 1px solid #334477; border-radius: 10px; padding: 8px; }
  #dir.collapsed #search, #dir.collapsed #islandList, #dir.collapsed .legend { display: none; }
  body.panel-open #dir { display: none !important; }
  #panel { left: 0; right: 0; bottom: 0; top: auto; width: auto; height: 62vh; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  #panel.collapsed { height: auto; }
  #panel.collapsed #panelBody, #panel.collapsed .tabs { display: none; }
  .mob-only { display: inline-block; }
  .close { padding: 6px 10px; font-size: .85rem; }
  .lbl { font-size: .72rem; padding: 2px 3px; }
  .lbl span { display: none; }
  .lbl.on span { display: inline; padding-right: 6px; }
}
.stype { display: inline-block; font-size: .7rem; border-radius: 6px; padding: 0 5px; vertical-align: 1px; }
.stype.rev { background: #422006; color: #fde68a; border: 1px solid #ca8a04; }
.stype.img { background: #3b0764; color: #e9d5ff; border: 1px solid #a855f7; }
.stype.off { background: #083344; color: #a5f3fc; border: 1px solid #06b6d4; }
.off-label { margin: 2px 0; color: #a5f3fc; font-size: .8rem; font-weight: 700; }
.revs { margin: 6px 0 0; padding-left: 1.2em; font-size: .78rem; color: #fde68a; }
.tbc.dead { background: #450a0a; color: #fecaca; border-color: #ef4444; }
s { color: var(--mute); word-break: break-all; }
