/* ── Reset & variables ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0a0a0f;
  --surface:      #12121a;
  --surface-alt:  #1c1c28;
  --border:       #2a2a3a;
  --accent:       #00c896;
  --accent-dark:  #009e76;
  --danger:       #e84040;
  --warn:         #f5a623;
  --text:         #e8e8f0;
  --text-muted:   #7878a0;
  --text-dim:     #4a4a6a;
  --ptt-size:     82px;
  --radius:       12px;
  --safe-top:     env(safe-area-inset-top, 0px);
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Screens ────────────────────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; }

/* ── Picker screen ──────────────────────────────────────────────────────── */
.app-header {
  padding: calc(var(--safe-top) + 32px) 24px 24px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--accent);
}

.tagline {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.picker-body {
  flex: 1;
  padding: 24px 16px calc(var(--safe-bottom) + 24px);
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 16px;
}

.route-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.route-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.route-card:active,
.route-card:hover {
  border-color: var(--accent);
  background: var(--surface-alt);
}

.route-card-airports {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.route-icao {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  color: var(--text);
}

.route-arrow {
  color: var(--accent);
  font-size: 18px;
}

.route-card-label {
  font-size: 13px;
  color: var(--text-muted);
}

.route-card-badge {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: rgba(0, 200, 150, 0.12);
  color: var(--accent);
  border-radius: 4px;
  padding: 2px 7px;
}

.demo-note {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
  text-align: center;
  padding: 0 8px;
}

/* ── Loading screen ─────────────────────────────────────────────────────── */
.loading-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px 24px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.loading-msg {
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
}

.loading-sub {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* ── Session screen ─────────────────────────────────────────────────────── */
.session-header {
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.btn-back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.session-route-label {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  color: var(--text);
}

.phase-counter {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.session-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

.phase-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Message boxes ──────────────────────────────────────────────────────── */
.message-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.message-box-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.atc-box .message-box-label  { color: var(--accent); }
.pilot-cue-box .message-box-label { color: var(--warn); }
.transcript-box .message-box-label { color: var(--text-muted); }

.message-text {
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
}

.pilot-cue-box {
  border-color: rgba(245, 166, 35, 0.3);
  background: rgba(245, 166, 35, 0.05);
}

/* ── Evaluation box ─────────────────────────────────────────────────────── */
.eval-box {
  border-radius: var(--radius);
  padding: 12px 16px;
  border: 1px solid var(--border);
}

.eval-box.pass  { border-color: rgba(0, 200, 150, 0.4); background: rgba(0, 200, 150, 0.08); }
.eval-box.partial { border-color: rgba(245, 166, 35, 0.4); background: rgba(245, 166, 35, 0.07); }
.eval-box.fail  { border-color: rgba(232, 64, 64, 0.4); background: rgba(232, 64, 64, 0.07); }
.eval-box.hint  { border-color: rgba(120, 120, 160, 0.4); background: var(--surface); }

.eval-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

/* ── Controls bar ───────────────────────────────────────────────────────── */
.session-controls {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 24px calc(var(--safe-bottom) + 20px);
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  max-width: 400px;
  margin: 0 auto;
}

/* PTT button */
.btn-ptt {
  width: var(--ptt-size);
  height: var(--ptt-size);
  border-radius: 50%;
  border: 3px solid var(--accent);
  background: var(--surface-alt);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
  flex-shrink: 0;
}

.btn-ptt:disabled {
  border-color: var(--border);
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-ptt.recording {
  background: var(--danger);
  border-color: var(--danger);
  transform: scale(1.08);
}

.ptt-icon { font-size: 22px; line-height: 1; }
.ptt-label { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }

/* Hint button */
.btn-hint {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.btn-hint:hover { border-color: var(--accent); color: var(--accent); }

/* Next button */
.btn-next {
  min-width: 80px;
  height: 44px;
  border-radius: 22px;
  border: 1px solid var(--accent);
  background: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 16px;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.btn-next:hover { background: var(--accent); color: #000; }

/* ── Completion screen ──────────────────────────────────────────────────── */
.complete-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px 32px calc(var(--safe-bottom) + 40px);
  text-align: center;
}

.complete-check {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(0, 200, 150, 0.15);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--accent);
}

.complete-center h2 {
  font-size: 24px;
  font-weight: 700;
}

.complete-route {
  font-size: 14px;
  color: var(--text-muted);
}

.btn-primary {
  margin-top: 8px;
  padding: 14px 32px;
  border-radius: 28px;
  border: none;
  background: var(--accent);
  color: #000;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--accent-dark); }

/* ── Utility ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
