:root {
  --bg: #050810;
  --panel: #0c1220;
  --panel2: #111a2e;
  --border: #1e3a5f;
  --cyan: #00d4ff;
  --cyan-dim: rgba(0, 212, 255, 0.15);
  --green: #30d158;
  --green-dim: rgba(48, 209, 88, 0.15);
  --red: #ff2d55;
  --amber: #ffb020;
  --text: #e8edf5;
  --muted: #7a8ba3;
  --mono: "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.scanlines {
  pointer-events: none;
  position: fixed; inset: 0; z-index: 200;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,.04) 2px, rgba(0,0,0,.04) 4px);
}

.hex-bg {
  pointer-events: none;
  position: fixed; inset: 0; z-index: 0;
  opacity: 0.12;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100' viewBox='0 0 56 100'%3E%3Cpath d='M28 0 L56 16 L56 48 L28 64 L0 48 L0 16 Z' fill='none' stroke='%2300d4ff' stroke-width='0.5'/%3E%3Cpath d='M28 36 L56 52 L56 84 L28 100 L0 84 L0 52 Z' fill='none' stroke='%2300d4ff' stroke-width='0.5'/%3E%3C/svg%3E");
  background-size: 56px 100px;
}

/* ── BOOT SEQUENCE ── */
.boot-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: #010204;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
  animation: bootFadeOut 0.6s ease 2.4s forwards;
}
.boot-overlay.done { display: none; }
.boot-lines {
  font-family: var(--mono); font-size: 0.85rem; color: var(--green);
  line-height: 1.9; max-width: 520px; width: 100%;
}
.boot-lines .bline { opacity: 0; white-space: pre-wrap; }
.boot-lines .bline.show { opacity: 1; animation: bootFlicker .15s steps(2); }
.boot-lines .bline.ok { color: var(--cyan); }
@keyframes bootFadeOut { to { opacity: 0; visibility: hidden; pointer-events: none; } }
@keyframes bootFlicker { 0% { opacity: .2; } 50% { opacity: 1; } 100% { opacity: 1; } }

/* ── CRT FLICKER ── */
.crt-flicker {
  pointer-events: none; position: fixed; inset: 0; z-index: 199;
  background: rgba(255,255,255,0.015);
  animation: crtFlicker 6s infinite;
}
@keyframes crtFlicker {
  0%, 96%, 100% { opacity: 0; }
  97% { opacity: 1; }
  98% { opacity: 0; }
  99% { opacity: .6; }
}

/* ── SCROLL REVEAL ── */
.reveal { opacity: 0; transform: translateY(22px); transition: opacity .7s ease, transform .7s ease; }
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ── TYPEWRITER CURSOR ── */
.caret {
  display: inline-block; width: 8px; height: 1em; margin-left: 2px;
  background: var(--red); vertical-align: text-bottom;
  animation: caretBlink 1s step-end infinite;
}
@keyframes caretBlink { 50% { opacity: 0; } }

/* ── GLITCH TEXT ── */
.glitch { position: relative; display: inline-block; animation: glitchShift 4.5s infinite; }
.glitch::before, .glitch::after {
  content: attr(data-text); position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  overflow: hidden; background: transparent;
}
.glitch::before { color: var(--cyan); animation: glitchBefore 4.5s infinite; clip-path: inset(0 0 0 0); }
.glitch::after { color: var(--amber); animation: glitchAfter 4.5s infinite; clip-path: inset(0 0 0 0); }
@keyframes glitchShift {
  0%, 92%, 100% { transform: translate(0,0); }
  93% { transform: translate(-2px, 1px); }
  94% { transform: translate(2px, -1px); }
  95% { transform: translate(-1px, 0); }
  96% { transform: translate(0,0); }
}
@keyframes glitchBefore {
  0%, 92%, 100% { opacity: 0; clip-path: inset(0 0 100% 0); }
  93% { opacity: .8; clip-path: inset(10% 0 60% 0); transform: translate(-3px,0); }
  95% { opacity: .8; clip-path: inset(60% 0 5% 0); transform: translate(3px,0); }
  96% { opacity: 0; }
}
@keyframes glitchAfter {
  0%, 92%, 100% { opacity: 0; clip-path: inset(100% 0 0 0); }
  93% { opacity: .7; clip-path: inset(70% 0 5% 0); transform: translate(3px,0); }
  95% { opacity: .7; clip-path: inset(5% 0 70% 0); transform: translate(-3px,0); }
  96% { opacity: 0; }
}

/* ── BUTTON PULSE ── */
.btn-primary { position: relative; }
.btn-primary::after {
  content: ""; position: absolute; inset: 0; border-radius: 4px;
  box-shadow: 0 0 0 0 rgba(255,45,85,.55);
  animation: btnPulse 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes btnPulse {
  0% { box-shadow: 0 0 0 0 rgba(255,45,85,.5); }
  70% { box-shadow: 0 0 0 12px rgba(255,45,85,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,45,85,0); }
}

/* ── MISSION LIST STAGGER ── */
.mission-box.visible li {
  animation: liIn .5s ease both;
  animation-delay: calc(var(--i, 0) * 90ms + .15s);
}
@keyframes liIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }

/* ── ADMIN ROW IN ── */
.row-in { animation: rowIn .4s ease both; }
@keyframes rowIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

.proto-banner {
  position: relative; z-index: 5;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--amber);
  background: rgba(255, 176, 32, 0.08);
  border-bottom: 1px solid rgba(255, 176, 32, 0.35);
  padding: 0.5rem 1rem;
}

header.nav {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 2rem;
  background: rgba(12, 18, 32, 0.92);
  border-bottom: 1px solid var(--border);
}
.brand { text-decoration: none; color: inherit; }
.brand-tag { display: block; font-size: 0.6rem; letter-spacing: 0.2em; color: var(--muted); }
.brand-title { font-size: 0.95rem; font-weight: 800; letter-spacing: 0.12em; color: var(--cyan); }
.nav-links { display: flex; gap: 0.5rem; }
.nav-links a {
  text-decoration: none; color: var(--muted); font-size: 0.8rem; letter-spacing: 0.06em;
  padding: 0.45rem 0.9rem; border-radius: 4px; transition: color .2s, background .2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--cyan); background: var(--cyan-dim); }

main {
  position: relative; z-index: 1;
  max-width: 860px; margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

.kicker { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.2em; color: var(--muted); margin-bottom: 0.75rem; }
.timestamp { font-family: var(--mono); font-size: 0.85rem; color: var(--red); margin-bottom: 1.5rem; }

h1 { font-size: 2.1rem; letter-spacing: 0.02em; margin-bottom: 0.4rem; line-height: 1.15; }
h1 .accent { color: var(--red); }
.subtitle { font-style: italic; color: var(--muted); margin-bottom: 2rem; font-size: 1rem; }

.terminal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cyan);
  border-radius: 6px;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.75rem;
  font-size: 0.95rem;
  line-height: 1.75;
}
.terminal p { margin-bottom: 1rem; }
.terminal p:last-child { margin-bottom: 0; }
.terminal .warn { color: var(--red); font-weight: 700; }
.terminal .quote { color: var(--amber); font-style: italic; }

.mission-box {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5rem 1.75rem;
  margin-bottom: 2rem;
}
.mission-box h3 { color: var(--cyan); font-size: 0.85rem; letter-spacing: 0.1em; margin-bottom: 0.9rem; }
.mission-box ul { list-style: none; }
.mission-box li {
  font-family: var(--mono); font-size: 0.85rem; color: var(--text);
  padding: 0.35rem 0; border-bottom: 1px dashed rgba(30,58,95,.6);
  display: flex; justify-content: space-between; gap: 1rem;
}
.mission-box li:last-child { border-bottom: none; }
.mission-box li span.label { color: var(--muted); }

.cta-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 2rem; }
.btn {
  display: inline-block; text-decoration: none; text-align: center;
  font-weight: 700; letter-spacing: 0.08em; font-size: 0.85rem;
  padding: 0.9rem 1.75rem; border-radius: 4px; cursor: pointer; border: none;
  transition: all .2s; font-family: inherit;
}
.btn-primary { background: var(--red); color: #fff; box-shadow: 0 0 0 rgba(255,45,85,0); }
.btn-primary:hover { box-shadow: 0 0 22px rgba(255,45,85,.4); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--cyan); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--cyan-dim); border-color: var(--cyan); }

footer.foot {
  position: relative; z-index: 1;
  text-align: center; padding: 2rem 1rem 3rem;
  color: var(--muted); font-size: 0.75rem; font-family: var(--mono); letter-spacing: 0.08em;
}

/* ── FORM ── */
.form-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
}
.form-card h2 { font-size: 1.3rem; letter-spacing: 0.06em; margin-bottom: 0.4rem; }
.form-card .form-desc { color: var(--muted); font-size: 0.85rem; margin-bottom: 1.75rem; }

.app-form { display: flex; flex-direction: column; gap: 1.1rem; }
.app-form label {
  display: flex; flex-direction: column; gap: 0.4rem;
  font-size: 0.75rem; letter-spacing: 0.06em; color: var(--muted);
}
.app-form input, .app-form select, .app-form textarea {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 4px;
  padding: 0.7rem 0.85rem; color: var(--text); font: inherit; font-size: 0.9rem;
}
.app-form input:focus, .app-form select:focus, .app-form textarea:focus {
  outline: none; border-color: var(--cyan);
}
.app-form textarea { resize: vertical; min-height: 80px; }

.form-feedback {
  font-family: var(--mono); font-size: 0.85rem;
  padding: 0.85rem 1rem; border-radius: 4px; margin-top: 0.25rem;
}
.form-feedback.success { background: var(--green-dim); color: var(--green); border: 1px solid var(--green); }
.form-feedback.error { background: rgba(255,45,85,.1); color: var(--red); border: 1px solid var(--red); }

.test-block { background: var(--panel2); border: 1px solid var(--border); border-left: 3px solid var(--amber); border-radius: 6px; padding: 1.1rem 1.25rem; }
.test-block .test-label { font-family: var(--mono); font-size: .72rem; letter-spacing: .04em; color: var(--amber); margin-bottom: .6rem; display: block; }
.test-block .test-prompt { font-size: .85rem; color: var(--text); margin-bottom: .75rem; }
.test-block pre { font-family: var(--mono); font-size: .8rem; color: var(--cyan); background: var(--panel); border: 1px solid var(--border); border-radius: 4px; padding: .8rem .95rem; overflow-x: auto; margin-bottom: .85rem; line-height: 1.6; }
.test-block input { width: 100%; }

.note-box {
  margin-top: 2rem; padding: 1rem 1.25rem; border-radius: 6px;
  background: rgba(0,212,255,.06); border: 1px dashed var(--border);
  font-size: 0.8rem; color: var(--muted); line-height: 1.6;
}

/* ── ADMIN ── */
.admin-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; gap: 1rem; }
.admin-count { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
table.admin-table th {
  text-align: left; background: var(--panel2); color: var(--cyan);
  padding: 0.65rem 0.85rem; font-size: 0.7rem; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.admin-table td { padding: 0.65rem 0.85rem; border-bottom: 1px solid rgba(30,58,95,.4); white-space: nowrap; }
table.admin-table tr:last-child td { border-bottom: none; }
table.admin-table tr:hover td { background: rgba(0,212,255,.04); }
.empty-state { padding: 3rem 1rem; text-align: center; color: var(--muted); font-size: 0.9rem; }

.btn-danger-armed { color: var(--red) !important; border-color: var(--red) !important; }

.status-select {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.3rem 0.5rem; font-family: inherit; font-size: 0.78rem;
}
table.admin-table td input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--cyan); cursor: pointer; }

.modal-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(4, 10, 20, .8);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 2.25rem 2.5rem; max-width: 420px; text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.modal-card p {
  font-size: 1.05rem; font-family: var(--mono);
  letter-spacing: .02em; line-height: 1.6;
}
.modal-card.success { border-color: var(--green); }
.modal-card.success p { color: var(--green); }
.modal-card.error { border-color: var(--red); }
.modal-card.error p { color: var(--red); }
.modal-card .btn { margin-top: 1.25rem; }

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; z-index: 300;
  transform: translate(-50%, 20px); opacity: 0;
  background: var(--panel2); border: 1px solid var(--cyan); color: var(--text);
  font-family: var(--mono); font-size: 0.82rem;
  padding: 0.75rem 1.25rem; border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  main { padding: 2rem 1rem 4rem; }
  h1 { font-size: 1.5rem; }
  header.nav { padding: 0.85rem 1rem; flex-wrap: wrap; gap: 0.5rem; }
  .mission-box li { flex-direction: column; align-items: flex-start; gap: 0.2rem; }
  .form-card, .terminal, .mission-box { padding: 1.25rem; }
}
