:root {
  --bg: #05070b;
  --glass: rgba(10, 13, 19, .78);
  --line: rgba(255, 255, 255, .1);
  --text: #e6ebf2;
  --muted: #8d99aa;
  --accent: #9cc0ff;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, sans-serif; overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: var(--accent); }

#app { position: fixed; inset: 0; }
#stage { position: absolute; inset: 0; touch-action: none; cursor: grab; }
#stage.dragging { cursor: grabbing; }
#sky { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.bar { position: absolute; z-index: 5; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  background: linear-gradient(to bottom, rgba(5, 7, 11, .85), rgba(5, 7, 11, 0)); pointer-events: none; }
.bar > * { pointer-events: auto; }
.back { display: flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 13px; padding: 6px 8px 6px 4px; border-radius: 8px; }
.back:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.titles { flex: 1; min-width: 0; }
.titles h1 { margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titles p { margin: 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titles p:empty { display: none; }
.tools { display: flex; gap: 6px; align-items: center; }
.tools .icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px); }
.tools .icon:hover, .tools .icon[aria-expanded="true"] { border-color: rgba(255, 255, 255, .25); }
.pill { height: 34px; padding: 0 14px; border-radius: 17px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px); font-weight: 500; font-size: 13px; color: var(--muted); }
.pill.on { color: #0b1220; background: var(--accent); border-color: var(--accent); }

.loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .12); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.readout { position: absolute; left: 12px; bottom: max(12px, env(safe-area-inset-bottom)); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #c9d4e2; background: rgba(5, 8, 12, .7); padding: 4px 9px; border-radius: 6px; pointer-events: none; white-space: nowrap; }
.tip { position: absolute; z-index: 4; pointer-events: none; background: rgba(12, 16, 22, .95); border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 8px; padding: 6px 10px; font-size: 12.5px; max-width: 280px; }
.tip b { color: #fff; font-weight: 600; }
.tip .sub { color: var(--muted); }

.zoom { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); display: grid; gap: 4px; }
.zoom button { width: 36px; height: 36px; border-radius: 9px; background: var(--glass); border: 1px solid var(--line); font-size: 18px; line-height: 1; display: grid; place-items: center; backdrop-filter: blur(8px); }
.zoom button:hover { border-color: rgba(255, 255, 255, .25); }

.pop { position: absolute; z-index: 6; top: calc(max(10px, env(safe-area-inset-top)) + 44px); right: 12px; width: 240px;
  background: rgba(12, 15, 21, .96); border: 1px solid var(--line); border-radius: 12px; padding: 8px; box-shadow: 0 16px 40px rgba(0, 0, 0, .5); }
.pop label { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; user-select: none; }
.pop label:hover { background: rgba(255, 255, 255, .05); }
.pop input { margin: 0; accent-color: var(--accent); }
.pop .sw { width: 14px; height: 3px; border-radius: 2px; flex: none; }
.pop .row { display: grid; grid-template-columns: 1fr 100px; align-items: center; gap: 8px; padding: 6px 8px 2px; color: var(--muted); font-size: 12px; }
.pop .row input { width: 100%; }
.pop hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }

.drawer { position: absolute; z-index: 6; top: 0; right: 0; bottom: 0; width: min(380px, 100%); overflow-y: auto;
  padding: calc(max(10px, env(safe-area-inset-top)) + 56px) 22px 28px; background: rgba(9, 12, 17, .94); border-left: 1px solid var(--line);
  backdrop-filter: blur(10px); }
.drawer .close { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 10px); right: 12px; width: 34px; height: 34px; font-size: 22px; color: var(--muted); border-radius: 9px; }
.drawer .close:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.drawer h2 { margin: 0; font-size: 20px; font-weight: 600; line-height: 1.25; }
.drawer .sub { margin: 4px 0 14px; color: var(--muted); font-size: 13px; }
.drawer .sub:empty { display: none; }
.drawer .caption p { margin: 0 0 12px; color: #cfd7e3; }
.facts { list-style: none; margin: 16px 0; padding: 12px 0 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.facts li { margin: 3px 0; }
.how { font-size: 12.5px; color: var(--muted); margin: 16px 0 10px; }
.keys { font-size: 12px; color: var(--muted); }
kbd { font: 11px ui-monospace, Menlo, monospace; border: 1px solid rgba(255, 255, 255, .18); border-radius: 4px; padding: 0 4px; color: #c9d2de; }
.credit { margin-top: 18px; font-size: 12px; color: var(--muted); }

@media (max-width: 640px) {
  .back span { display: none; }
  .titles h1 { font-size: 14px; }
  .drawer { top: auto; height: 62%; width: 100%; border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; padding-top: 22px; }
  .drawer .close { top: 8px; }
  .readout { display: none; }
  .pop { left: 12px; right: 12px; width: auto; }
}

.drawer .tool { margin: 14px 0 0; }
.drawer .tool a { color: var(--accent, #8fb8ff); text-decoration: none; font-weight: 500; }
