/* Canonical 60-30-10 True AMOLED #000000 Design System (WCAG AAA, 8pt Grid, GPU 120Hz) */
:root {
  --bg-amoled: #000000;          /* 60% Primary True Black OLED */
  --surface-card: #0d0d0d;       /* 30% Elevated Surface */
  --surface-elevated: #171717;
  --border-subtle: #262626;
  --text-primary: #fafafa;       /* 19.6:1 contrast on #000000 (WCAG AAA) */
  --text-muted: #a3a3a3;         /* 8.3:1 contrast on #000000 (WCAG AAA) */
  --accent-emerald: #10b981;     /* 10% Primary CTA / Safe / Active */
  --accent-emerald-ink: #021a12;
  --accent-amber: #f59e0b;       /* Live-Mic / Rescue Alert (High Visibility) */
  --accent-danger: #f87171;
  --radius-md: 12px;
  --radius-lg: 16px;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-amoled);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top, 0px) + var(--space-2)) var(--space-2)
    calc(env(safe-area-inset-bottom, 0px) + var(--space-3));
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* 5-State Visibility Gate */
.state-panel {
  display: none;
  flex-direction: column;
  gap: var(--space-2);
}
.app-shell[data-ui-state="loading"] #panel-loading,
.app-shell[data-ui-state="empty"] #panel-empty,
.app-shell[data-ui-state="success"] #panel-success,
.app-shell[data-ui-state="error"] #panel-error,
.app-shell[data-ui-state="offline"] #panel-offline {
  display: flex;
}

.hidden {
  display: none !important;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--border-subtle);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-emerald);
}

.brand-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.room-meta {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.live-mic-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  transition: transform 140ms ease, opacity 140ms ease;
}

.live-mic-pill[data-live="true"] {
  background: #2b1800;
  border-color: var(--accent-amber);
  color: #fde68a;
}

.mic-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.live-mic-pill[data-live="true"] .mic-indicator-dot {
  background: var(--accent-amber);
}

.card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.section-heading {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.card-title-row,
.voice-top-row,
.slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1);
}

.card-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.muted-copy {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.confirm-code-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: 0.25em;
  text-align: center;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  background: var(--bg-amoled);
  border: 1px solid var(--accent-emerald);
  color: var(--accent-emerald);
}

.pair-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.text-input {
  width: 100%;
  background: var(--bg-amoled);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 0.95rem;
}

.text-input:focus-visible,
button:focus-visible,
input[type="range"]:focus-visible {
  outline: 2px solid var(--accent-emerald);
  outline-offset: 2px;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.98);
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--accent-emerald);
  color: var(--accent-emerald-ink);
}

.btn-secondary {
  background: var(--surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-amber {
  background: var(--accent-amber);
  color: #1c1000;
}

.btn-amoled {
  background: var(--bg-amoled);
  color: var(--text-primary);
  border-color: #404040;
}

.btn-danger-ghost {
  background: transparent;
  color: var(--accent-danger);
  border: 1px solid #5c2222;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.region-chip,
.perm-badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.ptt-ring-btn {
  width: 100%;
  min-height: 152px;
  border-radius: var(--radius-lg);
  background: var(--bg-amoled);
  border: 2px solid var(--border-subtle);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: var(--space-2);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: transform 120ms ease, opacity 120ms ease;
}

.ptt-ring-btn[aria-pressed="true"] {
  border-color: var(--accent-emerald);
  background: #041f16;
  transform: scale(0.99);
}

.ptt-icon {
  width: 36px;
  height: 36px;
  color: var(--accent-emerald);
}

.ptt-main-label {
  font-size: 1.05rem;
  font-weight: 700;
}

.ptt-sub-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.voice-actions-row,
.remote-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-1);
}

.remote-grid {
  grid-template-columns: 1fr 1.6fr 1fr;
}

.reaction-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.chip-btn {
  flex: 1 1 auto;
  background: var(--bg-amoled);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-emerald);
}

.chat-feed {
  list-style: none;
  margin: 0;
  padding: var(--space-1);
  max-height: 160px;
  overflow-y: auto;
  background: var(--bg-amoled);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
}

.chat-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-1);
}

.rescue-banner,
.breaker-toast {
  background: #1f1400;
  border: 1px solid var(--accent-amber);
  border-radius: var(--radius-md);
  padding: 12px var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rescue-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.86rem;
}

.btn-inline {
  align-self: flex-start;
  background: transparent;
  color: var(--accent-amber);
  border: 1px solid var(--accent-amber);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
}

.skeleton-bar {
  height: 6px;
  width: 48%;
  border-radius: 999px;
  background: var(--accent-emerald);
  opacity: 0.75;
}

/* Pure #000000 AMOLED Pocket Dimmer */
.amoled-dimmer {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: #000000;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--space-3);
}

.dimmer-ptt-zone {
  flex: 1;
  background: #000000;
  border: 1px dashed #1f1f1f;
  border-radius: var(--radius-lg);
  color: #525252;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  touch-action: none;
}

.dimmer-hint-primary {
  font-size: 0.95rem;
  font-weight: 600;
}

.dimmer-hint-sub {
  font-size: 0.78rem;
  color: #3f3f3f;
}

.dimmer-exit-btn {
  margin-top: var(--space-2);
  background: #080808;
  color: #737373;
  border: 1px solid #1f1f1f;
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 0.85rem;
  cursor: pointer;
}

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