/* ── Init Screen (Waver-style) ── */
.init-container {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%; padding: 24px; gap: 16px; text-align: center;
}
.init-title { color: var(--accent); font-size: 28px; font-weight: 700; letter-spacing: 3px; }
.init-subtitle { color: var(--muted); font-size: 13px; }
.init-status { color: var(--muted); font-size: 11px; margin-top: 8px; }
.init-spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.init-spinner.done { border-top-color: var(--green); animation: none; border-color: var(--green); }
.init-spinner.error { border-top-color: var(--red); animation: none; border-color: var(--red); }
.init-info { color: var(--dim); font-size: 10px; line-height: 1.5; max-width: 300px; }
.init-version { color: #333; font-size: 9px; margin-top: auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Permission prompt ── */
.permission-bar {
  background: var(--blue-bg); border: 1px solid var(--blue-border); border-radius: 8px;
  padding: 10px 14px; margin-bottom: 10px; flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
}
.permission-icon { font-size: 20px; }
.permission-text { color: var(--accent); font-size: 11px; flex: 1; }
.permission-btn {
  background: var(--accent); color: var(--bg); border: none; border-radius: 6px;
  padding: 6px 14px; font-family: inherit; font-size: 11px; font-weight: 600; cursor: pointer;
}
:root {
  --bg: #0A0A1A;
  --bg-card: #0D0D2B;
  --border: #1A1A3E;
  --text: #CCC;
  --muted: #888;
  --dim: #555;
  --accent: #00E5FF;
  --gold: #FFD700;
  --green: #32CD32;
  --red: #FF4444;
  --blue-bg: #1A3A6E;
  --blue-border: #2A5A9E;
}

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

body {
  font-family: 'SF Mono', 'Menlo', 'Courier New', monospace;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── Screens ── */
.screen { display: none; flex-direction: column; flex: 1; padding: 12px 16px; overflow-y: auto; }
.screen.active { display: flex; }

/* ── Top Bar ── */
.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; flex-shrink: 0; }
.logo { color: var(--accent); font-size: 20px; font-weight: 700; letter-spacing: 2px; }
.version { color: var(--dim); font-size: 11px; }

/* ── Spectrum Canvas ── */
.spectrum-wrap {
  display: flex; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; margin-bottom: 10px; flex-shrink: 0;
}
.spectrum-wrap canvas { display: block; max-width: 100%; height: auto; }

/* ── Spectrogram Waterfall ── */
.spectrogram-wrap {
  display: flex; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; margin-bottom: 10px; flex-shrink: 0;
}
.spectrogram-wrap canvas { display: block; max-width: 100%; height: auto; }
.spectrogram-label {
  color: var(--dim); font-size: 8px; text-align: center; margin-top: -8px; margin-bottom: 10px;
}

/* ── Waver Test Panel ── */
.waver-panel {
  margin: 0 12px 8px; background: #111; border: 1px solid #3A7ADF; border-radius: 8px; overflow: hidden;
}
.waver-panel.hidden { display: none; }
.waver-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: #1A2A4A; }
.waver-title { color: #3A7ADF; font-size: 12px; font-weight: 600; }
.waver-close { background: none; border: none; color: #666; font-size: 16px; cursor: pointer; padding: 0 4px; }
.waver-body { padding: 12px; }
.waver-section { margin-bottom: 10px; }
.waver-section label { display: block; color: #888; font-size: 10px; margin-bottom: 4px; }
.waver-input {
  width: 100%; background: #1A1A2E; border: 1px solid #333; border-radius: 6px;
  padding: 6px 10px; color: #FFF; font-family: inherit; font-size: 12px;
}
.waver-select {
  width: 100%; background: #1A1A2E; border: 1px solid #333; border-radius: 6px;
  padding: 6px 10px; color: #FFF; font-family: inherit; font-size: 12px;
}
.waver-slider { width: 100%; margin-top: 4px; accent-color: var(--accent); }
.waver-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.waver-buttons .btn { width: auto; }
.btn-outline { background: transparent; color: var(--accent); border-color: #333; }
.waver-status {
  margin-top: 8px; padding: 6px 10px; border-radius: 6px; font-size: 10px; color: #888;
  background: #1A1A2E; min-height: 28px;
}
.waver-status.ok { color: var(--green); }
.waver-status.warn { color: var(--gold); }
.waver-status.error { color: var(--red); }

/* ── Signal Row ── */
.signal-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-shrink: 0; }
.signal-label { color: var(--muted); font-size: 11px; width: 40px; }
.signal-bar-bg { flex: 1; height: 8px; background: var(--border); border-radius: 4px; }
.signal-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.3s; }
.signal-value { color: var(--muted); font-size: 11px; width: 55px; text-align: right; }

/* ── Status ── */
.status-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; min-height: 24px; flex-shrink: 0; }
.pulse-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1.5s infinite; }
.pulse-dot.hidden { display: none; }
.status-text { color: var(--text); font-size: 13px; }

/* ── Action Area ── */
.action-area { display: flex; justify-content: center; gap: 8px; flex-shrink: 0; margin-bottom: 8px; }

/* ── Debug ── */
.debug-line { color: #333; font-size: 9px; text-align: center; margin-top: auto; flex-shrink: 0; }

/* ── Device Picker ── */
.device-picker { margin: 0 12px 8px; background: #111; border: 1px solid #3A7ADF; border-radius: 8px; overflow: hidden; }
.device-picker.hidden { display: none; }
.device-picker-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: #1A2A4A; }
.device-picker-title { color: #3A7ADF; font-size: 12px; font-weight: 600; }
.device-picker-close { background: none; border: none; color: #666; font-size: 16px; cursor: pointer; padding: 0 4px; }
.device-picker-item { display: flex; align-items: center; padding: 8px 12px; border-top: 1px solid #222; cursor: pointer; transition: background 0.15s; }
.device-picker-item:hover { background: #1A2A4A; }
.device-picker-item-dot { width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; flex-shrink: 0; }
.device-picker-item-dot.match { background: #32CD32; }
.device-picker-item-dot.nomatch { background: #FF4444; }
.device-picker-item-info { flex: 1; min-width: 0; }
.device-picker-item-label { color: #ccc; font-size: 12px; }
.device-picker-item-detail { color: #666; font-size: 10px; }
.device-picker-item-action { color: #3A7ADF; font-size: 11px; font-weight: 600; margin-left: 8px; white-space: nowrap; }

/* ── Buttons ── */
.btn {
  padding: 12px 28px; border-radius: 8px; font-family: inherit; font-size: 14px;
  font-weight: 600; cursor: pointer; border: 1px solid; transition: opacity 0.2s;
  display: block; width: 100%; text-align: center; margin-bottom: 8px;
}
.btn:active { opacity: 0.8; }
.btn-primary { background: var(--blue-bg); color: var(--accent); border-color: var(--blue-border); }
.btn-success { background: #1A3E1A; color: var(--green); border-color: var(--green); }
.btn-danger { background: #3A1A1A; color: var(--red); border-color: #5A2A2A; }
.btn-whatsapp { background: #075E54; color: #25D366; border-color: #128C7E; }
.btn-small { padding: 6px 14px; font-size: 11px; width: auto; display: inline-block; }

/* ── Navigation ── */
.nav-btn {
  background: none; border: none; color: var(--dim); font-family: inherit; font-size: 12px;
  padding: 10px 16px; cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.2s;
}
.nav-btn.active, .nav-btn:hover { color: var(--accent); border-bottom-color: var(--accent); }
.bottom-nav {
  display: flex; justify-content: space-around; background: var(--bg-card);
  border-top: 1px solid var(--border); padding: 4px 0; flex-shrink: 0;
}
.bottom-nav.hidden { display: none; }

/* ── Profile ── */
.scroll-content { flex: 1; overflow-y: auto; padding-bottom: 16px; }
.profile-section { margin-bottom: 16px; }
.profile-section label {
  display: block; color: #AAA; font-size: 10px; letter-spacing: 1px; margin-bottom: 6px;
}
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 14px; border-radius: 16px; border: 1px solid #333;
  background: transparent; color: var(--muted); font-family: inherit; font-size: 11px;
  cursor: pointer; transition: all 0.15s;
}
.chip.active { background: #0A2A3A; border-color: var(--accent); color: var(--accent); }
.option-row {
  display: block; width: 100%; padding: 8px 12px; border-radius: 6px; text-align: left;
  margin-bottom: 4px; border: 1px solid var(--border); background: transparent;
  color: var(--text); font-family: inherit; font-size: 12px; cursor: pointer;
}
.option-row.active { border-color: var(--accent); background: #0A2A3A; color: var(--accent); }
input[type="number"], input[type="text"] {
  background: #111; border: 1px solid #333; border-radius: 6px; padding: 8px 10px;
  color: #FFF; font-family: inherit; font-size: 13px; width: 100%;
}

/* ── SAS ── */
.sas-container {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%; padding: 16px; gap: 14px;
}
.sas-title { color: var(--gold); font-size: 20px; letter-spacing: 2px; }
.sas-subtitle { color: #AAA; font-size: 11px; text-align: center; }
.sas-digits {
  background: var(--bg-card); border: 2px solid var(--gold); border-radius: 12px;
  padding: 12px 28px; font-size: 32px; font-weight: 800; letter-spacing: 4px; color: var(--gold);
}
.sas-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; width: 100%; max-width: 280px; }
.sas-grid div {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 0; text-align: center; font-size: 17px; font-weight: bold; color: var(--accent);
}
.sas-warning { color: var(--dim); font-size: 10px; text-align: center; margin-top: 8px; }

/* ── Biometric ── */
.bio-container {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  height: 100%; padding: 16px; justify-content: center;
}
.bio-title { color: var(--green); font-size: 20px; letter-spacing: 2px; }
.bio-subtitle { color: #AAA; font-size: 11px; text-align: center; }
.bio-steps { width: 100%; }
.bio-step { display: flex; margin-bottom: 12px; }
.bio-step-dot {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid #333;
  display: flex; align-items: center; justify-content: center; font-size: 11px; flex-shrink: 0;
}
.bio-step-dot.active { border-color: var(--accent); background: #0A2A3A; }
.bio-step-dot.done { border-color: var(--green); background: #1A3E1A; color: var(--green); }
.bio-step-info { margin-left: 10px; }
.bio-step-label { color: var(--text); font-size: 13px; }
.bio-step-label.active { color: var(--accent); font-weight: 600; }
.bio-step-status { color: var(--dim); font-size: 10px; }
.bio-camera {
  background: var(--bg-card); border-radius: 12px; border: 1px solid var(--border);
  height: 140px; width: 100%; max-width: 300px; display: flex;
  flex-direction: column; align-items: center; justify-content: center;
}
.bio-frame {
  width: 80px; height: 80px; border-radius: 50%; border: 2px dashed var(--green);
  display: flex; align-items: center; justify-content: center; font-size: 36px;
}
.bio-prompt { color: var(--muted); font-size: 11px; margin-top: 8px; }
.bio-liveness { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 300px; }
.bio-live-label { color: var(--muted); font-size: 11px; }
.bio-live-dot { width: 10px; height: 10px; border-radius: 50%; background: #333; }
.bio-live-dot.scanning { background: #DAA520; }
.bio-live-dot.verified { background: var(--green); }
.bio-live-text { color: #AAA; font-size: 11px; }
.bio-zk {
  background: #111; border-radius: 8px; padding: 10px; width: 100%; max-width: 300px;
  color: var(--dim); font-size: 9px; text-align: center;
}

/* ── Connected ── */
.connected-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.connected-title { color: var(--green); font-size: 20px; letter-spacing: 2px; }
.connected-mode { color: var(--muted); font-size: 11px; margin-top: 2px; }
.session-timer { color: var(--green); font-size: 13px; }
.session-info { background: var(--bg-card); border-radius: 8px; padding: 8px; margin-bottom: 10px; color: var(--dim); font-size: 10px; }
.connected-content { flex: 1; overflow-y: auto; margin-bottom: 8px; display: flex; flex-direction: column; }

/* Chat bubbles */
.chat-bubble { max-width: 75%; padding: 8px 10px; border-radius: 8px; margin-bottom: 6px; font-size: 12px; }
.chat-bubble.me { align-self: flex-end; background: #0A2A3A; border: 1px solid #1A4A6E; }
.chat-bubble.them { align-self: flex-start; background: #1A1A3E; border: 1px solid #2A2A5E; }
.chat-time { font-size: 8px; color: var(--dim); display: block; text-align: right; margin-top: 3px; }

/* Chat input */
.chat-input-row { display: flex; gap: 6px; margin-bottom: 8px; }
.chat-input {
  flex: 1; background: #111; border: 1px solid #333; border-radius: 8px;
  padding: 8px 12px; color: #FFF; font-family: inherit; font-size: 12px;
}

/* i-Bubble cards */
.bubble-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; margin-bottom: 8px;
}
.bubble-card-header { display: flex; justify-content: space-between; align-items: center; }
.bubble-card-title { color: var(--text); font-size: 13px; font-weight: 600; }
.bubble-badge { padding: 2px 8px; border-radius: 4px; font-size: 9px; color: #FFF; }
.bubble-badge.rw { background: #2A4A0A; }
.bubble-badge.ro { background: #0A2A4A; }
.bubble-steward { color: #666; font-size: 10px; margin-top: 4px; }
.bubble-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ── History ── */
.history-entry {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 8px;
}
.history-entry-header { display: flex; justify-content: space-between; align-items: center; }
.history-entry-mode { color: var(--accent); font-size: 13px; font-weight: 600; }
.history-entry-time { color: var(--dim); font-size: 10px; }
.history-entry-detail { color: var(--muted); font-size: 11px; margin-top: 4px; }
.history-entry-duration { color: var(--green); font-size: 10px; margin-top: 2px; }
.history-empty { color: var(--dim); font-size: 12px; text-align: center; padding: 40px 20px; }
.history-debug { color: #333; font-size: 9px; margin-top: 8px; }

/* ── Data Exchange Log ── */
.data-log {
  margin: 0 12px 6px; background: #0A0A1A; border: 1px solid #1A3A3A; border-radius: 6px;
  max-height: 80px; overflow-y: auto; padding: 4px 8px; flex-shrink: 0;
}
.data-log.hidden { display: none; }
.data-log-entry { color: #3A7A3A; font-size: 8px; font-family: monospace; padding: 1px 0; border-bottom: 1px solid #0D1A0D; }
.data-log-entry.tx { color: #7A7A3A; }
.data-log-entry.rx { color: #3A7ADF; }
.data-log-entry.warn { color: #AA5533; }
.data-log-label { color: #333; font-size: 7px; margin-bottom: 2px; }

/* ── Animations ── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── Responsive ── */
@media (min-width: 500px) {
  body { max-width: 440px; margin: 0 auto; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
