:root {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0f;
  --bg-tertiary: #14141f;
  --bg-card: #1a1a2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent-primary: #00d4ff;
  --accent-secondary: #00ff88;
  --accent-warm: #ff9f43;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --success: #00ff88;
  --warning: #ffaa00;
  --info: #00b4d8;

  --sev-critical: #ff4466;
  --sev-high: #ff9f43;
  --sev-medium: #ffaa00;
  --sev-low: #00d4ff;
  --sev-possible: #a0a0b0;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 600px;
  height: 600px;
  overflow: hidden;
}

#app {
  width: 600px;
  height: 600px;
  position: relative;
}

.screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
}
.screen.hidden { display: none; }

.header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-secondary);
  gap: 12px;
  flex-shrink: 0;
  min-height: 64px;
}
.header h1 {
  font-size: 22px;
  font-weight: 600;
  flex: 1;
}
.header-meta {
  font-size: 13px;
  color: var(--text-secondary);
}
.status-pill {
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  background: rgba(160, 160, 176, 0.18);
  color: var(--text-secondary);
}
.status-pill[data-status="connected"] {
  background: rgba(0, 255, 136, 0.18);
  color: var(--success);
}
.status-pill[data-status="connecting"] {
  background: rgba(0, 212, 255, 0.18);
  color: var(--accent-primary);
}
.status-pill[data-status="error"], .status-pill[data-status="disconnected"] {
  background: rgba(255, 68, 102, 0.18);
  color: var(--danger);
}
.back-btn {
  background: transparent;
  color: var(--text-primary);
  font-size: 22px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  min-width: 44px;
  min-height: 44px;
}

.content {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
  min-height: 44px;
}
.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

.nav-bar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.nav-item {
  flex: 1;
  min-height: 88px;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.04em;
}
.nav-item:focus { background: var(--bg-card); }

.awaiting-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
}
.awaiting-pulse {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--accent-primary);
  box-shadow: 0 0 32px var(--focus-glow);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50%      { transform: scale(1.08); opacity: 1; }
}
.awaiting-label {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
}
.awaiting-sub {
  font-size: 14px;
  color: var(--text-secondary);
}

.finding-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
  border: 2px solid var(--bg-tertiary);
}
.severity-band {
  padding: 10px 16px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  color: #0a0a0f;
  background: var(--sev-possible);
}
.severity-band.sev-CRITICAL { background: var(--sev-critical); color: #ffffff; }
.severity-band.sev-HIGH     { background: var(--sev-high); color: #0a0a0f; }
.severity-band.sev-MEDIUM   { background: var(--sev-medium); color: #0a0a0f; }
.severity-band.sev-LOW      { background: var(--sev-low); color: #0a0a0f; }
.severity-band.sev-POSSIBLE { background: var(--sev-possible); color: #0a0a0f; }

.finding-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.finding-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}
.finding-confidence {
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}
.finding-citation {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-primary);
  padding: 6px 10px;
  background: rgba(0, 212, 255, 0.10);
  border-radius: var(--radius-sm);
  align-self: flex-start;
}
.finding-meta {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* Move 2: finding deck pager indicator ("Card i of N"). Cyan so it reads as a
   live position indicator on the additive display; hidden when the deck is empty. */
.finding-pager {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-primary);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.finding-pager:empty { display: none; }

.action-row {
  display: flex;
  gap: 8px;
}
/* Phase 2: 4-button D-pad layout (2x2) when a walk is active. */
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.action-grid .action-btn {
  min-height: 84px;
  position: relative;
}
/* Long-press progress ring around CONFIRM (Task 9). */
.lp-ring {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  pointer-events: none;
  opacity: 0;
  box-shadow: inset 0 0 0 3px var(--accent-primary);
}
.lp-ring.lp-armed {
  opacity: 1;
  animation: lpfill 2s linear forwards;
}
.lp-ring.lp-cancel {
  opacity: 0;
  animation: none;
  transition: opacity 0.15s ease;
}
@keyframes lpfill {
  0%   { clip-path: inset(0 100% 0 0); opacity: 0.5; }
  100% { clip-path: inset(0 0 0 0);   opacity: 1; }
}
.action-btn {
  flex: 1;
  min-height: 88px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 2px solid transparent;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.action-btn:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
  background: var(--bg-card);
}
.action-btn.confirm { background: rgba(0, 255, 136, 0.18); }
.action-btn.confirm:focus { background: rgba(0, 255, 136, 0.30); }
.action-btn.dismiss { background: var(--bg-tertiary); }
.action-btn.flag    { background: rgba(255, 159, 67, 0.18); }
.action-btn.flag:focus { background: rgba(255, 159, 67, 0.30); }
.action-btn.finish  { background: rgba(0, 212, 255, 0.18); }
.action-btn.finish:focus { background: rgba(0, 212, 255, 0.32); }

/* --- Phase 2: confirmation screen --- */
.summary-card {
  background: var(--bg-card);
  border: 2px solid var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
}
.summary-headline {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}
.picker-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  margin-top: 4px;
}
.recipient-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.recipient-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 14px;
  min-height: 56px;
  border: 2px solid transparent;
  text-align: left;
}
.recipient-row:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
  background: var(--bg-card);
}
.rcpt-check {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--text-muted);
}
.recipient-row.is-selected .rcpt-check {
  background: var(--success);
  border-color: var(--success);
}
.rcpt-name { font-size: 16px; font-weight: 600; }
.rcpt-email { font-size: 12px; color: var(--text-secondary); }
.recipient-empty { font-size: 14px; color: var(--text-secondary); padding: 12px 4px; }

/* --- Phase 2: sending / terminal screens --- */
.center-col {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 20px;
}
.spinner {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 6px solid var(--bg-tertiary);
  border-top-color: var(--accent-primary);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.sending-status {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
}
.terminal-icon {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 52px;
  font-weight: 800;
}
.terminal-icon.fatal {
  background: rgba(255, 68, 102, 0.18);
  color: var(--danger);
  border: 3px solid var(--danger);
}
.terminal-msg {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  max-width: 480px;
}
#failed .header h1 { color: var(--danger); }
.terminal-icon.success {
  background: rgba(0, 255, 136, 0.16);
  color: var(--success);
  border: 3px solid var(--success);
}
#complete .header h1 { color: var(--success); }

.action-btn.is-confirmed { background: var(--success); color: #0a0a0f; }
.action-btn.is-dismissed { background: var(--text-muted); color: #0a0a0f; }
.action-btn.is-flagged   { background: var(--accent-warm); color: #0a0a0f; }

/* --- Reconnect indicator (KI-035) --- */
.reconnect-indicator {
  position: fixed;
  bottom: 110px;
  right: 16px;
  background: rgba(255, 159, 67, 0.18);
  color: var(--accent-warm);
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  z-index: 200;
  pointer-events: none;
  opacity: 1;
  transition: opacity 400ms ease;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 280px;
}
.reconnect-indicator.fade-out { opacity: 0; }
.reconnect-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-warm);
  animation: pulse 1s ease-in-out infinite;
  flex-shrink: 0;
}

.hidden { display: none !important; }
.text-muted { color: var(--text-secondary); }

/* --- Phase 2: home FINISH WALK + add-recipient form --- */
.home-nav { flex-wrap: wrap; }
.home-nav .nav-item { min-height: 72px; }
.nav-item[disabled] { opacity: 0.4; pointer-events: none; }
.nav-secondary {
  background: transparent;
  font-size: 14px;
  min-height: 48px;
  flex-basis: 100%;
}
.field-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}
.field-input {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 16px;
  min-height: 52px;
  width: 100%;
}
.field-input:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 14px;
  min-height: 52px;
  color: var(--text-primary);
  border: 2px solid transparent;
  text-align: left;
}
.checkbox-row:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}
.checkbox-row[aria-pressed="true"] .rcpt-check {
  background: var(--success);
  border-color: var(--success);
}
.field-error {
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
}
