/* Mobile Exam Simulator Styles (iPhone 12 Optimized) */
:root {
  --bg-app: #0b0f17;
  --bg-card: #151c2c;
  --bg-elevated: #1c2538;
  --border: #1e293b;
  --border-strong: #2e3d55;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #2dd4bf;
  --accent-teal: #0d9488;
  --accent-math: #6366f1;
  --accent-sci: #10b981;
  --accent-lang: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
}

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

body {
  background: var(--bg-app);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
}

/* Exam Header */
header.exam-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 15, 23, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.btn-back-link {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 8px;
  text-decoration: none;
  flex-shrink: 0;
}

.exam-nav-title {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exam-timer-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 15px;
  font-weight: 800;
  background: rgba(45, 212, 191, 0.12);
  border: 1px solid rgba(45, 212, 191, 0.3);
  color: var(--accent);
  padding: 5px 10px;
  border-radius: 9999px;
  flex-shrink: 0;
}

.exam-timer-pill.urgent {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--danger);
  animation: pulse 1s infinite;
}
@keyframes pulse { 50% { opacity: 0.6; } }

/* Main Screens */
.screen-view {
  flex: 1;
  display: none;
  flex-direction: column;
}
.screen-view.active {
  display: flex;
}

/* Exam Hub */
.hub-content {
  padding: 20px 16px 80px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hub-hero {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-elevated) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hub-hero h1 { font-size: 20px; font-weight: 800; }
.hub-hero p { font-size: 13px; color: var(--text-muted); line-height: 1.4; }

.exam-card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.exam-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.exam-card:active {
  transform: scale(0.98);
  border-color: var(--accent);
}

.card-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.exam-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.exam-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.exam-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exam-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.btn-start-exam {
  background: var(--accent-teal);
  color: #f8fafc;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

/* Active Exam Flow */
.test-content-area {
  flex: 1;
  padding: 16px 16px 100px;
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.question-status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.btn-nav-sheet-trigger {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* Passage card */
.passage-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.passage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.passage-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  max-height: 220px;
  overflow-y: auto;
  padding-right: 6px;
}

/* Question Box */
.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.question-text {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-main);
}

.question-text img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 10px 0;
  background: #ffffff;
  padding: 6px;
}

/* Choices list */
.choices-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 52px;
}
.choice-item:active { transform: scale(0.99); }

.choice-item.selected {
  background: rgba(45, 212, 191, 0.12);
  border-color: var(--accent);
}

.choice-letter {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-muted);
  flex-shrink: 0;
}
.choice-item.selected .choice-letter {
  background: var(--accent);
  color: #0b0f17;
  border-color: var(--accent);
}

.choice-html {
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-main);
  flex: 1;
}

/* Sticky Bottom Test Bar */
.test-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(11, 15, 23, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 90;
}

.btn-test-nav {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn-test-nav:disabled { opacity: 0.3; }

.btn-flag-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.btn-flag-toggle.flagged {
  border-color: var(--warning);
  color: var(--warning);
  background: rgba(245, 158, 11, 0.1);
}

.btn-next-submit {
  background: var(--accent);
  color: #0b0f17;
  border: none;
  padding: 10px 22px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

/* Navigator Sheet (Modal) */
.nav-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 150;
  display: none;
  align-items: flex-end;
}
.nav-sheet-backdrop.open { display: flex; }

.nav-sheet {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-height: 75vh;
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.nav-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-sheet-header h3 { font-size: 16px; font-weight: 800; }
.nav-sheet-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
}

.grid-legend {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.dot-answered { background: var(--success); }
.dot-flagged { background: var(--warning); }
.dot-empty { background: var(--border-strong); }

.question-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.grid-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.grid-cell.answered { background: rgba(16, 185, 129, 0.2); border-color: var(--success); color: var(--success); }
.grid-cell.flagged { border-color: var(--warning); color: var(--warning); }
.grid-cell.current { outline: 2px solid var(--accent); }

/* Results Screen */
.results-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.score-display-ring {
  font-size: 42px;
  font-weight: 900;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.stat-pills-row {
  display: flex;
  gap: 10px;
  width: 100%;
}
.stat-pill {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-pill .num { font-size: 18px; font-weight: 800; }
.stat-pill .lbl { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }

/* Review list */
.review-header {
  font-size: 16px;
  font-weight: 800;
  margin-top: 14px;
}

.review-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.review-item.correct { border-left: 4px solid var(--success); }
.review-item.wrong { border-left: 4px solid var(--danger); }

.review-qnum {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-dim);
}
.review-ans-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}
