:root {
  --bg: #f6f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #fff1f2;
  --primary: #b91c3c;
  --primary-hover: #9f1239;
  --primary-light: #ffe4e6;
  --accent: #0284c7;
  --emerald: #10b981;
  --emerald-light: #d1fae5;
  --amber: #f59e0b;
  --amber-light: #fef3c7;
  --rose: #e11d48;
  --rose-light: #ffe4e6;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 16px 36px rgba(185, 28, 60, 0.14);
  --radius: 14px;
  --radius-sm: 9px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Header & Navigation */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}

.topbar-inner {
  max-width: 1340px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), #881337);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(185, 28, 60, 0.3);
}

.brand-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

.nav-tabs {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.nav-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s ease;
}

.nav-btn:hover {
  background: var(--surface-3);
  color: var(--primary);
}

.nav-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 3px 10px rgba(185, 28, 60, 0.25);
}

.container {
  max-width: 1340px;
  margin: 0 auto;
  padding: 22px 24px 72px;
}

/* Buttons & Inputs */
button, .btn {
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all 0.15s ease;
  text-decoration: none;
}

button:hover, .btn:hover {
  border-color: #cbd5e1;
  background: var(--surface-2);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.btn-success {
  background: var(--emerald);
  color: #fff;
  border-color: var(--emerald);
}

.btn-success:hover {
  background: #059669;
  border-color: #059669;
}

.btn-danger {
  background: var(--rose);
  color: #fff;
  border-color: var(--rose);
}

.btn-soft {
  background: var(--surface-3);
  color: var(--primary);
  border-color: var(--primary-light);
}

.btn-soft:hover {
  background: var(--primary-light);
}

.btn-lg {
  padding: 12px 22px;
  font-size: 15px;
  border-radius: 11px;
}

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
  border-radius: 7px;
}

input, select, textarea {
  font: inherit;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(185, 28, 60, 0.12);
}

label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

/* Cards & Grid */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 980px) {
  .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 680px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .container { padding: 16px 14px 56px; }
}

/* Mode Selector Cards */
.mode-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.mode-card:hover {
  border-color: #fda4af;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.mode-card.selected {
  border-color: var(--primary);
  background: linear-gradient(180deg, #fff1f2 0%, #ffffff 100%);
  box-shadow: var(--shadow-lg);
}

.mode-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  margin-bottom: 8px;
}

.mode-title {
  font-size: 16px;
  font-weight: 800;
  margin: 0 0 6px;
  color: var(--text);
}

.mode-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 14px;
}

.mode-meta {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  display: flex;
  justify-content: space-between;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}

/* Utility & Badges */
.between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.flex {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
}

.pill-green {
  background: var(--emerald-light);
  color: #065f46;
}

.pill-amber {
  background: var(--amber-light);
  color: #92400e;
}

.pill-rose {
  background: var(--rose-light);
  color: #9f1239;
}

.pill-navy {
  background: #e2e8f0;
  color: #1e293b;
}

.progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.35s ease;
}

/* Timer & Simulator Bar */
.sim-header {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
}

.timer-digits {
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: #fff;
}

.timer-digits.warn { color: #fbbf24; }
.timer-digits.danger { color: #fb7185; }

/* Computer-Delivered IELTS Split-Screen Layout */
.cd-split {
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 18px;
  align-items: start;
}

@media (max-width: 1024px) {
  .cd-split {
    grid-template-columns: 1fr;
  }
}

.cd-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  max-height: 76vh;
  overflow: hidden;
}

.cd-pane-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.cd-pane-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
}

/* Passage Themes & Font Sizes */
.passage-body.font-sm { font-size: 13.5px; line-height: 1.65; }
.passage-body.font-md { font-size: 15px; line-height: 1.72; }
.passage-body.font-lg { font-size: 16.5px; line-height: 1.8; }

.passage-body.theme-sepia {
  background: #fdf8ee;
  color: #292524;
}

.passage-body.theme-dark {
  background: #0f172a;
  color: #e2e8f0;
}

.para-block {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  border-left: 3px solid transparent;
  transition: background 0.15s;
}

.para-block:hover {
  border-left-color: #fda4af;
}

.para-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 24px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  margin-right: 8px;
}

.para-hint-box {
  font-size: 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 5px 10px;
  border-radius: 7px;
  margin-bottom: 6px;
  font-weight: 600;
}

/* Highlights inside Passage */
mark.hl-yellow { background: #fef08a; color: #0f172a; padding: 1px 3px; border-radius: 3px; }
mark.hl-green  { background: #bbf7d0; color: #064e3b; padding: 1px 3px; border-radius: 3px; }
mark.hl-pink   { background: #fecdd3; color: #881337; padding: 1px 3px; border-radius: 3px; }

/* Question Cards in Right Pane */
.q-group-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 18px;
  overflow: hidden;
}

.q-group-head {
  background: #f8fafc;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.q-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.q-item:last-child {
  border-bottom: none;
}

.q-item.active-q {
  background: #fff1f2;
}

.q-num-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  border-radius: 8px;
  background: #1e293b;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
}

.q-num-badge.answered {
  background: var(--emerald);
}

.q-num-badge.flagged {
  background: var(--amber);
}

.mc-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 7px;
  cursor: pointer;
  font-size: 13.5px;
  transition: all 0.12s;
}

.mc-option:hover {
  background: var(--surface-2);
  border-color: #cbd5e1;
}

.mc-option.chosen {
  background: var(--surface-3);
  border-color: var(--primary);
  font-weight: 600;
}

.tfng-btn-group {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.tfng-choice {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.tfng-choice.chosen {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.inline-fill-input {
  display: inline-block;
  width: 175px;
  padding: 6px 10px;
  font-weight: 700;
  color: var(--primary);
  border: 2px solid #cbd5e1;
  border-radius: 7px;
  margin: 0 4px;
}

.inline-fill-input.overflow-err {
  border-color: var(--rose);
  background: #ffe4e6;
}

/* Bottom Question Palette Bar */
.palette-bar {
  position: sticky;
  bottom: 10px;
  z-index: 30;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  margin-top: 16px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pal-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 800;
  border: 1px solid #475569;
  background: #1e293b;
  color: #cbd5e1;
  cursor: pointer;
}

.pal-btn.done {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #fff;
}

.pal-btn.flagged {
  background: var(--amber);
  border-color: var(--amber);
  color: #0f172a;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.25);
}
