@font-face {
  font-family: 'Orbitron';
  src: url('/fonts/orbitron.woff2') format('woff2');
  font-weight: 400 900;
  font-display: swap;
}

:root {
  --bg: #02030a;
  --panel: rgba(6, 12, 28, 0.78);
  --cyan: #22d3ee;
  --blue: #3b82f6;
  --purple: #a855f7;
  --yellow: #fde047;
  --text: #d6e4ff;
  --muted: #7184ab;
  --danger: #fb7185;
  --line: rgba(34, 211, 238, 0.25);
  --line-strong: rgba(34, 211, 238, 0.6);
  --glow-cyan: 0 0 4px rgba(34, 211, 238, 0.9), 0 0 16px rgba(34, 211, 238, 0.45);
  --glow-purple: 0 0 4px rgba(168, 85, 247, 0.9), 0 0 18px rgba(168, 85, 247, 0.5);
  --glow-yellow: 0 0 4px rgba(253, 224, 71, 0.85), 0 0 14px rgba(253, 224, 71, 0.4);
  --hud: 'Orbitron', 'Eurostile', 'Bank Gothic', ui-sans-serif, system-ui, sans-serif;
  --body: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(59, 130, 246, 0.22), transparent 70%),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgba(168, 85, 247, 0.18), transparent 70%),
    radial-gradient(ellipse 50% 40% at 0% 80%, rgba(34, 211, 238, 0.1), transparent 70%),
    var(--bg);
}

/* HUD grid and scan lines */
body::before,
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

body::before {
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.06) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

body::after {
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 3px);
}

header,
main {
  position: relative;
  z-index: 1;
}

a {
  color: var(--cyan);
}

/* Header */
.hud-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(14px + env(safe-area-inset-top)) 20px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(2, 6, 20, 0.95), rgba(2, 6, 20, 0.6));
  box-shadow: 0 1px 24px rgba(34, 211, 238, 0.12);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.brand-name {
  font-family: var(--hud);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.32em;
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
}

.hud-nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.hud-nav a,
.hud-nav button {
  font-family: var(--hud);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}

.hud-nav a[aria-current='page'] {
  color: var(--yellow);
  text-shadow: var(--glow-yellow);
}

.hud-nav button {
  white-space: nowrap;
}

@media (max-width: 520px) {
  .hud-header {
    padding-left: 14px;
    padding-right: 14px;
  }

  .brand {
    gap: 12px;
  }

  .brand-name {
    font-size: 15px;
    letter-spacing: 0.2em;
  }

  .hud-nav {
    gap: 12px;
  }

  .hud-nav a,
  .hud-nav button {
    font-size: 10px;
    letter-spacing: 0.14em;
  }

  .reactor {
    --size: 32px;
  }
}

/* Arc reactor logo */
.reactor {
  --size: 40px;
  position: relative;
  display: inline-block;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: radial-gradient(circle, #f0fdff 0 14%, var(--cyan) 22%, rgba(34, 211, 238, 0.15) 46%, transparent 62%);
  box-shadow: var(--glow-cyan), inset 0 0 10px rgba(34, 211, 238, 0.6);
  border: 2px solid rgba(34, 211, 238, 0.85);
  animation: pulse 3.2s ease-in-out infinite;
}

.reactor::before,
.reactor::after {
  content: '';
  position: absolute;
  border-radius: 50%;
}

.reactor::before {
  inset: -7px;
  border: 2px dashed rgba(168, 85, 247, 0.8);
  box-shadow: var(--glow-purple);
  animation: spin 14s linear infinite;
}

.reactor::after {
  inset: 5px;
  border: 1px solid rgba(240, 253, 255, 0.55);
  border-left-color: transparent;
  border-right-color: transparent;
  animation: spin 4s linear infinite reverse;
}

.reactor.large {
  --size: 96px;
  margin: 8px auto 28px;
  display: block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 6px rgba(34, 211, 238, 1), 0 0 30px rgba(34, 211, 238, 0.7), inset 0 0 14px rgba(34, 211, 238, 0.8);
  }
}

/* Layout */
.hud-main {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.hud-main.narrow {
  max-width: 600px;
}

.hud-status {
  margin: 0 0 20px;
  font-family: var(--hud);
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--yellow);
  text-shadow: var(--glow-yellow);
}

.hud-status .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: var(--glow-yellow);
  animation: blink 2s steps(2, start) infinite;
}

@keyframes blink {
  to {
    opacity: 0.25;
  }
}

.grid {
  display: grid;
  gap: 20px;
}

@media (min-width: 860px) {
  .grid.two {
    grid-template-columns: 1fr 1fr;
  }
}

/* Panels with corner brackets */
.panel {
  position: relative;
  margin-bottom: 20px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 30px rgba(34, 211, 238, 0.05), 0 0 30px rgba(59, 130, 246, 0.08);
  backdrop-filter: blur(6px);
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
}

.panel::before,
.panel::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  pointer-events: none;
}

.panel::before {
  top: -1px;
  left: -1px;
  border-top: 2px solid var(--cyan);
  border-left: 2px solid var(--cyan);
  filter: drop-shadow(0 0 4px var(--cyan));
}

.panel::after {
  right: -1px;
  bottom: -1px;
  border-right: 2px solid var(--purple);
  border-bottom: 2px solid var(--purple);
  filter: drop-shadow(0 0 4px var(--purple));
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--hud);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
}

h1 {
  font-size: 20px;
}

h2 {
  font-size: 14px;
}

h3 {
  font-size: 12px;
  margin: 18px 0 10px;
  color: var(--purple);
  text-shadow: var(--glow-purple);
}

p {
  line-height: 1.55;
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--danger);
  text-shadow: 0 0 10px rgba(251, 113, 133, 0.4);
}

.success {
  color: var(--yellow);
}

/* Forms */
.row {
  display: flex;
  gap: 10px;
}

.form-grid {
  display: grid;
  gap: 10px;
}

@media (min-width: 640px) {
  .form-grid.cols {
    grid-template-columns: 1fr 1fr;
  }
}

label.field {
  display: grid;
  gap: 6px;
  font-family: var(--hud);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  font-family: var(--body);
  font-size: 16px;
  letter-spacing: normal;
  text-transform: none;
}

input:not([type='checkbox']),
select {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(2, 8, 22, 0.9);
  border: 1px solid var(--line);
  border-radius: 2px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.row input:not([type='checkbox']) {
  flex: 1;
}

input:focus,
select:focus {
  border-color: var(--purple);
  box-shadow: var(--glow-purple);
}

.reveal-wrap {
  position: relative;
  display: block;
}

.reveal-wrap input:not([type='checkbox']) {
  padding-right: 76px;
}

.reveal-wrap button.reveal {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  padding: 6px 10px;
  font-size: 9px;
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.06);
  border-color: var(--line);
}

.reveal-wrap button.reveal[aria-pressed='true'] {
  color: var(--yellow);
  border-color: var(--yellow);
  text-shadow: var(--glow-yellow);
}

input::placeholder {
  color: #4a5a7e;
}

select {
  width: auto;
}

button {
  cursor: pointer;
  padding: 12px 18px;
  font-family: var(--hud);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cyan);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  transition: box-shadow 0.2s, color 0.2s, border-color 0.2s;
}

button:hover,
button:focus-visible {
  color: #fff;
  border-color: var(--cyan);
  box-shadow: var(--glow-cyan);
  outline: none;
}

button.primary {
  color: #fff;
  border: 0;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.45);
}

button.primary:hover {
  box-shadow: 0 0 22px rgba(168, 85, 247, 0.8);
}

button.danger {
  color: var(--danger);
  border-color: rgba(251, 113, 133, 0.5);
}

button.small {
  padding: 6px 10px;
  font-size: 9px;
}

button.link {
  padding: 0;
  border: 0;
  background: none;
}

button.link:hover {
  color: var(--yellow);
  box-shadow: none;
  text-shadow: var(--glow-yellow);
}

button.icon {
  padding: 4px 12px;
  border: 0;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
}

button.icon:hover {
  color: var(--danger);
  box-shadow: none;
}

/* Lists */
.items {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
}

.items:empty {
  display: none;
}

.items li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 4px 4px;
  border-bottom: 1px solid rgba(34, 211, 238, 0.12);
}

.items label {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  cursor: pointer;
}

.items li span {
  font-size: 17px;
  color: var(--text);
}

.items li.done span {
  color: var(--muted);
  text-decoration: line-through;
}

input[type='checkbox'] {
  appearance: none;
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  border: 1px solid var(--line-strong);
  background: rgba(2, 8, 22, 0.9);
  cursor: pointer;
  transition: box-shadow 0.2s, background 0.2s;
}

input[type='checkbox']:hover {
  box-shadow: var(--glow-cyan);
}

input[type='checkbox'] {
  display: grid;
  place-content: center;
}

input[type='checkbox']::after {
  content: '';
  width: 6px;
  height: 11px;
  margin-top: -3px;
  border: solid var(--bg);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.15s;
}

input[type='checkbox']:checked {
  background: var(--yellow);
  border-color: var(--yellow);
  box-shadow: var(--glow-yellow);
}

input[type='checkbox']:checked::after {
  transform: rotate(45deg) scale(1);
}

.ghost {
  margin-top: 14px;
}

/* Jarvis reply */
.reply {
  min-height: 1.6em;
  margin: 16px 0 0;
  padding-left: 14px;
  border-left: 2px solid var(--yellow);
  font-family: var(--mono);
  font-size: 15px;
  color: var(--yellow);
  text-shadow: var(--glow-yellow);
}

.reply:empty {
  display: none;
}

/* Voice */
.voice {
  display: grid;
  justify-items: center;
  gap: 6px;
}

button.mic {
  position: relative;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  box-shadow: none;
}

button.mic:hover,
button.mic:focus-visible {
  box-shadow: none;
}

button.mic:focus-visible .mic-core {
  outline: 2px solid var(--yellow);
  outline-offset: 16px;
}

button.mic:disabled {
  cursor: progress;
}

.mic-core {
  --size: 120px;
  display: block;
  margin: 22px;
  transition: border-color 0.2s;
}

button.mic:hover .mic-core {
  box-shadow: 0 0 6px rgba(34, 211, 238, 1), 0 0 36px rgba(34, 211, 238, 0.75), inset 0 0 14px rgba(34, 211, 238, 0.8);
}

.mic-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 38px;
  height: 38px;
  transform: translate(-50%, -50%);
  fill: var(--bg);
  stroke: var(--bg);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

button.mic[data-state='listening'] .mic-core {
  border-color: var(--yellow);
  background: radial-gradient(circle, #fffbe6 0 14%, var(--yellow) 24%, rgba(253, 224, 71, 0.15) 46%, transparent 62%);
  animation: listen 0.9s ease-in-out infinite;
}

button.mic[data-state='listening'] .mic-core::before {
  border-color: rgba(253, 224, 71, 0.85);
  animation-duration: 3s;
}

button.mic[data-state='thinking'] .mic-core::before {
  animation-duration: 1s;
}

@keyframes listen {
  50% {
    box-shadow: 0 0 8px rgba(253, 224, 71, 1), 0 0 48px rgba(253, 224, 71, 0.7), inset 0 0 16px rgba(253, 224, 71, 0.8);
  }
}

.mic-hint {
  margin: 0;
  font-family: var(--hud);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

button.mic[data-state='listening'] + .mic-hint {
  color: var(--yellow);
  text-shadow: var(--glow-yellow);
}

.heard {
  min-height: 1.5em;
  margin: 0;
  font-style: italic;
  text-align: center;
  color: var(--text);
}

.typed {
  margin-top: 20px;
}

.hero {
  padding-top: 28px;
  text-align: center;
}

.hero .hud-status {
  margin-bottom: 4px;
}

.hero .mic-core {
  --size: 150px;
  margin: 34px;
}

.hero .reply,
.hero .typed {
  text-align: left;
}

.switches {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 28px;
  margin-top: 18px;
}

.panel-link {
  font-family: var(--hud);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cyan);
  text-decoration: none;
}

.panel-link:hover {
  color: var(--yellow);
  text-shadow: var(--glow-yellow);
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

a.summary-tile {
  display: grid;
  gap: 6px;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

a.summary-tile .value {
  margin-top: 0;
}

a.summary-tile:hover,
a.summary-tile:focus-visible {
  border-color: var(--cyan);
  box-shadow: var(--glow-cyan);
}

label.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--hud);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
}

/* Admin */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.tile {
  padding: 14px;
  border: 1px solid var(--line);
  background: rgba(2, 8, 22, 0.7);
}

.tile .label {
  font-family: var(--hud);
  font-size: 9px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}

.tile .value {
  margin-top: 8px;
  font-family: var(--hud);
  font-size: 18px;
  color: var(--yellow);
  text-shadow: var(--glow-yellow);
  overflow-wrap: anywhere;
}

.tile .value.small {
  white-space: pre-line;
  font-size: 11px;
  line-height: 1.6;
  letter-spacing: 0.05em;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 8px 10px;
  font-family: var(--hud);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--purple);
  border-bottom: 1px solid rgba(168, 85, 247, 0.4);
}

td {
  padding: 10px;
  vertical-align: top;
  border-bottom: 1px solid rgba(34, 211, 238, 0.1);
}

td .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-family: var(--hud);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  border: 1px solid currentColor;
}

.badge.admin {
  color: var(--yellow);
}

.badge.member {
  color: var(--cyan);
}

.badge.off {
  color: var(--danger);
}

.speech {
  color: var(--yellow);
}

.key-box {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--yellow);
  box-shadow: var(--glow-yellow);
  background: rgba(30, 24, 2, 0.35);
}

.key-box code {
  display: block;
  margin: 10px 0;
  padding: 10px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--yellow);
  background: rgba(0, 0, 0, 0.5);
  overflow-wrap: anywhere;
}

.key-box ol {
  margin: 10px 0 0;
  padding-left: 20px;
  line-height: 1.7;
}

.key-box ol code {
  display: inline;
  margin: 0;
  padding: 1px 5px;
}

/* Sign-in */
.auth-panel {
  margin-top: 6vh;
  text-align: left;
}

.auth-title {
  text-align: center;
  margin-bottom: 6px;
}

.auth-sub {
  text-align: center;
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
}

[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
