/* Secret Signal — design tokens
 * Dark, signal-cyan HUD aesthetic. Single accent (cyan) signals "live".
 * Indie-tone palette stays; gold reserved for status:ok moments.
 */
:root {
  --bg-0: #0b0f1a;
  --bg-1: #11172a;
  --bg-2: #1a2240;
  --surface: rgba(17, 23, 42, 0.78);
  --surface-2: rgba(11, 15, 26, 0.6);

  --fg: #f1f4ff;
  --fg-mute: #aab4d2;
  --fg-dim: #7d88a8;

  --accent: #38e1ff;       /* signal cyan — primary interactive */
  --accent-2: #7c5cff;     /* indigo — secondary */
  --gold: #f5b94a;          /* confirmation / success highlight */
  --danger: #ff6b80;
  --ok: #34e08a;

  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);

  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 0 1px rgba(56, 225, 255, 0.35), 0 0 24px rgba(56, 225, 255, 0.25);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;

  --t-fast: 140ms;
  --t-med: 220ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --font-ui: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI",
             "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --font-display: "Orbitron Variable", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono Variable", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100dvh;
  background:
    radial-gradient(1100px 760px at 16% -12%, rgba(56, 225, 255, 0.24) 0%, rgba(27, 37, 82, 0.82) 36%, transparent 68%),
    radial-gradient(900px 620px at 108% 4%, rgba(124, 92, 255, 0.30) 0%, rgba(42, 27, 82, 0.78) 38%, transparent 70%),
    radial-gradient(680px 460px at 50% 112%, rgba(56, 225, 255, 0.11) 0%, transparent 66%),
    var(--bg-0);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Skip link — visible only on keyboard focus. */
.skip-link {
  position: absolute;
  top: -100px;
  left: 12px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--accent);
  color: var(--bg-0);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: top var(--t-fast) var(--ease-out);
}
.skip-link:focus { top: 12px; outline: none; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero {
  text-align: center;
  padding: 16px 8px 4px;
}

.badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.20), rgba(56, 225, 255, 0.18));
  border: 1px solid var(--border);
  color: var(--fg-mute);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.title {
  margin: 14px 0 6px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(32px, 5.4vw, 52px);
  letter-spacing: -0.015em;
  line-height: 1.05;
  background: linear-gradient(135deg, #ffffff 0%, var(--accent) 55%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 0;
  color: var(--fg-mute);
  font-size: 15px;
}

.card {
  background: rgba(17, 23, 42, 0.88);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-lg);
}

.card-closed {
  text-align: center;
  border-color: var(--accent);
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(125, 211, 252, 0.10), transparent 60%),
    rgba(17, 23, 42, 0.88);
}
.closed-title {
  margin: 4px 0 10px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg);
}
.closed-message {
  margin: 0;
  color: var(--fg-mute);
  font-size: 14px;
  line-height: 1.5;
}

/* Form */
form label {
  display: block;
  color: var(--fg-mute);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: stretch;
  padding-bottom: 10px;
}

.select-wrap {
  position: relative;
  flex: 1 1 260px;
  min-width: 0;
}
.select-caret {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  color: var(--fg-mute);
  pointer-events: none;
}
[dir="rtl"] .select-caret { right: auto; left: 14px; }

select,
button {
  font: inherit;
  color: inherit;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border: 1px solid var(--border);
  outline: none;
  min-height: 48px;          /* touch target ≥44px (Apple HIG) */
  transition:
    border-color var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out),
    transform 80ms var(--ease-out),
    background var(--t-fast) var(--ease-out),
    opacity var(--t-fast) var(--ease-out);
}

select {
  flex: 1 1 100%;
  width: 100%;
  background: rgba(11, 15, 26, 0.7);
  color: var(--fg);
  appearance: none;
  -webkit-appearance: none;
  padding-inline-end: 40px;
  cursor: pointer;
}
select:disabled { opacity: 0.55; cursor: not-allowed; }

button {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #0b0f1a;
  border: none;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  padding-inline: 22px;
  width: 100%;
  margin-top: 18px;
  box-shadow: 0 8px 24px rgba(56, 225, 255, 0.25);
}
button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(56, 225, 255, 0.35);
}
button:active:not(:disabled) { transform: translateY(0); }
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* Focus rings — keyboard only (a11y). */
:focus { outline: none; }
:focus-visible {
  border-color: var(--accent) !important;
  box-shadow: var(--shadow-glow);
}

/* Status */
.status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 1.6em;
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--fg-mute);
}
.status:has(.status-text:empty) { display: none; }

.status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  flex: 0 0 auto;
}
.status.ok    { color: var(--ok); }
.status.error { color: var(--danger); }
.status.ok    .status-text { color: var(--ok); }
.status.error .status-text { color: var(--danger); }

/* Brief pulse on success — signals "transmission received". */
.status.ok.pulse .status-icon {
  animation: pulse-glow var(--t-med) var(--ease-out);
}
@keyframes pulse-glow {
  0%   { transform: scale(0.6); opacity: 0; }
  60%  { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(1);    opacity: 1; }
}

/* Registered list */
.list-card { padding-bottom: 12px; }
.list-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg);
}

.count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  padding: 4px 10px;
  border: 1px solid rgba(56, 225, 255, 0.35);
  border-radius: 999px;
  background: rgba(56, 225, 255, 0.08);
}

.registered {
  list-style: none;
  padding: 0;
  margin: 8px 0 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.registered li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 14px;
  overflow: hidden;
  /* Staggered entrance. */
  animation: li-in 320ms var(--ease-out) both;
}
.registered li:nth-child(1)  { animation-delay: 0ms; }
.registered li:nth-child(2)  { animation-delay: 30ms; }
.registered li:nth-child(3)  { animation-delay: 60ms; }
.registered li:nth-child(4)  { animation-delay: 90ms; }
.registered li:nth-child(5)  { animation-delay: 120ms; }
.registered li:nth-child(6)  { animation-delay: 150ms; }
.registered li:nth-child(7)  { animation-delay: 180ms; }
.registered li:nth-child(8)  { animation-delay: 210ms; }
.registered li:nth-child(n+9){ animation-delay: 240ms; }

@keyframes li-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dot {
  width: 8px; height: 8px;
  border-radius: 999px;
  background: var(--ok);
  flex: 0 0 auto;
  box-shadow: 0 0 10px rgba(52, 224, 138, 0.65);
  /* Soft live-pulse. */
  animation: dot-live 2.4s ease-in-out infinite;
}
.dot.dot-offline {
  background: var(--fg-dim);
  box-shadow: none;
  animation: none;
}
@keyframes dot-live {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: 0.7; transform: scale(0.85); }
}

.name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--fg-dim);
  font-size: 14px;
  padding: 14px 4px 8px;
  margin: 0;
}
.empty-icon { color: var(--fg-dim); flex: 0 0 auto; }
.empty.hidden { display: none; }

.foot {
  text-align: center;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding-top: 8px;
}

/* RTL — flip gradients, status, caret already handled. */
[dir="rtl"] .status { flex-direction: row-reverse; }
[dir="rtl"] .row    { flex-direction: row-reverse; }
[dir="rtl"] .empty  { flex-direction: row-reverse; }

/* Generic hide — used to collapse conditional fieldsets. */
.hidden { display: none !important; }

/* Radio groups */
.radio-group {
  border: 0;
  margin: 20px 0 0;
  padding: 0;
  min-width: 0;
}
.radio-group > legend {
  display: block;
  width: 100%;
  color: var(--fg-mute);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 12px;
  padding: 0;
}
.radio-group .options {
  display: grid;
  gap: 8px;
}
.radio-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(11, 15, 26, 0.5);
  cursor: pointer;
  user-select: none;
  transition:
    border-color var(--t-fast) var(--ease-out),
    background var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out);
}
.radio-card:hover { border-color: var(--border-strong); }
.radio-card input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--fg-dim);
  border-radius: 999px;
  background: transparent;
  flex: 0 0 auto;
  position: relative;
  cursor: pointer;
  transition:
    border-color var(--t-fast) var(--ease-out),
    background var(--t-fast) var(--ease-out);
}
.radio-card input[type="radio"]:checked {
  border-color: var(--accent);
  background: radial-gradient(circle, var(--accent) 0 4px, transparent 5px);
}
.radio-card:has(input:checked) {
  border-color: var(--accent);
  background: rgba(56, 225, 255, 0.07);
  box-shadow: 0 0 0 1px rgba(56, 225, 255, 0.45) inset;
}
.radio-card .radio-card-label {
  flex: 1 1 auto;
  font-size: 13px;
  color: var(--fg);
  line-height: 1.35;
}

/* Status pill / mode pill in registered list */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: rgba(11, 15, 26, 0.4);
  color: var(--fg-dim);
  white-space: nowrap;
  flex: 0 0 auto;
}
.tag.status-online  {
  color: var(--ok);
  border-color: rgba(52, 224, 138, 0.45);
  background: rgba(52, 224, 138, 0.08);
}
.tag.status-offline {
  color: var(--fg-dim);
}
.tag.mode {
  color: var(--accent);
  border-color: rgba(56, 225, 255, 0.35);
  background: rgba(56, 225, 255, 0.06);
}
.registered li .tags {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-inline-start: auto;
  flex: 0 0 auto;
}
.registered li .name { min-width: 0; }

/* Mobile */
@media (max-width: 520px) {
  .shell { padding: 28px 16px 56px; gap: 18px; }
  .row { flex-direction: column; }
  button { width: 100%; min-width: 0; }
  .select-wrap { flex: 1 1 100%; }
  select { font-size: 16px; }       /* prevent iOS auto-zoom on focus */
}

/* Fullscreen status overlay */
.status-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 15, 26, 0.92);
  opacity: 0;
  pointer-events: none;
  animation: overlay-in 280ms var(--ease-out) forwards;
}
.status-overlay.hidden { display: none; }
.status-overlay.hiding { animation: overlay-out 400ms var(--ease-out) forwards; }

.status-overlay .overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 42px 48px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg), 0 0 60px rgba(56, 225, 255, 0.10);
  text-align: center;
  max-width: 86vw;
}

.status-overlay .overlay-icon svg {
  width: 48px;
  height: 48px;
}

.status-overlay .overlay-text {
  font-family: var(--font-display);
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 700;
  line-height: 1.25;
  color: var(--fg);
}

.status-overlay .overlay-name {
  font-family: var(--font-display);
  font-size: clamp(32px, 6vw, 48px);
  font-weight: 800;
  line-height: 1.1;
  color: var(--fg);
  word-break: break-word;
  max-width: 100%;
}
.status-overlay .overlay-name:empty { display: none; }

.status-overlay.ok    .overlay-text { color: var(--ok); }
.status-overlay.error .overlay-text { color: var(--danger); }
.status-overlay.ok    .overlay-name { color: var(--ok); }
.status-overlay.error .overlay-name { color: var(--danger); }
.status-overlay.ok    .overlay-icon { color: var(--ok); }
.status-overlay.error .overlay-icon { color: var(--danger); }

@keyframes overlay-in {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes overlay-out {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.96); }
}

[dir="rtl"] .status-overlay .overlay-content { flex-direction: column; }

/* Reduced motion — respect user preference. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
