/* =========================================================================
   Maths Revision — v0.3 styles
   Aesthetic: editorial / academic. Warm off-white paper, deep ink,
   oxblood accent. Reads like a well-typeset textbook.
   ========================================================================= */

:root {
  /* Palette */
  --paper: #f6f1e8;
  --paper-deep: #ece5d4;
  --ink: #1a1715;
  --ink-soft: #4a443e;
  --ink-mute: #8a8278;
  --rule: #d6cdb9;
  --rule-soft: #e6dfcd;

  --accent: #6b1f2a;          /* oxblood */
  --accent-deep: #4a1118;
  --accent-soft: #f0d8d8;

  --correct: #2d5a3f;
  --correct-soft: #d8e8dd;
  --incorrect: #8a2a2a;
  --incorrect-soft: #f0d8d8;

  /* Typography */
  --display: 'Fraunces', 'Times New Roman', serif;
  --body: 'Source Serif 4', Georgia, serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;

  /* Layout */
  --container: 980px;
  --narrow: 720px;
  --radius: 4px;
  --radius-lg: 8px;

  /* Motion */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  position: relative;
}
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.35;
  mix-blend-mode: multiply;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(80,60,30,0.08), transparent),
    radial-gradient(1px 1px at 70% 80%, rgba(80,60,30,0.06), transparent),
    radial-gradient(1px 1px at 40% 60%, rgba(80,60,30,0.05), transparent);
  background-size: 200px 200px, 250px 250px, 180px 180px;
}
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input { font: inherit; color: inherit; }

/* ---- Layout ---- */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 28px;
  position: relative;
  z-index: 2;
}
.container.narrow { max-width: var(--narrow); }

/* ---- Standard topbar ---- */
.topbar {
  border-bottom: 1px solid var(--rule);
  background: rgba(246, 241, 232, 0.92);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}
.topbar-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand {
  font-family: var(--display);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  display: inline-block;
  font-size: 28px;
  color: var(--accent);
  font-weight: 400;
  font-style: italic;
  transform: translateY(-1px);
}
.brand-text { font-style: italic; font-weight: 400; }
.nav { display: flex; gap: 4px; }
.nav-btn {
  font-family: var(--body);
  font-size: 14px;
  padding: 8px 14px;
  border-radius: var(--radius);
  color: var(--ink-soft);
  letter-spacing: 0.01em;
  transition: color 120ms var(--ease), background 120ms var(--ease);
}
.nav-btn:hover { color: var(--ink); background: var(--paper-deep); }
.nav-btn.active { color: var(--accent); background: var(--accent-soft); }

/* ---- Session-mode topbar (lockdown) ---- */
.session-topbar {
  border-bottom: 1px solid var(--rule);
  background: var(--ink);
  color: var(--paper);
  position: sticky;
  top: 0;
  z-index: 12;
}
.session-topbar-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.session-meta {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-grow: 1;
}
.session-meta-label {
  font-family: var(--display);
  font-style: italic;
  font-size: 16px;
  font-weight: 500;
  color: var(--paper);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-feature-settings: "tnum";
}
.session-meta-progress {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--rule);
  font-feature-settings: "tnum";
  letter-spacing: 0.04em;
}
.session-meta-marks {
  font-family: var(--display);
  font-style: italic;
  font-size: 18px;
  color: var(--accent-soft);
  font-feature-settings: "tnum";
}
.session-exit-btn {
  font-family: var(--body);
  font-size: 13px;
  color: var(--paper);
  padding: 8px 14px;
  border: 1px solid var(--ink-mute);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: border-color 120ms var(--ease), background 120ms var(--ease);
}
.session-exit-btn:hover {
  border-color: var(--paper);
  background: rgba(255,255,255,0.06);
}
.exit-icon {
  font-size: 18px;
  line-height: 1;
  font-weight: 300;
}

/* When body has .session-active, hide regular topbar/footer and reshape */
body.session-active .topbar,
body.session-active #footer { display: none; }
body.session-active .session-topbar { display: block; }

/* ---- Views ---- */
.view {
  display: none;
  padding: 56px 0 80px;
  animation: fadeIn 280ms var(--ease);
}
.view.active { display: block; }
body.session-active #view-session { padding: 0; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Header blocks ---- */
.header-block { margin-bottom: 48px; max-width: 640px; }
.eyebrow {
  font-family: var(--body);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 16px;
}
.display {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(36px, 5vw, 56px);
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--ink);
  margin-bottom: 16px;
  font-style: italic;
}
.lede {
  font-size: 18px;
  color: var(--ink-soft);
  line-height: 1.55;
  max-width: 56ch;
}

/* ---- Chapters list (home) ---- */
.chapters-list { border-top: 1px solid var(--rule); }
.chapter {
  border-bottom: 1px solid var(--rule);
  padding: 24px 0;
}
.chapter-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}
.chapter-number {
  font-family: var(--display);
  font-size: 32px;
  font-weight: 500;
  color: var(--accent);
  font-style: italic;
  flex-shrink: 0;
  width: 56px;
  letter-spacing: -0.02em;
}
.chapter-title {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  flex-grow: 1;
}
.chapter-meta {
  font-size: 13px;
  color: var(--ink-mute);
  font-feature-settings: "tnum";
}
.chapter-toggle {
  font-size: 14px;
  color: var(--ink-mute);
  transition: transform 200ms var(--ease);
}
.chapter.open .chapter-toggle { transform: rotate(90deg); }

.chapter-actions {
  margin-top: 12px;
  margin-left: 72px;
  display: none;
  gap: 12px;
}
.chapter.open .chapter-actions { display: flex; }
.text-btn {
  font-size: 13px;
  color: var(--accent);
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms var(--ease);
}
.text-btn:hover { border-color: var(--accent); }

.rules-grid {
  display: none;
  margin-top: 16px;
  margin-left: 72px;
  gap: 8px;
  flex-direction: column;
}
.chapter.open .rules-grid { display: flex; }

.rule-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  transition: background 120ms var(--ease);
  cursor: pointer;
}
.rule-row:hover { background: var(--paper-deep); }
.rule-row.checked { background: var(--accent-soft); }

.rule-checkbox {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--ink-mute);
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  transition: all 120ms var(--ease);
}
.rule-row.checked .rule-checkbox {
  background: var(--accent);
  border-color: var(--accent);
}
.rule-checkbox::after {
  content: '';
  width: 5px;
  height: 9px;
  border: solid var(--paper);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg) translateY(-1px);
  opacity: 0;
  transition: opacity 120ms var(--ease);
}
.rule-row.checked .rule-checkbox::after { opacity: 1; }

.rule-content { flex-grow: 1; }
.rule-name {
  font-size: 15px;
  color: var(--ink);
  font-weight: 500;
  font-family: var(--body);
}
.rule-section {
  font-size: 12px;
  color: var(--ink-mute);
  margin-left: 8px;
  font-feature-settings: "tnum";
}
.rule-summary {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 4px;
  line-height: 1.5;
}

/* ---- Actions ---- */
.actions {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}
.actions.secondary { margin-top: 24px; }
.primary-btn {
  font-family: var(--display);
  font-size: 18px;
  font-style: italic;
  font-weight: 500;
  background-color: #1a1715;
  background-color: var(--ink);
  color: #f6f1e8;
  color: var(--paper);
  padding: 16px 28px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  transition: background 160ms var(--ease), transform 80ms var(--ease);
  letter-spacing: -0.005em;
}
.primary-btn:hover {
  background-color: #6b1f2a;
  background-color: var(--accent);
}
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { background: var(--ink-mute); cursor: not-allowed; opacity: 0.5; }
.primary-btn .arrow { font-size: 22px; transition: transform 200ms var(--ease); }
.primary-btn:hover .arrow { transform: translateX(4px); }

.ghost-btn {
  font-size: 13px;
  color: var(--ink-mute);
  padding: 6px 0;
  border-bottom: 1px solid transparent;
  transition: color 120ms var(--ease), border-color 120ms var(--ease);
}
.ghost-btn:hover { color: var(--accent); border-color: var(--accent); }

.secondary-btn {
  font-family: var(--display);
  font-size: 18px;
  font-style: italic;
  font-weight: 500;
  background-color: transparent;
  color: var(--ink);
  border: 1.5px solid var(--ink);
  padding: 14px 26px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  transition: background 160ms var(--ease), color 160ms var(--ease), transform 80ms var(--ease);
  letter-spacing: -0.005em;
}
.secondary-btn:hover {
  background-color: var(--ink);
  color: var(--paper);
}
.secondary-btn:active { transform: translateY(1px); }

/* Drill input + inline symbol toolbar */
.drill-answer-row {
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.drill-answer-row .answer-input { flex: 1 1 200px; min-width: 0; }
.drill-symbols {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.drill-sym {
  font-family: var(--display);
  font-size: 18px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--ink-mute);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 120ms var(--ease), background 120ms var(--ease);
}
.drill-sym:hover { border-color: var(--ink); background-color: rgba(0,0,0,0.03); }

/* MCQ options inside Quick Practice */
.mcq-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 24px;
}
.mcq-option {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background-color: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--ink-mute);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 17px;
  font-family: inherit;
  cursor: pointer;
  transition: background 120ms var(--ease), border-color 120ms var(--ease);
}
.mcq-option:hover:not(:disabled) {
  border-color: var(--ink);
  background-color: rgba(0,0,0,0.02);
}
.mcq-option:disabled { cursor: not-allowed; opacity: 0.85; }
.mcq-option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
.mcq-option-text { flex: 1; }
.mcq-option-correct {
  border-color: #2f7a3a;
  background-color: rgba(47, 122, 58, 0.08);
}
.mcq-option-correct .mcq-option-letter { background-color: #2f7a3a; }
.mcq-option-wrong {
  border-color: var(--accent);
  background-color: rgba(107, 31, 42, 0.08);
}
.mcq-option-wrong .mcq-option-letter { background-color: var(--accent); }
.mcq-image { max-width: 100%; margin-top: 16px; border-radius: var(--radius); }
.mcq-option-image {
  width: 100%;
  height: auto;
  max-height: 180px;
  border-radius: 6px;
  background: #fdfaf3;
}
.mcq-option-image-mode {
  flex-direction: column;
  align-items: stretch;
  padding: 12px;
  gap: 8px;
}
.mcq-option-image-mode .mcq-option-letter { align-self: flex-start; }
.mcq-explanation {
  margin-top: 12px;
  padding: 12px 14px;
  background-color: rgba(0,0,0,0.04);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--ink);
}
@media (max-width: 540px) {
  .mcq-options { grid-template-columns: 1fr; }
}

/* =========================================================================
   Session view — full-page, locked, exam-feel
   ========================================================================= */

.session-page {
  min-height: calc(100vh - 70px); /* viewport minus session-topbar height */
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 48px 28px 64px;
  position: relative;
  z-index: 2;
}

.session-question {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
}

/* The question itself sits high on the page, generous breathing room */
.question-block {
  padding-top: 24px;
  padding-bottom: 32px;
}
.question-meta {
  font-family: var(--display);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-style: italic;
  margin-bottom: 20px;
  display: flex;
  gap: 14px;
  align-items: baseline;
}
.question-meta-marks {
  background: var(--accent);
  color: var(--paper);
  padding: 3px 10px;
  border-radius: var(--radius);
  font-style: normal;
  font-size: 12px;
  letter-spacing: 0.08em;
}
.question-context {
  font-family: var(--body);
  font-size: 14px;
  color: var(--ink-mute);
  font-style: italic;
  margin-bottom: 16px;
  letter-spacing: 0.02em;
}
.question-text {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.4;
  letter-spacing: -0.01em;
  max-width: 60ch;
}
.question-text .katex { font-size: 1.05em; }

/* Visual divider before the answer area */
.answer-divider {
  margin: 48px 0 24px;
  height: 1px;
  background: var(--rule);
  position: relative;
}
.answer-divider::after {
  content: 'Your answer';
  position: absolute;
  top: -10px;
  left: 0;
  background: var(--paper);
  padding-right: 14px;
  font-family: var(--display);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
}

/* Math symbol toolbar — sits above the input */
.math-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.math-key {
  font-family: var(--mono);
  font-size: 14px;
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 6px 11px;
  border-radius: 3px;
  color: var(--ink);
  min-width: 36px;
  text-align: center;
  transition: all 120ms var(--ease);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.math-key:hover {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
}
.math-key:active { transform: translateY(1px); }
.math-key.fn-key {
  font-family: var(--body);
  font-size: 13px;
  font-style: italic;
  color: var(--accent);
}
.math-key.fn-key:hover { color: var(--paper); }
.math-key.calc-toggle {
  margin-left: auto;
  font-family: var(--body);
  font-size: 13px;
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}
.math-key.calc-toggle:hover { background: var(--accent); border-color: var(--accent); }

.answer-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 8px;
}
.answer-input {
  flex-grow: 1;
  font-family: var(--mono);
  font-size: 19px;
  background: var(--paper);
  border: 1.5px solid var(--rule);
  border-radius: var(--radius);
  padding: 18px 18px;
  outline: none;
  transition: border-color 160ms var(--ease), background 160ms var(--ease);
  min-width: 0;
}
.answer-input:focus {
  border-color: var(--accent);
  background: var(--paper);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.submit-btn {
  font-family: var(--display);
  font-size: 17px;
  font-style: italic;
  font-weight: 500;
  background: var(--ink);
  color: var(--paper);
  padding: 0 28px;
  border-radius: var(--radius);
  transition: background 160ms var(--ease);
  white-space: nowrap;
}
.submit-btn:hover:not(:disabled) { background: var(--accent); }
.submit-btn:disabled { background: var(--ink-mute); opacity: 0.5; cursor: not-allowed; }

.answer-helper {
  font-size: 13px;
  color: var(--ink-mute);
  margin-top: 6px;
  font-style: italic;
}
.answer-helper code {
  font-family: var(--mono);
  background: var(--paper-deep);
  padding: 1px 5px;
  border-radius: 3px;
  font-style: normal;
  color: var(--ink-soft);
  font-size: 12px;
}

/* Result feedback */
.result {
  margin-top: 20px;
  padding: 22px 26px;
  border-radius: var(--radius);
  border-left: 4px solid;
  animation: slideIn 240ms var(--ease);
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.result.correct {
  background: var(--correct-soft);
  border-color: var(--correct);
  color: var(--correct);
}
.result.incorrect {
  background: var(--incorrect-soft);
  border-color: var(--incorrect);
  color: var(--incorrect);
}
.result.partial {
  background: #fff7e8;
  border-color: #d49a3a;
  color: #8a5a14;
}
.ai-checking {
  font-size: 14px;
  color: var(--ink-soft);
  font-style: italic;
  padding: 10px 0;
}
.ai-note {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-soft);
  font-style: italic;
}
.your-answer {
  margin: 6px 0 4px;
  font-size: 14px;
  color: var(--ink-soft);
}
.your-answer strong {
  color: inherit;
  font-family: var(--mono, ui-monospace, monospace);
  font-weight: 600;
}

/* ===== Start practice modal ===== */
.start-modal { max-width: 580px; }
.start-mode-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 18px 0;
}
.start-mode-card {
  display: block;
  text-align: left;
  padding: 16px 18px;
  background: var(--paper-deep, #faf7f0);
  border: 1px solid var(--rule, #e5e1d8);
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s, background 0.15s, transform 0.06s;
}
.start-mode-card:hover {
  border-color: var(--accent, #4a7c59);
  background: #fff;
}
.start-mode-card:active { transform: scale(0.99); }
.start-mode-name {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 4px;
}
.start-mode-desc {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
}
.start-modal-focus {
  margin: 18px 0 6px;
  padding: 8px 0;
  border-top: 1px solid var(--rule, #e5e1d8);
}
.start-modal-focus summary {
  cursor: pointer;
  font-weight: 500;
  padding: 6px 0;
}

/* ===== Exam mode ===== */
#exam-container {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
}
.exam-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding: 32px 0 28px;
  border-bottom: 1px solid var(--rule, #e5e1d8);
  margin-bottom: 28px;
}
.exam-timer-box { text-align: right; }
.exam-timer {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 32px;
  font-weight: 600;
  color: var(--ink);
}
.exam-timer-warning { color: var(--incorrect, #b04a3a); }
.exam-section { margin: 36px 0; }
.exam-section h3 {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 4px;
}
.exam-mcq-list, .exam-sr-list { padding-left: 28px; }
.exam-mcq, .exam-sr {
  margin: 22px 0;
  padding: 16px 18px;
  background: var(--paper-deep, #faf7f0);
  border-radius: var(--radius, 6px);
}
.exam-q-text { margin-bottom: 12px; line-height: 1.55; }
.exam-q-header { float: right; }
.exam-q-marks {
  font-size: 13px;
  color: var(--ink-soft);
  font-style: italic;
}
.exam-mcq-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.exam-mcq-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
.exam-mcq-option:hover { background: rgba(0, 0, 0, 0.03); }
.exam-mcq-label {
  font-weight: 600;
  width: 18px;
  flex-shrink: 0;
}
.exam-mcq-text { flex: 1; }
.exam-sr-input {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--rule, #d8d3c4);
  border-radius: 4px;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 14px;
  resize: vertical;
}
.exam-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 48px 0 32px;
}
/* Result states on review */
.exam-result-correct { border-left: 3px solid var(--correct, #4a7c59); }
.exam-result-partial { border-left: 3px solid #d49a3a; }
.exam-result-incorrect { border-left: 3px solid var(--incorrect, #b04a3a); }
.exam-result-row {
  margin: 8px 0;
  font-weight: 500;
  font-size: 14px;
}
.exam-your-answer {
  background: rgba(0, 0, 0, 0.03);
  padding: 8px 12px;
  border-radius: 4px;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 13px;
  white-space: pre-wrap;
  margin: 6px 0;
}
.exam-explanation {
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  font-style: italic;
}
.exam-worked {
  margin-top: 12px;
  font-size: 14px;
}
.exam-worked summary {
  cursor: pointer;
  color: var(--ink-soft);
  font-style: italic;
}

.drill-source {
  margin: -4px 0 12px;
  font-style: italic;
}

/* Mastery page: chapter with no ticked rules (greyed placeholder row) */
.mastery-chapter-empty {
  opacity: 0.55;
}
.mastery-chapter-empty .mastery-chapter-header {
  cursor: default;
}
.mastery-chapter-empty:hover {
  opacity: 0.75;
}
.result-headline {
  font-family: var(--display);
  font-style: italic;
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 4px;
}
.result-detail { font-size: 14px; color: var(--ink-soft); }

.worked-solution {
  margin-top: 24px;
  padding: 22px 26px;
  background: var(--paper-deep);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
}
.worked-solution h4 {
  font-family: var(--display);
  font-style: italic;
  font-size: 17px;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 14px;
}
.worked-solution ol { list-style: none; counter-reset: step; }
.worked-solution li {
  counter-increment: step;
  padding-left: 36px;
  position: relative;
  margin-bottom: 10px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.worked-solution li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--display);
  font-size: 14px;
  color: var(--accent);
  font-weight: 500;
  width: 24px;
  height: 24px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-style: italic;
}

.next-btn {
  font-family: var(--display);
  font-size: 17px;
  font-style: italic;
  font-weight: 500;
  background-color: #6b1f2a;
  background-color: var(--accent);
  color: #f6f1e8;
  color: var(--paper);
  padding: 14px 28px;
  border: 1px solid #6b1f2a;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  margin-top: 28px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.next-btn:hover {
  background-color: #4a1118;
  background-color: var(--accent-deep);
}

/* End-of-session screen */
.session-end {
  text-align: center;
  padding: 56px 24px;
  width: 100%;
}
.session-end .display { margin-bottom: 24px; }
.session-summary { font-family: var(--body); font-size: 18px; color: var(--ink-soft); }
.session-score {
  font-family: var(--display);
  font-style: italic;
  font-size: 64px;
  color: var(--accent);
  margin: 24px 0;
  font-feature-settings: "tnum";
  letter-spacing: -0.02em;
}

/* Empty session-eligible state */
.empty-state {
  text-align: center;
  padding: 80px 24px;
}
.empty-state .display { margin-bottom: 16px; }
.empty-state p {
  color: var(--ink-soft);
  margin-bottom: 24px;
  max-width: 40ch;
  margin-left: auto;
  margin-right: auto;
}

/* =========================================================================
   Calculator panel
   ========================================================================= */
.calc-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 280px;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 36px -8px rgba(20, 10, 0, 0.4), 0 4px 12px -4px rgba(0,0,0,0.2);
  z-index: 100;
  overflow: hidden;
  animation: calcPop 220ms var(--ease);
}
@keyframes calcPop {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.calc-panel[hidden] { display: none; }
.calc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.calc-title {
  font-family: var(--display);
  font-style: italic;
  font-size: 14px;
  color: var(--paper);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.calc-close {
  font-size: 22px;
  color: var(--rule);
  line-height: 1;
  font-weight: 300;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  transition: background 120ms var(--ease);
}
.calc-close:hover { background: rgba(255,255,255,0.1); color: var(--paper); }
.calc-display {
  width: 100%;
  background: transparent;
  color: var(--paper);
  font-family: var(--mono);
  font-size: 22px;
  text-align: right;
  padding: 16px;
  border: 0;
  outline: none;
  font-feature-settings: "tnum";
}
.calc-keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: rgba(255,255,255,0.08);
}
.calc-key {
  background: var(--ink);
  color: var(--paper);
  padding: 16px 0;
  font-family: var(--mono);
  font-size: 16px;
  transition: background 100ms var(--ease);
  border: 0;
  cursor: pointer;
}
.calc-key:hover { background: #2a241f; }
.calc-key:active { background: #383028; }
.calc-key-fn { color: var(--accent-soft); font-style: italic; }
.calc-key-op { color: var(--paper); background: #2a241f; }
.calc-key-eq { background: var(--accent); color: var(--paper); font-weight: 500; }
.calc-key-eq:hover { background: var(--accent-deep); }

/* =========================================================================
   Mastery view — chapter-grouped
   ========================================================================= */
.mastery-chapters { border-top: 1px solid var(--rule); }
.mastery-chapter {
  border-bottom: 1px solid var(--rule);
}
.mastery-chapter-header {
  display: grid;
  grid-template-columns: 56px 1fr auto 100px 22px;
  gap: 16px;
  align-items: center;
  padding: 18px 0;
  cursor: pointer;
  user-select: none;
  transition: background 120ms var(--ease);
}
.mastery-chapter-header:hover { background: var(--paper-deep); }
.mastery-chapter-num {
  font-family: var(--display);
  font-style: italic;
  font-size: 28px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.mastery-chapter-title {
  font-family: var(--display);
  font-size: 19px;
  color: var(--ink);
  font-weight: 500;
}
.mastery-chapter-stats {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-mute);
  font-feature-settings: "tnum";
  white-space: nowrap;
}
.mastery-chapter-bar {
  height: 8px;
  background: var(--rule-soft);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.mastery-chapter-bar-fill {
  height: 100%;
  background: var(--bar-fill, var(--accent));
  border-radius: 4px;
  transition: width 400ms var(--ease), background-color 200ms var(--ease);
}
.mastery-chapter-toggle {
  font-size: 14px;
  color: var(--ink-mute);
  transition: transform 200ms var(--ease);
  text-align: center;
}
.mastery-chapter.open .mastery-chapter-toggle { transform: rotate(90deg); }

.mastery-rules {
  display: none;
  padding: 8px 0 24px 72px;
}
.mastery-chapter.open .mastery-rules { display: block; }

.mastery-rule {
  display: grid;
  grid-template-columns: 1fr 70px 70px 100px;
  gap: 16px;
  padding: 10px 0;
  align-items: center;
}
.mastery-rule-header {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 500;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 8px;
  margin-bottom: 4px;
}
.mastery-rule-name {
  font-size: 14px;
  color: var(--ink);
}
.mastery-rule-section {
  font-size: 11px;
  color: var(--ink-mute);
  margin-left: 6px;
  font-feature-settings: "tnum";
}
.mastery-rule-num {
  font-family: var(--mono);
  font-size: 13px;
  text-align: right;
  font-feature-settings: "tnum";
  color: var(--ink-soft);
}
.mastery-rule-bar {
  height: 5px;
  background: var(--rule-soft);
  border-radius: 3px;
  overflow: hidden;
}
.mastery-rule-bar-fill {
  height: 100%;
  background: var(--bar-fill, var(--accent));
  border-radius: 3px;
  transition: width 400ms var(--ease), background-color 200ms var(--ease);
}
.mastery-rule-untried {
  font-style: italic;
  color: var(--ink-mute);
}

/* ---- Footer ---- */
.footer { border-top: 1px solid var(--rule); padding: 32px 0; margin-top: 60px; }

/* ---- Utilities ---- */
.muted { color: var(--ink-mute); }
.small { font-size: 13px; }

/* ---- Responsive ---- */
@media (max-width: 720px) {
  body { font-size: 16px; }
  .topbar-inner, .session-topbar-inner { padding: 14px 20px; flex-wrap: wrap; }
  .container { padding: 0 20px; }
  .display { font-size: 36px; }

  /* Session: more compact on phones */
  .session-page { padding: 24px 18px 40px; }
  .question-text { font-size: 22px; }
  .question-block { padding: 16px 0 24px; }
  .answer-input { font-size: 17px; padding: 14px 14px; }
  .answer-row { flex-direction: column; }
  .submit-btn { padding: 14px 24px; }
  .math-toolbar { padding: 8px 8px; gap: 4px; }
  .math-key { padding: 8px 10px; min-width: 32px; font-size: 13px; }

  .chapter-actions, .rules-grid { margin-left: 0; }
  .chapter-number { width: 44px; font-size: 26px; }
  .nav-btn { padding: 6px 10px; font-size: 13px; }

  .mastery-chapter-header {
    grid-template-columns: 44px 1fr 18px;
    grid-template-areas:
      "num title toggle"
      ".   stats stats"
      ".   bar   bar";
    gap: 8px 12px;
  }
  .mastery-chapter-num { grid-area: num; }
  .mastery-chapter-title { grid-area: title; }
  .mastery-chapter-stats { grid-area: stats; font-size: 12px; }
  .mastery-chapter-bar { grid-area: bar; }
  .mastery-chapter-toggle { grid-area: toggle; }
  .mastery-rules { padding-left: 0; }
  .mastery-rule {
    grid-template-columns: 1fr 50px 80px;
  }
  .mastery-rule .mastery-rule-num.tries { display: none; }

  /* Calculator: bottom-of-screen on phones */
  .calc-panel {
    bottom: 12px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
  }
  .calc-key { padding: 14px 0; font-size: 15px; }

  /* Session-mode: marks counter still readable */
  .session-meta-marks { font-size: 16px; }
  .session-exit-btn { padding: 6px 10px; font-size: 12px; }
}

/* KaTeX tweak */
.katex-display { margin: 0.5em 0; }
.katex { color: inherit; }

/* =========================================================================
 * Layout: sidebar + main (v0.8)
 * ======================================================================= */

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  align-items: start;
  max-width: 1280px;
  margin: 0 auto;
}

.layout-main {
  min-width: 0;  /* prevent grid blow-out from long content */
}

.sidebar {
  position: sticky;
  top: 24px;
  align-self: start;
  padding: 24px 20px;
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

/* During a practice session, hide the whole sidebar */
body.session-active .sidebar { display: none; }
body.session-active .layout { grid-template-columns: 1fr; }

/* Profile card at top of sidebar */
.sidebar-profile {
  background: rgba(107, 31, 42, 0.04);
  border: 1px solid rgba(107, 31, 42, 0.12);
  border-radius: 10px;
  padding: 14px 14px 12px;
  margin-bottom: 22px;
}

.sidebar-profile-year {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}

.sidebar-profile-courses {
  font-size: 13px;
  color: var(--ink-mute);
  margin-bottom: 8px;
  line-height: 1.4;
}

.sidebar-profile-due {
  font-family: var(--display);
  font-style: italic;
  font-size: 13px;
  color: var(--accent);
  margin: 4px 0 10px;
  padding: 6px 10px;
  background: rgba(107, 31, 42, 0.07);
  border-radius: var(--radius);
  border-left: 2px solid var(--accent);
}
.sidebar-profile-due.is-empty {
  color: var(--ink-mute);
  background: rgba(0, 0, 0, 0.03);
  border-left-color: var(--ink-mute);
}

.sidebar-profile-edit {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.sidebar-profile-edit:hover { color: var(--accent-deep); }

/* Sidebar headings + chapter list */
.sidebar-heading {
  font-family: 'Fraunces', serif;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  margin: 0 0 10px;
}

.sidebar-chapter-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-chapter-link {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.sidebar-chapter-link:hover {
  background: rgba(0, 0, 0, 0.04);
}

.sidebar-chapter-link.empty {
  opacity: 0.45;
}

.sidebar-chapter-num {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
  text-align: center;
}

.sidebar-chapter-title {
  font-size: 13.5px;
  line-height: 1.3;
}

.sidebar-chapter-progress {
  font-size: 11px;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sidebar-chapter-bar {
  grid-column: 2 / 4;
  height: 3px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}

.sidebar-chapter-bar-fill {
  height: 100%;
  background: var(--bar-fill, var(--accent));
  border-radius: 2px;
  transition: width 0.25s ease, background-color 200ms ease;
}

.sidebar-empty-message {
  padding: 12px;
  font-size: 13px;
  color: var(--ink-mute);
  font-style: italic;
  line-height: 1.5;
}

/* =========================================================================
 * Profile modal
 * ======================================================================= */

.profile-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 14, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  animation: profile-fade-in 0.2s ease;
}
.profile-modal-overlay.is-open { display: flex; }

@keyframes profile-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.profile-modal {
  background: var(--paper);
  border-radius: 12px;
  padding: 32px 36px 28px;
  max-width: 460px;
  width: 100%;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  animation: profile-rise 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes profile-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.profile-modal-title {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--ink);
}

.profile-modal-lede {
  margin: 0 0 24px;
  color: var(--ink-mute);
  font-size: 14.5px;
  line-height: 1.5;
}

.profile-modal-field {
  border: none;
  padding: 0;
  margin: 0 0 22px;
}

.profile-modal-field legend {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  margin-bottom: 10px;
  padding: 0;
}

.profile-modal-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-modal-options-stacked {
  flex-direction: column;
  gap: 6px;
}

.profile-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  flex: 1;
  min-width: 120px;
}
.profile-option[hidden] { display: none; }

.profile-modal-options-stacked .profile-option {
  flex: 0 0 auto;
}

.profile-option:hover {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(107, 31, 42, 0.3);
}

.profile-option:has(input:checked) {
  background: rgba(107, 31, 42, 0.08);
  border-color: var(--accent);
}

.profile-option input {
  margin: 0;
  accent-color: var(--accent);
}

.profile-option span {
  font-size: 14.5px;
  font-family: 'Source Serif 4', serif;
}

.profile-modal-note {
  margin: 8px 0 0;
}

.profile-modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

/* =========================================================================
 * Mobile: stack sidebar above main
 * ======================================================================= */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding: 16px 20px 20px;
  }
  .sidebar-chapters { display: none; } /* main view already shows full chapters */
  .sidebar-profile { margin-bottom: 0; }
}

@media (max-width: 600px) {
  .profile-modal {
    padding: 24px 20px 20px;
  }
  .profile-modal-title { font-size: 22px; }
  .profile-modal-options { flex-direction: column; }
}

/* =========================================================================
 * Dashboard (home view) — v0.11
 * ======================================================================= */

.dashboard {
  margin: 32px 0 48px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.dashboard-card {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 20px 24px 22px;
}

.dashboard-card-wide { grid-column: 1 / -1; }
.dashboard-card-empty {
  text-align: center;
  color: var(--ink-mute);
  font-style: italic;
}

.dashboard-card-title {
  font-family: var(--display);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-mute);
  margin: 0 0 12px;
}

.dashboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dashboard-list-inline { gap: 4px; }

.dashboard-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: baseline;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}
.dashboard-row:last-child { border-bottom: none; }

.dashboard-rule-name {
  font-family: var(--body);
  font-size: 14.5px;
  color: var(--ink);
  line-height: 1.3;
}

.dashboard-rule-section {
  font-family: var(--display);
  font-size: 11px;
  font-style: italic;
  color: var(--ink-mute);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.dashboard-rule-acc {
  font-family: var(--display);
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dashboard-empty {
  margin: 0;
  padding: 8px 0;
}

@media (max-width: 700px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================================================
 * Sidebar "Add learned rules" button — v0.11
 * ======================================================================= */

.sidebar-add-rules-btn {
  display: grid;
  grid-template-columns: 22px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  margin: 0 0 22px;
  background: var(--paper);
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.sidebar-add-rules-btn:hover {
  background: rgba(107, 31, 42, 0.05);
  border-style: solid;
}

.sidebar-add-rules-btn .plus {
  grid-row: 1 / -1;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 400;
  text-align: center;
  color: var(--accent);
}

.sidebar-add-rules-btn .label {
  font-family: var(--display);
  font-size: 14.5px;
  font-style: italic;
  color: var(--accent);
  font-weight: 500;
}

.sidebar-add-rules-btn .hint {
  font-family: var(--body);
  font-size: 11.5px;
  color: var(--ink-mute);
  font-style: italic;
}
.sidebar-add-rules-btn .hint.is-empty { color: var(--ink-mute); }

/* =========================================================================
 * Rules modal (Add learned rules) — v0.11
 * ======================================================================= */

.rules-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 14, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  animation: profile-fade-in 0.2s ease;
}
.rules-modal-overlay.is-open { display: flex; }

.rules-modal {
  background: var(--paper);
  border-radius: 12px;
  width: 100%;
  max-width: 760px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  animation: profile-rise 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.rules-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--rule);
  gap: 16px;
}

.rules-modal-title {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--ink);
}

.rules-modal-lede {
  margin: 0;
  color: var(--ink-mute);
  font-size: 13.5px;
  line-height: 1.45;
}

.rules-modal-close {
  background: none;
  border: none;
  font-size: 26px;
  font-weight: 300;
  color: var(--ink-mute);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.rules-modal-close:hover { color: var(--ink); }

.rules-modal-body {
  overflow-y: auto;
  padding: 16px 28px 24px;
  flex: 1;
}

.rules-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  border-top: 1px solid var(--rule);
  background: rgba(0, 0, 0, 0.02);
  gap: 16px;
}

.rules-modal-counts {
  font-family: var(--display);
  font-size: 13px;
  font-style: italic;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
}

@media (max-width: 600px) {
  .rules-modal { max-height: calc(100vh - 24px); }
  .rules-modal-header { padding: 18px 20px 12px; }
  .rules-modal-body { padding: 12px 20px 20px; }
  .rules-modal-footer { padding: 12px 20px; }
}
