/* ============================================================================
   Design tokens
   Ported 1:1 from retention_mobile/src/constants/colors.ts and constants/text.ts
   so this app and the mobile app stay visually identical. If a value changes
   there, change it here.
   ========================================================================== */

:root {
  /* --- blue palette --- */
  --blue-lightest: #e8f1fa;
  --blue-lighter: #dceaf7;
  --blue-light: #b7d4ee;
  --blue: #1775c9;
  --blue-mid-light: #1569b5;
  --blue-mid-dark: #115897;
  --blue-dark: #0e4679;

  /* --- green palette --- */
  --green-lightest: #ecfdf5;
  --green-light: #a6f4c5;
  --green: #12b76a;
  --green-mid: #0d8f52;

  /* --- red palette --- */
  --red-lightest: #ffeee9;
  --red-light: #fecaba;
  --red: #fb5321;
  --red-mid: #c9421a;

  /* --- orange palette --- */
  --orange-lightest: #fef4eb;
  --orange-light: #fddcc0;
  --orange: #f88f34;

  /* --- neutral palette --- */
  --white: #ffffff;
  --neutral-lightest: #fafafa;
  --neutral-lighter: #e6e9ec;
  --neutral-light: #a2aab9;
  --neutral: #495c74;
  --neutral-dark: #2c3746;
  --black: #1a2029;

  /* --- semantic: background --- */
  --bg-surface: var(--white);
  --bg-surface-secondary: var(--blue-lightest);
  --bg-surface-tertiary: var(--neutral-lighter);

  /* --- semantic: text + icon --- */
  --texticon-primary: var(--black);
  --texticon-secondary: var(--white);
  --texticon-tertiary: var(--neutral);
  --texticon-brand: var(--blue);
  --texticon-disabled: var(--neutral-light);
  --texticon-success: var(--green);
  --texticon-critical: var(--red);
  --texticon-warning: var(--orange);

  /* --- semantic: fills --- */
  --fill-primary: var(--blue);
  --fill-primary-hover: var(--blue-mid-light);
  --fill-primary-active: var(--blue-mid-dark);
  --fill-secondary: var(--white);
  --fill-secondary-hover: var(--blue-lightest);
  --fill-secondary-active: var(--blue-light);
  --fill-success: var(--green-lightest);
  --fill-critical: var(--red-lightest);
  --fill-warning: var(--orange-lightest);
  --bg-fill-tooltip: var(--black);

  /* --- semantic: strokes --- */
  --stroke-primary: var(--blue);
  --stroke-secondary: var(--blue-light);
  --stroke-tertiary: var(--blue-lightest);
  --stroke-disabled: var(--neutral-lighter);
  --stroke-success: var(--green-light);
  --stroke-critical: var(--red);
  --stroke-warning: var(--orange-light);

  /* --- elevation (Figma Elevation 1: soft blue shadow) --- */
  --elevation-one: 0 6px 10px rgba(3, 139, 234, 0.1);
  --elevation-two: 0 10px 24px rgba(3, 139, 234, 0.14);

  /* --- radii, matching card.tsx / button.tsx --- */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 999px;
}

/* ============================================================================
   Base + typography (sizes from constants/text.ts)
   ========================================================================== */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg-surface-secondary);
  color: var(--texticon-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.h1 {
  font-size: 32px;
  font-weight: 700;
  line-height: 45px;
}
.h2 {
  font-size: 24px;
  font-weight: 700;
  line-height: 34px;
}
.h3 {
  font-size: 20px;
  font-weight: 700;
  line-height: 29px;
}
.title {
  font-size: 20px;
  font-weight: 500;
  line-height: 26px;
}
.subtitle {
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
}
.body {
  font-size: 16px;
  line-height: 22px;
}
.caption {
  font-size: 12px;
  font-weight: 500;
  line-height: 15px;
}

.text-tertiary {
  color: var(--texticon-tertiary);
}
.text-brand {
  color: var(--texticon-brand);
}
.text-success {
  color: var(--texticon-success);
}
.text-critical {
  color: var(--texticon-critical);
}
.text-warning {
  color: #c2410c;
}

/* ============================================================================
   Layout
   ========================================================================== */

.app {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px 64px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  background: var(--bg-surface-secondary);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.brand-mark {
  display: grid;
  place-items: center;
  color: var(--blue);
}

.topbar-spacer {
  flex: 1;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.wrap {
  flex-wrap: wrap;
}
.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.section {
  margin-top: 28px;
}
.section-head {
  margin-bottom: 12px;
}

/* ============================================================================
   Card (mirrors components/ui/card.tsx)
   ========================================================================== */

.card {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--stroke-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--elevation-one);
  padding: 16px;
}
.card-sm {
  padding: 8px;
  border-radius: var(--radius-sm);
}
.card-lg {
  border-radius: var(--radius-xl);
}
.card-flat {
  box-shadow: none;
}

.card-tap {
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease,
    background-color 0.12s ease;
}
.card-tap:hover {
  background: var(--fill-secondary-hover);
  box-shadow: var(--elevation-two);
  transform: translateY(-1px);
}
.card-tap:active {
  transform: translateY(0);
}

/* ============================================================================
   Button (mirrors components/ui/button.tsx: 48px tall, 12px radius)
   ========================================================================== */

.btn {
  text-decoration: none; /* many buttons are links */
  /* min-height, not height: long term names on narrow screens must wrap
     inside the button rather than spill out of it. */
  min-height: 48px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--elevation-one);
  transition: background-color 0.12s ease, opacity 0.12s ease;
}
.btn-primary {
  background: var(--fill-primary);
  color: var(--texticon-secondary);
}
.btn-primary:hover {
  background: var(--fill-primary-hover);
}
.btn-primary:active {
  background: var(--fill-primary-active);
}
.btn-secondary {
  background: var(--fill-secondary);
  color: var(--texticon-brand);
  border: 1px solid var(--stroke-secondary);
}
.btn-secondary:hover {
  background: var(--fill-secondary-hover);
}
.btn-tertiary {
  background: var(--fill-secondary-hover);
  color: var(--texticon-brand);
  border: 1px solid var(--stroke-secondary);
}
.btn-text {
  min-height: 0;
  padding: 4px;
  background: transparent;
  box-shadow: none;
  color: var(--texticon-brand);
  font-size: 12px;
  font-weight: 500;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-block {
  width: 100%;
}

/* ============================================================================
   Pills / chips (mirrors components/retention/RetentionPills.tsx)
   ========================================================================== */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--stroke-secondary);
  background: var(--fill-secondary-hover);
  color: var(--texticon-brand);
  font-size: 12px;
  font-weight: 500;
  line-height: 15px;
  white-space: nowrap;
}
.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}
.pill-success {
  background: var(--fill-success);
  border-color: var(--stroke-success);
  color: var(--green-mid);
}
.pill-critical {
  background: var(--fill-critical);
  border-color: var(--red-light);
  color: var(--red-mid);
}
.pill-warning {
  background: var(--fill-warning);
  border-color: var(--stroke-warning);
  color: #c2410c;
}
.pill-neutral {
  background: var(--bg-surface-tertiary);
  border-color: var(--neutral-lighter);
  color: var(--texticon-tertiary);
}

.chip {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--stroke-secondary);
  background: var(--fill-secondary);
  color: var(--texticon-brand);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.chip:hover {
  background: var(--fill-secondary-hover);
}
.chip[aria-pressed="true"] {
  background: var(--fill-primary);
  border-color: var(--fill-primary);
  color: var(--texticon-secondary);
}

/* ============================================================================
   Search
   ========================================================================== */

.search {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke-secondary);
  background: var(--fill-secondary);
  font-size: 16px;
  color: var(--texticon-primary);
  box-shadow: var(--elevation-one);
}
.search::placeholder {
  color: var(--texticon-disabled);
}
.search:focus {
  outline: 2px solid var(--stroke-primary);
  outline-offset: -1px;
}

/* ============================================================================
   Term detail
   ========================================================================== */

.definition-block {
  background: var(--bg-surface-secondary);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.example-block {
  border-left: 3px solid var(--stroke-secondary);
  padding-left: 12px;
}
.contrast-block {
  background: var(--fill-warning);
  border: 1px solid var(--stroke-warning);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

/* ============================================================================
   Inline references + tooltip
   BG_FILL_TOOLTIP already exists in the mobile palette (neutral black), so the
   tooltip matches what the app would show on device.
   ========================================================================== */

.ref {
  cursor: help;
  /* Underline only, no colour change - the sentence has to stay readable with
     a dozen of these in it. */
  border-bottom: 1px dashed var(--stroke-secondary);
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.ref:hover,
.ref:focus-visible {
  border-bottom-color: var(--stroke-primary);
  background: var(--fill-secondary-hover);
  outline: none;
}
/* A term reference goes somewhere; a glossary word only explains itself. */
.ref-term {
  color: var(--texticon-brand);
  cursor: pointer;
  border-bottom-style: solid;
}

.tooltip {
  position: fixed;
  z-index: 100;
  max-width: 300px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-fill-tooltip, var(--black));
  color: var(--texticon-secondary);
  box-shadow: var(--elevation-two);
  pointer-events: none;
}
.tooltip-title {
  display: block;
  font-size: 12px;
  font-weight: 700;
  line-height: 16px;
  color: var(--blue-light);
}
.tooltip-body {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 18px;
}
.tooltip-hint {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--neutral-light);
}

/* ============================================================================
   Assessment
   Deliberately plain for v1 - see ASSESSMENT-DESIGN.md.
   ========================================================================== */

.progress-row {
  display: flex;
  gap: 4px;
  padding: 12px 0;
}
.progress-seg {
  flex: 1;
  height: 6px;
  border-radius: 4px;
  background: var(--bg-surface-tertiary);
}
.progress-seg.done {
  background: var(--fill-primary);
}
.progress-seg.current {
  background: var(--stroke-secondary);
}

.quiz-card {
  background: var(--bg-surface-secondary);
  border-radius: var(--radius-xl);
  padding: 16px 12px;
  border: 1px solid var(--stroke-tertiary);
}

.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}
.option {
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  background: var(--fill-secondary);
  border: 1px solid var(--stroke-secondary);
  border-radius: var(--radius-md);
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.option:hover:not(:disabled) {
  background: var(--fill-secondary-hover);
}
.option[aria-pressed="true"] {
  background: var(--fill-secondary-active);
  border-color: var(--stroke-primary);
}
.option.correct {
  background: var(--fill-success);
  border-color: var(--stroke-success);
}
.option.incorrect {
  background: var(--fill-critical);
  border-color: var(--stroke-critical);
}
.option:disabled {
  cursor: default;
}
.option-mark {
  flex: 0 0 auto;
  font-weight: 700;
}

.score-ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto;
  background: var(--fill-secondary);
  border: 6px solid var(--stroke-secondary);
  box-shadow: var(--elevation-one);
}
.score-ring.pass {
  border-color: var(--green);
}
.score-ring.fail {
  border-color: var(--red);
}

.stat-card {
  flex: 1;
  min-width: 96px;
  background: var(--bg-surface-tertiary);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.review-item {
  border: 1px solid var(--stroke-disabled);
  border-radius: var(--radius-md);
  padding: 12px;
}
.review-item.miss {
  border-color: var(--red-light);
  background: var(--fill-critical);
}

.btn-compact {
  min-height: 40px;
  padding: 8px 16px;
  font-size: 14px;
  white-space: nowrap;
}

/* Two side-by-side actions that stack on narrow screens. */
.two-up {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Flag left, advance right - the primary action stays under the thumb. */
.study-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.neighbor-nav {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
}
.neighbor-nav .btn {
  flex: 0 1 auto;
  text-align: center;
}

@media (max-width: 560px) {
  .topbar .btn {
    white-space: nowrap;
  }
  .neighbor-nav {
    flex-direction: column;
    align-items: stretch;
  }
  .two-up,
  .study-actions {
    grid-template-columns: 1fr;
  }
  .h1 {
    font-size: 28px;
    line-height: 38px;
  }
}

.hidden {
  display: none !important;
}

/* ============================================================================
   Series 65
   ========================================================================== */

.s65-hero {
  margin-top: 12px;
  gap: 6px;
  border-color: var(--stroke-primary);
  background: linear-gradient(135deg, var(--white) 55%, var(--blue-lighter));
}

/* Preserve the line breaks that lay out Roman-numeral (I, II, III) stems. */
.stem {
  white-space: pre-line;
}

.option-letter {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--texticon-brand);
  background: var(--fill-secondary-hover);
  border: 1px solid var(--stroke-secondary);
}
.option[aria-pressed="true"] .option-letter {
  background: var(--fill-primary);
  border-color: var(--fill-primary);
  color: var(--texticon-secondary);
}
.option-text {
  flex: 1;
}

.explanation {
  margin-top: 16px;
  padding: 12px 14px;
  gap: 8px;
  background: var(--fill-secondary);
  border: 1px solid var(--stroke-secondary);
  border-radius: var(--radius-md);
}

.chip-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.three-up {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.resume-card {
  border-color: var(--stroke-warning);
  background: var(--fill-warning);
}

/* Progress/accuracy bar with an optional marker at the 70.8% pass line. */
.meter {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: var(--bg-surface-tertiary);
  overflow: hidden;
}
.meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 4px;
  background: var(--fill-primary);
  transition: width 0.2s ease;
}
.meter-fill.good {
  background: var(--green);
}
.meter-fill.weak {
  background: var(--red);
}
.meter-pass {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 70.8%;
  width: 2px;
  background: var(--black);
  opacity: 0.55;
}

.exam-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 18px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--fill-secondary);
  border: 1px solid var(--stroke-secondary);
  color: var(--texticon-primary);
}
.timer.low {
  color: var(--red-mid);
  background: var(--fill-critical);
  border-color: var(--stroke-critical);
}


.nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
}
.nav-cell {
  position: relative;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--neutral-light);
  background: var(--fill-secondary);
  color: var(--texticon-tertiary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.nav-cell.answered {
  border: 1px solid var(--fill-primary);
  background: var(--fill-secondary-hover);
  color: var(--texticon-brand);
}
.nav-cell.marked::after {
  content: "\2691";
  position: absolute;
  top: 1px;
  right: 3px;
  font-size: 10px;
  color: var(--orange);
}
.nav-cell:hover {
  border-color: var(--stroke-primary);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th,
.table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--stroke-tertiary);
  white-space: nowrap;
}
.table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--texticon-tertiary);
}
.row-link {
  cursor: pointer;
}
.row-link:hover {
  background: var(--fill-secondary-hover);
}

@media (max-width: 560px) {

  .three-up {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   Icons, navigation chrome, focus mode
   ========================================================================== */

.icon {
  flex: 0 0 auto;
  vertical-align: middle;
}

.top-nav {
  display: flex;
  gap: 8px;
}
.nav-link {
  position: relative;
  text-decoration: none;
}
.nav-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--red);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg-surface-secondary);
}

/* Bottom tab bar - phones only. Mirrors the Retention mobile app. */
.tab-bar {
  display: none;
}

@media (max-width: 640px) {
  .top-nav {
    display: none;
  }
  .tab-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid var(--stroke-secondary);
    box-shadow: 0 -4px 12px rgba(3, 139, 234, 0.08);
  }
  .app {
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  color: var(--texticon-tertiary);
  text-decoration: none;
  border-radius: var(--radius-md);
}
.tab.active {
  color: var(--texticon-brand);
}
.tab-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 30px;
  border-radius: var(--radius-pill);
}
.tab.active .tab-icon {
  background: var(--fill-secondary-hover);
}
.tab-icon .nav-badge {
  top: -4px;
  right: 2px;
}
.tab-label {
  font-size: 11px;
  font-weight: 600;
  line-height: 14px;
}

/* Timed exams hide every way off the page except the exam's own exit. */
body.focus-mode .topbar,
body.focus-mode .tab-bar {
  display: none;
}
body.focus-mode .app {
  padding-bottom: calc(100px + env(safe-area-inset-bottom));
}

/* ============================================================================
   Exam: sticky header and pinned action bar
   ========================================================================== */

.exam-head {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: 0 -16px;
  padding: 10px 16px 8px;
  background: var(--bg-surface-secondary);
  border-bottom: 1px solid var(--stroke-tertiary);
}
.exam-head .exam-bar {
  gap: 8px;
}
.exam-title {
  flex: 1;
  text-align: center;
}
.exam-subbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  min-height: 24px;
}
.exam-screen .quiz-card {
  margin-top: 16px;
}
.exam-hint {
  margin-top: 10px;
}
@media (max-width: 640px), (hover: none) {
  .exam-hint {
    display: none;
  }
}

.icon-btn {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--stroke-secondary);
  border-radius: var(--radius-md);
  background: var(--fill-secondary);
  color: var(--texticon-tertiary);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--fill-secondary-hover);
  color: var(--texticon-primary);
}

/* One row, pinned to the bottom, on every screen size. */
.action-bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  transform: translateX(-50%);
  width: min(880px, 100%);
  display: flex;
  gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(232, 241, 250, 0.96);
  border-top: 1px solid var(--stroke-secondary);
  backdrop-filter: blur(6px);
}
.action-btn {
  flex: 1;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke-secondary);
  background: var(--fill-secondary);
  color: var(--texticon-brand);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--elevation-one);
}
.action-btn:hover:not(:disabled) {
  background: var(--fill-secondary-hover);
}
.action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.action-btn.primary {
  flex: 1.4;
  background: var(--fill-primary);
  border-color: var(--fill-primary);
  color: var(--texticon-secondary);
}
.action-btn.primary:hover {
  background: var(--fill-primary-hover);
}
.action-btn.marked {
  background: var(--fill-warning);
  border-color: var(--stroke-warning);
  color: #c2410c;
}
.action-arrow {
  font-size: 18px;
}

.nav-cell.marked::after {
  content: "";
  position: absolute;
  top: 0;
  right: 4px;
  width: 7px;
  height: 10px;
  background: var(--orange);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%);
}

/* ============================================================================
   Confirm dialog - port of retention_mobile ConfirmDialog
   ========================================================================== */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(65, 79, 95, 0.7);
  animation: dialog-fade 0.15s ease-out;
}
.dialog {
  width: 100%;
  max-width: 358px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 24px 16px;
  background: var(--white);
  border: 1px solid var(--stroke-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--elevation-two);
  animation: dialog-rise 0.15s ease-out;
}
@keyframes dialog-fade {
  from { opacity: 0; }
}
@keyframes dialog-rise {
  from { transform: translateY(8px) scale(0.98); }
}
.dialog-copy {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.dialog-actions {
  display: flex;
  gap: 8px;
}
.dialog-actions .btn {
  flex: 1;
  height: auto;
  min-height: 48px;
}
.btn-critical {
  background: var(--red);
  color: var(--white);
}
.btn-critical:hover {
  background: var(--red-mid);
}

@media (prefers-reduced-motion: reduce) {
  .dialog-backdrop,
  .dialog {
    animation: none;
  }
}

/* ============================================================================
   Spaced review
   ========================================================================== */

/* Day 1 / Day 3 / Day 7 pills - sizes from RetentionPills.tsx */
.rpills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.rpill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 4px;
  border-radius: var(--radius-pill);
  border: 1px solid;
  font-size: 11px;
  font-weight: 600;
  line-height: 14px;
}
.rpill-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}
.rpill.complete {
  background: var(--fill-success);
  border-color: var(--stroke-success);
  color: var(--green);
}

.review-hero.has-due {
  border-color: var(--stroke-primary);
}

.review-home {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  border-color: var(--stroke-primary);
}
.review-home-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: var(--blue);
  background: var(--fill-secondary-hover);
}

.review-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid;
  font-size: 14px;
  line-height: 20px;
}
.review-note .icon {
  margin-top: 1px;
}
.note-info {
  background: var(--fill-secondary-hover);
  border-color: var(--stroke-secondary);
  color: var(--blue-mid-dark);
}
.note-success {
  background: var(--fill-success);
  border-color: var(--stroke-success);
  color: var(--green-mid);
}
.note-warning {
  background: var(--fill-warning);
  border-color: var(--stroke-warning);
  color: #c2410c;
}
.note-neutral {
  background: var(--bg-surface-tertiary);
  border-color: var(--neutral-lighter);
  color: var(--texticon-tertiary);
}

/* ============================================================================
   Storage warning, data page, footer
   ========================================================================== */

.storage-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 16px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke-critical);
  background: var(--fill-critical);
  color: var(--red-mid);
  box-shadow: var(--elevation-one);
}
.storage-banner-mark {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--red);
  color: var(--white);
  font-weight: 700;
}
.storage-banner-copy {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 14px;
  line-height: 20px;
  color: var(--texticon-primary);
}
.storage-banner-copy strong {
  color: var(--red-mid);
}
.storage-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
@media (max-width: 640px) {
  .storage-banner {
    flex-wrap: wrap;
  }
  .storage-banner-actions {
    width: 100%;
    justify-content: space-between;
  }
}

/* A <label> styled as a button, wrapping a visually hidden file input. */
.file-btn {
  position: relative;
  cursor: pointer;
}
.file-btn input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.file-btn:focus-within {
  outline: 2px solid var(--stroke-primary);
  outline-offset: 2px;
}

.app-footer {
  margin-top: 40px;
  padding: 16px 0 8px;
  border-top: 1px solid var(--stroke-tertiary);
  text-align: center;
  font-size: 13px;
}
.app-footer a {
  color: var(--texticon-tertiary);
}
body.focus-mode .app-footer {
  display: none;
}

/* Visually hidden, still read by screen readers (used by glossary search). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================================
   Ad slots
   Hidden entirely while advertising is off, so nothing reserves space or
   shifts the layout. Add ?ads=preview to reveal the placeholders.
   ========================================================================== */

.ad-slot {
  margin: 24px 0;
  text-align: center;
}
.ad-slot.is-placeholder {
  display: none;
}
.ads-preview .ad-slot.is-placeholder {
  display: block;
  min-height: 96px;
  padding: 24px 12px;
  border: 2px dashed var(--stroke-secondary);
  border-radius: var(--radius-md);
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(23, 117, 201, 0.04) 10px,
    rgba(23, 117, 201, 0.04) 20px
  );
  color: var(--texticon-disabled);
}
.ad-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--texticon-disabled);
  margin-bottom: 6px;
}
.ad-slot.is-placeholder .ad-label {
  margin-bottom: 0;
}
.ad-unit {
  min-height: 90px;
}
/* Belt and braces: no ads while a timed exam is on screen. */
body.focus-mode .ad-slot {
  display: none !important;
}

/* ============================================================================
   Flashcards
   The flip is a CSS keyframe on the newly rendered face, not a JS-timed
   transition, so a throttled background tab can never leave a card mid-turn.
   ========================================================================== */

.fc-promo {
  align-items: center;
  gap: 12px;
  margin: 8px 0 20px;
}

.flashcard-meta {
  gap: 8px;
  margin: 12px 0 10px;
}

.flashcard {
  perspective: 1200px;
  border-radius: var(--radius-xl);
  outline: none;
}
.flashcard-face {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 300px;
  padding: 24px 20px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--stroke-secondary);
  background: var(--fill-secondary);
  box-shadow: var(--elevation-one);
  animation: card-flip 0.32s ease-out;
  transform-origin: center;
}
.flashcard.is-front {
  cursor: pointer;
}
.flashcard.is-front .flashcard-face {
  align-items: center;
  justify-content: center;
  text-align: center;
  background: linear-gradient(160deg, var(--white) 60%, var(--blue-lighter));
}
.flashcard.is-front:hover .flashcard-face {
  border-color: var(--stroke-primary);
  box-shadow: var(--elevation-two);
}
.flashcard:focus-visible .flashcard-face {
  outline: 2px solid var(--stroke-primary);
  outline-offset: 3px;
}
@keyframes card-flip {
  from {
    transform: rotateY(-80deg);
    opacity: 0.2;
  }
}

.flashcard-term {
  margin: 0;
  font-size: 32px;
  line-height: 40px;
  font-weight: 700;
  color: var(--texticon-primary);
}
.flashcard-term-sm {
  font-size: 24px;
  line-height: 32px;
}
.flashcard-prompt {
  margin: 0;
  max-width: 34ch;
}

.flip-btn {
  margin-top: 16px;
}
.grade-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}
.grade-row .btn {
  gap: 8px;
}
.grade-miss {
  background: var(--fill-critical);
  border: 1px solid var(--stroke-critical);
  color: var(--red-mid);
}
.grade-miss:hover {
  background: var(--red-light);
}
.fc-hint {
  margin-top: 10px;
  text-align: center;
}
@media (hover: none) {
  .fc-hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flashcard-face {
    animation: none;
  }
}
