@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

/* Ensure hidden attribute always wins over display:flex/block rules */
[hidden] { display: none !important; }

:root {
  --bg: #f4f4f4;
  --surface: #ffffff;
  --surface-2: #e8e8e8;
  --border: #e0e0e0;
  --text: #161616;
  --text-muted: #525252;
  --primary: #0f62fe;
  --primary-light: #edf5ff;
  --success: #198038;
  --success-light: #defbe6;
  --error: #da1e28;
  --error-light: #fff1f1;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);

  --hashicorp: #7b42bc;
  --aws: #e8880a;
  --azure: #0078d4;
  --redhat: #cc0000;
  --cncf: #326ce5;
}

[data-theme="dark"] {
  --bg: #161616;
  --surface: #262626;
  --surface-2: #393939;
  --border: #525252;
  --text: #f4f4f4;
  --text-muted: #a8a8a8;
  --primary: #4589ff;
  --primary-light: rgba(69, 137, 255, 0.15);
  --success: #42be65;
  --success-light: rgba(66, 190, 101, 0.15);
  --error: #ff8389;
  --error-light: rgba(255, 131, 137, 0.15);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ────────────────────────────────────────────── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.header-logo {
  flex-shrink: 0;
  display: block;
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.app-header .subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── Layout ─────────────────────────────────────────────── */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Theme toggle ────────────────────────────────────────── */
.theme-toggle {
  margin-left: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s;
  color: var(--text);
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--border);
}

/* ── Cert logo ───────────────────────────────────────────── */
.cert-logo-wrap {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.35rem;
}

.cert-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--surface-2);
  padding: 4px;
}

.onboard-cert-logo {
  width: 22px;
  height: 22px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: filter 0.15s, opacity 0.15s;
  text-decoration: none;
}

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

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--border);
}

/* ── Dashboard ───────────────────────────────────────────── */
.vendor-section {
  margin-bottom: 2.5rem;
}

.vendor-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.vendor-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.vendor-header h2 {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.track-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.track-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: box-shadow 0.15s, transform 0.15s;
}

.track-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.track-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.exam-code {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.track-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.q-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.q-count strong {
  color: var(--text);
}

/* ── Quiz header ─────────────────────────────────────────── */
.quiz-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.quiz-header-info {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.quiz-track-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.quiz-progress-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.progress-bar-outer {
  height: 3px;
  background: var(--border);
}

.progress-bar-inner {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}

/* ── Setup screen ────────────────────────────────────────── */
.setup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
  max-width: 480px;
  margin: 0 auto;
}

.setup-card h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.setup-card .exam-code-large {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.setup-field {
  margin-bottom: 1.5rem;
}

.setup-field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.count-options {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.count-btn {
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
}

.count-btn.selected,
.count-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* ── Question card ───────────────────────────────────────── */
.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.question-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.domain-tag {
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 4px;
}

.difficulty-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.difficulty-easy {
  background: #dcfce7;
  color: #15803d;
}

.difficulty-medium {
  background: #fef9c3;
  color: #854d0e;
}

.difficulty-hard {
  background: #fee2e2;
  color: #dc2626;
}

.multiselect-hint {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
}

.question-counter {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.question-stem {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.65;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.choice-label {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  font-size: 0.9rem;
  line-height: 1.5;
  user-select: none;
}

.choice-label:hover:not(.locked) {
  border-color: var(--primary);
  background: var(--primary-light);
}

.choice-label.correct {
  border-color: var(--success);
  background: var(--success-light);
}

.choice-label.incorrect {
  border-color: var(--error);
  background: var(--error-light);
}

.choice-label input {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.choice-key {
  font-weight: 700;
  min-width: 1.2rem;
  flex-shrink: 0;
  color: var(--text-muted);
}

/* ── Feedback ────────────────────────────────────────────── */
.feedback-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.feedback-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.feedback-status.correct {
  color: var(--success);
}

.feedback-status.incorrect {
  color: var(--error);
}

.feedback-explanation {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.65;
}

/* ── Quiz actions ────────────────────────────────────────── */
.quiz-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* ── Results ─────────────────────────────────────────────── */
.results-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 480px;
  margin: 0 auto;
}

.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  border: 4px solid;
}

.score-circle.pass {
  border-color: var(--success);
  color: var(--success);
}

.score-circle.fail {
  border-color: var(--error);
  color: var(--error);
}

.score-pct {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.score-label {
  font-size: 0.75rem;
  opacity: 0.75;
}

.results-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.results-subtitle {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.results-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Loading / error ─────────────────────────────────────── */
.state-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  gap: 1rem;
  text-align: center;
  color: var(--text-muted);
}

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

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

/* ── Onboarding ──────────────────────────────────────────── */
.onboard-card {
  max-width: 560px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
}

.onboard-card h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.onboard-subtitle {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.onboard-vendor {
  margin-bottom: 1.5rem;
}

.onboard-vendor-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.onboard-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 0.4rem;
  transition: border-color 0.12s, background 0.12s;
  user-select: none;
}

.onboard-option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.onboard-option input[type="radio"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.onboard-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 500;
}

.onboard-error {
  font-size: 0.85rem;
  color: var(--error);
  margin-bottom: 1rem;
}

.onboard-submit {
  width: 100%;
  justify-content: center;
  padding: 0.75rem;
  margin-top: 0.5rem;
}


@media (max-width: 640px) {
  .container {
    padding: 1.5rem 1rem;
  }

  .question-card {
    padding: 1.25rem;
  }

  .quiz-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

/* ── Resource pills (dashboard cards) ───────────────────── */
.card-resource-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.resource-pill {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  text-decoration: none;
  color: var(--text-muted);
  background: var(--surface-2);
  transition: border-color 0.12s, color 0.12s;
}

.resource-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Domain breakdown (results screen) ──────────────────── */
.domain-breakdown {
  margin: 1.5rem 0;
  text-align: left;
}

.domain-breakdown h3,
.resource-links h3 {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.domain-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.domain-table th {
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.domain-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.domain-weight {
  color: var(--text-muted);
  white-space: nowrap;
}

.domain-bar-cell { width: 100px; }

.domain-bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.domain-bar {
  height: 6px;
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* ── Exam tip ────────────────────────────────────────────── */
.exam-tip {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  padding: 0.85rem 1rem;
  border-radius: 0 8px 8px 0;
  margin: 1.5rem 0;
  text-align: left;
  font-size: 0.87rem;
  line-height: 1.5;
}

.tip-icon { font-size: 1.2rem; flex-shrink: 0; }

/* ── Resource links (results screen) ────────────────────── */
.resource-links {
  margin: 1.5rem 0;
  text-align: left;
}

.resource-link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.resource-link {
  font-size: 0.82rem;
  padding: 0.3rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  text-decoration: none;
  color: var(--primary);
  background: var(--surface);
  transition: background 0.12s, border-color 0.12s;
}

.resource-link:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.quiz-track-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.quiz-header-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.quiz-session-label,
.quiz-timer {
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
}

.quiz-session-label {
  background: var(--primary-light);
  color: var(--primary);
}

.quiz-timer {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}

.quiz-timer.is-urgent {
  background: var(--error-light);
  color: var(--error);
  border-color: #fecaca;
}

.study-hub {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hub-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.track-badge-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

.track-badge-row h2 {
  font-size: 1.35rem;
  line-height: 1.3;
}

.hub-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.exam-date-card {
  min-width: 280px;
}

.exam-date-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.exam-date-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.exam-date-row input[type="date"] {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  min-height: 44px;
}

.countdown-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.5rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 700;
}

.countdown-badge.is-green {
  background: var(--success-light);
  color: var(--success);
}

.countdown-badge.is-yellow {
  background: #fef3c7;
  color: #a16207;
}

.countdown-badge.is-red {
  background: var(--error-light);
  color: var(--error);
}

.countdown-badge.is-neutral {
  background: var(--surface-2);
  color: var(--text-muted);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1rem;
  box-shadow: var(--shadow);
}

.stat-box strong {
  display: block;
  font-size: 1.4rem;
  margin-bottom: 0.2rem;
}

.stat-box span {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.domain-readiness {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.section-heading {
  margin-bottom: 1rem;
}

.section-heading h3 {
  font-size: 1rem;
  margin-bottom: 0.2rem;
}

.section-heading p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.no-diagnostic-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  text-decoration: none;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  font-weight: 600;
  flex-wrap: wrap;
}

.readiness-row + .readiness-row {
  margin-top: 0.9rem;
}

.readiness-labels {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
}

.readiness-name {
  font-weight: 600;
}

.readiness-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.readiness-track {
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.readiness-bar {
  height: 100%;
  border-radius: 999px;
}

.readiness-bar.is-strong {
  background: var(--success);
}

.readiness-bar.is-building {
  background: #d97706;
}

.readiness-bar.is-risk {
  background: var(--error);
}

.readiness-bar.is-empty {
  background: var(--border);
}

.study-modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.mode-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 180px;
  padding: 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
  color: var(--text);
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

button.mode-card {
  width: 100%;
  cursor: pointer;
}

.mode-card h4 {
  font-size: 1rem;
  margin-bottom: 0.45rem;
}

.mode-card p {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.mode-footer {
  margin-top: 1rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
}

.mode-card:hover,
.mode-card.active {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.mode-card.disabled,
.mode-card:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.drill-options {
  margin-top: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.drill-option-group + .drill-option-group {
  margin-top: 0.85rem;
}

.drill-option-group span {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.45rem;
}

.drill-button-row {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.drill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
}

.drill-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.hub-footer {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.results-card-wide {
  max-width: 760px;
}

.results-kicker {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
}

.results-note,
.results-save-status {
  margin: 1rem 0 0;
  color: var(--text-muted);
}

.results-save-status {
  color: var(--error);
}

@media (max-width: 820px) {
  .hub-header {
    grid-template-columns: 1fr;
  }

  .exam-date-card {
    min-width: 0;
  }

  .stats-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .quiz-header-info {
    flex-direction: column;
    align-items: flex-start;
  }

  .quiz-header-meta {
    justify-content: flex-start;
  }

  .stats-row {
    grid-template-columns: 1fr;
  }

  .no-diagnostic-banner,
  .readiness-labels,
  .exam-date-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ── Import page ─────────────────────────────────────────── */
.import-intro { margin-bottom: 2rem; }
.import-intro h2 { font-size: 1.4rem; margin-bottom: 0.4rem; }
.import-intro p { color: var(--text-muted); }

.import-section { margin-bottom: 1.5rem; }

.import-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.import-select, .import-input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
}

.import-select:focus, .import-input:focus, .import-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.import-textarea {
  width: 100%;
  min-height: 180px;
  padding: 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.8rem;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
}

.import-format-hint { margin-bottom: 0.75rem; }
.import-format-hint summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--primary);
  user-select: none;
}
.import-pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  overflow-x: auto;
  margin: 0.5rem 0;
  white-space: pre;
}
.import-hint-note { font-size: 0.8rem; color: var(--text-muted); line-height: 1.7; }

.import-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}
.import-tab {
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.import-tab.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.import-counter {
  font-size: 0.82rem;
  color: var(--success);
  font-weight: 600;
  margin: 0.35rem 0 0;
  min-height: 1.2em;
}

.import-file-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.6rem;
}
.import-file-btn { cursor: pointer; }

.import-error {
  background: var(--error-light);
  border-left: 3px solid var(--error);
  padding: 0.75rem 1rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.85rem;
  color: var(--error);
  white-space: pre-wrap;
  margin-bottom: 1rem;
}

.import-success {
  background: var(--success-light);
  border-left: 3px solid var(--success);
  padding: 1.25rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.import-success-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}
.import-success-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.import-submit {
  width: 100%;
  justify-content: center;
  padding: 0.75rem;
  margin-top: 0.5rem;
}

.preview-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.preview-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
}
.preview-stem {
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
}
.preview-choices {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.4rem;
}
.preview-choice {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.preview-choice.correct {
  color: var(--success);
  font-weight: 600;
}
.preview-tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  margin-right: 0.3rem;
}

.muted { color: var(--text-muted); font-size: 0.82rem; }

/* ── Study Plan / Pacing Guide ───────────────────────────── */
.study-plan {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.plan-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.plan-pace-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.plan-pace-badge.is-good { background: var(--success-light); color: var(--success); }
.plan-pace-badge.is-warn { background: #fef3c7; color: #a16207; }
.plan-pace-badge.is-behind { background: var(--error-light); color: var(--error); }

/* Course row */
.plan-course-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.plan-course-display { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.plan-course-form    { display: flex; align-items: center; gap: 0.5rem; flex: 1; flex-wrap: wrap; }

.plan-course-input {
  flex: 1;
  min-width: 200px;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.875rem;
}
.plan-course-input:focus { outline: none; border-color: var(--primary); }

.plan-course-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.plan-course-link:hover { text-decoration: underline; }
.plan-course-icon { font-size: 1rem; }

.btn-ghost {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
  text-decoration: underline;
}
.btn-ghost:hover { color: var(--text); }

/* Phase pills */
.plan-phases {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
}

.plan-phase-pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.plan-phase-pill.is-complete {
  border-color: var(--success);
  background: var(--success-light);
}
.plan-phase-pill.is-active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.plan-phase-icon-em { font-size: 1.1rem; }

.plan-phase-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.plan-phase-name  { font-size: 0.8rem; font-weight: 600; }
.plan-phase-count { font-size: 0.75rem; color: var(--text-muted); }
.plan-phase-pill.is-complete .plan-phase-count,
.plan-phase-pill.is-active   .plan-phase-count { color: inherit; opacity: 0.75; }

.plan-phase-bar-outer {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.plan-phase-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.plan-phase-pill.is-complete .plan-phase-bar { background: var(--success); }

/* Section label */
.plan-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.45rem;
}

/* Up next */
.plan-all-done {
  text-align: center;
  padding: 1rem;
  color: var(--success);
  font-weight: 600;
  font-size: 0.95rem;
}

/* Plan task rows */
.plan-task {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  user-select: none;
  margin-bottom: 0.35rem;
}
.plan-task:last-child { margin-bottom: 0; }
.plan-task:hover { border-color: var(--primary); }
.plan-task.is-next { border-color: var(--primary); background: var(--primary-light); }
.plan-task.is-done { opacity: 0.5; background: var(--surface-2); border-color: var(--border); }
.plan-task.is-done .plan-task-label { text-decoration: line-through; }

.plan-task-check {
  margin-top: 2px;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}
.plan-task-body { flex: 1; min-width: 0; }
.plan-task-label { font-size: 0.9rem; font-weight: 500; display: block; line-height: 1.4; }
.plan-task-desc  { font-size: 0.78rem; color: var(--text-muted); display: block; margin-top: 0.1rem; }

.plan-task-link {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: center;
}
.plan-task-link:hover { text-decoration: underline; }

/* Full plan collapsible */
.plan-full {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.plan-full-toggle {
  list-style: none;
  padding: 0.7rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  background: var(--surface-2);
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.plan-full-toggle::-webkit-details-marker { display: none; }
.plan-full-toggle::after { content: "▸"; transition: transform 0.2s; }
.plan-full[open] .plan-full-toggle::after { transform: rotate(90deg); }

.plan-task-list {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.plan-phase-group-header {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.plan-phase-group-header.is-done { color: var(--success); }
.plan-phase-group-count { font-weight: 500; }

@media (max-width: 640px) {
  .plan-phases { grid-template-columns: repeat(2, 1fr); }
}

/* ── Daily Study Log ─────────────────────────────────────── */
.study-log {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.log-today {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.log-today-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.log-today-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.log-saved-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--success);
}

.log-form {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.log-row {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.log-field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}

.log-mood-btns {
  display: flex;
  gap: 0.4rem;
}

.log-mood-btn {
  font-size: 1.3rem;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  line-height: 1;
  transition: border-color 0.12s, background 0.12s;
  opacity: 0.5;
}

.log-mood-btn:hover,
.log-mood-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  opacity: 1;
}

.log-hours-input {
  width: 80px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.875rem;
  -moz-appearance: textfield;
}
.log-hours-input::-webkit-outer-spin-button,
.log-hours-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.log-hours-input:focus { outline: none; border-color: var(--primary); }

.log-note-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
  resize: vertical;
  line-height: 1.5;
}
.log-note-input:focus { outline: none; border-color: var(--primary); }

.log-form-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Log history */
.log-history {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.log-history-toggle {
  list-style: none;
  padding: 0.7rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  background: var(--surface-2);
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.log-history-toggle::-webkit-details-marker { display: none; }
.log-history-toggle::after { content: "▸"; transition: transform 0.2s; }
.log-history[open] .log-history-toggle::after { transform: rotate(90deg); }

.log-history-list {
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.log-entry {
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.log-entry-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.log-entry-date {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
}

.log-entry-badges {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.log-mood-display { font-size: 1rem; }

.log-hours-display {
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--primary-light);
  color: var(--primary);
  padding: 1px 6px;
  border-radius: 999px;
}

.log-entry-note {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

.log-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0.75rem 0;
}

/* ── Header actions ──────────────────────────────────────────────────────── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.3rem 0.4rem;
  border-radius: 6px;
  line-height: 1;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--surface-alt); color: var(--text); }

/* ── Help modal ──────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-box {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.22);
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem 0.9rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; margin: 0; }

.modal-close {
  font-size: 1rem;
  color: var(--text-muted);
}

.modal-body {
  overflow-y: auto;
  padding: 1.2rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.help-section h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.6rem;
  color: var(--primary);
}

.help-section p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0 0 0.6rem;
  line-height: 1.6;
}

.help-section ul {
  margin: 0 0 0.8rem;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.help-section li {
  font-size: 0.87rem;
  color: var(--text);
  line-height: 1.55;
}

.help-section code {
  font-family: monospace;
  font-size: 0.82rem;
  background: var(--surface-alt);
  padding: 1px 5px;
  border-radius: 4px;
}

.help-section .btn {
  font-size: 0.85rem;
  padding: 0.45rem 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  margin-top: 0.2rem;
}

.help-note {
  font-size: 0.78rem !important;
  color: var(--text-muted) !important;
  margin-top: 0.5rem !important;
}

.modal-footer {
  padding: 0.9rem 1.4rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.help-section a {
  color: var(--primary);
}
[data-theme="dark"] .help-section a {
  color: #74b3ff;
}

/* ── Lab links ───────────────────────────────────────────────────────────── */
.lab-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.lab-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color 0.15s, background 0.15s;
}
.lab-link:hover { border-color: var(--primary); background: var(--primary-light); }
.lab-link-icon { font-size: 1.1rem; flex-shrink: 0; }
.lab-link-arrow { margin-left: auto; color: var(--text-muted); font-size: 0.85rem; }

/* ── User badge (IBM email initials) ─────────────────────────────────────── */
.user-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: default;
  flex-shrink: 0;
}
