@font-face { font-family: "Inter"; src: url("../fonts/InterVariable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/plexmono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/plexmono-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/plexmono-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --bg: #020309;
  --ink: #DDE3EE;
  --muted: #8A93A6;
  --faint: #5A6378;
  --line: rgba(221, 227, 238, 0.14);
  --glass: rgba(8, 11, 22, 0.62);
  --glass-hi: rgba(14, 18, 34, 0.86);
  --yellow: #FFD21E;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gut: 22px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); overflow: hidden;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#gl { touch-action: none; cursor: grab; }
#gl.drag { cursor: grabbing; }
#gl.over { cursor: pointer; }
#overlay { pointer-events: none; }
button, input, select { font: inherit; color: inherit; }
.ui { position: fixed; z-index: 5; }

/* brand + counter */
#brand { left: var(--gut); top: calc(var(--gut) - 2px); pointer-events: none; text-shadow: 0 1px 8px rgba(0,0,0,0.75), 0 0 2px rgba(0,0,0,0.6); }
#brand::before { content: ""; position: absolute; z-index: -1; left: -60px; top: -60px; width: 480px; height: 220px; background: radial-gradient(closest-side, rgba(2,3,9,0.6), rgba(2,3,9,0)); pointer-events: none; }
#brand .title { font-size: 13px; letter-spacing: 0.02em; font-weight: 500; }
#brand .hf { color: var(--yellow); font-weight: 600; }
#brand .sub { color: var(--muted); }
#brand .counter { margin-top: 12px; font-family: var(--mono); font-weight: 500; font-size: 30px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
#brand .counter .unit { font-family: var(--sans); font-size: 14px; color: var(--muted); font-weight: 400; letter-spacing: 0; }
#brand .when { margin-top: 6px; font-family: var(--mono); font-size: 13px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }

/* search */
#searchbox { z-index: 8; right: calc(var(--gut) + 92px); top: var(--gut); width: 360px; }
.search { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 19px; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: border-color .2s; }
.search:focus-within { border-color: rgba(255, 210, 30, 0.55); }
.search svg { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-family: var(--mono); font-size: 13px; }
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button { filter: invert(0.6); }
#suggest { list-style: none; margin: 6px 0 0; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--glass-hi); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); max-height: 60vh; overflow: auto; }
#suggest li { display: flex; align-items: baseline; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-family: var(--mono); font-size: 12.5px; }
#suggest li .id { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#suggest li .id b { color: var(--yellow); font-weight: 500; }
#suggest li .meta { color: var(--faint); font-size: 11.5px; white-space: nowrap; }
#suggest li.on, #suggest li:hover { background: rgba(255, 255, 255, 0.07); }
#suggest li.fam .id::before { content: "family · "; color: var(--muted); }
#searchmsg { margin-top: 6px; padding: 7px 12px; font-size: 12px; color: var(--muted); border-radius: 10px; background: var(--glass); }

.iconbtn { width: 38px; height: 38px; border-radius: 19px; border: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: grid; place-items: center; cursor: pointer; padding: 0; transition: border-color .2s, background .2s; }
.iconbtn:hover { border-color: rgba(221, 227, 238, 0.35); }
.iconbtn svg { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linecap: round; }
#aboutbtn { right: var(--gut); top: var(--gut); font-family: Georgia, serif; font-style: italic; font-size: 17px; }
#ctlbtn { right: calc(var(--gut) + 46px); top: var(--gut); }
#ctlbtn.on { border-color: rgba(255, 210, 30, 0.5); }

/* controls */
.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
#controls { right: var(--gut); top: calc(var(--gut) + 50px); width: 320px; padding: 12px 14px; display: flex; flex-direction: column; gap: 11px; transition: opacity .25s, transform .25s; }
#controls.hide { opacity: 0; transform: translateY(-6px); pointer-events: none; }
#controls .row { display: flex; align-items: center; gap: 10px; }
#controls .lbl { width: 76px; white-space: nowrap; flex: none; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.seg { display: flex; flex: 1; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { flex: 1; background: none; border: 0; padding: 6px 4px; font-size: 12px; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { color: #0B0F19; background: var(--yellow); font-weight: 600; }
select { flex: 1; min-width: 0; appearance: none; -webkit-appearance: none; background: rgba(255,255,255,0.04) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238A93A6' stroke-width='1.3'/%3E%3C/svg%3E") no-repeat right 10px center / 10px 6px;
  border: 1px solid var(--line); border-radius: 9px; padding: 6px 28px 6px 10px; font-size: 12.5px; cursor: pointer; outline: 0; }
select option { background: #0B0F19; color: var(--ink); }
.legend { flex-wrap: wrap; gap: 6px 12px !important; font-size: 11.5px; color: var(--muted); }
.legend:empty { display: none !important; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; box-shadow: 0 0 6px currentColor; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); cursor: pointer; margin-right: 14px; user-select: none; }
.toggle input { display: none; }
.toggle .sw { width: 28px; height: 16px; border-radius: 8px; background: rgba(255,255,255,0.12); position: relative; transition: background .2s; }
.toggle .sw::after { content: ""; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--ink); transition: transform .2s; }
.toggle input:checked + .sw { background: rgba(255, 210, 30, 0.85); }
.toggle input:checked + .sw::after { transform: translateX(12px); background: #0B0F19; }

/* timeline */
#timebar { left: 50%; transform: translateX(-50%); bottom: calc(var(--gut) + env(safe-area-inset-bottom)); width: min(760px, calc(100% - 2 * var(--gut))); display: flex; align-items: center; gap: 14px; }
#play { flex: none; width: 42px; height: 42px; border-radius: 21px; }
#play svg { fill: var(--ink); stroke: none; width: 16px; height: 16px; }
#play .i-pause { display: none; }
#play.playing .i-play { display: none; }
#play.playing .i-pause { display: block; }
.track { position: relative; flex: 1; height: 42px; }
#time { position: absolute; left: 0; right: 0; top: 8px; width: 100%; margin: 0; height: 16px; background: none; -webkit-appearance: none; appearance: none; cursor: pointer; }
#time::-webkit-slider-runnable-track { height: 2px; border-radius: 1px; background: linear-gradient(90deg, rgba(255,210,30,0.85) var(--p, 100%), rgba(221,227,238,0.18) var(--p, 100%)); }
#time::-moz-range-track { height: 2px; background: rgba(221,227,238,0.18); }
#time::-moz-range-progress { height: 2px; background: rgba(255,210,30,0.85); }
#time::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -6px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 4px rgba(255,210,30,0.18), 0 0 12px rgba(255,210,30,0.6); border: 0; }
#time::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--yellow); border: 0; box-shadow: 0 0 12px rgba(255,210,30,0.6); }
.ticks { position: absolute; left: 7px; right: 7px; top: 27px; height: 14px; pointer-events: none; }
.ticks span { position: absolute; transform: translateX(-50%); font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.ticks span::before { content: ""; position: absolute; left: 50%; top: -9px; width: 1px; height: 5px; background: rgba(221,227,238,0.25); }

#status { left: var(--gut); bottom: calc(var(--gut) + 6px + env(safe-area-inset-bottom)); font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 10px; transition: opacity .6s; font-family: var(--mono); }
#status .bar { width: 90px; height: 2px; background: rgba(221,227,238,0.15); border-radius: 1px; overflow: hidden; }
#status .bar i { display: block; height: 100%; width: 0; background: var(--yellow); transition: width .3s; }
#status.done { opacity: 0; }
#hint { left: 50%; transform: translateX(-50%); bottom: calc(var(--gut) + 56px + env(safe-area-inset-bottom)); font-size: 12px; color: var(--muted); pointer-events: none; transition: opacity 1.2s; white-space: nowrap; text-shadow: 0 1px 6px #000; }
#hint.gone { opacity: 0; }

/* hover / pinned card */
.card { position: fixed; z-index: 7; min-width: 240px; max-width: 340px; padding: 12px 14px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--glass-hi); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5); pointer-events: none; transition: opacity .15s; }
.card.pinned { pointer-events: auto; border-color: rgba(255, 210, 30, 0.38); }
.card .x { display: none; position: absolute; right: 6px; top: 4px; background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 2px 6px; }
.card.pinned .x { display: block; }
.card .cid { font-family: var(--mono); font-weight: 500; font-size: 13px; word-break: break-all; padding-right: 16px; }
.card .cid .org { color: var(--muted); font-weight: 400; }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 9px 0 0; font-size: 12px; }
.card dt { color: var(--faint); }
.card dd { margin: 0; color: var(--ink); }
.card dd .sw { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.card .acts { display: none; gap: 8px; margin-top: 11px; }
.card.pinned .acts { display: flex; }
.btn { display: inline-flex; align-items: center; justify-content: center; height: 30px; padding: 0 12px; border-radius: 8px; font-size: 12px; font-weight: 600; text-decoration: none; cursor: pointer;
  background: var(--yellow); color: #0B0F19; border: 0; }
.btn.ghost { background: none; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.btn.off { opacity: .45; pointer-events: none; }

/* about */
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(2, 3, 9, 0.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); padding: 16px; }
.modal[hidden] { display: none; }
.sheet { position: relative; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; padding: 24px 26px 18px; border: 1px solid var(--line); border-radius: 16px; background: rgba(9, 12, 24, 0.94); font-size: 13.5px; line-height: 1.55; color: #C9D0DD; }
.sheet h2 { margin: 0 0 12px; font-size: 17px; color: var(--yellow); font-weight: 600; }
.sheet b { color: var(--ink); font-weight: 600; }
.sheet code { font-family: var(--mono); font-size: 12px; color: var(--ink); }
.sheet a { color: var(--yellow); }
.sheet .x { position: absolute; right: 10px; top: 8px; background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; }
.sheet .keys { color: var(--muted); font-size: 12px; }
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); }
#nogl[hidden] { display: none; }
#nogl { position: fixed; inset: 0; display: grid; place-items: center; z-index: 20; color: var(--muted); }

/* phones */
@media (max-width: 760px) {
  :root { --gut: 16px; }
  #brand .title .sub { display: none; }
  #brand .title { font-size: 12px; }
  #brand .counter { font-size: 22px; margin-top: 8px; }
  #brand .when { font-size: 11.5px; }
  #searchbox { left: var(--gut); right: var(--gut); top: calc(var(--gut) + 92px); width: auto; }
  #controls { left: var(--gut); right: var(--gut); width: auto; top: calc(var(--gut) + 140px); }
  #ctlbtn { right: calc(var(--gut) + 46px); }
  #hint { display: none; }
  .card { left: 12px !important; right: 12px; max-width: none; bottom: calc(86px + env(safe-area-inset-bottom)); top: auto !important; }
  #status { bottom: calc(var(--gut) + 58px + env(safe-area-inset-bottom)); }
  .ticks span.mid { display: none; }
}

.hourglass { color: var(--muted, #8B93A7); vertical-align: -2px; animation: hg 1.6s ease-in-out infinite; }
@keyframes hg { 0%, 40% { transform: rotate(0); } 60%, 100% { transform: rotate(180deg); } }
