:root {
  --void: #040704;
  --panel: #08110a;
  --line: #16351a;
  --phos: #6dff57;
  --phos-dim: #2f7a28;
  --ink: #c6f3b8;
  --mute: #6f8c68;
  --amber: #e3a53a;
  --font: "Spline Sans Mono", ui-monospace, monospace;
  --display: "Oxanium", "Spline Sans Mono", sans-serif;
  --pad: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; min-height: 100dvh; background: var(--void); color: var(--ink); font-family: var(--font); }
body { overflow-x: hidden; padding-bottom: calc(12px + var(--safe-bot)); }
button, input { font-size: 16px; }
#scan {
  pointer-events: none; position: fixed; inset: 0; z-index: 9;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,.12) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
#rain { position: fixed; inset: 0; z-index: 0; opacity: .22; }
.top, main, .theater, .link, .plug { position: relative; z-index: 1; }
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: calc(10px + var(--safe-top)) var(--pad) 10px;
  border-bottom: 1px solid var(--line);
}
.mark { display: flex; gap: 10px; align-items: center; color: var(--phos); }
.mark strong { font-family: var(--display); letter-spacing: .16em; font-size: 14px; }
.mark small { display: block; color: var(--mute); font-weight: 300; font-size: 11px; }
nav { display: flex; gap: 8px; }
nav button, .search button, .plug button, .chat button, .install {
  font-family: var(--font); background: transparent; color: var(--phos);
  border: 1px solid var(--phos-dim); padding: 12px 14px; min-height: 44px; cursor: pointer;
}
nav button.on, .cats button.on { background: var(--phos); color: var(--void); }
.link-state { margin-left: auto; color: var(--mute); font-size: 11px; }
.link-state.live { color: var(--phos); }
.view { display: none; padding: 18px var(--pad) 28px; }
.view.on { display: block; }
.hero h1 {
  font-family: var(--display); font-weight: 700; font-size: clamp(28px, 9vw, 52px);
  line-height: .95; margin: 8px 0 12px; max-width: 14ch;
}
.hero h1 em { font-style: normal; color: var(--amber); }
.kicker { color: var(--amber); font-size: 12px; margin: 0; }
.lede { max-width: 62ch; color: var(--mute); line-height: 1.5; font-size: 14px; }
.search { display: flex; gap: 8px; margin: 20px 0 12px; }
.search input, .chat input {
  flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  font-family: var(--font); padding: 12px; min-height: 44px;
}
.cats { display: flex; flex-wrap: nowrap; gap: 8px; margin-bottom: 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cats button {
  font-family: var(--font); font-size: 12px; background: transparent; flex: 0 0 auto;
  color: var(--ink); border: 1px solid var(--line); padding: 10px 12px; min-height: 40px; cursor: pointer;
}
.meta-line { color: var(--mute); font-size: 12px; }
.wall { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
.tile {
  position: relative; cursor: pointer; border: 1px solid transparent;
  background: linear-gradient(180deg, #0c190e, #070d08);
  padding: 0; text-align: left; color: inherit; font-family: inherit; width: 100%;
}
.tile:hover, .tile:focus-visible { border-color: var(--phos); }
.tile img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; filter: saturate(.7) contrast(1.1); }
.tile .cap { padding: 8px; }
.tile h3 { margin: 0; font-size: 13px; line-height: 1.3; font-weight: 500; }
.tile p { margin: 4px 0 0; color: var(--mute); font-size: 11px; }
.tile .jack {
  position: absolute; top: 8px; right: 8px; font-size: 10px;
  background: var(--void); color: var(--amber); padding: 3px 6px; border: 1px solid var(--amber);
}
.theater {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: min(58dvh, 460px);
  width: 100%; background: rgba(4,7,4,.94); border-top: 1px solid var(--line);
  padding: 16px var(--pad) calc(16px + var(--safe-bot)); overflow: auto; z-index: 4;
}
.cover-wrap { display: flex; gap: 12px; }
.cover-wrap img { width: 64px; height: 96px; object-fit: cover; }
.agent-kicker { color: var(--amber); font-size: 11px; margin: 0 0 4px; }
.agents { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.agents li { border: 1px solid var(--line); padding: 8px 4px; font-size: 10px; color: var(--mute); text-align: center; }
.agents li.hot { border-color: var(--phos); color: var(--phos); box-shadow: 0 0 12px #6dff5733; }
.agents li.done { color: var(--phos-dim); border-color: var(--phos-dim); }
.log { margin-top: 12px; font-size: 12px; line-height: 1.45; max-height: 28vh; overflow: auto; }
.log div { border-left: 2px solid var(--phos-dim); padding: 4px 8px; margin-bottom: 6px; }
.log b { color: var(--phos); font-weight: 500; }
.plug {
  position: fixed; inset: 0; z-index: 8; background: rgba(2,4,2,.9);
  display: grid; place-items: center; padding: var(--pad);
}
.plug-box { text-align: center; max-width: 28rem; }
.socket {
  width: 88px; height: 88px; margin: 0 auto 18px; border: 2px solid var(--amber);
  border-radius: 50%; position: relative; box-shadow: 0 0 40px #e3a53a44;
  animation: pulse 1.6s ease-in-out infinite;
}
.socket.live { border-color: var(--phos); box-shadow: 0 0 40px #6dff5744; }
.pin {
  position: absolute; left: 50%; top: -34px; width: 10px; height: 48px;
  margin-left: -5px; background: var(--amber); animation: jack 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 70px #e3a53a88; } }
@keyframes jack { 50% { top: -10px; } }
.plug h2 { font-family: var(--display); font-size: clamp(28px, 8vw, 42px); margin: 0 0 8px; }
.plug-status { color: var(--amber); font-size: 13px; }
.plug button { margin-top: 12px; padding: 12px 22px; border-color: var(--amber); color: var(--amber); width: min(100%, 280px); }
.link {
  position: relative; display: grid; grid-template-columns: 1fr; gap: 14px;
  background: #07110a; border-top: 1px solid var(--line);
  padding: 14px var(--pad) calc(16px + var(--safe-bot));
}
.player { display: flex; gap: 12px; align-items: center; }
.player img { width: 56px; height: 84px; object-fit: cover; }
.player audio { width: 100%; }
.msgs { height: 28vh; overflow: auto; font-size: 14px; }
.msgs .me { color: var(--amber); }
.msgs .ai { color: var(--ink); }
.chat form { display: flex; gap: 8px; margin-top: 8px; }
.hist { display: grid; grid-template-columns: 1fr; gap: 10px; }
.hist button {
  display: flex; gap: 10px; background: var(--panel); border: 1px solid var(--line);
  color: inherit; text-align: left; padding: 8px; cursor: pointer; font-family: inherit; width: 100%; min-height: 44px;
}
.hist img { width: 48px; height: 72px; object-fit: cover; }
.install {
  position: fixed; left: var(--pad); right: var(--pad); bottom: calc(12px + var(--safe-bot));
  z-index: 6; background: var(--void);
}
.sr { position: absolute; left: -9999px; }
@media (min-width: 720px) {
  :root { --pad: 28px; }
  .wall { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .tile .jack { opacity: 0; }
  .tile:hover .jack { opacity: 1; }
  .theater {
    left: auto; right: 0; top: 64px; bottom: 0; height: auto; width: min(420px, 100%);
    border-left: 1px solid var(--line); border-top: 0;
  }
  .link { grid-template-columns: 1.1fr .9fr; position: fixed; left: 0; right: 0; bottom: 0; }
  .hist { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .cats { flex-wrap: wrap; overflow: visible; }
  .install { left: auto; right: var(--pad); width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  #rain, #scan, .socket, .pin { animation: none; }
}
