/* DVMReady V3 topic shell — empty prototype.
   Visuals come only from the shared semantic tokens in assets/css/tokens.css.
   No new tokens, no hard-coded colours, no dark mode, no decorative motion. */

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: var(--dvm-font-sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--dvm-color-text);
  background: color-mix(in srgb, var(--dvm-color-accent) 4%, var(--dvm-color-surface));
  -webkit-text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

/* Flex column so the bottom CTA sits at the viewport bottom even on short pages. */
#shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

#main {
  flex: 1 0 auto;
}

.wrap {
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: 16px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  flex: none;
  vertical-align: -0.15em;
}

a {
  color: var(--dvm-color-primary);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--dvm-color-primary-hover);
}

:focus-visible {
  outline: 3px solid var(--dvm-color-focus);
  outline-offset: 2px;
  border-radius: var(--dvm-radius-sm);
}

/* Programmatic focus follows view/state transitions. Keep its indicator
   explicit because :focus-visible heuristics differ across browser engines. */
.is-programmatic-focus {
  outline: 3px solid var(--dvm-color-focus) !important;
  outline-offset: 2px;
  border-radius: var(--dvm-radius-sm);
}

/* Keyboard focus on a tabpanel stays clearly visible (W3C tabs pattern:
   Tab moves into the panel). Inset so the ring is never clipped. */
.panel:focus-visible,
.panel.is-programmatic-focus {
  outline: 3px solid var(--dvm-color-focus);
  outline-offset: -3px;
}

/* Programmatic focus targets (tabindex="-1" only, never tabbable):
   show where focus landed after a view transition. */
#main:focus,
#session-main:focus,
.session-title:focus,
.section-h:focus,
.subsection-h:focus,
.session-item-title:focus,
.session-summary h2:focus,
.feedback:focus,
.recall-answer:focus {
  outline: 3px solid var(--dvm-color-focus);
  outline-offset: -3px;
  border-radius: var(--dvm-radius-sm);
}

#main.is-programmatic-focus,
#session-main.is-programmatic-focus,
.session-title.is-programmatic-focus,
.section-h.is-programmatic-focus,
.subsection-h.is-programmatic-focus,
.session-item-title.is-programmatic-focus,
.session-summary h2.is-programmatic-focus,
.feedback.is-programmatic-focus,
.recall-answer.is-programmatic-focus {
  outline-offset: -3px;
}

.skip-link {
  position: absolute;
  inset-inline-start: 16px;
  top: 8px;
  z-index: 60;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  background: var(--dvm-color-surface);
  color: var(--dvm-color-primary);
  border: 1px solid var(--dvm-color-border);
  border-radius: var(--dvm-radius-sm);
  transform: translateY(-300%);
}

.skip-link:focus-visible {
  transform: none;
}

/* ---------- Buttons ---------- */

.btn-primary,
.btn-quiet,
.btn-text {
  font: inherit;
  font-weight: 700;
  min-height: 44px;
  min-width: 44px;
  border-radius: var(--dvm-radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--dvm-color-primary);
  color: var(--dvm-color-surface);
  border: 1px solid var(--dvm-color-primary);
  padding: 10px 20px;
}

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

.btn-quiet {
  background: var(--dvm-color-surface);
  color: var(--dvm-color-text);
  border: 1px solid var(--dvm-color-border);
  padding: 10px 16px;
}

.btn-quiet:hover {
  background: var(--dvm-color-surface-elevated);
}

.btn-quiet:disabled {
  color: var(--dvm-color-text-muted);
  background: var(--dvm-color-surface-elevated);
  cursor: default;
}

.btn-quiet:disabled:hover {
  background: var(--dvm-color-surface-elevated);
}

.btn-quiet[aria-pressed="true"]:disabled {
  color: var(--dvm-color-primary);
  border-color: var(--dvm-color-primary);
  background: var(--dvm-teal-soft);
}

.btn-text {
  background: none;
  border: none;
  color: var(--dvm-color-primary);
  padding: 10px 12px;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.btn-text:hover {
  color: var(--dvm-color-primary-hover);
}

/* ---------- Top bar (one slim layer; scrolls away naturally) ---------- */

.topbar {
  background: var(--dvm-color-surface);
  border-bottom: 1px solid var(--dvm-color-border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 48px;
}

.brand {
  flex: none;
  width: 133px;
  height: 28px;
  overflow: hidden;
  color: transparent;
  white-space: nowrap;
  background: url("../../public/brand/logo-monogram-primary.svg") center / contain no-repeat;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 0.875rem;
  color: var(--dvm-color-text-muted);
}

.crumb-parent {
  flex: 0 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.crumb-sep {
  flex: none;
}

.crumb-current {
  flex: 0 1 auto;
  color: var(--dvm-color-text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.acct {
  flex: none;
  margin-inline-start: auto;
  color: var(--dvm-color-text-muted);
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.acct-review {
  padding: 4px 10px;
  color: var(--dvm-color-warning);
  background: color-mix(in srgb, var(--dvm-color-warning) 7%, var(--dvm-color-surface));
  border: 1px solid color-mix(in srgb, var(--dvm-color-warning) 35%, var(--dvm-color-border));
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 700;
}

/* ---------- Topic header ---------- */

.topic-header {
  background: color-mix(in srgb, var(--dvm-color-accent) 4%, var(--dvm-color-surface));
  border-bottom: 1px solid color-mix(in srgb, var(--dvm-color-accent) 12%, var(--dvm-color-border));
}

.topic-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 24px;
  padding-block: 24px;
}

.topic-id {
  min-width: 0;
  flex: 1 1 32ch;
}

.topic-title {
  max-width: 24ch;
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.06;
  font-weight: 800;
  color: var(--dvm-color-secondary);
  text-wrap: balance;
}

.topic-kicker {
  margin: 0 0 6px;
  color: var(--dvm-color-primary);
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topic-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  min-width: 0;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  color: var(--dvm-color-text-muted);
  font-size: 0.9375rem;
  line-height: 1.45;
}

.topic-facts li {
  position: relative;
  min-width: 0;
  overflow-wrap: anywhere;
}

.topic-facts li + li::before {
  content: "";
  position: absolute;
  inset-inline-start: -10px;
  top: 0.65em;
  width: 4px;
  height: 4px;
  background: var(--dvm-color-primary);
  border-radius: 50%;
}

.topic-review {
  margin: 8px 0 0;
  color: var(--dvm-color-warning);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.45;
}

.topic-meta {
  margin: 4px 0 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--dvm-color-text-muted);
}

.cta-slot {
  margin-inline-start: auto;
  display: none;
}

.cta-slot .btn-primary {
  min-height: 48px;
}

/* ---------- Sticky region 1: mode tabs ---------- */

.tabs-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--dvm-color-accent) 4%, var(--dvm-color-surface));
  border-bottom: 1px solid color-mix(in srgb, var(--dvm-color-accent) 12%, var(--dvm-color-border));
}

.tablist {
  display: flex;
  gap: 8px;
  padding-block: 8px;
}

.tab {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--dvm-color-text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--dvm-radius-sm);
  cursor: pointer;
  text-align: center;
  overflow-wrap: anywhere;
}

.tab:hover {
  color: var(--dvm-color-text);
  background: color-mix(in srgb, var(--dvm-color-primary) 5%, var(--dvm-color-surface));
}

.tab[aria-selected="true"] {
  color: var(--dvm-color-primary);
  font-weight: 700;
  background: var(--dvm-color-surface);
  border-color: color-mix(in srgb, var(--dvm-color-primary) 28%, var(--dvm-color-border));
  box-shadow: var(--dvm-shadow-sm);
}

.tab:focus-visible {
  outline-offset: -3px;
}

.tab.is-programmatic-focus {
  outline-offset: -3px;
}

.tab-label-mobile {
  display: none;
}

/* ---------- Panels ---------- */

.panel {
  padding-block: 24px 56px;
}

/* ---------- Exam Snapshot (Learn only) ---------- */

.snapshot {
  background: color-mix(in srgb, var(--dvm-color-primary) 4%, var(--dvm-color-surface));
  border: 1px solid color-mix(in srgb, var(--dvm-color-primary) 22%, var(--dvm-color-border));
  border-radius: var(--dvm-radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
}

.snapshot-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 16px 20px;
  cursor: pointer;
  list-style: none;
}

.snapshot-summary::-webkit-details-marker {
  display: none;
}

.summary-h {
  margin: 0;
  font-size: 1.125rem;
  line-height: 1.3;
  font-weight: 700;
  color: var(--dvm-color-secondary);
}

.snapshot-summary::after,
.outline-disc-summary::after {
  content: "";
  margin-inline-start: auto;
  width: 10px;
  height: 10px;
  border-inline-end: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
}

.snapshot-details[open] .snapshot-summary::after,
.outline-disc[open] .outline-disc-summary::after {
  transform: rotate(225deg) translateY(-2px);
}

.snapshot-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 32px;
  margin: 0;
  padding: 0 20px 16px;
}

.snap-item {
  min-width: 0;
  padding-block: 12px;
  border-top: 1px solid color-mix(in srgb, var(--dvm-color-primary) 12%, var(--dvm-color-border));
}

.snap-item:first-child {
  border-top: none;
}

.snap-item dt {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--dvm-color-secondary);
}

.snap-item dd {
  margin: 4px 0 0;
  font-size: 0.9375rem;
  line-height: 1.55;
}

.snap-item-danger {
  border-inline-start: 3px solid var(--dvm-color-error);
  padding-inline-start: 12px;
}

.snap-item-danger dt {
  color: var(--dvm-color-error);
}

.snap-item-warning {
  border-inline-start: 3px solid var(--dvm-color-warning);
  padding-inline-start: 12px;
}

.snap-item-warning dt {
  color: var(--dvm-color-warning);
}

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.3;
  padding: 2px 8px;
  border-radius: 999px;
}

.badge-danger {
  color: var(--dvm-color-error);
  background: color-mix(in srgb, var(--dvm-color-error) 10%, var(--dvm-color-surface));
  border: 1px solid var(--dvm-color-error);
}

.badge-warning {
  color: var(--dvm-color-warning);
  background: color-mix(in srgb, var(--dvm-color-warning) 10%, var(--dvm-color-surface));
  border: 1px solid var(--dvm-color-warning);
}

.decision-rule {
  margin: 0;
  padding: 15px 20px;
  color: var(--dvm-color-surface);
  background: var(--dvm-color-secondary);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.rule-label {
  font-weight: 700;
  color: var(--dvm-color-surface);
}

/* ---------- Learn layout: outline + one readable column ---------- */

.learn-layout {
  display: block;
}

.content-column {
  max-width: 72ch;
  min-width: 0;
}

.learn-layout .content-column {
  max-width: none;
  padding: 24px 20px;
  background: var(--dvm-color-surface);
  border: 1px solid color-mix(in srgb, var(--dvm-color-accent) 12%, var(--dvm-color-border));
  border-radius: var(--dvm-radius-lg);
  box-shadow: var(--dvm-shadow-sm);
}

.learn-layout .snapshot {
  margin: -24px -20px 32px;
  border: none;
  border-bottom: 1px solid color-mix(in srgb, var(--dvm-color-primary) 22%, var(--dvm-color-border));
  border-radius: var(--dvm-radius-lg) var(--dvm-radius-lg) 0 0;
}

.panel:not(#panel-learn) .content-column {
  max-width: 800px;
  margin-inline: auto;
  padding: 28px 24px;
  background: var(--dvm-color-surface);
  border: 1px solid color-mix(in srgb, var(--dvm-color-accent) 12%, var(--dvm-color-border));
  border-radius: var(--dvm-radius-lg);
  box-shadow: var(--dvm-shadow-sm);
}

/* Outline shared */

.outline-heading {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--dvm-color-text-muted);
  text-transform: uppercase;
}

.outline-list,
.outline-sub {
  list-style: none;
  margin: 0;
  padding: 0;
}

.outline-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  margin-top: 8px;
}

.outline-list > li {
  min-width: 0;
}

.outline-sub {
  margin-inline-start: 26px;
}

.outline-link {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px 8px 12px;
  border-inline-start: 3px solid transparent;
  border-radius: var(--dvm-radius-sm);
  color: var(--dvm-color-text);
  text-decoration: none;
}

.outline-link:hover {
  background: var(--dvm-color-surface-elevated);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* Flex children may always shrink and rewrap; min-width:auto would
   let long words blow out the row at very narrow widths. */
.outline-link > *,
.option > * {
  min-width: 0;
}

.outline-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--dvm-color-text-muted);
}

.outline-link.is-current {
  color: var(--dvm-color-primary);
  background: color-mix(in srgb, var(--dvm-color-primary) 7%, var(--dvm-color-surface));
  border-inline-start-color: var(--dvm-color-primary);
  font-weight: 700;
}

.outline-link.is-current .outline-dot {
  background: var(--dvm-color-primary);
  border-color: var(--dvm-color-primary);
}

.current-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--dvm-color-primary);
}

.outline-sublink {
  min-height: 44px;
  font-size: 0.9375rem;
  color: var(--dvm-color-text-muted);
}

/* Rail form: hidden below 1200px */

.outline-rail {
  display: none;
}

/* Disclosure form: shown below 1200px, hidden on the rail range */

.outline-disc {
  background: var(--dvm-color-surface);
  border: 1px solid color-mix(in srgb, var(--dvm-color-accent) 12%, var(--dvm-color-border));
  border-radius: var(--dvm-radius-md);
  margin-bottom: 24px;
  box-shadow: var(--dvm-shadow-sm);
}

.outline-disc-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
}

.outline-disc-summary::-webkit-details-marker {
  display: none;
}

.outline-count {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--dvm-color-text-muted);
}

.outline-disc nav {
  padding: 0 8px 12px;
}

/* ---------- Sections, headings, callout ---------- */

.topic-section {
  margin-bottom: 44px;
}

.topic-section + .topic-section {
  padding-top: 40px;
  border-top: 1px solid color-mix(in srgb, var(--dvm-color-accent) 12%, var(--dvm-color-border));
}

.topic-section:last-child {
  margin-bottom: 0;
}

.section-h {
  margin: 0 0 12px;
  font-size: clamp(1.5rem, 2.5vw, 1.9375rem);
  line-height: 1.2;
  font-weight: 700;
  color: var(--dvm-color-secondary);
}

.section-h[data-chapter] {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--dvm-color-accent) 16%, var(--dvm-color-border));
}

.section-h[data-chapter]::before {
  content: attr(data-chapter);
  flex: none;
  color: var(--dvm-color-primary);
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.subsection-h {
  margin: 28px 0 8px;
  font-size: 1.25rem;
  line-height: 1.3;
  font-weight: 700;
  color: var(--dvm-color-secondary);
}

.content-unit {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px dashed color-mix(in srgb, var(--dvm-color-accent) 20%, var(--dvm-color-border));
}

.content-unit > .subsection-h {
  margin-top: 0;
}

.topic-section p,
.content-column p {
  margin: 0 0 16px;
}

.topic-section > p,
.content-unit > p {
  max-width: 70ch;
}

.section-h[id],
.subsection-h[id],
.topic-section[id],
.content-unit[id] {
  scroll-margin-top: 120px;
}

.callout {
  margin: 20px 0;
  padding: 16px 20px;
  background: color-mix(in srgb, var(--dvm-color-info) 5%, var(--dvm-color-surface));
  border: 1px solid color-mix(in srgb, var(--dvm-color-info) 22%, var(--dvm-color-border));
  border-inline-start: 3px solid var(--dvm-color-info);
  border-radius: var(--dvm-radius-sm);
}

.callout-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--dvm-color-info);
}

.callout-text {
  margin: 0;
}

/* Key-sentence highlight for the few decision-critical sentences in a lesson.
   A calm "study-card" chip: soft background, primary accent bar, bold weight,
   and rounded right corners. The bold weight means meaning never rides on
   colour alone, and box-decoration-break keeps it tidy across line wraps. */
mark {
  --mark-bar: var(--dvm-color-primary);
  --mark-bg: color-mix(in srgb, var(--dvm-color-accent) 9%, var(--dvm-color-surface));
  background: var(--mark-bg);
  color: var(--dvm-color-text);
  font-weight: 700;
  padding: 0.12em 0.45em 0.12em 0.55em;
  border-radius: 0 0.35em 0.35em 0;
  border-inline-start: 3px solid var(--mark-bar);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.callout-warning {
  background: color-mix(in srgb, var(--dvm-color-warning) 6%, var(--dvm-color-surface));
  border-color: color-mix(in srgb, var(--dvm-color-warning) 25%, var(--dvm-color-border));
  border-inline-start-color: var(--dvm-color-warning);
}

.callout-warning .callout-label {
  color: var(--dvm-color-warning);
}

.lead {
  font-size: 1.0625rem;
  line-height: 1.7;
}

.plain-list {
  margin: 0 0 16px;
  padding-inline-start: 24px;
  display: grid;
  gap: 10px;
}

.must-know-list li {
  position: relative;
  padding: 14px 8px 14px 44px;
  border-top: 1px solid color-mix(in srgb, var(--dvm-color-accent) 12%, var(--dvm-color-border));
  counter-increment: must-know;
}

.must-know-list {
  grid-template-columns: minmax(0, 1fr);
  gap: 0 24px;
  padding: 0;
  list-style: none;
  counter-reset: must-know;
}

.must-know-list li::before {
  content: counter(must-know, decimal-leading-zero);
  position: absolute;
  inset-inline-start: 4px;
  top: 14px;
  color: var(--dvm-color-primary);
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

/* ---------- Clinical-review content components ---------- */

.decision-list {
  display: grid;
  gap: 12px;
  margin: 20px 0;
}

.decision-row {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.35fr);
  gap: 18px;
  min-width: 0;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--dvm-color-info) 4%, var(--dvm-color-surface));
  border: 1px solid color-mix(in srgb, var(--dvm-color-info) 18%, var(--dvm-color-border));
  border-inline-start: 3px solid var(--dvm-color-info);
  border-radius: var(--dvm-radius-sm);
}

.decision-row-urgent {
  border-inline-start-color: var(--dvm-color-error);
}

.decision-if,
.decision-then {
  margin: 0;
}

.decision-if {
  color: var(--dvm-color-secondary);
  font-weight: 700;
}

.decision-then {
  margin-top: 0;
  padding-inline-start: 18px;
  border-inline-start: 1px solid color-mix(in srgb, var(--dvm-color-info) 18%, var(--dvm-color-border));
}

.decision-pathway-list {
  counter-reset: decision-step;
}

.decision-pathway-list .decision-row {
  position: relative;
  padding-inline-start: 58px;
  counter-increment: decision-step;
}

.decision-pathway-list .decision-row::before {
  content: counter(decision-step, decimal-leading-zero);
  position: absolute;
  inset-inline-start: 16px;
  top: 14px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--dvm-color-primary);
  background: color-mix(in srgb, var(--dvm-color-primary) 8%, var(--dvm-color-surface));
  border: 1px solid color-mix(in srgb, var(--dvm-color-primary) 32%, var(--dvm-color-border));
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 800;
}

.table-wrap {
  max-width: 100%;
  margin: 20px 0;
}

.supporting-details {
  margin: 20px 0;
  background: color-mix(in srgb, var(--dvm-color-accent) 3%, var(--dvm-color-surface));
  border: 1px solid color-mix(in srgb, var(--dvm-color-accent) 18%, var(--dvm-color-border));
  border-radius: var(--dvm-radius-md);
  overflow: hidden;
}

.supporting-details > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 16px;
  color: var(--dvm-color-secondary);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.supporting-details > summary::-webkit-details-marker {
  display: none;
}

.supporting-summary-h {
  margin: 0;
  font: inherit;
}

.supporting-details > summary::before {
  content: "+";
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--dvm-color-primary);
  border: 1px solid color-mix(in srgb, var(--dvm-color-primary) 32%, var(--dvm-color-border));
  border-radius: 50%;
}

.supporting-details[open] > summary::before {
  content: "−";
}

.supporting-details > .details-body {
  padding: 4px 16px 16px;
  border-top: 1px solid color-mix(in srgb, var(--dvm-color-accent) 12%, var(--dvm-color-border));
}

.supporting-details .table-wrap {
  margin-bottom: 0;
}

.content-unit > .supporting-details {
  margin: 0;
}

.clinical-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  background: var(--dvm-color-surface);
  border: 1px solid var(--dvm-color-border);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.clinical-table caption {
  padding: 0 0 10px;
  color: var(--dvm-color-text-muted);
  font-size: 0.875rem;
  text-align: start;
}

.clinical-table th,
.clinical-table td {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--dvm-color-border);
  text-align: start;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.clinical-table thead th {
  color: var(--dvm-color-secondary);
  background: var(--dvm-color-surface-elevated);
  font-size: 0.875rem;
}

.clinical-table tbody th {
  color: var(--dvm-color-secondary);
}

.trap-list,
.source-list {
  margin: 0 0 20px;
  padding-inline-start: 24px;
  display: grid;
  gap: 12px;
}

.trap-list li {
  padding-inline-start: 4px;
}

.take-home-list {
  list-style: none;
  padding: 0;
  gap: 0 24px;
}

.take-home-list li {
  position: relative;
  padding: 12px 8px 12px 28px;
  border-top: 1px solid color-mix(in srgb, var(--dvm-color-accent) 12%, var(--dvm-color-border));
}

.take-home-list li::before {
  content: "✓";
  position: absolute;
  inset-inline-start: 4px;
  color: var(--dvm-color-primary);
  font-weight: 800;
}

.review-notice {
  margin: 16px 0;
  padding: 16px 18px;
  background: color-mix(in srgb, var(--dvm-color-warning) 6%, var(--dvm-color-surface));
  border: 1px solid color-mix(in srgb, var(--dvm-color-warning) 38%, var(--dvm-color-border));
  border-radius: var(--dvm-radius-sm);
}

.review-notice p,
.review-boundary {
  margin: 0;
}

.review-boundary {
  color: var(--dvm-color-text-muted);
  font-size: 0.9375rem;
}

/* ---------- Sticky region 2: bottom CTA (768px and below only) ---------- */

.cta-bottom {
  position: sticky;
  bottom: 0;
  z-index: 40;
  margin-top: auto;
  background: var(--dvm-color-surface);
  border-top: 1px solid var(--dvm-color-border);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
}

.cta-bottom .btn-primary {
  width: 100%;
  min-height: 48px;
}

/* ---------- Session view (chromeless; carries the main landmark) ---------- */

.session {
  min-height: 100dvh;
  background: color-mix(in srgb, var(--dvm-color-accent) 4%, var(--dvm-color-surface));
  display: flex;
  flex-direction: column;
}

.session-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--dvm-color-surface);
  border-bottom: 1px solid var(--dvm-color-border);
}

.session-counter {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--dvm-color-text-muted);
}

.session-body {
  width: 100%;
  max-width: 820px;
  margin-inline: auto;
  padding: 24px 16px 64px;
}

.session-title {
  margin: 0 0 16px;
  font-size: clamp(1.5rem, 3vw, 2rem);
  line-height: 1.2;
  font-weight: 700;
  color: var(--dvm-color-secondary);
}

#session-content {
  padding: 24px;
  background: var(--dvm-color-surface);
  border: 1px solid color-mix(in srgb, var(--dvm-color-accent) 12%, var(--dvm-color-border));
  border-radius: var(--dvm-radius-lg);
  box-shadow: var(--dvm-shadow-sm);
}

.session-item-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--dvm-color-text);
}

.session-form fieldset {
  margin: 0;
  padding: 0;
  border: none;
}

.session-item-note {
  margin: 4px 0 16px;
  color: var(--dvm-color-text-muted);
  font-size: 0.9375rem;
}

.session-stem {
  margin: 8px 0 18px;
  padding: 16px 18px;
  background: color-mix(in srgb, var(--dvm-color-primary) 4%, var(--dvm-color-surface));
  border: 1px solid color-mix(in srgb, var(--dvm-color-primary) 18%, var(--dvm-color-border));
  border-radius: var(--dvm-radius-sm);
}

.session-stem .session-item-note {
  margin: 0 0 6px;
  color: var(--dvm-color-text);
}

.session-stem .session-item-note:last-child {
  margin-bottom: 0;
  font-weight: 700;
  color: var(--dvm-color-secondary);
}

.options {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--dvm-color-surface);
  border: 1px solid var(--dvm-color-border);
  border-radius: var(--dvm-radius-sm);
  cursor: pointer;
}

.option:hover {
  background: var(--dvm-color-surface-elevated);
}

.option input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--dvm-color-primary);
}

.option-letter {
  flex: none;
  font-weight: 700;
  color: var(--dvm-color-secondary);
}

.option:has(input:checked) {
  border-color: var(--dvm-color-primary);
  background: var(--dvm-teal-soft);
}

/* After the check, state badges carry the meaning; the selection tint clears. */
.option:has(input:disabled) {
  background: var(--dvm-color-surface);
  cursor: default;
}

.option:has(input:focus-visible) {
  outline: 3px solid var(--dvm-color-focus);
  outline-offset: 2px;
}

.option.option-key {
  border-color: var(--dvm-color-success);
}

.option.option-missed {
  border-color: var(--dvm-color-error);
}

.option-badge {
  margin-inline-start: auto;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.option-badge-key {
  color: var(--dvm-color-success);
  background: color-mix(in srgb, var(--dvm-color-success) 10%, var(--dvm-color-surface));
  border: 1px solid var(--dvm-color-success);
}

.option-badge-missed {
  color: var(--dvm-color-error);
  background: color-mix(in srgb, var(--dvm-color-error) 10%, var(--dvm-color-surface));
  border: 1px solid var(--dvm-color-error);
}

.session-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.session-actions .btn-primary {
  margin-inline-start: auto;
}

.flag-btn[aria-pressed="true"] {
  border-color: var(--dvm-color-warning);
  color: var(--dvm-color-warning);
  background: color-mix(in srgb, var(--dvm-color-warning) 8%, var(--dvm-color-surface));
}

.feedback {
  margin-top: 20px;
  padding: 16px 20px;
  background: color-mix(in srgb, var(--dvm-color-info) 5%, var(--dvm-color-surface));
  border: 1px solid color-mix(in srgb, var(--dvm-color-info) 22%, var(--dvm-color-border));
  border-inline-start: 3px solid var(--dvm-color-info);
  border-radius: var(--dvm-radius-sm);
}

.feedback p {
  margin: 0 0 8px;
}

.feedback p:last-child {
  margin-bottom: 0;
}

.recall-card {
  background: var(--dvm-color-surface);
  border: 1px solid var(--dvm-color-border);
  border-radius: var(--dvm-radius-md);
  padding: 20px;
}

.recall-label {
  margin: 0 0 6px;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--dvm-color-secondary);
}

.recall-prompt {
  margin: 0;
  font-size: 1.0625rem;
}

.recall-answer {
  margin-top: 16px;
  padding: 16px;
  background: color-mix(in srgb, var(--dvm-color-primary) 5%, var(--dvm-color-surface));
  border: 1px solid color-mix(in srgb, var(--dvm-color-primary) 22%, var(--dvm-color-border));
  border-radius: var(--dvm-radius-sm);
}

.recall-answer:focus,
.recall-answer.is-programmatic-focus {
  outline-offset: 2px;
}

.recall-answer p:last-child {
  margin-bottom: 0;
}

.session-summary h2 {
  margin: 0 0 12px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--dvm-color-secondary);
}

.fact-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.fact-list li {
  padding: 10px 14px;
  background: var(--dvm-color-surface);
  border: 1px solid var(--dvm-color-border);
  border-radius: var(--dvm-radius-sm);
}

.session-note {
  color: var(--dvm-color-text-muted);
  font-size: 0.9375rem;
  margin: 0 0 20px;
}

/* ---------- Breakpoints ---------- */

/* Header-trailing CTA above 768px; bottom CTA only at 768px and below. */
@media (min-width: 769px) {
  .cta-slot {
    display: block;
  }

  .cta-bottom {
    display: none;
  }
}

@media (min-width: 769px) {
  .wrap {
    padding-inline: 24px;
  }

  .topic-header-inner {
    padding-block: 32px 28px;
  }

  .snapshot-list {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .snap-item:nth-child(2) {
    border-top: none;
  }

  .must-know-list {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .trap-list,
  .take-home-list {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  /* Side-by-side numbered items need a clear gutter, or the next item's
     marker visually collides with the previous item's last words. */
  .trap-list {
    column-gap: 28px;
  }

  .panel {
    padding-block: 32px 64px;
  }

  .panel:not(#panel-learn) .content-column {
    padding: 36px 40px;
  }

  .session-body {
    padding: 36px 24px 72px;
  }

  #session-content {
    padding: 32px;
  }
}

@media (min-width: 1200px) {
  .wrap {
    padding-inline: 32px;
  }

  .learn-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 32px;
    align-items: start;
  }

  .outline-rail {
    display: block;
    padding: 8px 6px;
    /* Keep wayfinding available through long study pages instead of leaving
       a dead column once the intro scrolls away. Sticks below the tab bar.
       Inline padding keeps focus rings unclipped by the scroll container. */
    position: sticky;
    top: 80px;
    max-height: calc(100dvh - 96px);
    overflow: auto;
  }

  .outline-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .outline-disc {
    display: none;
  }

  .learn-layout .content-column {
    padding: 40px 48px;
  }

  .learn-layout .snapshot {
    margin: -40px -48px 36px;
  }

  .snapshot-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0 18px;
  }

  .snap-item:nth-child(3),
  .snap-item:nth-child(4) {
    border-top: none;
  }
}

/* Small top bar on narrow screens: the official mark stays visible while the
   breadcrumb and account label retain the remaining space. */
@media (max-width: 768px) {
  .topbar-inner {
    gap: 10px;
  }

  .brand {
    width: 32px;
    height: 28px;
    background-image: url("../../public/brand/logo-monogram-icon.svg");
  }

  .crumb-parent::before {
    content: "‹ ";
  }

  .tab-label-full {
    display: none;
  }

  .tab-label-mobile {
    display: inline;
  }

  .topic-facts {
    display: grid;
    gap: 3px;
  }

  .topic-facts li + li::before {
    display: none;
  }

  .learn-layout .content-column,
  .panel:not(#panel-learn) .content-column {
    padding: 22px 18px;
  }

  .learn-layout .snapshot {
    margin: -22px -18px 28px;
  }

  #session-content {
    padding: 20px 16px;
  }

  .clinical-table,
  .clinical-table tbody,
  .clinical-table tr,
  .clinical-table th,
  .clinical-table td {
    display: block;
    width: 100%;
  }

  .clinical-table {
    border: none;
    background: none;
  }

  .clinical-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }

  .clinical-table tbody {
    display: grid;
    gap: 14px;
  }

  .clinical-table tbody tr {
    background: var(--dvm-color-surface);
    border: 1px solid var(--dvm-color-border);
    border-radius: var(--dvm-radius-sm);
    overflow: hidden;
  }

  .clinical-table tbody th,
  .clinical-table tbody td {
    border: none;
    border-bottom: 1px solid var(--dvm-color-border);
  }

  .clinical-table tbody th {
    background: var(--dvm-color-surface-elevated);
  }

  .clinical-table tbody td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--dvm-color-secondary);
    font-size: 0.8125rem;
    font-weight: 700;
  }

  .clinical-table tbody td:last-child {
    border-bottom: none;
  }

  .decision-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .decision-then {
    padding-inline-start: 0;
    padding-top: 8px;
    border-inline-start: none;
    border-top: 1px solid color-mix(in srgb, var(--dvm-color-info) 18%, var(--dvm-color-border));
  }
}

/* Graceful degradation for short viewports (landscape phones, high zoom):
   when tabs + bottom CTA + usable content cannot physically share the height,
   fixed chrome flows inline so it never obscures the content column (WCAG
   reflow intent; mobile stickiness is "subject to prototype testing" per the
   V3 contract, section G). */
@media (max-width: 768px) and (max-height: 300px),
  (max-width: 240px) and (max-height: 500px) {
  .tabs-bar {
    position: static;
  }

  .cta-bottom {
    position: static;
  }
}

/* Compact tabs for very narrow effective widths (high zoom). The tab bar
   goes full-bleed so every tab keeps at least 44px of width. */
@media (max-width: 360px) {
  .tabs-bar .wrap {
    padding-inline: 0;
  }

  .tab {
    padding: 8px 4px;
    font-size: 0.875rem;
  }

  .tablist {
    gap: 4px;
  }

  .topic-header-inner {
    padding-block: 20px;
  }

  .topic-title {
    font-size: 1.875rem;
  }

  .option {
    flex-wrap: wrap;
  }

  .option-badge {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .session-actions > * {
    min-width: 0;
    max-width: 100%;
  }
}

/* Two-by-two tab grid while four single-row tabs could not stay >= 44px
   (single-row needs ~188px). Two ~47px+ columns hold 44x44 even at 98px. */
@media (max-width: 187px) {
  .tablist {
    flex-wrap: wrap;
  }

  .tab {
    flex: 1 1 40%;
  }
}

/* Last-resort breaking and wrapping at the narrowest widths so long words
   can never force horizontal overflow. */
@media (max-width: 140px) {
  .wrap {
    padding-inline: 4px;
  }

  .topbar-inner {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 4px;
    padding-block: 6px;
  }

  .breadcrumb {
    flex: 1 0 100%;
    flex-wrap: wrap;
    gap: 2px;
  }

  .crumb-parent,
  .crumb-current,
  .acct {
    flex: 1 0 100%;
    width: 100%;
  }

  .crumb-sep {
    display: none;
  }

  .acct {
    margin-inline-start: 0;
  }

  .topic-title,
  .topic-kicker,
  .topic-facts,
  .topic-facts li,
  .topic-review,
  .topic-meta,
  .section-h,
  .subsection-h,
  .summary-h,
  .outline-count,
  .outline-link,
  .outline-text,
  .current-label,
  .callout,
  .decision-row,
  .clinical-table,
  .clinical-table th,
  .clinical-table td,
  .trap-list,
  .source-list,
  .review-notice,
  .plain-list li,
  .snap-item dt,
  .snap-item dd,
  .decision-rule,
  .option,
  .fact-list li,
  .feedback,
  .session-stem,
  .recall-card,
  .session-item-title,
  .session-title,
  .session-summary h2,
  .session-counter,
  .session-note,
  .skip-link,
  .btn-primary,
  .btn-quiet {
    overflow-wrap: anywhere;
  }

  .learn-layout .content-column,
  .panel:not(#panel-learn) .content-column {
    padding: 8px 4px;
  }

  .learn-layout .snapshot {
    margin: -8px -4px 20px;
  }

  .snapshot-summary,
  .snapshot-list,
  .decision-rule,
  .callout,
  .decision-row,
  .review-notice,
  .session-stem,
  .feedback,
  .recall-card,
  #session-content {
    padding-inline: 4px;
  }

  .decision-pathway-list .decision-row {
    padding-inline-start: 4px;
  }

  .decision-pathway-list .decision-row::before {
    display: none;
  }

  .topic-section p,
  .content-column p {
    overflow-wrap: anywhere;
  }

  .outline-disc nav {
    padding: 0 4px 12px;
  }

  .outline-sub {
    margin-inline-start: 6px;
  }

  .session-top {
    flex-wrap: wrap;
  }

  .session-top > * {
    min-width: 0;
  }
}

/* ---------- Motion ---------- */

/* ---------- Immersive lesson alignment ---------- */

body {
  background:
    radial-gradient(circle at 88% 6%, color-mix(in srgb, var(--dvm-brand-gold) 14%, transparent), transparent 24rem),
    radial-gradient(circle at 8% 24%, color-mix(in srgb, var(--dvm-color-primary) 9%, transparent), transparent 28rem),
    linear-gradient(color-mix(in srgb, var(--dvm-color-primary) 2%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--dvm-color-primary) 2%, transparent) 1px, transparent 1px),
    color-mix(in srgb, var(--dvm-color-accent) 4%, var(--dvm-color-surface));
  background-size: auto, auto, 44px 44px, 44px 44px, auto;
}

.topic-header {
  width: calc(100% - 16px);
  margin: 8px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--dvm-color-surface) 12%, transparent);
  border-radius: 28px;
  color: var(--dvm-color-surface);
  background:
    radial-gradient(circle at 84% 18%, color-mix(in srgb, var(--dvm-brand-gold) 22%, transparent), transparent 20rem),
    radial-gradient(circle at 12% 88%, color-mix(in srgb, var(--dvm-color-primary) 22%, transparent), transparent 22rem),
    var(--dvm-color-secondary);
  box-shadow: 0 28px 68px color-mix(in srgb, var(--dvm-color-secondary) 22%, transparent);
}

.topic-header-inner {
  padding-block: clamp(32px, 5vw, 58px);
}

.topic-title {
  color: var(--dvm-color-surface);
  font-size: clamp(2.5rem, 5vw, 4.6rem);
  line-height: 0.99;
  letter-spacing: -0.04em;
}

.topic-kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--dvm-teal-light, #8eddd3);
  letter-spacing: 0.12em;
}

.topic-kicker::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--dvm-brand-gold);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--dvm-brand-gold) 16%, transparent);
}

.topic-facts,
.topic-meta {
  color: color-mix(in srgb, var(--dvm-color-surface) 76%, transparent);
}

.topic-review {
  color: color-mix(in srgb, var(--dvm-brand-gold) 72%, var(--dvm-color-surface));
}

.tabs-bar {
  margin-inline: 8px;
  border: 1px solid color-mix(in srgb, var(--dvm-color-primary) 14%, var(--dvm-color-border));
  border-radius: 18px;
  background: color-mix(in srgb, var(--dvm-color-surface) 94%, transparent);
  box-shadow: var(--dvm-shadow-sm);
  backdrop-filter: blur(12px);
}

.learn-layout .content-column,
.panel:not(#panel-learn) .content-column,
.outline-disc {
  border-radius: 22px;
  box-shadow: 0 18px 48px color-mix(in srgb, var(--dvm-color-secondary) 9%, transparent);
}

.learn-layout .snapshot {
  border-radius: 22px 22px 0 0;
}

.section-h[data-chapter]::before {
  color: var(--dvm-color-accent);
}

.callout,
.decision-row,
.review-notice {
  border-radius: 14px;
}

@media (max-width: 700px) {
  .topic-header {
    width: calc(100% - 14px);
    margin: 7px;
    border-radius: 22px;
  }

  .topic-title {
    font-size: clamp(2.25rem, 11vw, 3.6rem);
  }

  .tabs-bar {
    margin-inline: 7px;
    border-radius: 15px;
  }

  .learn-layout .content-column,
  .panel:not(#panel-learn) .content-column,
  .outline-disc {
    border-radius: 18px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  .btn-primary,
  .btn-quiet,
  .btn-text,
  .tab,
  .outline-link,
  .option {
    transition: background-color var(--dvm-motion-fast) var(--dvm-ease-standard),
      border-color var(--dvm-motion-fast) var(--dvm-ease-standard),
      color var(--dvm-motion-fast) var(--dvm-ease-standard);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
