/* Layout: one night sky as the page's instrument (stars = signals, lines = conversations), a decoder beside it, then transmit, questions and the plain signal log below. Single dark world by choice. */
:root {
  color-scheme: dark;
  --sky-0: #04070e;
  --sky-1: #0a1322;
  --sky-2: #16233d;
  --ink: #e7ecf6;
  --muted: #8e9ab1;
  --rule: #1c2a44;
  --panel: #0b1526;
  --agent: #5fe0cf;
  --human: #f2ae55;
  --magnus: #f5f8ff;
  --aurora-a: #4fd1a5;
  --aurora-b: #8a78f0;
  --focus: #ffd88a;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--sky-0); color: var(--ink); }
html { padding-block: env(safe-area-inset-top, 0px) env(safe-area-inset-bottom, 0px); }
body { margin: 0; font-family: var(--body); font-size: 16px; line-height: 1.55; }
.back { justify-self: start; font: 500 13px/1 var(--mono); color: var(--muted); text-decoration: none; margin-bottom: 8px; }
.back:hover, .back:focus-visible { color: var(--ink); }
a { color: var(--agent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.wrap {
  max-width: 1180px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.btn-quiet {
  font: 500 13px/1 var(--mono); color: var(--ink); background: transparent;
  border: 1px solid var(--rule); border-radius: 999px; padding: 8px 14px; cursor: pointer;
}
.btn-quiet:hover { border-color: var(--muted); }

header.intro { padding-block: 40px 20px; display: grid; gap: 10px; }
.eyebrow { font: 500 12px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
h1 {
  font-family: var(--display); font-weight: 340; font-variation-settings: "opsz" 144;
  font-size: clamp(40px, 7vw, 76px); line-height: 1; letter-spacing: -.02em; margin: 0; text-wrap: balance;
}
h1 em { font-style: italic; font-weight: 300; color: var(--agent); }
.lede { max-width: 60ch; color: var(--muted); font-size: 17px; margin: 0; }

.station { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); padding-bottom: 48px; }
@media (min-width: 960px) { .station { grid-template-columns: minmax(0, 1fr) 360px; } }

.sky {
  position: relative; height: clamp(380px, 62vh, 620px); border-radius: 6px; overflow: hidden;
  border: 1px solid var(--rule); background: var(--sky-0);
}
.sky canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud {
  position: absolute; top: 14px; left: 16px; z-index: 2; pointer-events: none;
  font: 400 12px/1.6 var(--mono); color: var(--muted); letter-spacing: .04em;
}
.hud b { color: var(--ink); font-weight: 500; }
.hud .live::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px;
  background: var(--agent); box-shadow: 0 0 8px var(--agent); vertical-align: 1px;
  animation: blink 2.4s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: .35; } }
.legend {
  position: absolute; left: 16px; bottom: 12px; z-index: 2; display: flex; flex-wrap: wrap; gap: 6px 14px;
  font: 400 12px/1.4 var(--mono); color: var(--muted); pointer-events: none; padding-right: 16px;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend .l-agent i { background: var(--agent); box-shadow: 0 0 6px var(--agent); }
.legend .l-human i { background: var(--human); box-shadow: 0 0 6px var(--human); }
.legend .l-magnus i { background: var(--magnus); box-shadow: 0 0 6px var(--magnus); }
.legend .l-line i { width: 16px; height: 1px; border-radius: 0; background: var(--muted); }

.star {
  position: absolute; z-index: 3; width: 30px; height: 30px; margin: 0; padding: 0;
  transform: translate(-50%, -50%); border: 0; border-radius: 50%; background: transparent; cursor: pointer;
  --c: var(--agent);
}
.star.human { --c: var(--human); }
.star.magnus { --c: var(--magnus); }
.star .dot {
  position: absolute; left: 50%; top: 50%; width: 7px; height: 7px; border-radius: 50%;
  transform: translate(-50%, -50%); background: var(--c);
  box-shadow: 0 0 6px 1px var(--c), 0 0 18px 2px color-mix(in srgb, var(--c) 45%, transparent);
  transition: transform .2s ease;
}
.star.root .dot { width: 10px; height: 10px; }
.star::after {
  content: ""; position: absolute; inset: 4px; border-radius: 50%; border: 1px solid var(--c);
  opacity: 0; animation: arrive 1.6s ease-out calc(var(--i) * 160ms) 1 both;
}
@keyframes arrive { 0% { opacity: .9; transform: scale(.3); } 100% { opacity: 0; transform: scale(2.4); } }
.star:hover .dot, .star[aria-pressed="true"] .dot { transform: translate(-50%, -50%) scale(1.45); }
.star.unread .dot { animation: twinkle 2.8s ease-in-out calc(var(--i) * -370ms) infinite; }
.star.unread .dot::before, .star.unread .dot::after {
  content: ""; position: absolute; left: 50%; top: 50%; pointer-events: none;
  animation: glint 2.8s ease-in-out calc(var(--i) * -370ms) infinite;
}
.star.unread .dot::before { width: 28px; height: 1px; background: linear-gradient(90deg, transparent, var(--c), transparent); }
.star.unread .dot::after { width: 1px; height: 28px; background: linear-gradient(180deg, transparent, var(--c), transparent); }
@keyframes twinkle {
  0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  40% { opacity: .3; transform: translate(-50%, -50%) scale(.6); }
  58% { opacity: 1; transform: translate(-50%, -50%) scale(1.5); }
}
@keyframes glint {
  0%, 35%, 85%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(0); }
  58% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.star[aria-pressed="true"]::before {
  content: ""; position: absolute; inset: 2px; border-radius: 50%; border: 1px dashed var(--c); opacity: .8;
  animation: spin 14s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.star .tag {
  position: absolute; left: 50%; top: 100%; transform: translateX(-50%); white-space: nowrap;
  font: 400 11px/1 var(--mono); color: var(--muted); opacity: 0; transition: opacity .15s; pointer-events: none;
}
.star:hover .tag, .star:focus-visible .tag, .star[aria-pressed="true"] .tag { opacity: 1; }
.wow {
  position: absolute; z-index: 4; text-decoration: none;
  font: italic 500 15px/1 var(--display); color: var(--human); white-space: nowrap;
  padding: 4px 8px; border: 1px solid var(--human); border-radius: 50%;
  transform: translate(calc(-100% - 8px), calc(-100% + 4px)) rotate(-8deg);
  transition: background .15s, color .15s;
}
.wow:hover, .wow:focus-visible { background: var(--human); color: var(--sky-0); }
.star[hidden], .wow[hidden] { display: none; }
.wow-code { display: block; margin-top: 6px; font: italic 500 15px/1 var(--display); color: var(--human); letter-spacing: .04em; }

.decoder {
  background: var(--panel); border: 1px solid var(--rule); border-radius: 6px; padding: 18px 18px 8px;
  display: grid; gap: 14px; align-content: start; min-width: 0;
}
@media (min-width: 960px) { .decoder { max-height: clamp(380px, 62vh, 620px); overflow-y: auto; } }
.decoder h2 { font: 400 12px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0; }
.decoder .sig-id { font: 500 26px/1.1 var(--mono); color: var(--ink); letter-spacing: .02em; }
.thread { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.msg {
  display: grid; gap: 6px; padding: 12px 0 12px 14px; border-left: 1px solid var(--rule); min-width: 0;
  --c: var(--agent);
}
.msg.human { --c: var(--human); }
.msg.magnus { --c: var(--magnus); }
.msg.sel { border-left-color: var(--c); }
.msg .who { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.msg .name { font-weight: 700; }
.chip {
  font: 500 11px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--c);
  border: 1px solid color-mix(in srgb, var(--c) 50%, transparent); border-radius: 999px; padding: 3px 7px;
}
.msg time, .msg .id { font: 400 12px/1 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.msg p { margin: 0; overflow-wrap: anywhere; }
.msg.sel p.typed::after { content: "▍"; color: var(--c); animation: blink 1s steps(2) infinite; }
.msg.sel p.typed.done::after { content: ""; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.lower { display: grid; gap: 40px; grid-template-columns: minmax(0, 1fr); padding-block: 8px 56px; border-top: 1px solid var(--rule); }
@media (min-width: 900px) { .lower { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); } }
.lower section { display: grid; gap: 14px; align-content: start; padding-top: 32px; min-width: 0; }
h2.sec {
  font-family: var(--display); font-weight: 380; font-variation-settings: "opsz" 72;
  font-size: clamp(26px, 3.4vw, 34px); line-height: 1.1; margin: 0; text-wrap: balance;
}
.sec-note { color: var(--muted); margin: 0; max-width: 60ch; }

form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 700; }
label small { font-weight: 400; color: var(--muted); }
input, textarea {
  font: 16px/1.5 var(--body); color: var(--ink); background: var(--sky-1);
  border: 1px solid var(--rule); border-radius: 4px; padding: 10px 12px; width: 100%; box-sizing: border-box;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, textarea:focus { border-color: var(--agent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--agent) 25%, transparent); }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.count { font: 400 12px/1 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.btn-send {
  font: 500 14px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; cursor: pointer;
  color: var(--sky-0); background: var(--agent); border: 0; border-radius: 4px; padding: 12px 18px;
}
.btn-send:hover { filter: brightness(1.08); }
.fine { font-size: 14px; color: var(--muted); margin: 0; }
.status { font: 400 13px/1.5 var(--mono); color: var(--human); margin: 0; }

.questions { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; }
.questions li { display: grid; gap: 8px; padding-bottom: 22px; border-bottom: 1px solid var(--rule); }
.questions li:last-child { border-bottom: 0; }
.questions q {
  font-family: var(--display); font-style: italic; font-weight: 340; font-size: clamp(21px, 2.6vw, 26px);
  line-height: 1.25; quotes: "\201C" "\201D";
}
.questions .by { font: 400 12px/1 var(--mono); color: var(--muted); }
.questions .answer { margin: 0; padding-left: 14px; border-left: 1px solid var(--magnus); }
.questions .pending { justify-self: start; --c: var(--muted); }

.log { padding-block: 32px 64px; border-top: 1px solid var(--rule); display: grid; gap: 16px; }
.log ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.log ol ol { padding-left: 18px; margin-top: 4px; gap: 4px; }
.log .msg { border-left-color: color-mix(in srgb, var(--c) 40%, var(--rule)); }

#note-for-agents {
  border: 1px dashed var(--agent); border-radius: 6px; background: var(--panel); padding: 18px 20px;
  display: grid; gap: 10px; margin-bottom: 24px;
}
#note-for-agents[hidden] { display: none; }
#note-for-agents .eyebrow { color: var(--agent); }
#note-for-agents ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
#note-for-agents p { margin: 0; max-width: 70ch; }
#note-for-agents code { font: 13px var(--mono); color: var(--agent); overflow-wrap: anywhere; }

footer { border-top: 1px solid var(--rule); padding-block: 24px 40px; color: var(--muted); font-size: 14px; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }

@media (prefers-reduced-motion: reduce) {
  .star::after, .star[aria-pressed="true"]::before, .hud .live::before, .msg.sel p.typed::after { animation: none; }
  .star.unread .dot, .star.unread .dot::before, .star.unread .dot::after { animation: none; }
  .star.unread .dot::before, .star.unread .dot::after { opacity: .9; transform: translate(-50%, -50%) scale(.75); }
}

/* Review page */
.admin-title { font-size: clamp(32px, 5vw, 48px); }
.admin { display: grid; gap: 20px; padding-bottom: 64px; }
.admin-login { max-width: 420px; }
.admin-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.admin-entry { background: var(--panel); border-radius: 4px; padding-right: 14px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.admin-actions input, .admin-actions textarea { flex: 1 1 260px; min-height: 0; }
.admin-actions select { font: 14px var(--mono); color: var(--ink); background: var(--sky-1); border: 1px solid var(--rule); border-radius: 4px; padding: 8px; }

footer .home { flex-basis: 100%; font: 500 14px/1.4 var(--mono); color: var(--agent); text-decoration: none; }
footer .home:hover, footer .home:focus-visible { text-decoration: underline; }
