:root {
  --blue: #05acec;
  --blue-2: #a5d6f6;
  --blue-d: #007dad;
  --bg: #07090c;
  --bg-2: #10151b;
  --ink: #eef3f7;
  --ink-2: #9aa7b2;
  --ink-3: #5d6872;
  --line: rgba(255, 255, 255, 0.09);
  --glass: rgba(16, 21, 27, 0.72);
  --halo: rgba(5, 172, 236, 0.20);
  --halo-2: rgba(165, 214, 246, 0.06);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  --font: 'Inter Tight', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
:root[data-theme='light'] {
  --bg: #f5f7fa;
  --bg-2: #e6ebf0;
  --ink: #0d1318;
  --ink-2: #56616b;
  --ink-3: #98a3ad;
  --line: rgba(13, 19, 24, 0.09);
  --glass: rgba(255, 255, 255, 0.78);
  --halo: rgba(5, 172, 236, 0.14);
  --halo-2: rgba(255, 255, 255, 0.9);
  --shadow: 0 30px 70px rgba(30, 50, 70, 0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: radial-gradient(120% 90% at 50% 45%, var(--bg-2) 0%, var(--bg) 62%);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: background 0.5s;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }

/* stage */
.stage { position: fixed; inset: 0; cursor: grab; }
.stage.grabbing { cursor: grabbing; }
.stage.zoomed { cursor: move; }
.stage.tagging { cursor: crosshair; }
#spin { position: absolute; inset: 0; width: 100%; height: 100%; }
.halo {
  position: absolute; left: 50%; top: 48%; width: min(92vw, 1100px); aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, var(--halo) 0%, var(--halo-2) 45%, transparent 100%);
  filter: blur(10px);
  pointer-events: none;
  transition: transform 1.1s cubic-bezier(.2,.7,.2,1), opacity 0.8s, translate 0.2s linear;
}
.focus .halo { transform: translate(-50%, -50%) scale(1.25); opacity: 0.55; }

/* pins */
.pins { position: absolute; inset: 0; pointer-events: none; }
.pin {
  position: absolute; left: 0; top: 0; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  pointer-events: auto; display: grid; place-items: center;
  transition: opacity 0.25s;
}
.pin .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--blue); box-shadow: 0 0 0 3px rgba(5, 172, 236, 0.25), 0 0 18px 2px rgba(5, 172, 236, 0.7);
  transition: transform 0.25s;
}
.pin::before {
  content: ''; position: absolute; width: 12px; height: 12px; border-radius: 50%;
  border: 1.5px solid var(--blue-2); animation: ping 2.4s cubic-bezier(.2,.6,.3,1) infinite;
}
.pin:nth-child(2)::before { animation-delay: .6s; }
.pin:nth-child(3)::before { animation-delay: 1.2s; }
.pin:nth-child(4)::before { animation-delay: 1.8s; }
@keyframes ping { 0% { transform: scale(1); opacity: .9; } 80%, 100% { transform: scale(3.4); opacity: 0; } }
.pin .lbl {
  position: absolute; left: 30px; top: 50%; transform: translate(-6px, -50%); white-space: nowrap;
  font-size: 12.5px; font-weight: 500; letter-spacing: .01em; padding: 6px 10px 6px 8px; border-radius: 8px;
  background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
}
.pin .lbl b { font-family: var(--mono); font-weight: 500; color: var(--blue); margin-right: 7px; font-size: 11px; }
.pin:hover .lbl, .pin:focus-visible .lbl { opacity: 1; transform: translate(0, -50%); }
.pin:hover .dot { transform: scale(1.3); }
.focus .pin { opacity: 0 !important; pointer-events: none; }
.tagging .pin { pointer-events: none; }
.tagging .pin .lbl { opacity: 1; transform: translate(0, -50%); }
.pin.hidden { opacity: 0 !important; pointer-events: none; }

/* reticle on the focused part */
.reticle { position: absolute; left: 0; top: 0; width: 64px; height: 64px; margin: -32px 0 0 -32px; pointer-events: none; opacity: 0; transform: scale(1.6) rotate(45deg); transition: opacity .35s, transform .55s cubic-bezier(.2,.8,.2,1); }
.reticle.on { opacity: 1; transform: scale(1) rotate(0); }
.reticle i { position: absolute; width: 14px; height: 14px; border: 2px solid var(--blue); }
.reticle i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; }
.reticle i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; }
.reticle i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; }
.reticle i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; }
.reticle::after { content: ''; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 14px var(--blue); }

.leader { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; transition: opacity .3s; }
.leader.on { opacity: 1; }
.leader path { stroke: var(--blue); stroke-width: 1.2; stroke-dasharray: 4 4; }
.leader circle { fill: var(--blue); stroke: none; }

/* ident + tools */
.ident { position: fixed; left: 32px; top: calc(28px + var(--safe-t)); pointer-events: none; transition: opacity .4s; }
.brand { font-weight: 700; font-size: 13px; letter-spacing: .32em; text-transform: uppercase; color: var(--blue); }
.ident h1 { font-weight: 500; font-size: clamp(20px, 2.1vw, 30px); letter-spacing: -.01em; margin-top: 10px; max-width: 16ch; line-height: 1.1; }
.ident .meta { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); }
.ident .sep { width: 18px; height: 1px; background: var(--ink-3); }
.tools { position: fixed; right: 24px; top: calc(24px + var(--safe-t)); display: flex; gap: 6px; }
.icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: var(--ink-2); border: 1px solid transparent; transition: color .2s, background .2s, border-color .2s; }
.icon svg { width: 20px; height: 20px; }
.icon:hover, .icon.on { color: var(--ink); background: var(--glass); border-color: var(--line); }

/* headline stats */
.headline { position: fixed; left: 32px; bottom: calc(118px + var(--safe-b)); display: flex; gap: 28px; pointer-events: none; transition: opacity .4s, transform .4s; }
.headline div { display: flex; flex-direction: column; gap: 4px; }
.headline .v { font-size: 30px; font-weight: 300; letter-spacing: -.02em; }
.headline .v small { font-size: 13px; font-weight: 500; color: var(--blue); margin-left: 3px; letter-spacing: 0; }
.headline .l { font-family: var(--mono); font-size: 10.5px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .08em; }
.focus .headline, .focus .ident { opacity: 0; }

/* bottom dock: angle dial + chapters */
.dock { position: fixed; left: 0; right: 0; bottom: calc(22px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 14px; pointer-events: none; }
.dial { position: relative; width: min(420px, 80vw); height: 30px; overflow: hidden; pointer-events: auto; cursor: ew-resize; -webkit-mask: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent); mask: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent); }
.ticks { position: absolute; left: 50%; top: 0; height: 16px; display: flex; will-change: transform; }
.ticks i { flex: 0 0 auto; width: 12px; height: 100%; position: relative; }
.ticks i::after { content: ''; position: absolute; left: 0; bottom: 0; width: 1px; height: 6px; background: var(--ink-3); }
.ticks i.major::after { height: 12px; background: var(--ink-2); }
.needle { position: absolute; left: 50%; top: 0; width: 2px; height: 16px; margin-left: -1px; background: var(--blue); border-radius: 1px; box-shadow: 0 0 8px var(--blue); }
.deg { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); font-family: var(--mono); font-size: 10.5px; color: var(--ink-2); }

.chapters { display: flex; align-items: center; gap: 2px; padding: 5px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); pointer-events: auto; box-shadow: var(--shadow); }
.chap { position: relative; height: 38px; padding: 0 14px; border-radius: 11px; font-size: 13px; font-weight: 500; color: var(--ink-2); display: flex; align-items: center; gap: 8px; overflow: hidden; transition: color .2s, background .2s; white-space: nowrap; }
.chap b { font-family: var(--mono); font-size: 10.5px; font-weight: 500; color: var(--ink-3); }
.chap:hover { color: var(--ink); }
.chap.on { color: var(--ink); background: rgba(5, 172, 236, .14); }
.chap.on b { color: var(--blue); }
.chap .fillbar { position: absolute; left: 0; bottom: 0; height: 2px; width: 0; background: var(--blue); }
.play { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: var(--ink-2); }
.play svg { width: 16px; height: 16px; }
.play:hover, .play.on { color: var(--blue); }

.hint { position: fixed; left: 50%; bottom: calc(140px + var(--safe-b)); transform: translateX(-50%); font-size: 12px; color: var(--ink-2); letter-spacing: .02em; padding: 7px 14px; border-radius: 99px; border: 1px solid var(--line); pointer-events: none; transition: opacity .8s; white-space: nowrap; }
.hint.gone { opacity: 0; }

/* feature card */
.card {
  position: fixed; right: max(32px, 5vw); top: 50%; width: min(380px, 34vw); padding: 26px 26px 18px;
  border-radius: 20px; background: var(--glass); border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.2); -webkit-backdrop-filter: blur(22px) saturate(1.2);
  transform: translate(24px, -50%); opacity: 0; pointer-events: none;
  transition: opacity .4s, transform .55s cubic-bezier(.2,.8,.2,1);
}
.card.on { opacity: 1; transform: translate(0, -50%); pointer-events: auto; }
.card .handle { display: none; }
.card .close, .specs .close { position: absolute; right: 14px; top: 14px; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--ink-2); }
.card .close:hover, .specs .close:hover { color: var(--ink); background: var(--line); }
.card .close svg, .specs .close svg { width: 18px; height: 18px; }
.kicker { display: flex; gap: 10px; align-items: center; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--blue); }
.kicker span:first-child { color: var(--ink-3); }
.card h2, .specs h2 { font-size: 28px; font-weight: 500; letter-spacing: -.015em; margin: 12px 0 12px; line-height: 1.1; }
.card p { font-size: 14.5px; line-height: 1.6; color: var(--ink-2); }
.cimg { display: none; margin: 18px 0 0; height: 230px; border-radius: 14px; background: radial-gradient(closest-side, rgba(5, 172, 236, .16), transparent 80%), var(--line); overflow: hidden; }
.cimg.on { display: flex; align-items: center; justify-content: center; }
.cimg img { display: block; height: 100%; width: auto; max-width: 100%; padding: 22px 24px; box-sizing: border-box; object-fit: contain; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 1px; margin-top: 20px; border-radius: 12px; overflow: hidden; background: var(--line); }

.stats > div { background: var(--glass); padding: 12px 12px 11px; }
.stats .v { font-size: 17px; font-weight: 500; }
.stats .l { font-family: var(--mono); font-size: 10px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }
.cardnav { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; font-size: 13px; color: var(--ink-2); }
.cardnav button { padding: 8px 6px; color: var(--ink-2); }
.cardnav button:hover { color: var(--blue); }
.cardnav span { font-family: var(--mono); font-size: 11px; }

/* specs panel */
.specs {
  position: fixed; right: 0; top: 0; bottom: 0; width: min(420px, 100vw); padding: calc(32px + var(--safe-t)) 30px 30px;
  background: var(--glass); border-left: 1px solid var(--line); backdrop-filter: blur(26px); -webkit-backdrop-filter: blur(26px);
  transform: translateX(102%); transition: transform .5s cubic-bezier(.2,.8,.2,1); overflow-y: auto; touch-action: pan-y; user-select: text;
}
.specs.on { transform: none; }
.specs h3 { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--blue); margin: 26px 0 8px; font-weight: 500; }
.specs .row { display: flex; justify-content: space-between; gap: 18px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.specs .row span:first-child { color: var(--ink-2); }
.specs .row span:last-child { text-align: right; }

/* tag mode */
.tagbar { position: fixed; left: 50%; top: calc(20px + var(--safe-t)); transform: translate(-50%, -150%); display: flex; gap: 10px; align-items: center; padding: 8px 10px 8px 16px; border-radius: 14px; background: var(--glass); border: 1px solid var(--blue); backdrop-filter: blur(16px); font-size: 13px; transition: transform .4s; z-index: 5; }
.tagbar.on { transform: translate(-50%, 0); }
.tagbar span { color: var(--ink-2); }
.tagbar select, .tagbar button { font: inherit; font-size: 12.5px; padding: 7px 11px; border-radius: 9px; background: var(--line); color: var(--ink); border: 0; }
.tagbar button:hover { background: var(--blue); color: #fff; }

/* loader */
.loader { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--bg); z-index: 10; transition: opacity .6s; font-family: var(--mono); font-size: 11px; color: var(--ink-2); }
.loader.gone { opacity: 0; pointer-events: none; }
.loader .ring { width: 54px; height: 54px; }
.loader circle { stroke: var(--line); stroke-width: 2; }
.loader #loadArc { stroke: var(--blue); stroke-dasharray: 107; stroke-dashoffset: 107; transform: rotate(-90deg); transform-origin: center; transition: stroke-dashoffset .2s; }

/* phones */
@media (max-width: 760px) {
  .ident { left: 20px; top: calc(18px + var(--safe-t)); }
  .ident h1 { font-size: 19px; }
  .tools { right: 12px; top: calc(14px + var(--safe-t)); gap: 0; }
  .headline { left: 20px; right: 20px; bottom: calc(126px + var(--safe-b)); gap: 0; justify-content: space-between; }
  .headline .v { font-size: 22px; }
  .hint { bottom: calc(196px + var(--safe-b)); font-size: 11px; }
  .chap { padding: 0 11px; }
  .chap span { display: none; }
  .chap.on span { display: inline; }
  .pin .lbl { display: none; }
  .card { left: 0; right: 0; top: auto; bottom: 0; width: auto; border-radius: 22px 22px 0 0; padding: 14px 22px calc(18px + var(--safe-b)); transform: translateY(105%); max-height: 54vh; overflow-y: auto; }
  .card.on { transform: none; }
  .card .handle { display: block; width: 38px; height: 4px; border-radius: 2px; background: var(--ink-3); margin: 0 auto 14px; }
  .card h2 { font-size: 23px; margin: 8px 0; }
  .card p { font-size: 14px; line-height: 1.5; }
  .stats { margin-top: 14px; }
  .cimg { height: 170px; margin-top: 12px; }
  .cimg img { padding: 16px 18px; }
  .stats > div { padding: 9px 10px; }
  .stats .v { font-size: 15px; }
  .stats .l { font-size: 9.5px; }
  .cardnav { margin-top: 8px; }
  /* the menu fades out under the card: its buttons must not catch taps meant for the card */
  .focus .dock { opacity: 0; pointer-events: none; }
  .focus .dock * { pointer-events: none !important; }
  .card { z-index: 4; }
  .dock { transition: opacity .3s; }
}
