/* UK liver transplant policy explorer - styles */
:root {
  --ink: #1f2937;
  --muted: #6b7280;
  --surface: #f8fafc;
  --border: #e5e7eb;
  --teal: #0e7490;
  --teal-soft: #ecfeff;
  --red: #b91c1c;
  --red-soft: #fef2f2;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --green: #047857;
  --green-soft: #ecfdf5;
  --indigo: #4338ca;
  --indigo-soft: #eef2ff;
}

body { color: var(--ink); background: #ffffff; }
.navbar .route-pill { font-size: .8rem; }

/* ---- Typography & page framing ---- */
.page-intro { max-width: 62rem; margin: 1rem 0 1.25rem; }
.page-intro h2 { font-weight: 700; letter-spacing: -0.01em; margin-bottom: .5rem; }
.page-intro p { font-size: 1.05rem; line-height: 1.6; color: #374151; }
.section-title { font-weight: 700; font-size: 1.35rem; margin: 1.5rem 0 .75rem; }
.form-help { color: var(--muted); font-size: .85rem; margin-bottom: .75rem; line-height: 1.4; }
.block-intro { line-height: 1.55; }
.block-note { color: var(--muted); font-size: .88rem; line-height: 1.45; margin: .75rem 0 0; padding-top: .5rem; border-top: 1px dashed var(--border); }
.disclaimer { color: #991b1b; font-size: .9rem; margin-top: 1rem; margin-bottom: 0; }
.card .card-header { font-weight: 600; background: var(--surface); }
.card { margin-bottom: 1rem; }
.card.html-fill-item { flex: 0 0 auto !important; }  /* cards keep their natural height inside layout_columns */
.card-hint { color: var(--muted); font-weight: 400; font-size: .85rem; margin-left: .5rem; }

.ref-badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .72rem; font-weight: 600; color: var(--teal);
  background: var(--teal-soft); border: 1px solid #a5f3fc; border-radius: 999px; padding: .1rem .55rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ref-badge .ref-page { color: var(--muted); font-weight: 500; }
.block-heading { font-weight: 600; margin: .25rem 0 .5rem; }
.block-section + .block-section { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }

ul.policy-list, ol.policy-list { padding-left: 1.2rem; margin-bottom: .25rem; }
ul.policy-list > li, ol.policy-list > li { margin-bottom: .45rem; line-height: 1.5; }
ul.policy-sublist { padding-left: 1.1rem; margin: .3rem 0 .2rem; }
ul.policy-sublist > li { margin-bottom: .25rem; line-height: 1.45; font-size: .95rem; }
.item-lead { font-weight: 600; }
ul.compact > li, ol.compact > li { margin-bottom: .25rem; font-size: .92rem; }
ol.algo > li { margin-bottom: .6rem; }

.kv { display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { font-weight: 600; color: #374151; }
.kv dd { margin: 0; line-height: 1.5; }
.kv.glossary { grid-template-columns: minmax(9rem, 16rem) 1fr; gap: .6rem 1.25rem; }
.kv.glossary dt { color: var(--teal); }
.policy-table { font-size: .92rem; }
.policy-table td, .policy-table th { vertical-align: top; }

details.policy-wording { margin: .5rem 0 1rem; }
details.policy-wording summary { cursor: pointer; font-weight: 600; color: var(--teal); }
details.policy-wording .policy-wording-body { margin-top: .5rem; padding: .75rem 1rem; background: var(--surface); border-radius: .5rem; line-height: 1.55; }

/* ---- Route pills and coloured cards ---- */
.route-pill { display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .02em; color: var(--pill, var(--teal));
  background: color-mix(in srgb, var(--pill, var(--teal)) 10%, white); border: 1px solid color-mix(in srgb, var(--pill, var(--teal)) 35%, white);
  border-radius: 999px; padding: .15rem .65rem; white-space: nowrap; }
.card-bad { border-left: 5px solid var(--red); }
.card-warn { border-left: 5px solid var(--amber); }
.card-ok { border-left: 5px solid var(--green); }
.card-info { border-left: 5px solid var(--indigo); }
.col-title { font-size: 1.1rem; font-weight: 700; margin: .25rem 0 .75rem; }
.col-title-bad { color: var(--red); }
.col-title-warn { color: var(--amber); }


.search-hit { padding: .55rem 0; border-bottom: 1px solid var(--border); }
.search-hit:last-child { border-bottom: 0; }
.search-title { font-weight: 600; text-decoration: none; }
.search-where { display: block; color: var(--muted); font-size: .78rem; margin: .1rem 0; }
.search-snippet { font-size: .88rem; color: #374151; line-height: 1.4; }

/* ---- Verdict boxes ---- */
.verdict { border-radius: .6rem; padding: .8rem 1rem; margin: .25rem 0 1rem; border: 1px solid var(--border); border-left-width: 6px; background: var(--surface); }
.verdict-headline { font-weight: 700; font-size: 1.02rem; line-height: 1.35; }
.verdict-reasons { margin: .5rem 0 0; padding-left: 1.1rem; font-size: .92rem; }
.verdict-reasons li { margin-bottom: .2rem; }
.verdict-detail { margin: .5rem 0 0; font-size: .9rem; line-height: 1.5; color: #374151; }
.verdict-ok { border-left-color: var(--green); background: var(--green-soft); }
.verdict-ok .verdict-headline { color: var(--green); }
.verdict-warn { border-left-color: var(--amber); background: var(--amber-soft); }
.verdict-warn .verdict-headline { color: var(--amber); }
.verdict-bad { border-left-color: var(--red); background: var(--red-soft); }
.verdict-bad .verdict-headline { color: var(--red); }
.verdict-info { border-left-color: var(--indigo); background: var(--indigo-soft); }
.verdict-info .verdict-headline { color: var(--indigo); }
.verdict-muted { border-left-color: var(--muted); }
.verdict-muted .verdict-headline { color: var(--muted); font-weight: 600; }

/* ---- UKELD scale ---- */
.scale { position: relative; height: 4.2rem; margin: .5rem .5rem .25rem; }
.scale-bar { position: absolute; top: 2.4rem; left: 0; right: 0; height: .6rem; border-radius: 999px;
  background: linear-gradient(90deg, #a7f3d0 0%, #fde68a 35%, #fca5a5 62%, #f87171 100%); }
.scale-threshold { position: absolute; top: 1.9rem; width: 2px; height: 1.6rem; background: #111827; transform: translateX(-1px); }
.scale-marker { position: absolute; top: 1.1rem; width: 0; height: 0; transform: translateX(-.55rem); border-left: .55rem solid transparent; border-right: .55rem solid transparent; border-top: .8rem solid var(--teal); }
.scale-marker span { position: absolute; top: -1.9rem; left: -1.4rem; width: 2.8rem; text-align: center; font-weight: 700; font-size: .9rem; color: var(--teal); }
.scale-ticks { position: absolute; top: 3.1rem; left: 0; right: 0; display: flex; justify-content: space-between; font-size: .68rem; color: var(--muted); }
.formula { margin-top: .5rem; padding: .6rem .75rem; background: var(--surface); border-radius: .5rem; border: 1px solid var(--border); }
.formula-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.formula code { display: block; white-space: normal; font-size: .82rem; color: var(--ink); margin: .3rem 0; }
.formula-ref { font-size: .78rem; color: var(--muted); line-height: 1.4; }

/* ---- Flow steps / timeline ---- */
.flow { display: flex; flex-wrap: wrap; gap: .3rem; align-items: stretch; margin: .25rem 0 .75rem; }
.flow-step { flex: 1 1 10rem; min-width: 9rem; border: 1px solid var(--border); border-top: 4px solid var(--step, var(--teal)); border-radius: .6rem; padding: .55rem .7rem; background: #fff; display: flex; gap: .55rem; align-items: flex-start; }
.flow-num { flex: 0 0 auto; font-size: .72rem; font-weight: 700; color: #fff; background: var(--step, var(--teal)); border-radius: 999px; width: 1.35rem; height: 1.35rem; line-height: 1.35rem; text-align: center; margin-top: .1rem; }
.flow-text { font-size: .88rem; line-height: 1.35; }
.flow-arrow { align-self: center; color: var(--muted); font-size: 1.1rem; }
.timeline { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; }
.timeline-item { display: contents; }
.timeline-when { font-weight: 700; color: var(--teal); white-space: nowrap; font-variant-numeric: tabular-nums; }
.timeline-what { line-height: 1.45; padding-bottom: .35rem; border-bottom: 1px dashed var(--border); }

/* ---- Checklists ---- */
.chk-group { border: 1px solid var(--border); border-radius: .6rem; padding: .6rem .8rem .2rem; margin-bottom: .6rem; background: #fff; }
.chk-group-title { font-weight: 600; font-size: .92rem; margin-bottom: .35rem; display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.chk-rule { font-weight: 500; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.chk-exclusions { border-color: #fecaca; background: var(--red-soft); }
.chk-group .form-check { margin-bottom: .35rem; }
.chk-group .form-check-label { font-size: .9rem; line-height: 1.4; }

/* ---- Super-urgent table ---- */
.su-table-controls { margin: .25rem 0 .5rem; }
.su-table { font-size: .9rem; }
.su-table td { vertical-align: top; }
.cat-badge { display: inline-block; font-weight: 700; color: #fff; background: var(--red); border-radius: .4rem; padding: .05rem .5rem; font-variant-numeric: tabular-nums; }

/* ---- Appendices ---- */
.appendix-head { margin: .5rem 0 1rem; }
.appendix-head h3 { font-weight: 700; font-size: 1.3rem; margin-bottom: .4rem; }
.appendix-status { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ---- Quiz ---- */
.quiz-card .card-body { padding: .9rem 1.1rem; }
.quiz-q { font-weight: 600; margin-bottom: .5rem; line-height: 1.45; display: flex; gap: .6rem; align-items: flex-start; }
.quiz-num { flex: 0 0 auto; font-size: .75rem; font-weight: 700; color: #fff; background: var(--teal); border-radius: 999px; width: 1.4rem; height: 1.4rem; line-height: 1.4rem; text-align: center; }
.quiz-actions { display: flex; gap: .6rem; align-items: center; margin: .5rem 0 2rem; flex-wrap: wrap; }
.quiz-score { font-weight: 700; font-size: 1.1rem; color: var(--teal); }

/* ---- Sidebar / inputs ---- */
.form-group, .shiny-input-container { margin-bottom: .6rem; }
.shiny-input-container label { font-size: .85rem; margin-bottom: .15rem; }
.shiny-input-container .form-control, .shiny-input-container .form-select { font-size: .9rem; padding: .3rem .5rem; }

/* ---- Reference badges are links to the policy PDF ---- */
a.ref-badge { text-decoration: none; cursor: pointer; }
a.ref-badge:hover { background: #cffafe; border-color: var(--teal); color: #155e75; }
.verdict a.ref-badge, .kv a.ref-badge { vertical-align: middle; margin-left: .15rem; }
.route-head { margin-bottom: .25rem; }
.appendix-status .form-help { font-size: .78rem; }


/* =====================================================================
   Redesign (Oct 2026): clearer hierarchy and phone-first layout
   ===================================================================== */

/* ---- Page frame ---- */
body { background: #f6f8fa; -webkit-text-size-adjust: 100%; }
.navbar + .container-fluid, body > .container-fluid { max-width: 76rem; margin: 0 auto; padding-left: 1rem; padding-right: 1rem; }
.tab-content > .tab-pane { padding-bottom: 1rem; }

/* ---- Navbar: one row on desktop, sticky, compact ---- */
.navbar { position: sticky; top: 0; z-index: 1030; background: #fff !important; border-bottom: 1px solid var(--border); box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.navbar .brand { font-weight: 700; letter-spacing: -0.01em; font-size: 1.05rem; display: inline-flex; align-items: center; gap: .5rem; }
.navbar .brand-mark { font-size: .7rem; font-weight: 800; letter-spacing: .04em; color: #fff; background: var(--teal); border-radius: .35rem; padding: .15rem .4rem; }
.navbar-brand { white-space: nowrap; margin-right: 1rem; }
@media (max-width: 991.98px) {
  .navbar > .container-fluid { flex-wrap: wrap; }
  .navbar-header { display: flex; align-items: center; justify-content: space-between; width: 100%; min-width: 0; }
  .navbar-brand { min-width: 0; white-space: normal; flex: 1 1 auto; margin-right: .5rem; }
  .navbar .brand { font-size: .98rem; }
  .navbar-toggle, .navbar-toggler { flex: 0 0 auto; margin-right: 0 !important; }
}
.navbar .nav-link { font-size: .92rem; padding-left: .6rem !important; padding-right: .6rem !important; color: #374151; white-space: nowrap; }
.navbar .nav-link.active { color: var(--teal) !important; font-weight: 600; }
@media (min-width: 992px) {
  .navbar .nav-link.active { box-shadow: inset 0 -3px 0 var(--teal); }
}
@media (max-width: 991.98px) {
  .navbar-collapse { max-height: calc(100vh - 4rem); overflow-y: auto; padding-bottom: .5rem; }
  .navbar .nav-link { font-size: 1rem; padding-top: .7rem; padding-bottom: .7rem; border-bottom: 1px solid var(--border); }
  .navbar .nav-link.active { box-shadow: inset 3px 0 0 var(--teal); padding-left: .9rem !important; }
  .navbar .dropdown-menu { border: 0; box-shadow: none; padding-left: .75rem; }
}
@media (min-width: 992px) and (max-width: 1440px) {
  .navbar .brand-text { display: none; }   /* keep just the badge so the links fit */
}

/* ---- Footer ---- */
.site-footer { max-width: 76rem; margin: 2rem auto 0; padding: 1.25rem 1rem 2rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; }
.site-footer p { margin: 0 0 .3rem; }

/* ---- Page intros ---- */
.page-intro { max-width: 46rem; margin: 1.5rem 0 1.25rem; }
.page-intro h2 { font-size: 1.75rem; }
.page-intro p { font-size: 1.02rem; }

/* ---- Overview: hero with search ---- */
.hero { max-width: 46rem; margin: 2rem 0 2.25rem; }
.eyebrow { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--teal); margin-bottom: .5rem; }
.hero h1 { font-weight: 800; letter-spacing: -0.02em; font-size: 2.2rem; line-height: 1.15; margin-bottom: .75rem; }
.hero .lead { font-size: 1.1rem; line-height: 1.6; color: #374151; margin-bottom: 1.25rem; }
.hero-search { background: #fff; border: 1px solid var(--border); border-radius: .8rem; padding: .9rem 1rem .4rem; box-shadow: 0 1px 3px rgba(15, 23, 42, .06); }
.hero-search-label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.hero-search .form-control { font-size: 1rem; padding: .55rem .75rem; border-radius: .55rem; }
.hero-new { margin: .9rem 0 0; font-size: .9rem; color: #374151; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.new-tag { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #9d174d; background: #fdf2f8; border: 1px solid #fbcfe8; border-radius: 999px; padding: .1rem .5rem; }
.search-results { max-height: 22rem; overflow: auto; margin: .25rem 0 .5rem; border-top: 1px solid var(--border); }
.search-count { font-size: .78rem; color: var(--muted); margin: .5rem 0 0; }
.search-empty { margin-top: .25rem; }

/* ---- Overview sections ---- */
.ov-section { margin: 0 0 2.5rem; }
.section-title { font-weight: 700; font-size: 1.35rem; letter-spacing: -0.01em; margin: 0 0 .4rem; }
.section-sub { color: var(--muted); margin: 0 0 1rem; max-width: 46rem; }
.ov-section > .section-title + :not(.section-sub) { margin-top: .9rem; }

/* Numbered steps */
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; counter-reset: none; }
.step { display: flex; gap: .75rem; background: #fff; border: 1px solid var(--border); border-radius: .75rem; padding: .9rem 1rem; min-width: 0; }
.step-num { flex: 0 0 auto; width: 1.9rem; height: 1.9rem; border-radius: 999px; background: var(--stage, var(--teal)); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: .9rem; }
.step-body { min-width: 0; display: flex; flex-direction: column; }
.step-title { font-size: 1rem; font-weight: 700; margin: .2rem 0 .3rem; line-height: 1.3; }
.step-short { font-size: .92rem; color: #374151; line-height: 1.45; margin: 0 0 .4rem; flex: 1; }
.step-more summary { font-size: .82rem; color: var(--muted); cursor: pointer; margin-bottom: .3rem; }
.step-more p { font-size: .88rem; line-height: 1.5; color: #374151; }
.step-link { font-weight: 600; font-size: .9rem; text-decoration: none; }

/* Route cards */
.route-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); gap: .75rem; }
.route-card { min-width: 0; border: 1px solid var(--border); border-radius: .75rem; padding: .9rem 1rem; background: #fff; display: flex; flex-direction: column; gap: .45rem; border-left: 5px solid var(--pill, var(--teal)); }
.route-title { font-size: 1.02rem; font-weight: 700; margin: 0; color: var(--pill, var(--teal)); }
.route-card p { font-size: .92rem; line-height: 1.5; margin: 0; flex: 1; color: #374151; }
.route-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; padding-top: .35rem; }
.route-link { font-weight: 600; text-decoration: none; white-space: nowrap; }

/* Key numbers */
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .6rem; }
.stat-tile { border: 1px solid var(--border); border-radius: .7rem; padding: .75rem .8rem; background: #fff; min-width: 0; }
.stat-tile .stat-value { font-size: 1.45rem; font-weight: 800; line-height: 1.1; color: var(--teal); font-variant-numeric: tabular-nums; }
.stat-tile .stat-label { font-size: .8rem; color: #374151; line-height: 1.3; margin-top: .3rem; }
.stat-tile .stat-ref { font-size: .72rem; color: var(--muted); margin-top: .3rem; }

/* Scope */
.scope { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.scope-col { background: #fff; border: 1px solid var(--border); border-radius: .75rem; padding: .9rem 1rem .5rem; }
.scope-col h3 { font-size: .95rem; font-weight: 700; margin-bottom: .5rem; }
.scope-yes { border-top: 4px solid var(--green); }
.scope-no { border-top: 4px solid #9ca3af; }

/* ---- Cards ---- */
.card { border-radius: .75rem; border-color: var(--border); box-shadow: none; }
.card .card-header { background: #fff; border-bottom-color: var(--border); }
.card-header.d-flex { flex-wrap: wrap; row-gap: .35rem; }
.fold-card > summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; border-bottom: 0; border-radius: .75rem; }
.fold-card > summary::-webkit-details-marker { display: none; }
.fold-card > summary::after { content: "+"; font-weight: 700; color: var(--teal); font-size: 1.2rem; line-height: 1; }
.fold-card[open] > summary { border-bottom: 1px solid var(--border); border-radius: .75rem .75rem 0 0; }
.fold-card[open] > summary::after { content: "\2212"; }

/* ---- Tabs: level 1 = segmented pills, level 2 = underline ---- */
.tab-label { display: inline-flex; align-items: center; gap: .45rem; }
.tab-dot { width: .6rem; height: .6rem; border-radius: 999px; display: inline-block; flex: 0 0 auto; }
.card > .card-header .nav-pills .nav-link { color: #374151; font-weight: 600; font-size: .92rem; border-radius: .55rem; padding: .45rem .85rem; }
.card > .card-header .nav-pills .nav-link.active { background: var(--teal-soft); color: #155e75; box-shadow: inset 0 0 0 1.5px var(--teal); }
.card > .card-header .nav-pills .nav-link.active .tab-dot { box-shadow: 0 0 0 2px #fff; }
.nav-underline .nav-link, .nav-tabs .nav-link { font-size: .92rem; }
.subnav-lead { margin: 1.25rem 0 .25rem; }
.subnav-lead h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: .2rem; }
.subnav-lead p, .subnav-lead-p { color: var(--muted); margin-bottom: .25rem; font-size: .95rem; }

/* ---- Calculator inputs ---- */
.input-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .75rem; align-items: end; }
.input-grid > .shiny-input-container { width: 100% !important; min-width: 0; }
.input-grid > .shiny-input-container:has(.checkbox), .input-grid > .shiny-input-container:has(select) { grid-column: 1 / -1; }
.shiny-input-container .form-control, .shiny-input-container .form-select { width: 100%; }
.fold { margin-top: .5rem; }
.fold > summary { cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--teal); }
.fold-body { margin-top: .4rem; }
.scale-legend { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; font-size: .8rem; color: #374151; margin: 0 .5rem 1rem; }
.scale-legend span::before { content: ""; display: inline-block; width: 2px; height: .8rem; background: #111827; margin-right: .4rem; vertical-align: -2px; }

/* Long unbroken strings (URLs, slash-joined terms) wrap instead of widening the page */
.card-body, .page-intro, .kv dd, .verdict, .step-body, .route-card { overflow-wrap: anywhere; }

/* ---- Phones and small tablets ---- */
@media (max-width: 991.98px) {
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 767.98px) {
  .navbar + .container-fluid, body > .container-fluid { padding-left: .75rem; padding-right: .75rem; }
  .hero { margin: 1.25rem 0 1.75rem; }
  .hero h1 { font-size: 1.65rem; }
  .hero .lead { font-size: 1rem; }
  .page-intro { margin: 1.1rem 0 1rem; }
  .page-intro h2 { font-size: 1.45rem; }
  .page-intro p { font-size: .97rem; line-height: 1.55; }
  .section-title { font-size: 1.2rem; }
  .steps { grid-template-columns: 1fr; gap: .5rem; }
  .step { padding: .8rem .85rem; }
  .route-grid { grid-template-columns: 1fr; gap: .6rem; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scope { grid-template-columns: 1fr; }
  .kv, .kv.glossary { grid-template-columns: 1fr; gap: .15rem; }
  .kv dd { margin-bottom: .6rem; }
  .timeline { grid-template-columns: 1fr; gap: 0; }
  .timeline-when { padding-top: .5rem; }

  /* 16px inputs stop iPhone Safari zooming in on focus */
  .shiny-input-container .form-control, .shiny-input-container .form-select, .form-control, .form-select { font-size: 16px !important; }
  .shiny-input-container label { font-size: .88rem; }
  .form-check-input { width: 1.15em; height: 1.15em; }
  .chk-group .form-check-label, .checkbox label { font-size: .95rem; }

  /* Sub-tabs scroll sideways instead of wrapping into a jumble */
  .tab-pane .nav-pills, .tab-pane .nav-underline, .tab-pane .nav-tabs, .card-header .nav {
    flex-wrap: nowrap !important; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none;
    scroll-snap-type: x proximity; -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); padding-right: 1.5rem; }
  .tab-pane .nav::-webkit-scrollbar, .card-header .nav::-webkit-scrollbar { display: none; }
  .tab-pane .nav .nav-item, .card-header .nav .nav-item { flex: 0 0 auto; scroll-snap-align: start; }
  .tab-pane .nav .nav-link, .card-header .nav .nav-link { white-space: nowrap; }

  /* Cards: less padding so text gets the width */
  .card-body { padding: .85rem .85rem; }
  .card-header { padding: .65rem .85rem; }
  .bslib-navs-card-title, .card > .card-header:has(.nav) { padding: .5rem .5rem; }

  /* Pathway flows become vertical numbered lists */
  .flow { flex-direction: column; gap: .4rem; }
  .flow-step { flex: 1 1 auto; min-width: 0; }
  .flow-arrow, .journey-arrow { display: none; }

  /* Tables stack into label/value cards */
  table.stack-sm thead { display: none; }
  table.stack-sm, table.stack-sm tbody, table.stack-sm tr, table.stack-sm td { display: block; width: 100%; }
  table.stack-sm tr { border: 1px solid var(--border); border-radius: .6rem; margin-bottom: .5rem; padding: .35rem .6rem; background: #fff; }
  table.stack-sm td { border: 0; padding: .2rem 0; box-shadow: none !important; background: transparent !important; }
  table.stack-sm td[data-label]::before { content: attr(data-label); display: block; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

  .verdict { padding: .7rem .8rem; }
  .route-pill, .ref-badge { white-space: normal; max-width: 100%; }
  .appendix-head h3 { font-size: 1.15rem; }
  .su-table-controls .shiny-options-group { display: flex; flex-wrap: wrap; gap: .25rem .75rem; }
  .quiz-actions .btn { flex: 1 1 auto; }
}
@media (max-width: 360px) {
  .input-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
}
@media print {
  .navbar, .site-footer, .quiz-actions, .hero-search { display: none !important; }
  .card { break-inside: avoid; }
}
