:root {
  --bg: #0f1419;
  --panel: rgba(16, 22, 28, 0.78);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #eef2f5;
  --muted: #a7b3bd;
  --accent: #7dd3fc;
  --accent-2: #fbbf24;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, sans-serif;
  overflow: hidden;
}
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
a { color: var(--accent); }

#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
#stage.hovering canvas { cursor: pointer; }

.bar {
  position: fixed; top: 12px; left: 16px; right: 16px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
.back, .title, .time {
  background: var(--panel); border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 12px;
}
.back { padding: 8px 12px; text-decoration: none; color: var(--text); font: 500 13px 'JetBrains Mono', monospace; }
.back:hover { color: var(--accent); }
.title { padding: 6px 14px; }
.title h1 { margin: 0; font: 600 17px/1.2 'Space Grotesk', sans-serif; letter-spacing: -0.01em; }
.title .sub { margin: 0; font-size: 12px; color: var(--muted); }
.views { margin-left: auto; display: flex; gap: 6px; padding: 6px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.views .chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); opacity: 1; }
.views .chip[aria-pressed="false"] { opacity: 1; }
.time { display: flex; align-items: center; gap: 8px; padding: 6px 10px; }
.time-label { font-size: 13px; min-width: 7.5ch; color: var(--accent-2); }
#time-slider { width: 130px; accent-color: var(--accent-2); }
.chip {
  font: 500 12px 'JetBrains Mono', monospace; color: var(--text);
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 5px 9px; cursor: pointer;
}
.chip:hover, .chip:focus-visible { border-color: var(--accent); }
.chip[aria-pressed="false"] { opacity: 0.55; }

.tip {
  position: fixed; left: 0; top: 0; pointer-events: none;
  padding: 5px 10px; border-radius: 8px;
  background: rgba(10, 14, 18, 0.9); border: 1px solid var(--panel-border);
  font: 500 12px 'JetBrains Mono', monospace; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 14px)); opacity: 0; transition: opacity 0.12s;
}
.tip.on { opacity: 1; }

.card {
  position: fixed; right: 16px; bottom: 16px; width: min(360px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  padding: 16px 18px 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.card[hidden] { display: none; }
.card-kicker { margin: 0 0 4px; font-size: 11px; color: var(--accent-2); text-transform: uppercase; letter-spacing: 0.08em; }
.card h2 { margin: 0 0 6px; font: 600 20px/1.25 'Space Grotesk', sans-serif; }
.card p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.card-close {
  position: absolute; top: 8px; right: 10px; background: none; border: 0;
  color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1;
}
.card-close:hover { color: var(--text); }
.card-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.card-links a {
  display: block; padding: 8px 12px; border-radius: 9px; text-decoration: none;
  background: rgba(125, 211, 252, 0.1); border: 1px solid rgba(125, 211, 252, 0.28);
  color: var(--text); font-size: 14px;
}
.card-links a:hover, .card-links a:focus-visible { background: rgba(125, 211, 252, 0.2); }
.card-links a::after { content: ' →'; color: var(--accent); }

.index { position: fixed; left: 16px; bottom: 16px; max-width: min(380px, calc(100vw - 32px)); }
.index details {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.index summary { cursor: pointer; padding: 8px 12px; font: 500 13px 'JetBrains Mono', monospace; }
.index details[open] { max-height: 60vh; overflow: auto; }
.index-intro { margin: 0 12px 8px; font-size: 13px; color: var(--muted); }
.index ul { margin: 0; padding: 0 12px 12px 30px; font-size: 13px; }
.index li { margin: 3px 0; }

.loading {
  position: fixed; inset: 0; display: grid; place-items: center;
  color: var(--muted); background: var(--bg); transition: opacity 0.5s;
}
.loading.done { opacity: 0; pointer-events: none; }
.loading.fail { white-space: normal; padding: 24px; text-align: center; }
.nojs { position: fixed; top: 45%; left: 16px; right: 16px; text-align: center; }

@media (max-width: 640px) {
  .bar { top: 10px; left: 10px; right: 10px; gap: 8px; }
  .title { display: none; }
  .views { margin-left: 0; order: 3; width: 100%; justify-content: space-between; }
  .views .chip { flex: 1; padding: 5px 4px; }
  .time { margin-left: auto; }
  #time-slider { width: 90px; }
  .card { right: 10px; left: 10px; bottom: 10px; width: auto; }
  .index { left: 10px; bottom: 10px; }
  body.card-open .index { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .tip, .loading { transition: none; }
}
