/* ==========================================
   NOCO Tool Framework — shared by ALL clinical tools
   ------------------------------------------
   One stylesheet for every page under /tools/tools/. Loads AFTER
   /includes/styles.css (several rules below win ties by that order)
   and is CORE-precached by the offline protocol app.

   Brand grammar (matches navbar / protocol headers):
   navy 135deg chrome + red cap line, gold detail, site tokens for
   every surface so both themes work. Never hardcode a color here
   unless it sits on navy chrome (chrome is dark in both themes).

   Sections:
     0. Brand tokens
     1. Page scaffolding (title, headings)
     2. Section headers (navy band; legacy class names kept)
     3. Buttons + forms
     4. Results: stat tiles, formula boxes
     5. Tables
     6. Bootstrap modal brand header
     7. Checklist family: sections, items, checkboxes
     8. Checklist modals + narrative form components
     9. Action bars
    10. Responsive + print
    11. Converted tool pages (body.fl-v2): the Phase 11 template
   ========================================== */

/* ---------- 0. Brand tokens ---------- */

/* The --tool-* names are aliases of the site brand tokens in
   /includes/styles.css; fallbacks match the old literal values for
   any context that loads this sheet without styles.css. The red
   follows the admin site colour (--brand-red). */
:root {
    --tool-navy-deep: var(--brand-navy, #0c1929);
    --tool-navy: var(--brand-navy-2, #142742);
    --tool-navy-soft: var(--brand-navy-3, #1e3a5f);
    --tool-navy-band: var(--brand-band, linear-gradient(135deg, #0c1929 0%, #142742 100%));
    --tool-red: var(--brand-red, #c0392b);
    /* Solid red FILLS that carry white text or a white glyph (checked
       checkmark, PDF button, NIHSS info/score fills). Pinned, unlike
       --tool-red, which follows the admin site colour: the owner chose the
       site colour for caps and rules only, and an admin-picked colour has
       no guaranteed contrast under white text. */
    --tool-red-fill: #c0392b;
    --tool-red-fill-deep: #922b20;
    --tool-red-deep: var(--brand-red-deep, #922b20);
    --tool-gold: var(--brand-gold, #d9b380);
    /* Red used AS TEXT on page surfaces needs a brighter dark variant. */
    --tool-red-text: #a93226;
    /* Severity surfaces that carry WHITE text (same value both themes —
       the *-soft tokens go too pale in dark mode for white text).
       Now point at the site fill tokens; fallbacks match their values. */
    --tool-severity-green: var(--success-fill, #1E7345);
    --tool-severity-amber: var(--warning-fill, #B45309);
}

[data-theme="dark"] {
    --tool-red-text: #ff8a80;
}

/* ---------- 1. Page scaffolding ---------- */

h1 {
    font-weight: 600;
    margin-bottom: 1.5rem;
}

/* Standard tool page title: navy icon tile + red-tinted underline. */
.tool-page-title {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    padding-bottom: 0.85rem;
    border-bottom: 3px solid color-mix(in srgb, var(--tool-red) 55%, transparent);
}

.tool-page-title i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    flex: 0 0 auto;
    border-radius: 12px;
    font-size: 1.6rem;
    color: #fff;
    background: linear-gradient(135deg, var(--tool-navy-deep) 0%, var(--tool-navy-soft) 100%);
    border: 1px solid rgba(146, 43, 32, 0.35);
    box-shadow: 0 2px 8px rgba(12, 25, 41, 0.35);
}

/* ---------- 2. Section headers ----------
   Navy band + red cap, white text in both themes. The legacy class
   names (section-header-reference / -treatment / -note) are kept so
   existing markup lands on-brand; the cap color still distinguishes
   them: reference = red, treatment/input = gold, note = muted red.
   Generic name for new markup: .tool-section-header (+ cap modifiers). */

.tool-section-header,
.section-header-reference,
.section-header-treatment,
.section-header-note {
    background: var(--tool-navy-band);
    border-bottom: 3px solid var(--tool-red);
    border-radius: 12px 12px 0 0;
    padding: 0.85rem 1.25rem;
    color: #fff;
}

.section-header-treatment,
.tool-cap-gold {
    border-bottom-color: var(--tool-gold);
}

.section-header-note,
.tool-cap-muted {
    border-bottom-color: rgba(146, 43, 32, 0.55);
}

.tool-cap-green {
    border-bottom-color: var(--success-soft);
}

.tool-section-header h2, .tool-section-header h3, .tool-section-header h4,
.tool-section-header h5, .tool-section-header h6,
.section-header-reference h2, .section-header-reference h3, .section-header-reference h4,
.section-header-reference h5, .section-header-reference h6,
.section-header-treatment h2, .section-header-treatment h3, .section-header-treatment h4,
.section-header-treatment h5, .section-header-treatment h6,
.section-header-note h2, .section-header-note h3, .section-header-note h4,
.section-header-note h5, .section-header-note h6 {
    color: #fff;
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.tool-section-header i,
.section-header-reference i,
.section-header-treatment i,
.section-header-note i {
    color: var(--tool-gold);
}

.tool-section-header small,
.section-header-reference small,
.section-header-treatment small,
.section-header-note small {
    color: rgba(255, 255, 255, 0.75);
}

/* ---------- 3. Buttons + forms ---------- */

/* Soft, touch-friendly sizing — but never inflate small buttons. */
.btn:not(.btn-sm):not(.btn-close) {
    min-height: 48px;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.3s ease;
}

/* Large buttons (Calculate, Reset) keep Bootstrap's 1.25rem label here
   until the Tools family moves to the shared .btn-lg size. */
.btn-lg, .btn-group-lg > .btn {
    --bs-btn-font-size: 1.25rem;
}

/* Outline buttons and .btn-check segmented toggles are themed for
   every page in /includes/styles.css (Bootstrap bridge): token labels
   and tints, the navy --selected-bg for neutral choices, status fills
   for severity choices. Only the Tools sizing above stays here. */

/* Icon buttons (.icon-btn / .modal-close in /includes/styles.css) take
   the Tools touch size at every width, like the 48px buttons above. */
.icon-btn,
.modal-close {
    --icon-btn-size: 44px;
}

/* Form controls — Tools sizing only (48px, 16px type, roomier padding).
   The well, the --border-strong frame, hover, focus ring, placeholder
   and disabled look come from the one field recipe in
   /includes/styles.css. */
.form-control, .form-select {
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 16px;
    min-height: 48px;
}

.form-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

/* Addon geometry; its surface and frame come from /includes/styles.css,
   matching the field beside it. */
.input-group-text {
    font-weight: 500;
    border-radius: 10px;
}

/* Alert geometry (colors come from /includes/styles.css tokens). */
.alert {
    border-radius: 10px;
    border: 2px solid;
    padding: 1rem 1.25rem;
}

/* ---------- 4. Results ---------- */

/* Big-number results use the shared .stat-tile (/includes/styles.css;
   section 11.6 below). */

/* Formula / calculation callout. */
.tool-formula {
    background: var(--result-blue-bg);
    border: 2px solid var(--result-blue-border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    color: var(--text-primary);
}

.tool-formula code,
.tool-formula .formula-text {
    color: var(--text-primary);
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.95rem;
}

/* JS-injected step-by-step calculation panels (shared by the
   calculator family). */
.calculation-content {
    font-family: monospace;
    font-size: 1.1rem;
    line-height: 1.8;
}

.formula-highlight {
    font-weight: bold;
    color: var(--tool-red-text);
}

.formula-result {
    font-weight: bold;
    color: var(--success-soft);
}

/* Tokened status pills for JS-injected badges. */
.tool-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}

.tool-badge-danger {
    background: color-mix(in srgb, var(--danger-soft) 15%, transparent);
    color: var(--danger-soft);
    border: 1px solid color-mix(in srgb, var(--danger-soft) 40%, transparent);
}

.tool-badge-success {
    background: color-mix(in srgb, var(--success-soft) 15%, transparent);
    color: var(--success-soft);
    border: 1px solid color-mix(in srgb, var(--success-soft) 40%, transparent);
}

.tool-badge-warning {
    background: color-mix(in srgb, var(--warning-soft) 15%, transparent);
    color: var(--warning-soft);
    border: 1px solid color-mix(in srgb, var(--warning-soft) 40%, transparent);
}

.tool-badge-neutral {
    background: var(--neutral-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
}

/* ---------- 5. Tables ---------- */

/* Brand table: navy header row, token borders. Apply to <table>. */
.table-navy {
    --bs-table-bg: transparent;
    border-color: var(--border-soft);
}

.table-navy thead th {
    background: linear-gradient(135deg, var(--tool-navy) 0%, var(--tool-navy-soft) 100%);
    color: #fff !important;
    border-color: var(--tool-navy-soft);
    font-weight: 600;
    letter-spacing: 0.03em;
}

/* ---------- 6. Bootstrap modal brand header ----------
   Replaces .modal-header.bg-primary/.bg-info/etc on tool modals. */
.modal-header-brand {
    background: var(--tool-navy-band);
    border-bottom: 3px solid var(--tool-red);
    color: #fff;
    /* Follow the modal panel's inner corner (16px panel minus its
       border, from the Bootstrap bridge in /includes/styles.css). */
    border-radius: var(--bs-modal-inner-border-radius, 12px) var(--bs-modal-inner-border-radius, 12px) 0 0;
}

.modal-header-brand .modal-title,
.modal-header-brand h1, .modal-header-brand h2, .modal-header-brand h3,
.modal-header-brand h4, .modal-header-brand h5, .modal-header-brand h6,
.modal-header-brand i {
    color: #fff;
}

.modal-header-brand .btn-close {
    filter: invert(1) grayscale(100%) brightness(180%);
}

/* ---------- 7. Checklist family ----------
   Class names preserved from the old checklist-tool.css so every
   checklist page (bvm, igel, needlecric, pacing, surgcric, and the
   intubation/rsi forks) restyles without markup changes. Geometry is
   intentionally unchanged; only surfaces/colors moved onto tokens. */

.intubation-tool-container * {
    box-sizing: border-box;
}

.intubation-tool-container {
    max-width: 800px;
    margin: 0 auto 3rem;
    overflow: hidden;
    padding-bottom: 20px;
    font-size: 16px;
}

.checklist-section {
    background-color: var(--card-bg);
    border-radius: 10px;
    margin: 15px;
    box-shadow: 0 4px 14px rgba(40, 50, 75, 0.06), 0 1px 3px rgba(40, 50, 75, 0.04);
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
    border: 1px solid var(--border-medium);
}

[data-theme="dark"] .checklist-section {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.checklist-section:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px var(--shadow-medium);
}

.checklist-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 13px 16px;
    background: var(--tool-navy-band);
    border-bottom: 3px solid var(--tool-red);
}

.section-title {
    display: flex;
    align-items: center;
}

.section-title i {
    color: var(--tool-gold);
    font-size: 20px;
    margin-right: 10px;
}

.section-title h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
}

.section-status {
    background-color: rgba(255, 255, 255, 0.14);
    color: #fff;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

/* Completed section: the red cap turns green. */
.checklist-section.completed {
    border-color: var(--success-soft);
}

.checklist-section.completed .section-header {
    border-bottom-color: var(--success-soft);
}

.checklist-items {
    padding: 5px 0;
}

.checklist-item {
    display: flex;
    flex-direction: column;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-soft);
    transition: background-color 0.2s;
    position: relative;
}

.checklist-item:nth-child(even) {
    background-color: var(--neutral-bg);
}

.checklist-item:last-child {
    border-bottom: none;
}

.checklist-item:hover {
    background-color: var(--hover-bg);
}

.checklist-item.checked {
    background-color: color-mix(in srgb, var(--success-soft) 8%, transparent);
    border-left: 4px solid var(--success-soft);
}

.checklist-item-row {
    display: flex;
    width: 100%;
    align-items: flex-start;
}

/* Custom checkboxes — checked state is brand red. */
.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 45px;
    margin-bottom: 0;
    cursor: pointer;
    font-size: 16px;
    user-select: none;
    flex: 1;
    min-height: 30px;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkbox-label {
    padding: 4px 0;
    font-weight: 700;
    font-size: 22px;
    color: var(--text-primary);
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 30px;
    width: 30px;
    background-color: var(--input-bg);
    border: 2px solid var(--border-medium);
    border-radius: 4px;
    transition: all 0.2s;
}

.checkbox-container:hover input ~ .checkmark {
    background-color: color-mix(in srgb, var(--tool-red) 10%, var(--input-bg));
    border-color: var(--tool-red);
    transform: scale(1.05);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--tool-red-fill, #c0392b);
    border-color: var(--tool-red-fill, #c0392b);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 11px;
    top: 6px;
    width: 8px;
    height: 16px;
    border: solid white;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
}

/* Step detail text under each checkbox. */
.info-content {
    margin-top: 3px;
    padding: 0px 12px 5px 0;
    background-color: transparent;
    font-size: 13px;
    line-height: 1.3;
    color: var(--text-secondary);
    margin-left: 45px;
    font-weight: 400;
}

.info-content.always-visible {
    display: block !important;
}

.info-content p {
    margin: 0;
    color: var(--text-secondary);
}

.info-content ul {
    margin-top: 2px;
    margin-bottom: 2px;
    padding-left: 20px;
}

.info-content ul li {
    color: var(--text-primary);
    font-size: 17px;
    margin-bottom: 3px;
    line-height: 1.3;
    font-weight: 500;
}

.info-content strong {
    color: var(--tool-red-text);
    font-weight: 700;
}

.info-content b {
    color: var(--text-primary);
    font-weight: 700;
}

/* ---------- 8. Checklist modals + narrative components ----------
   The hand-rolled .tool-modal dialogs (NOT Bootstrap modals) and the
   narrative-generator form bits every checklist tool duplicates. */

.tool-modal {
    display: none;
    position: fixed;
    z-index: 1050;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(2, 6, 14, 0.6);
    animation: toolModalFade 0.3s;
}

@keyframes toolModalFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tool-modal .modal-content {
    position: relative;
    background-color: var(--card-bg);
    color: var(--text-primary);
    margin: 10vh auto;
    padding: 0;
    border: 1px solid var(--border-soft);
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.3);
    animation: toolModalSlide 0.3s;
}

[data-theme="dark"] .tool-modal .modal-content {
    box-shadow: 0 12px 44px rgba(0, 0, 0, 0.6);
}

@keyframes toolModalSlide {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.tool-modal .large-modal {
    max-width: 700px;
}

.tool-modal .modal-header {
    padding: 15px 20px;
    background: var(--tool-navy-band);
    color: #fff;
    border-bottom: 3px solid var(--tool-red);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tool-modal .modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
}

.tool-modal .close-modal {
    color: #fff;
    background: none;
    border: none;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    opacity: 0.75;
    transition: opacity 0.2s;
}

.tool-modal .close-modal:hover {
    opacity: 1;
}

.tool-modal .modal-body {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.tool-modal .modal-footer {
    padding: 15px 20px;
    background-color: var(--neutral-bg);
    text-align: right;
    border-top: 1px solid var(--border-soft);
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.tool-modal .session-buttons {
    justify-content: space-between;
}

/* Narrative form bits. */
.narrative-form {
    max-width: 100%;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px 15px;
}

.form-row .form-group {
    flex: 1;
    padding: 0 10px;
    min-width: 180px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Narrative fields keep their compact 1px geometry but use the site
   field colours: the --border-strong frame (3:1) and the focus ring. */
.form-input {
    padding: 10px;
    border: 1px solid var(--border-strong, #7D8DA6);
    border-radius: 8px;
    width: 100%;
    font-size: 16px;
    background-color: var(--input-bg);
    color: var(--text-primary);
}

.form-input:focus {
    border-color: var(--focus-color, #2F5F94);
    outline: none;
    box-shadow: var(--focus-ring, 0 0 0 2px #fff, 0 0 0 4px #2F5F94);
}

/* Inside tool modals, selects and input-group seams match .form-input
   geometry (the big Bootstrap-flavored sizing above is for page forms). */
.tool-modal .form-select,
.narrative-form .form-select {
    padding: 10px;
    border: 1px solid var(--border-strong, #7D8DA6);
    border-radius: 8px;
    min-height: 0;
    font-size: 16px;
}

.tool-modal .input-group {
    display: flex;
    align-items: stretch;
}

.tool-modal .input-group .form-input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    flex: 1;
}

.tool-modal .input-group .input-group-text {
    border: 1px solid var(--border-strong, #7D8DA6);
    border-left: 0;
    border-radius: 0 8px 8px 0;
    padding: 10px;
    background-color: var(--neutral-bg);
    color: var(--text-secondary);
}

/* JS-injected read-only values in narrative forms. */
.form-control-static {
    padding: 10px 0;
    font-weight: 600;
    color: var(--text-primary);
}

.form-section {
    margin-top: 20px;
    margin-bottom: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-soft);
}

.form-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 18px;
    color: var(--text-primary);
}

.comp-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.comp-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-bottom: 10px;
    padding: 10px 15px;
    background-color: var(--neutral-bg);
    border-radius: 6px;
    transition: all 0.2s;
    border: 1px solid var(--border-soft);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.comp-checkbox:hover {
    background-color: var(--hover-bg);
    border-color: var(--primary-soft);
}

.comp-checkbox input[type="checkbox"] {
    margin-right: 12px;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.comp-checkbox span {
    font-size: 15px;
    padding: 2px 0;
    color: var(--text-primary);
}

.comp-checkbox.complication-check-label {
    opacity: 0.5;
    pointer-events: none;
}

.comp-checkbox.complication-check-label.enabled {
    opacity: 1;
    pointer-events: auto;
}

.narrative-box {
    background-color: var(--neutral-bg);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 15px;
    font-size: 16px;
    line-height: 1.6;
    white-space: pre-wrap;
    color: var(--text-primary);
}

/* ---------- 9. Action bars ---------- */

.tool-actions {
    padding: 15px;
    text-align: center;
}

.action-warning {
    background: var(--result-orange-bg);
    border: 1px solid var(--result-orange-border);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 15px;
    font-size: 14px;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.action-button {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: #fff;
    /* Default chrome so a modifier-less .action-button is never
       white-on-buttonface. */
    background-color: #52627a;
}

.action-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px var(--shadow-medium);
}

.action-button i {
    margin-right: 6px;
}

.reset-button,
.close-button {
    background-color: #52627a;
}

.reset-button:hover,
.close-button:hover {
    background-color: #42526a;
}

/* White label: use the success fill (passes in both themes), not -soft. */
.generate-button,
.save-button {
    background-color: var(--success-fill, #1E7345);
}

.generate-button:hover,
.save-button:hover {
    background-color: color-mix(in srgb, var(--success-fill, #1E7345) 85%, #000);
}

.pdf-button {
    background-color: var(--tool-red-fill, #c0392b);
}

.pdf-button:hover {
    background-color: #a93226;
}

.primary-button {
    background-color: var(--tool-navy-soft);
}

.primary-button:hover {
    background-color: #2c4f7c;
}

/* ---------- 10. Responsive + print ---------- */

@media (max-width: 768px) {
    .tool-page-title {
        font-size: 1.5rem;
    }

    .tool-page-title i {
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
    }

    .form-row {
        flex-direction: column;
    }

    .action-buttons {
        flex-direction: column;
    }

    .tool-modal .modal-content {
        width: 95%;
        margin: 10px auto;
    }

    .checklist-item {
        padding: 15px;
    }
}

/* Touch targets. */
@media (max-width: 992px) {
    .checkbox-container {
        padding-left: 50px;
    }

    .checkmark {
        width: 32px;
        height: 32px;
    }

    .checkbox-container .checkmark:after {
        left: 12px;
        top: 6px;
        width: 8px;
        height: 16px;
    }

    .action-button {
        padding: 12px 20px;
        font-size: 16px;
    }
}

/* Reduced motion: no hover lifts or checkbox pop (the site-wide list
   is in /includes/styles.css). */
@media (prefers-reduced-motion: reduce) {
    .checklist-section:hover,
    .action-button:hover,
    .checkbox-container:hover input ~ .checkmark {
        transform: none;
    }
}

/* Print: always paper-white, chrome hidden, checkboxes outlined.
   Works from EITHER theme: tokens are re-declared to their light
   values so dark-mode Ctrl+P never emits near-white text or dark
   surfaces. */
@media print {
    @page {
        size: letter portrait;
        margin: 0.5cm;
    }

    :root,
    [data-theme="dark"] {
        --text-primary: #0E1620;
        --text-secondary: #344256;
        --text-muted: #56657C;
        --card-bg: #fff;
        --container-bg: #fff;
        --neutral-bg: #F5F7FA;
        --neutral-light: #FAFBFC;
        --input-bg: #fff;
        --hover-bg: #fff;
        --border-soft: #D4E1EC;
        --border-medium: #B8CDE0;
        --border-strong: #7D8DA6;
        --surface-2: #F1F4F8;
        --primary-text: #2F5F94;
        --success-text: #1E7345;
        --warning-text: #9A4A07;
        --danger-text: #B03A2E;
        --info-text: #2E5C8A;
        --success-soft: #1E7345;
        --warning-soft: #9A4A07;
        --danger-soft: #B03A2E;
        --info-soft: #2E5C8A;
        --result-blue-bg: #E6EBF1;
        --result-blue-border: #B6C6D6;
        --result-orange-bg: #F3E9E1;
        --result-orange-border: #DCC0A8;
        --alert-bg: #F6E7E6;
        --alert-border: #E3BAB6;
        --alert-text: #721c24;
        --tool-red-text: #a93226;
        --shadow-soft: rgba(0, 0, 0, 0);
        --shadow-medium: rgba(0, 0, 0, 0);
    }

    body {
        font-size: 12pt;
        line-height: 1.3;
        background: #fff !important;
        color: #000 !important;
    }

    .navbar, .app-tool-bar, .breadcrumb-nav, .back-to-top, .site-footer,
    .tool-actions, .tool-modal, .theme-toggle, .btn,
    .edit-selection-btn, .toggle-info-btn {
        display: none !important;
    }

    /* Opt-out of the button hide (e.g. selected answers a report needs). */
    .btn.print-keep,
    .action-button.print-keep {
        display: inline-flex !important;
    }

    /* Navy chrome flattens to paper — background-image gradients do not
       yield to background-color overrides, so clear them here once. */
    .tool-section-header,
    .section-header-reference,
    .section-header-treatment,
    .section-header-note,
    .modal-header-brand {
        background: #f0f4f8 !important;
        border-bottom-color: #1e3a5f !important;
        color: #000 !important;
    }

    .tool-section-header h1, .tool-section-header h2, .tool-section-header h3,
    .tool-section-header h4, .tool-section-header h5, .tool-section-header h6,
    .tool-section-header i, .tool-section-header small,
    .section-header-reference h2, .section-header-reference h3,
    .section-header-reference h4, .section-header-reference h5,
    .section-header-reference h6, .section-header-reference i,
    .section-header-treatment h2, .section-header-treatment h3,
    .section-header-treatment h4, .section-header-treatment h5,
    .section-header-treatment h6, .section-header-treatment i,
    .section-header-note h2, .section-header-note h3, .section-header-note h4,
    .section-header-note h5, .section-header-note h6, .section-header-note i {
        color: #000 !important;
    }

    .table-navy thead th {
        background: #f0f4f8 !important;
        color: #000 !important;
        border-color: #B8CDE0 !important;
    }

    .tool-formula {
        background: #fff !important;
        border-color: #B8CDE0 !important;
        box-shadow: none !important;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .intubation-tool-container {
        max-width: 100%;
        margin: 0;
        padding: 0;
    }

    .checklist-section {
        page-break-inside: avoid;
        break-inside: avoid;
        margin: 10px 0 !important;
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        border-left: 3px solid #1e3a5f !important;
        border-radius: 0 !important;
        transform: none !important;
        background: #fff !important;
    }

    .checklist-section .section-header {
        background: #f0f4f8 !important;
        border-bottom: 2px solid #1e3a5f !important;
        padding: 8px 10px !important;
    }

    .section-title h2 {
        color: #000 !important;
    }

    .section-title i {
        color: #8b1a10 !important;
    }

    .section-status {
        background: #eee !important;
        color: #333 !important;
    }

    .checklist-item,
    .checklist-item:nth-child(even) {
        background: #fff !important;
    }

    .checkbox-label,
    .info-content,
    .info-content p,
    .info-content ul li {
        color: #000 !important;
    }

    .info-content {
        background-color: transparent !important;
        padding: 5px 10px !important;
    }

    .info-content strong {
        color: #8b1a10 !important;
    }

    .checkbox-container {
        padding-left: 25px !important;
    }

    .checkmark {
        border: 1px solid #000 !important;
        width: 16px !important;
        height: 16px !important;
        background-color: white !important;
    }

    .checkbox-container input:checked ~ .checkmark {
        background-color: white !important;
        border: 1px solid #000 !important;
    }

    .checkbox-container .checkmark:after {
        left: 5px !important;
        top: 2px !important;
        width: 3px !important;
        height: 8px !important;
        border-color: #000 !important;
    }
}

/* ---------- 11. Converted tool pages (body.fl-v2) ----------
   Phase 11 moves the tools onto the shared components a batch at a
   time. A converted page links this sheet through includes/head.php,
   puts class="fl-v2" on <body>, opens with tool_header() (from
   tool-registry.php) and uses the shared classes in
   /includes/styles.css. Every rule below either targets a class that
   only converted markup emits, or sits under :where(.fl-v2), which
   adds no weight: such a rule keeps the specificity of the legacy rule
   it overrides and wins by source order. A tool that has not converted
   yet (no fl-v2, none of the new classes) renders exactly as before.
   Once every tool has converted, fold these rules into the sections
   above and delete what they override. */

/* 11.1 Page heading (tool_header): h1.tool-page-title holds a 52px
   navy .icon-tile--brand with the registry icon, then the registry
   title at the page-title size; the .page-back link follows it. The
   legacy '.tool-page-title i' tile (section 1) is undone on the glyph
   inside the new tile. The red-tinted rule under the title stays. */
:where(.fl-v2) .tool-page-title {
    font-size: var(--fs-page-title);
    line-height: 1.15;
    margin-bottom: 1rem;
}

.tool-page-title > .icon-tile {
    width: 3.25rem;
    height: 3.25rem;
    font-size: 1.6rem;
    box-shadow: 0 2px 8px rgba(12, 25, 41, 0.35);
}

.tool-page-title > .icon-tile > i {
    display: inline;
    width: auto;
    height: auto;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    color: inherit;
    font-size: 1em;
}

.tool-page-title-text {
    min-width: 0;
    overflow-wrap: break-word;
}

/* The back link sits right under the title, so it drops the phone
   gap the shared rule adds under a hero band. */
.tool-page-title + .page-back {
    margin-top: 0;
}

/* 11.2 Disclaimer (.alert.alert-warning.tool-disclaimer, under the
   back link): alerts on converted pages take the shared 12px corner. */
:where(.fl-v2) .alert {
    border-radius: var(--r-md);
}

/* 11.3 Controls keep the Tools 48px height and 1.25rem .btn-lg label
   (sections 3 and the owner decision), on the shared corners: 8px
   buttons and fields, 12px .btn-lg. */
:where(.fl-v2) .btn:not(.btn-sm):not(.btn-close) {
    border-radius: var(--bs-btn-border-radius);
}

:where(.fl-v2) .form-control,
:where(.fl-v2) .form-select,
:where(.fl-v2) .input-group-text {
    border-radius: var(--r-sm);
}

:where(.fl-v2) .form-control,
:where(.fl-v2) .form-select {
    min-height: var(--control-h-lg);
}

/* Selects keep room for Bootstrap's chevron: the Tools side padding
   (16px; 10px in checklist dialogs) let a long option run under it. */
:where(.fl-v2) .form-select {
    padding-right: 2.5rem;
}

:where(.fl-v2) .tool-modal .form-select,
:where(.fl-v2) .narrative-form .form-select {
    padding-right: 2.25rem;
}

/* A native time picker's clock icon needs the room in a half-width
   phone column ('09:08 PM' was cut at the 16px side padding). */
:where(.fl-v2) .form-control[type="time"] {
    padding-inline: 0.5rem;
}

/* 11.4 Section card: a Bootstrap .card (bridged in styles.css, no
   hover lift) opened by a .card-header.fl-band holding an h2. Caps
   carry meaning: default red = reference (and results), .is-cap-gold
   = input or treatment, .is-cap-success = complete, .is-cap-muted =
   note. Band actions (info buttons) are .icon-btn.icon-btn--chrome in
   .fl-band-actions; they reach into the band's padding so a 44px
   target does not thicken the band. */
.fl-band .icon-btn {
    margin-block: -0.6rem;
}

.fl-band-actions:last-child {
    margin-right: -0.5rem;
}

/* A heading a script focuses (tabindex="-1": the results or form band
   title after Calculate / New calculation, a wizard step title) is a
   reading position, not a control: no ring, like the site's other
   tabindex="-1" targets (the global focus ring skips them; this stops
   the browser's own ring after a keyboard activation). */
:where(.fl-v2) :is(h1, h2, h3, h4, h5, h6)[tabindex="-1"]:focus {
    outline: none;
}

/* 11.5 Choices: .btn-check radios + label.btn.btn-outline-secondary
   (a neutral choice) or a status outline (a choice that carries a
   meaning), grouped by a fieldset/legend or a role="radiogroup" named
   by its band title. Checked labels take the shared selected paint
   (styles.css: the navy --selected-bg, or the status fill); .has-check
   on the group adds the ti-check glyph. .tool-choice is a stacked
   label (a score over its caption) filling its grid cell; its check
   sits in the top corner instead of above the score. An unselected
   neutral choice is framed in --border-strong (3:1 or better on the
   card in both themes; the shared outline frame is decorative). */
:where(.fl-v2) .btn-check + .btn-outline-secondary,
:where(.fl-v2) .btn-outline-secondary[aria-pressed] {
    --bs-btn-border-width: 1.5px;
    --bs-btn-border-color: var(--border-strong);
    --bs-btn-disabled-border-color: var(--border-strong);
}

/* Dark: the navy selected fill sits about 1.2:1 from the dark card and
   its --brand-navy-3 frame about 1.5:1, so a picked neutral choice
   (a .btn-check label or an aria-pressed toggle) would lose its frame
   while the unpicked ones keep theirs. It keeps a light frame instead
   (--primary-text: 8.2:1 on the card, 7.0:1 on the fill); the gold
   ring of an alternate mode keeps its gold. */
[data-theme="dark"] :where(.fl-v2) :is(.btn-check:checked + .btn-outline-secondary, .btn-outline-secondary.is-selected, .btn-outline-secondary[aria-pressed="true"]):not(.is-gold-ring) {
    --bs-btn-active-border-color: var(--primary-text);
}

.btn-check + .btn.tool-choice {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    width: 100%;
    height: 100%;
    min-height: 4.5rem;
    padding: 0.75rem 0.5rem;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
}

.tool-choice-value {
    font-size: 1.25rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.tool-choice-label {
    font-size: var(--fs-body-sm);
    font-weight: 600;
}

.has-check .btn-check:checked + .btn.tool-choice::before,
.btn-check:checked + .btn.tool-choice.has-check::before {
    position: absolute;
    top: 0.4rem;
    right: 0.5rem;
    font-size: 1rem;
}

/* 11.6 Results: a role="status" region of .stat-tile readouts
   (.stat-tile--lg for the one primary result, .stat-strip for a row).
   Severity is a solid status pill (.status-pill.is-solid + a tone,
   icon plus word); .tool-severity is its result-size variant. */
/* The unit after a value inside .stat-value
   (<span class="stat-unit">mL/hour</span>): smaller, lighter and in the
   reader's case (the uppercase .stat-label under it is the name). */
:where(.fl-v2) .stat-unit {
    font-size: 0.5em;
    font-weight: 700;
    letter-spacing: 0;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Tiles in a strip stretch to one height; figure and label sit on the
   bottom edge, so the labels line up when the figures differ in size
   (a .stat-tile--lg beside a plain tile). */
:where(.fl-v2) .stat-strip > .stat-tile {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.status-pill.tool-severity {
    gap: 0.4rem;
    padding: 0.35rem 0.85rem;
    font-size: var(--fs-body);
}

/* 11.7 Formulas and worked steps: a .callout.is-info (styles.css)
   holding .calculation-content or <code>, in the site mono stack. */
:where(.fl-v2) .calculation-content,
:where(.fl-v2) .tool-formula code,
:where(.fl-v2) .tool-formula .formula-text {
    font-family: var(--font-mono);
}

/* A formula in a callout (4-2-1, O2, the Winter's and Altitude
   reference formulas) reads at body size, so a rule fits on one phone
   line. A script's worked steps (.calculation-steps: Winter's,
   Altitude) keep section 4's 1.1rem/1.8 and step down on phones, so
   their long lines wrap less. */
:where(.fl-v2) .callout .calculation-content:not(.calculation-steps) {
    font-size: 0.95rem;
    line-height: 1.5;
}

@media (max-width: 768px) {
    :where(.fl-v2) .calculation-steps {
        font-size: 0.9rem;
    }
}

/* Worked-step titles (.formula-highlight) and results (.formula-result)
   stay bold in the callout's text colour (section 4 paints them red
   and green, and green on an abnormal value such as a PaCO2 gap would
   read as 'normal'). */
:where(.fl-v2) .calculation-content :is(.formula-highlight, .formula-result) {
    color: inherit;
}

/* 11.8 Reference tables: .table.table-navy inside
   <div class="table-scroll" tabindex="0" role="region" aria-label="...">,
   which scrolls sideways at every width instead of squeezing columns. */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.table-scroll > .table {
    margin-bottom: 0;
}

/* The navy head is one gradient across the row (each cell painted its
   own, so a narrow '#' or 'NM' cell showed mostly the dark start). */
:where(.fl-v2) .table-navy thead tr {
    background: linear-gradient(135deg, var(--tool-navy) 0%, var(--tool-navy-soft) 100%);
}

:where(.fl-v2) .table-navy thead th {
    background: transparent;
}

/* Dark: Bootstrap's tinted rows (.table-danger, .table-warning, ...)
   keep their LIGHT striped, hover and active paints, so a striped or
   hoverable table turned a tinted row pink. On dark they keep the
   status tint (styles.css) with the page text. */
[data-theme="dark"] :where(.fl-v2) :is(.table-primary, .table-info, .table-success, .table-warning, .table-danger) {
    --bs-table-striped-bg: rgba(255, 255, 255, 0.04);
    --bs-table-striped-color: var(--text-primary);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.08);
    --bs-table-hover-color: var(--text-primary);
    --bs-table-active-bg: rgba(255, 255, 255, 0.08);
    --bs-table-active-color: var(--text-primary);
}

/* 11.9 Modals. A Bootstrap .modal whose .modal-header is also an
   .fl-band, with a .modal-close (ti-x, aria-label="Close"; white on
   the band from styles.css); the band follows the panel's inner
   corner. The hand-rolled .tool-modal takes the same close button and
   the shared 16px panel. Modal titles keep a sentence-case title type
   on the band rather than the uppercase section label. */
.modal-header.fl-band {
    border-radius: var(--bs-modal-inner-border-radius) var(--bs-modal-inner-border-radius) 0 0;
}

.fl-band > .modal-title {
    font-size: var(--fs-band-title);
    font-weight: 700;
    letter-spacing: normal;
    text-transform: none;
}

:where(.fl-v2) .tool-modal .modal-content {
    border-radius: var(--r-lg);
}

:where(.fl-v2) .tool-modal .modal-header {
    border-top-left-radius: calc(var(--r-lg) - 1px);
    border-top-right-radius: calc(var(--r-lg) - 1px);
}

:where(.fl-v2) .tool-modal .modal-footer {
    border-bottom-left-radius: calc(var(--r-lg) - 1px);
    border-bottom-right-radius: calc(var(--r-lg) - 1px);
}

:where(.fl-v2) .tool-modal .modal-header h2 {
    font-size: var(--fs-band-title);
    font-weight: 700;
}

/* 11.10 Skill-checklist tools (bvm, igel, intubation, needlecric,
   pacing, rsi, surgcric): the 800px .intubation-tool-container now
   holds the H1, back link and disclaimer as well as the sections.
   Sections lose the hover lift and 15px side margins and take the
   section-card corner, frame and elevation; the head is a band (label
   type, the success cap when complete); type moves from px to rem
   (the same sizes at the default 16px root, but they now follow the
   reader's font size). The PDF export (html2pdf) captures the
   container: tool_header($key, ['pdf_ignore' => true]) and
   data-html2canvas-ignore="true" on the disclaimer keep the title,
   back link and disclaimer out of it, as before (11.15 hides them in
   html2pdf's own copy too). The column no longer clips: the back
   link's focus ring and the title tile's shadow sit on its left edge,
   and flow-root keeps the block formatting context overflow:hidden
   gave it, so no margin moves. */
:where(.fl-v2) .intubation-tool-container {
    display: flow-root;
    overflow: visible;
    margin: 0 auto;
    padding-bottom: 0;
    font-size: 1rem;
}

:where(.fl-v2) .checklist-section {
    margin: 0 0 1.5rem;
    border-width: 1.5px;
    border-radius: var(--r-lg);
    box-shadow: var(--elev-1);
    transition: none;
}

:where(.fl-v2) .checklist-section:hover {
    transform: none;
    box-shadow: var(--elev-1);
}

:where(.fl-v2) .checklist-section .section-header {
    padding: 0.85rem 1.1rem;
}

/* A finished section's cap is a rule, not a text fill: --success-text
   (light #1E7345, dark #81C995) reads 7.7:1 on the navy band in dark,
   where --success-fill was 2.6:1, and matches the section frame. */
:where(.fl-v2) .checklist-section.completed .section-header {
    border-bottom-color: var(--success-text);
}

/* The global 'body .section-title' heading size (styles.css type
   scale) also matches this wrapper div; the h2 inside sets the type. */
:where(.fl-v2) .checklist-section .section-title {
    font-size: inherit;
    line-height: 1.3;
}

:where(.fl-v2) .section-title h2 {
    font-size: var(--fs-band-label);
    font-weight: 800;
    letter-spacing: 0.06em;
}

:where(.fl-v2) .section-title i {
    font-size: 1.25rem;
    margin-right: 0.6rem;
}

:where(.fl-v2) .section-status {
    font-size: 0.8125rem;
}

:where(.fl-v2) .checkbox-container {
    font-size: 1rem;
}

:where(.fl-v2) .checkbox-label {
    font-size: 1.375rem;
}

:where(.fl-v2) .info-content {
    font-size: 0.8125rem;
}

:where(.fl-v2) .info-content ul li {
    font-size: 1.0625rem;
}

:where(.fl-v2) .form-section h3 {
    font-size: 1.125rem;
}

:where(.fl-v2) .comp-checkbox span {
    font-size: 0.9375rem;
}

:where(.fl-v2) .form-input,
:where(.fl-v2) .narrative-box,
:where(.fl-v2) .tool-modal .form-select,
:where(.fl-v2) .narrative-form .form-select {
    font-size: 1rem;
}

:where(.fl-v2) .action-warning {
    font-size: 0.875rem;
}

:where(.fl-v2) .action-button {
    font-size: 0.9375rem;
}

@media (max-width: 992px) {
    :where(.fl-v2) .action-button {
        font-size: 1rem;
    }
}

/* The step box is the only cue that a step is a control: its empty
   frame takes --border-strong (3:1 or better on both row tints, both
   themes; --border-medium was 1.5-1.8:1). The hover and checked rules
   are more specific and keep their red; print keeps its own frame. */
:where(.fl-v2) .checkmark {
    border-color: var(--border-strong);
}

/* The checkbox itself is a 0x0, opacity-0 input, so keyboard focus
   rings the visible box. */
:where(.fl-v2) .checkbox-container input:focus-visible ~ .checkmark {
    outline: var(--focus-outline);
    outline-offset: var(--focus-offset);
}

/* Complications stay dimmed until 'No complications' is cleared, but
   they are still operable (not disabled), so the text keeps 4.5:1
   (0.5 measured 3.4:1 in light). */
:where(.fl-v2) .comp-checkbox.complication-check-label {
    opacity: 0.7;
}

/* The action area lines up with the full-width sections. */
:where(.fl-v2) .tool-actions {
    padding-inline: 0;
}

/* 11.11 Actions: .form-actions (styles.css), right-aligned:
   [Print .pill-btn] [.btn-secondary Reset] [.btn-primary Calculate].
   In Tools the row centres the pill against the 48px buttons; on small
   phones it stacks full width with the main action on top, like the
   shared modal action bar. */
.form-actions {
    align-items: center;
}

@media (max-width: 480px) {
    .form-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .form-actions > .pill-btn {
        justify-content: center;
    }
}

/* 11.12 Phones: the title tile steps down with the title. */
@media (max-width: 768px) {
    .tool-page-title > .icon-tile {
        width: 2.75rem;
        height: 2.75rem;
        font-size: 1.3rem;
    }
}

/* 11.13 Print: bands flatten to paper like the legacy headers, and the
   page-level controls (back link, pills, band buttons, action rows)
   drop out. Same approach as section 10. */
@media print {
    .fl-band {
        background: #f0f4f8 !important;
        border-bottom-color: #1e3a5f !important;
        color: #000 !important;
    }

    .fl-band :is(h1, h2, h3, h4, h5, h6, i, .fl-band-title) {
        color: #000 !important;
    }

    .fl-band .icon-btn,
    .pill-btn,
    .form-actions {
        display: none !important;
    }

    .stat-tile {
        background: #fff !important;
        border-color: #B8CDE0 !important;
    }

    /* Scroll regions print whole instead of clipping a wide table. */
    .table-scroll {
        overflow: visible;
    }
}

/* 11.14 Checklist selections (intubation, rsi, igel). The chip a step
   fills after a picker dialog and its Edit button
   (.btn.btn-outline-secondary.btn-sm) share one .selection-row under
   the step text; the picker options are .choice-tile tiles
   (styles.css) stacked vertically, the check in the top corner. The
   tool sheets keep only what is theirs (rsi: the meds list; igel: the
   size details). */
:where(.fl-v2) .selection-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 0.5rem;
    margin-left: 45px;
}

:where(.fl-v2) .info-content .selection-row {
    margin-left: 0;
}

:where(.fl-v2) .selection-row > * {
    margin-top: 0.5rem;
}

:where(.fl-v2) :is(.selected-meds-display, .selected-grade-display) {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border-soft);
    border-radius: var(--r-sm);
    background-color: var(--surface-2);
    color: var(--text-primary);
    font-size: 0.875rem;
}

/* intubation, rsi: the chip itself is the role="status" region and the
   script toggles .active. Empty, it stays rendered with no box: a live
   region that is display:none when it fills is not reliably read out. */
:where(.fl-v2) :is(.selected-meds-display, .selected-grade-display)[role="status"]:not(.active) {
    margin: 0;
    padding: 0;
    border: 0;
}

/* igel: the script shows and hides the chip with an inline display,
   inside an always-rendered .selection-status (role="status") wrapper
   that adds no box. */
:where(.fl-v2) .selection-row > .selection-status {
    margin-top: 0;
}

:where(.fl-v2) .selection-status > .selected-grade-display {
    display: none;
    margin-top: 0.5rem;
}

:where(.fl-v2) :is(.selected-med-item, .selected-grade-item) {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
}

:where(.fl-v2) :is(.selected-med-item, .selected-grade-item) i {
    color: var(--primary-text);
    font-size: 1rem;
}

:where(.fl-v2) :is(.grade-options, .size-options) {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
    gap: 0.75rem;
}

:where(.fl-v2) :is(.grade-option, .size-option).choice-tile {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.9rem;
}

:where(.fl-v2) :is(.grade-option, .size-option, .medication-option).choice-tile::after {
    position: absolute;
    top: 0.6rem;
    right: 0.75rem;
}

:where(.fl-v2) :is(.grade-label, .size-label) {
    position: absolute;
    inset: 0;
    margin: 0;
    cursor: pointer;
}

/* 11.15 Checklist 'Export as PDF' (html2pdf 0.10.1 + html2canvas 1.x).
   The export captures .intubation-tool-container. html2pdf lays out
   its own copy (inside .html2pdf__container) to place the page breaks;
   html2canvas then draws that copy WITHOUT the [data-html2canvas-ignore]
   title, back link and disclaimer. Dropping them from the copy keeps
   both on one layout (otherwise every break is measured ~245px off and
   sections split across pages). Sections take back the 15px inset the
   PDF has always had: html2canvas draws a few px right of its frame,
   so a flush section loses its right border. */
:where(.fl-v2) .html2pdf__container [data-html2canvas-ignore] {
    display: none;
}

:where(.fl-v2) .html2pdf__container .checklist-section {
    margin: 15px 15px 20px;
}

/* Plain colours only in the copy. html2canvas 1.x parses hex, rgb(a),
   hsl(a) and named colours; a color-mix() value computes to
   color(srgb ...) and the export fails ('Error creating PDF'). It reads
   every element of the copy, hidden ones included (the script hides the
   action bar, whose .action-warning uses the warning tint). The copy is
   always the light theme (each checklist forces it for the export).
   The ticked row's tint is a color-mix() in its own rule: the copy gets
   the same tint as plain rgba (the light --success-text #1E7345 at 8%). */
:where(.fl-v2) .html2pdf__container .checklist-item.checked {
    background-color: rgba(30, 115, 69, 0.08);
}

/* The color-mix() tint and border tokens take their solid light values
   in the copy: the same values styles.css keeps for engines without
   color-mix(). The :root names built on them are declared again so they
   pick the solid values up (a custom property keeps the value it got
   where it was declared). */
:where(.fl-v2) .html2pdf__container {
    --neutral-tint: #ECECED;
    --primary-tint: #E6ECF2;
    --success-tint: #E4EEE9;
    --success-border: #B0CEBE;
    --warning-tint: #F3E9E1;
    --warning-border: #DCC0A8;
    --danger-tint: #F6E7E6;
    --danger-border: #E3BAB6;
    --info-tint: #E6EBF1;
    --info-border: #B6C6D6;
    --ce-tint: #FAF4ED;
    --alert-bg: var(--danger-tint);
    --alert-border: var(--danger-border);
    --result-blue-bg: var(--info-tint);
    --result-blue-border: var(--info-border);
    --result-orange-bg: var(--warning-tint);
    --result-orange-border: var(--warning-border);
}

/* No transition or animation runs in the copy. html2canvas draws it in
   its own frame, where the stylesheets load again, so a transition
   (the tick box, the row tint, the Edit buttons) replays from its
   unstyled start and is drawn part-way: ticks came out only some of the
   time, and a part-way colour can compute to oklab(), which html2canvas
   cannot parse either. An animation settles at once. */
:where(.fl-v2) .html2pdf__container,
:where(.fl-v2) .html2pdf__container *,
:where(.fl-v2) .html2pdf__container *::before,
:where(.fl-v2) .html2pdf__container *::after {
    transition: none !important;
    animation-duration: 0s !important;
    animation-delay: 0s !important;
}

/* The frame each tool's script puts on the captured sections (one of
   three class hooks; the theme is forced light during the capture, and
   the navy token is theme-stable). needlecric and surgcric also mark
   the section heads. */
:where(.fl-v2) :is(.intubation-tool-container.pdf-capture .checklist-section, .checklist-section.pdf-capture, .pdf-capture-section) {
    border: 2px solid var(--tool-navy-soft);
    border-radius: var(--r-lg);
    overflow: hidden;
}

:where(.fl-v2) .section-header.pdf-capture-header {
    border-bottom: 1px solid var(--tool-navy-soft);
}

/* 11.16 Monitoring logs (iabp, impella). A toolbar above the log
   (.tool-log-actions), the 'Completed: x/y' count that starts an
   action row (.tool-progress), the offline-app fallback alert's
   .modal-close, and the status pills the log script writes in its
   cells (status-ok / -caution / -critical / -neutral), each with an
   icon beside the word. */
:where(.fl-v2) .tool-log-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

:where(.fl-v2) .tool-progress {
    margin-right: auto;
    color: var(--text-secondary);
}

:where(.fl-v2) .alert-dismissible > .modal-close {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
}

:where(.fl-v2) .status-pill.status-ok {
    --pill-color: var(--success-text);
    --pill-fill: var(--success-fill);
}

:where(.fl-v2) .status-pill.status-caution {
    --pill-color: var(--warning-text);
    --pill-fill: var(--warning-fill);
}

:where(.fl-v2) .status-pill.status-critical {
    --pill-color: var(--danger-text);
    --pill-fill: var(--danger-fill);
}

/* (the print header's summary pills carry a text mark already) */
:where(.fl-v2) td .status-pill:is(.status-ok, .status-caution, .status-critical)::before {
    font-family: 'tabler-icons';
    font-size: 1.1em;
    font-weight: 400;
    line-height: 1;
}

:where(.fl-v2) td .status-pill.status-ok::before {
    content: "\ea5e"; /* ti-check */
    content: "\ea5e" / "";
}

:where(.fl-v2) td .status-pill.status-caution::before {
    content: "\ea06"; /* ti-alert-triangle */
    content: "\ea06" / "";
}

:where(.fl-v2) td .status-pill.status-critical::before {
    content: "\ea05"; /* ti-alert-circle */
    content: "\ea05" / "";
}
