/* Layout: the city fills the screen; glass HUD panels float at the edges like a night-time dashboard.
   A single dark look by design (it is a night city). Accent = warm window light. */
:root {
  --night: #05070f;
  --glass: rgba(9, 13, 27, 0.72);
  --glass-strong: rgba(9, 13, 27, 0.9);
  --line: rgba(150, 170, 230, 0.16);
  --ink: #eaedf8;
  --muted: #8f97b6;
  --window: #ffc46b;
  --danger: #ff7a6b;
  --font-display: "Unbounded", "Segoe UI", system-ui, sans-serif;
  --font-body: "Geist", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  font: 14px/1.5 var(--font-body);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--window); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.stage { position: fixed; inset: 0; }
.stage canvas { display: block; touch-action: none; }

.hud { position: fixed; z-index: 2; }
.panel {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

/* ---------- top bar ---------- */
.hud-top {
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  left: max(16px, env(safe-area-inset-left, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; font-family: var(--font-display); font-weight: 800; font-size: 18px; letter-spacing: -0.01em; }
.repo-form { display: flex; background: var(--glass-strong); border: 1px solid var(--line); border-radius: 11px; overflow: hidden; flex: 0 1 380px; min-width: 0; }
.repo-form input { flex: 1; min-width: 0; background: transparent; border: 0; padding: 9px 12px; font-family: var(--font-mono); font-size: 13px; outline: none; }
.repo-form button { border: 0; background: var(--window); color: #1a1205; font-weight: 600; padding: 0 16px; }
.repo-form:focus-within { border-color: var(--window); }
.examples { display: flex; gap: 6px; flex-wrap: wrap; }
.examples button, .toolbar button, .toolbar a {
  background: var(--glass); border: 1px solid var(--line); border-radius: 9px; padding: 6px 11px;
  font-size: 12.5px; text-decoration: none; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.examples button { font-family: var(--font-mono); color: var(--muted); }
.examples button:hover, .toolbar button:hover { color: var(--ink); border-color: rgba(150, 170, 230, 0.4); }
.toolbar { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.toolbar button[aria-pressed="true"] { border-color: var(--window); color: var(--window); }
.toolbar .star { border-color: rgba(255, 196, 107, 0.5); color: var(--window); font-weight: 600; }

/* ---------- left panel ---------- */
.hud-left {
  left: max(16px, env(safe-area-inset-left, 0px));
  top: 118px;
  width: 320px;
  max-height: calc(100% - 190px);
  overflow-y: auto;
  padding: 16px 16px 12px;
  display: grid; gap: 12px; align-content: start;
}
.repo-name { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 17px; line-height: 1.25; overflow-wrap: anywhere; }
.repo-name a { text-decoration: none; }
.repo-name b { font-weight: 800; }
.repo-name a:hover { text-decoration: underline; text-decoration-color: var(--window); }
.repo-desc { margin: 0; color: var(--muted); font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stats div { display: grid; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.stats b { font-family: var(--font-display); font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: 11.5px; }
.notes p { margin: 0 0 6px; font-size: 12px; color: var(--window); line-height: 1.45; }
.search { position: relative; display: grid; gap: 4px; }
.search input { width: 100%; padding: 9px 34px 9px 11px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); border-radius: 10px; outline: none; font-size: 13px; }
.search input:focus { border-color: var(--window); }
.search kbd { position: absolute; right: 8px; top: 8px; font: 11px var(--font-mono); color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; }
.search-count { font: 11.5px var(--font-mono); color: var(--window); min-height: 1em; }
.token summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.token form { display: grid; gap: 6px; margin-top: 8px; font-size: 12px; }
.token label { color: var(--muted); }
.token-row { display: flex; gap: 6px; }
.token-row input { flex: 1; min-width: 0; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; }
.token-row button { border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 0 12px; }
.token p { margin: 0; color: var(--muted); font-size: 11.5px; }
.branch { margin: 0; font-size: 11.5px; color: var(--muted); }
.branch code { font-family: var(--font-mono); color: var(--ink); }

/* ---------- right panel ---------- */
.hud-right {
  right: max(16px, env(safe-area-inset-right, 0px));
  top: 118px;
  width: 290px;
  max-height: calc(100% - 190px);
  overflow-y: auto;
  padding: 14px 14px 10px;
}
.hud-right h2 { margin: 0 0 8px; font: 600 10.5px var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.hud-right h2:not(:first-child) { margin-top: 16px; }
.lang-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; gap: 2px; margin-bottom: 8px; }
.lang-bar i { display: block; min-width: 2px; }
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rows button {
  width: 100%; display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 9px;
  padding: 6px 8px; border: 1px solid transparent; border-radius: 8px; background: transparent; text-align: left;
}
.rows button:hover { background: rgba(255, 255, 255, 0.05); }
.rows button[aria-pressed="true"] { border-color: var(--window); background: rgba(255, 196, 107, 0.08); }
.rows i { width: 10px; height: 10px; border-radius: 3px; }
.rows .name { min-width: 0; display: grid; font-size: 13px; }
.rows .name b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rows .name small { color: var(--muted); font: 11px var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rows .pct { font: 12px var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- selection ---------- */
.selection {
  left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 50px); transform: translateX(-50%);
  width: min(520px, calc(100% - 32px)); padding: 16px 18px; display: grid; gap: 8px;
  border-color: rgba(255, 196, 107, 0.45);
  animation: rise 0.35s cubic-bezier(.2, .9, .3, 1);
}
.selection h2 { margin: 0; padding-right: 28px; font-family: var(--font-display); font-weight: 700; font-size: 18px; overflow-wrap: anywhere; }
.selection .path { margin: 0; font: 12px var(--font-mono); color: var(--muted); overflow-wrap: anywhere; }
.sel-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); }
.sel-meta span { display: inline-flex; align-items: center; gap: 6px; }
.sel-meta i { width: 9px; height: 9px; border-radius: 2px; }
.sel-actions { display: flex; gap: 8px; margin-top: 4px; }
.sel-actions a, .sel-actions button { padding: 7px 13px; border-radius: 9px; font-size: 13px; font-weight: 500; text-decoration: none; border: 1px solid var(--line); background: transparent; }
.sel-actions .primary { background: var(--window); border-color: var(--window); color: #1a1205; }
.close { position: absolute; top: 8px; right: 10px; width: 30px; height: 30px; border: 0; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; border-radius: 8px; }
.close:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }

/* ---------- labels, tooltip, toast, hint ---------- */
.city-label {
  position: absolute; left: 0; top: 0; z-index: 1; pointer-events: none;
  display: grid; justify-items: center; gap: 1px; padding: 4px 9px; border-radius: 8px;
  background: rgba(5, 7, 15, 0.62); border: 1px solid var(--line);
  font: 12px var(--font-mono); white-space: nowrap; transition: opacity 0.4s;
}
.city-label b { font-weight: 500; color: var(--ink); }
.city-label span { font-size: 10.5px; color: var(--muted); }
.tooltip {
  position: fixed; left: 0; top: 0; z-index: 5; pointer-events: none; max-width: 340px;
  display: grid; gap: 2px; padding: 8px 11px; border-radius: 10px;
  background: var(--glass-strong); border: 1px solid var(--line); font-size: 12px;
}
.tooltip b { font-size: 13px; }
.tooltip span { color: var(--muted); font-family: var(--font-mono); font-size: 11px; overflow-wrap: anywhere; }
.toast {
  position: fixed; z-index: 6; left: 50%; top: 80px; transform: translateX(-50%);
  padding: 8px 14px; border-radius: 10px; background: var(--window); color: #1a1205; font-weight: 600; font-size: 13px;
}
.hint {
  left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 14px); transform: translateX(-50%); margin: 0;
  font: 11.5px var(--font-mono); color: var(--muted); white-space: nowrap; pointer-events: none;
  text-shadow: 0 1px 8px var(--night);
}
.error {
  left: 50%; top: 80px; transform: translateX(-50%); width: min(560px, calc(100% - 32px));
  padding: 12px 44px 12px 16px; border-color: rgba(255, 122, 107, 0.5);
}
.error p { margin: 0; color: var(--ink); font-size: 13.5px; }
.error button { position: absolute; top: 6px; right: 8px; width: 30px; height: 30px; border: 0; background: transparent; color: var(--muted); font-size: 20px; }

/* ---------- loader ---------- */
.loader {
  position: fixed; inset: 0; z-index: 4; display: grid; place-content: center; justify-items: center; gap: 18px;
  background: radial-gradient(ellipse at center, rgba(5, 7, 15, 0.55), rgba(5, 7, 15, 0.92));
}
.loader p { margin: 0; font: 13px var(--font-mono); color: var(--muted); }
.skyline { display: flex; align-items: flex-end; gap: 6px; height: 54px; }
.skyline i { width: 12px; background: var(--window); border-radius: 2px 2px 0 0; animation: build 1.1s ease-in-out infinite; transform-origin: bottom; }
.skyline i:nth-child(1) { height: 26px; background: #3178c6; }
.skyline i:nth-child(2) { height: 44px; animation-delay: 0.12s; }
.skyline i:nth-child(3) { height: 34px; background: #f1e05a; animation-delay: 0.24s; }
.skyline i:nth-child(4) { height: 52px; background: #e34c26; animation-delay: 0.36s; }
.skyline i:nth-child(5) { height: 30px; background: #41b883; animation-delay: 0.48s; }
.noscript { position: fixed; inset: 0; display: grid; place-content: center; }

@keyframes build { 0%, 100% { transform: scaleY(0.35); } 50% { transform: scaleY(1); } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- small screens ---------- */
@media (max-width: 1100px) { .examples { display: none; } }
@media (max-width: 860px) {
  .hud-right { display: none; }
  .toolbar #shot, .toolbar #share, .toolbar #rec { display: none; }
}
@media (max-width: 640px) {
  .hud-top { gap: 8px; }
  .repo-form { flex: 1 1 100%; order: 3; }
  .toolbar { margin-left: auto; }
  .toolbar #home, .toolbar #mini { display: none; }
  .hud-left {
    top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); width: auto;
    right: max(16px, env(safe-area-inset-right, 0px)); max-height: 38%; padding: 12px;
  }
  .hud-left .repo-desc, .hud-left .token, .hud-left .branch, .hud-left .notes { display: none; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stats b { font-size: 13px; }
  .hint { display: none; }
  .selection { bottom: auto; top: 120px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
