/* ================================================================
   Theme palette (CSS custom properties).
   Default = light. Overrides below via [data-theme="dark"|"high-contrast"].
   Auto mode: script in each HTML head maps the OS preference to an
   explicit attribute before first paint (prevents FOUC).
   ================================================================ */
:root {
    color-scheme: light;

    --bg-page: linear-gradient(to right, #e3f2fd, #ffffff);
    --bg-main: #ffffff;
    --bg-card: #fbfbfd;
    --bg-subtle: #f1f8ff;
    --bg-code: #f0f4f8;
    --bg-hover: #f7faff;

    --fg: #333333;
    --fg-heading: #1976d2;
    --fg-muted: #666666;
    --fg-subtle: #888888;

    --accent: #1976d2;
    --accent-dark: #1565c0;
    --accent-deep: #0d47a1;
    --accent-bg: rgba(25, 118, 210, 0.08);
    --accent-border: #64b5f6;

    --border: #e1e4e8;
    --border-strong: #c5cdd6;

    --success: #1b5e20;
    --success-bg: #e8f5e9;
    --warning: #bf360c;
    --warning-bg: #fff3e0;
    --danger: #9a1012;
    --danger-bg: #ffebee;

    --nav-bg: #1976d2;
    --nav-fg: #ffffff;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] {
    color-scheme: dark;

    --bg-page: #0d1117;
    --bg-main: #161b22;
    --bg-card: #1f2937;
    --bg-subtle: #1a2332;
    --bg-code: #0d1117;
    --bg-hover: #22303e;

    --fg: #e6edf3;
    --fg-heading: #82b6f0;
    --fg-muted: #a0aab5;
    --fg-subtle: #7d8894;

    --accent: #64b5f6;
    --accent-dark: #90caf9;
    --accent-deep: #bbdefb;
    --accent-bg: rgba(100, 181, 246, 0.15);
    --accent-border: #64b5f6;

    --border: #30363d;
    --border-strong: #444c56;

    --success: #81c784;
    --success-bg: rgba(46, 125, 50, 0.18);
    --warning: #ffb74d;
    --warning-bg: rgba(245, 127, 23, 0.18);
    --danger: #ef9a9a;
    --danger-bg: rgba(198, 40, 40, 0.18);

    --nav-bg: #1a2332;
    --nav-fg: #e6edf3;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.6);
}

[data-theme="high-contrast"] {
    color-scheme: light;

    --bg-page: #ffffff;
    --bg-main: #ffffff;
    --bg-card: #ffffff;
    --bg-subtle: #ffffff;
    --bg-code: #ffffff;
    --bg-hover: #e0e0e0;

    --fg: #000000;
    --fg-heading: #000000;
    --fg-muted: #000000;
    --fg-subtle: #000000;

    --accent: #0033aa;
    --accent-dark: #001a66;
    --accent-deep: #000033;
    --accent-bg: #ffff99;
    --accent-border: #000000;

    --border: #000000;
    --border-strong: #000000;

    --success: #006600;
    --success-bg: #ccffcc;
    --warning: #994400;
    --warning-bg: #ffff99;
    --danger: #990000;
    --danger-bg: #ffcccc;

    --nav-bg: #000000;
    --nav-fg: #ffffff;

    --shadow-sm: 0 0 0 1px #000000;
    --shadow-md: 0 0 0 2px #000000;
    --shadow-lg: 0 0 0 3px #000000;
}

body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: var(--bg-page);
    color: var(--fg);
    line-height: 1.6;
}

header {
    background: linear-gradient(to right, #2196F3, #64b5f6);
    color: #fff;
    padding: 30px 0;
    text-align: center;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Enhanced Header Container */
.header-container {
    background: linear-gradient(135deg, #1976d2 0%, #64b5f6 100%);
    color: white;
    padding: 40px 30px;
    margin-bottom: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
}

/* Decorative background pattern */
.header-container::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(45deg, transparent 45%, rgba(255, 255, 255, 0.1) 45%, rgba(255, 255, 255, 0.1) 55%, transparent 55%);
    background-size: 20px 20px;
    pointer-events: none;
}

/* Title styling */
.header-container h1 {
    margin: 0;
    font-size: 2.8em;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
}

/* Subtitle styling */
.header-container>p {
    margin: 10px 0 25px;
    font-size: 1.3em;
    font-weight: 300;
    opacity: 0.9;
    position: relative;
}

/* Info box styling */
.header-container .info-box {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 25px;
    border-radius: 8px;
    margin-top: 20px;
    position: relative;
    transform: translateY(0);
    transition: transform 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.header-container .info-box:hover {
    transform: translateY(-2px);
}

.header-container .info-box p {
    margin: 0;
    color: #333;
    line-height: 1.6;
    font-size: 1.05em;
}

.header-container .info-box strong {
    color: #1976d2;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 5px;
}

/* Responsive design */
@media (max-width: 768px) {
    .header-container {
        padding: 30px 20px;
        margin: 15px;
    }

    .header-container h1 {
        font-size: 2.2em;
    }

    .header-container>p {
        font-size: 1.1em;
    }

    .header-container .info-box {
        padding: 15px 20px;
    }

    .header-container .info-box p {
        font-size: 1em;
    }
}

/* Optional: Add animation on page load */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header-container h1,
.header-container>p,
.header-container .info-box {
    animation: fadeInUp 0.6s ease forwards;
}

.header-container>p {
    animation-delay: 0.2s;
}

.header-container .info-box {
    animation-delay: 0.4s;
}

nav {
    background-color: #1976d2;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Update your existing nav styles */
.nav-bar {
    list-style-type: none;
    padding: 0;
    margin: 0;
    overflow: hidden;
    text-align: center;
}

.nav-bar li {
    display: inline;
}

.nav-bar li a {
    display: inline-block;
    color: #fff;
    text-align: center;
    padding: 14px 20px;
    text-decoration: none;
    transition: all 0.3s ease;
    border-radius: 4px;
    position: relative;
}

/* Add these new styles for the active state */
.nav-bar li a.active {
    background-color: rgba(255, 255, 255, 0.1);
    font-weight: 500;
    box-shadow: inset 0 -3px 0 #fff;
}

/* Optional: Add a different hover effect for non-active items */
.nav-bar li a:not(.active):hover {
    background-color: #1565c0;
    transform: translateY(-3px);
}

/* Optional: Keep active item from moving on hover */
.nav-bar li a.active:hover {
    transform: none;
    background-color: rgba(255, 255, 255, 0.15);
}

main {
    background: #fff;
    padding: 30px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
}

section {
    margin-bottom: 25px;
    padding: 20px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background-color: #fafafa;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    color: #1976d2;
}

input[type="number"] {
    width: 100%;
    max-width: 200px;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 1em;
}

button {
    padding: 12px 24px;
    background: linear-gradient(to right, #4CAF50, #81c784);
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 50px;
    font-size: 1.1em;
    font-weight: bold;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

button:hover {
    background-color: #45a049;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

.button-group {
    text-align: center;
    margin-top: 30px;
}

table {
    border-collapse: collapse;
    width: auto;
    margin-top: 20px;
    background-color: #fff;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    overflow: hidden;
    table-layout: fixed;
    word-wrap: break-word;
}

table,
th,
td {
    border: 1px solid #ddd;
    padding: 5px;
    text-align: center;
    font-size: 0.85em;
}

table th,
table td {
    width: 50px;
    padding: 8px;
}

table th {
    background-color: #e3f2fd;
    font-weight: bold;
    color: #1976d2;
}

footer {
    text-align: center;
    padding: 30px;
    background-color: #333;
    color: #fff;
    margin-top: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}



.highlight {
    font-weight: bold;
    font-size: 1.05em;
    color: #1976d2;
}

.expected-frequencies-header {
    margin-top: 20px;
    font-size: 1.2em;
    font-weight: bold;
    color: #1976d2;
    text-align: left;
}

/* Add these styles to your existing CSS file */
.results-table {
    margin: 20px 0;
    width: 100%;
    border-collapse: collapse;
}

.results-table th,
.results-table td {
    padding: 10px;
    border: 1px solid #ddd;
    text-align: center;
}

.results-table th {
    background-color: #e3f2fd;
    color: #1976d2;
    font-weight: bold;
}

.results-table td {
    vertical-align: middle;
}

.results-table td div {
    margin: 3px 0;
}

.contribution {
    color: #1976d2;
    font-weight: bold;
}

.results-summary {
    margin-top: 20px;
    padding: 20px;
    background-color: #f5f5f5;
    border-radius: 8px;
}

.results-summary h3 {
    color: #1976d2;
    margin-top: 0;
}

.conclusion {
    margin-top: 15px;
    padding: 10px;
    background-color: #e3f2fd;
    border-radius: 4px;
}

/* Enhanced Styling */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 4px;
    color: white;
    opacity: 1;
    transition: opacity 0.3s ease;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.notification.success {
    background-color: #4CAF50;
}

.notification.warning {
    background-color: #ff9800;
}

.notification.error {
    background-color: #f44336;
}

/* Enhanced table styling */
.input-table input {
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.input-table input:focus {
    border-color: #2196F3;
    box-shadow: 0 0 5px rgba(33, 150, 243, 0.3);
}

.input-table input:hover {
    background-color: #f5f5f5;
}

/* Button group styling */
.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 20px 0;
}

.button-group button {
    min-width: 120px;
}

/* Tooltip styling */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]:before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    background-color: #333;
    color: white;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

[data-tooltip]:hover:before {
    opacity: 1;
    visibility: visible;
}

/* ================================================================
   Mobile-first polish.
   Target: 375px viewport (iPhone SE). All pages must be usable.
   WCAG 2.5.5 (AAA): interactive targets ≥ 44×44 CSS pixels.
   ================================================================ */

/* Prevent accidental horizontal scroll at the document level. Table-
   containers manage their own horizontal overflow internally. */
html, body {
    overflow-x: hidden;
}

/* Base: ensure all interactive controls meet touch-target minimums.
   On pointer devices this is invisible; on touch it prevents mis-taps. */
button,
.primary-button,
.secondary-button,
.action-button,
.card-button,
input[type="checkbox"] + span {
    min-height: 44px;
}

input[type="number"],
input[type="text"],
select,
textarea {
    min-height: 44px;
    font-size: 16px; /* prevents iOS Safari auto-zoom on focus */
}

/* Hamburger toggle for narrow viewports. Injected by layout.js. */
.nav-toggle {
    display: none;
    background: transparent;
    color: #fff;
    border: none;
    font-size: 1em;
    font-weight: 500;
    padding: 12px 18px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    border-radius: 8px;
}

.nav-toggle:hover,
.nav-toggle:focus {
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

.nav-toggle .menu-icon {
    margin-right: 8px;
    font-size: 1.2em;
    vertical-align: middle;
}

/* Chi-square input table on mobile: make every number cell tappable and
   the whole table horizontally scrollable without visual surprises. */
#input-table input[type="number"] {
    min-width: 62px;
    width: 100%;
    padding: 8px 6px;
    box-sizing: border-box;
}

#input-table input[type="text"] {
    min-width: 90px;
    padding: 8px 6px;
    box-sizing: border-box;
}

#input-table td {
    padding: 4px;
}

.table-container {
    position: relative;
}

/* Scroll-hint shadow on the right edge when content overflows.
   Fades away as the user scrolls to the end. */
.table-container::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 28px;
    pointer-events: none;
    background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.95));
    opacity: 0;
    transition: opacity 0.2s ease;
}

.table-container.is-overflowing::after {
    opacity: 1;
}

/* 2x2 inputs on Compare and Epi pages need a minimum so they don't crush */
#compare-table input[type="number"],
#epi-table input[type="number"] {
    min-width: 90px;
    width: 100%;
    padding: 8px 6px;
    box-sizing: border-box;
}

#compare-table input[type="text"],
#epi-table input[type="text"] {
    min-width: 100px;
    padding: 8px 6px;
    box-sizing: border-box;
}

/* Narrow-viewport layout (≤600px — phones, tight windows) */
@media (max-width: 600px) {
    body {
        width: 100%;
        padding: 10px;
    }

    main {
        padding: 18px 14px;
    }

    section {
        padding-left: 0;
        padding-right: 0;
    }

    .header-container {
        padding: 24px 18px;
    }

    .header-container h1 {
        font-size: 1.5em;
    }

    .header-container p {
        font-size: 0.95em;
    }

    /* Hamburger mode: toggle visible, list hidden until expanded */
    .nav-toggle {
        display: flex;
        align-items: center;
    }

    nav .nav-bar {
        display: none;
        padding: 8px 0;
    }

    nav .nav-bar.open {
        display: block;
    }

    .nav-bar li {
        display: block;
    }

    .nav-bar li a {
        display: block;
        text-align: left;
        padding: 14px 20px;
        border-radius: 0;
    }

    .nav-bar li a:not(.active):hover {
        transform: none;
    }

    /* Button groups stack on narrow */
    .button-group {
        flex-direction: column;
        align-items: stretch;
    }

    .button-group button {
        width: 100%;
        margin-bottom: 8px;
    }

    /* Landing-page cards don't need the hover-lift on touch */
    .calc-card:hover {
        transform: none;
    }

    /* Dataset library cards: full-width buttons */
    .dataset-card .button-group {
        flex-direction: column;
    }

    .dataset-card .button-group button {
        width: 100%;
    }

    /* Notation tables get a helpful "scroll →" hint via colored border */
    .notation-table-wrap {
        border-left: 3px solid #1976d2;
    }

    /* Trap filter buttons wrap cleanly */
    .trap-filter {
        padding: 10px;
    }

    .trap-filter-btn {
        flex-grow: 1;
        min-width: calc(50% - 4px);
    }

    /* Guide tree: case cards full-width, slightly smaller padding */
    .guide-case {
        padding: 10px 12px;
    }

    /* Three-level summary text smaller */
    .three-level-section summary small {
        display: block;
        margin-left: 0;
        margin-top: 3px;
        font-size: 0.8em;
    }

    /* Result banner text compacted */
    .ci-banner {
        font-size: 0.95em;
        padding: 10px 12px;
    }

    /* Dataset banner: tighter spacing, smaller title */
    .dataset-context-banner {
        padding: 12px 40px 12px 14px;
    }

    .dataset-context-banner .banner-title {
        font-size: 1em;
    }

    /* Stats grid becomes single-column */
    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    /* SVG histograms fit the viewport cleanly */
    svg.sim-histogram,
    svg.qq-plot,
    svg.normal-curve {
        width: 100%;
        max-width: 100%;
    }

    /* Compare test cards: full-width */
    .compare-tests {
        grid-template-columns: 1fr !important;
    }

    /* Epi cards: full-width */
    .epi-grid {
        grid-template-columns: 1fr !important;
    }

    /* Simulate result: stack plot below summary */
    .sim-result {
        grid-template-columns: 1fr !important;
    }

    /* Assumption Coach: stack plot + stats */
    .assm-result {
        grid-template-columns: 1fr !important;
    }
}

/* Very narrow (≤375px iPhone SE) — the hardest case */
@media (max-width: 375px) {
    body {
        padding: 8px;
    }

    main {
        padding: 14px 10px;
    }

    .header-container {
        padding: 18px 14px;
    }

    .header-container h1 {
        font-size: 1.35em;
    }

    /* Notation table: let cells wrap tightly */
    .notation-table {
        font-size: 0.85em;
    }

    .notation-table td {
        padding: 6px 6px;
    }

    /* Trap filter: 1 per row at extreme narrow */
    .trap-filter-btn {
        min-width: 100%;
    }
}

/* ================================================================
   Dark mode overrides.
   Targets structural elements that use hardcoded colors in the
   original light-mode rules above.
   ================================================================ */
[data-theme="dark"] body { background: var(--bg-page); color: var(--fg); }
[data-theme="dark"] main { background: var(--bg-main); color: var(--fg); box-shadow: var(--shadow-md); }

[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3,
[data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6 { color: var(--fg-heading); }

[data-theme="dark"] nav { background: var(--nav-bg); box-shadow: var(--shadow-md); }
[data-theme="dark"] .nav-bar li a { color: var(--nav-fg); }
[data-theme="dark"] .nav-bar li a.active { background: rgba(255,255,255,0.12); box-shadow: inset 0 -3px 0 var(--accent); }
[data-theme="dark"] .nav-bar li a:not(.active):hover { background: #0d47a1; }
[data-theme="dark"] .nav-toggle { color: var(--nav-fg); }
[data-theme="dark"] .nav-toggle:hover, [data-theme="dark"] .nav-toggle:focus { background: rgba(255,255,255,0.1); }

[data-theme="dark"] .header-container { background: linear-gradient(135deg, #1a2332 0%, #2d4562 100%); }

[data-theme="dark"] .info-box,
[data-theme="dark"] .instruction-panel,
[data-theme="dark"] .calc-card,
[data-theme="dark"] .result-box,
[data-theme="dark"] .stat-item,
[data-theme="dark"] .visualization-box,
[data-theme="dark"] .summary-stats-container,
[data-theme="dark"] .conclusion-box,
[data-theme="dark"] .compare-card,
[data-theme="dark"] .compare-summary,
[data-theme="dark"] .sim-summary,
[data-theme="dark"] .sim-plot,
[data-theme="dark"] .epi-card,
[data-theme="dark"] .assm-stats,
[data-theme="dark"] .assm-plot,
[data-theme="dark"] .assm-conditions,
[data-theme="dark"] .self-checks,
[data-theme="dark"] .self-check-card,
[data-theme="dark"] .three-level,
[data-theme="dark"] .three-level-section,
[data-theme="dark"] .guide-tree,
[data-theme="dark"] .guide-case,
[data-theme="dark"] .guide-walkthrough,
[data-theme="dark"] .dataset-card,
[data-theme="dark"] .error-trap,
[data-theme="dark"] details.show-work { background: var(--bg-card); color: var(--fg); border-color: var(--border); }

[data-theme="dark"] .compare-summary table,
[data-theme="dark"] .notation-table,
[data-theme="dark"] .compact-results-table,
[data-theme="dark"] .expected-table { background: var(--bg-main); color: var(--fg); }

[data-theme="dark"] .notation-table thead th,
[data-theme="dark"] .compact-results-table th { background: #2d3748; color: var(--fg-heading); border-bottom-color: var(--accent); }
[data-theme="dark"] .notation-table td,
[data-theme="dark"] .compact-results-table td { border-bottom-color: var(--border); color: var(--fg); }
[data-theme="dark"] .notation-table tr:hover td,
[data-theme="dark"] .compact-results-table tr:hover { background: var(--bg-hover); }
[data-theme="dark"] .notation-table td.sym { color: var(--fg-heading); }
[data-theme="dark"] .notation-table code,
[data-theme="dark"] code { background: var(--bg-code); color: var(--fg); }

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select { background: var(--bg-main); color: var(--fg); border-color: var(--border-strong); }
[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus { outline: 2px solid var(--accent); }

[data-theme="dark"] .primary-button { background: linear-gradient(to right, #1565c0, #1976d2); color: #fff; }
[data-theme="dark"] .primary-button:hover { background: linear-gradient(to right, #0d47a1, #1565c0); }
[data-theme="dark"] .secondary-button { background: transparent; color: var(--accent); border-color: var(--accent); }
[data-theme="dark"] .secondary-button:hover { background: rgba(100,181,246,0.12); }
[data-theme="dark"] .action-button { background: var(--bg-card); color: var(--fg); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .action-button.warning { background: rgba(245,127,23,0.2); color: #ffb74d; }
[data-theme="dark"] .card-button { background: var(--accent); color: #fff; }
[data-theme="dark"] .card-button:hover { background: var(--accent-dark); color: #0d1117; }
[data-theme="dark"] .trap-filter-btn { background: var(--bg-card); color: var(--accent); border-color: var(--border-strong); }
[data-theme="dark"] .trap-filter-btn:hover { background: var(--bg-hover); }
[data-theme="dark"] .trap-filter-btn.active { background: var(--accent); color: var(--bg-page); border-color: var(--accent); }

[data-theme="dark"] p, [data-theme="dark"] li, [data-theme="dark"] td, [data-theme="dark"] th { color: var(--fg); }
[data-theme="dark"] .stat-label, [data-theme="dark"] .check-source,
[data-theme="dark"] .ds-citation, [data-theme="dark"] .trap-citation,
[data-theme="dark"] .sim-runtime, [data-theme="dark"] .sim-note { color: var(--fg-muted); }
[data-theme="dark"] .stat-value { color: var(--fg-heading); }

[data-theme="dark"] .verdict.reject, [data-theme="dark"] .assm-verdict.green { background: rgba(46,125,50,0.25); color: #81c784; border-color: #81c784; }
[data-theme="dark"] .verdict.fail, [data-theme="dark"] .assm-verdict.yellow { background: rgba(245,127,23,0.2); color: #ffb74d; border-color: #ffb74d; }
[data-theme="dark"] .assm-verdict.red { background: rgba(198,40,40,0.2); color: #ef9a9a; border-color: #ef9a9a; }
[data-theme="dark"] .warning-message { background: rgba(245,127,23,0.18); color: #ffb74d; }
[data-theme="dark"] .warning-message strong { color: #ffb74d; }

[data-theme="dark"] .ci-banner { background: rgba(46,125,50,0.2); color: #c8e6c9; border-left-color: var(--success); }
[data-theme="dark"] .predict-reveal.matched { background: rgba(46,125,50,0.18); border-left-color: var(--success); color: var(--fg); }
[data-theme="dark"] .predict-reveal.mismatched { background: rgba(245,127,23,0.18); border-left-color: var(--warning); color: var(--fg); }

[data-theme="dark"] .self-check-card.correct { background: rgba(46,125,50,0.15); border-color: rgba(129,199,132,0.4); }
[data-theme="dark"] .self-check-card.incorrect { background: rgba(245,127,23,0.15); border-color: rgba(255,183,77,0.4); }
[data-theme="dark"] .check-buttons button.is-correct-answer { background: rgba(46,125,50,0.4) !important; color: #a5d6a7 !important; border-color: #66bb6a !important; }
[data-theme="dark"] .check-buttons button.is-wrong-answer { background: rgba(198,40,40,0.4) !important; color: #ef9a9a !important; border-color: #ef5350 !important; }

[data-theme="dark"] .dataset-context-banner { background: linear-gradient(135deg, #1a2332 0%, #1f2937 100%); border-left-color: var(--accent); }
[data-theme="dark"] .dataset-context-banner .banner-title { color: var(--fg-heading); }
[data-theme="dark"] .dataset-context-banner .banner-learn { background: var(--accent-bg); color: var(--fg); }
[data-theme="dark"] .banner-dismiss { color: var(--accent); }

[data-theme="dark"] .compare-divergence { background: rgba(100,181,246,0.12); border-left-color: var(--accent); }
[data-theme="dark"] .compare-note, [data-theme="dark"] .compare-meta { color: var(--fg-muted); }

[data-theme="dark"] .compare-card .trap-scenario,
[data-theme="dark"] .error-trap .trap-scenario { background: rgba(245,127,23,0.18); border-left-color: var(--warning); color: var(--fg); }
[data-theme="dark"] .error-trap .trap-looks-right { background: rgba(251,192,45,0.15); border-left-color: #fbc02d; color: var(--fg); }
[data-theme="dark"] .error-trap .trap-whats-wrong { background: rgba(198,40,40,0.18); border-left-color: var(--danger); color: var(--fg); }
[data-theme="dark"] .error-trap .trap-fix { background: rgba(46,125,50,0.18); border-left-color: var(--success); color: var(--fg); }

[data-theme="dark"] .three-level-section summary { background: rgba(100,181,246,0.12); color: var(--fg-heading); }
[data-theme="dark"] .show-work-toggle { background: rgba(100,181,246,0.12); color: var(--fg-heading); }
[data-theme="dark"] .show-work-math { background: var(--bg-code); color: var(--fg); }
[data-theme="dark"] .show-work-note { background: rgba(255,179,0,0.12); color: #ffcc80; border-left-color: #ffb300; }

[data-theme="dark"] .table-container::after { background: linear-gradient(to right, rgba(22,27,34,0), rgba(22,27,34,0.95)); }

[data-theme="dark"] .guide-case { border-left-color: var(--accent); }
[data-theme="dark"] .ds-learn { background: var(--accent-bg); color: var(--accent-deep); }
[data-theme="dark"] .ds-tag { background: rgba(255, 167, 38, 0.15); color: #ffb74d; }

[data-theme="dark"] dialog.predict-dialog { background: var(--bg-card); color: var(--fg); }
[data-theme="dark"] .predict-question { background: var(--bg-subtle); border-left-color: var(--accent); }
[data-theme="dark"] .predict-footnote { color: var(--fg-muted); border-top-color: var(--border); }

[data-theme="dark"] .notification.success { background: rgba(46,125,50,0.2); color: #a5d6a7; border: 1px solid #66bb6a; }
[data-theme="dark"] .notification.warning { background: rgba(245,127,23,0.2); color: #ffb74d; border: 1px solid #ffa726; }
[data-theme="dark"] .notification.error { background: rgba(198,40,40,0.2); color: #ef9a9a; border: 1px solid #ef5350; }
[data-theme="dark"] .notification.info { background: var(--accent-bg); color: var(--accent-deep); border: 1px solid var(--accent); }

[data-theme="dark"] .learning-mode-toggle { background: var(--bg-subtle); border-color: var(--accent-border); }
[data-theme="dark"] .learning-mode-switch { color: var(--accent-deep); }

[data-theme="dark"] .qq-plot text, [data-theme="dark"] .sim-histogram text, [data-theme="dark"] .normal-curve text { fill: var(--fg); }
[data-theme="dark"] .qq-plot line, [data-theme="dark"] .sim-histogram line, [data-theme="dark"] .normal-curve line { stroke: var(--fg-muted); }
[data-theme="dark"] .sim-plot .sim-histogram { background: var(--bg-main); }

/* Keep MathJax rendering legible in dark mode */
[data-theme="dark"] mjx-container { color: var(--fg); }

/* ---- Dark mode: second pass catches remaining light backgrounds ---- */
[data-theme="dark"] .section { background-color: var(--bg-card); color: var(--fg); }
[data-theme="dark"] .example-box,
[data-theme="dark"] .info-panel { background: var(--bg-subtle); color: var(--fg); }
[data-theme="dark"] .info-panel.visible { background: var(--bg-subtle); }
[data-theme="dark"] pre,
[data-theme="dark"] .report-preview-text { background: var(--bg-code); color: var(--fg); border: 1px solid var(--border); }
[data-theme="dark"] table { background: var(--bg-main); color: var(--fg); }
[data-theme="dark"] table th { background: #2d3748; color: var(--fg-heading); }
[data-theme="dark"] table td { color: var(--fg); }
[data-theme="dark"] #input-table input { background: var(--bg-main); color: var(--fg); border: 1px solid var(--border-strong); }
[data-theme="dark"] #input-table td,
[data-theme="dark"] #input-table th { background: transparent; border-color: var(--border); }
[data-theme="dark"] .results-table,
[data-theme="dark"] .results-table th,
[data-theme="dark"] .results-table td { background: var(--bg-card); color: var(--fg); border-color: var(--border); }
[data-theme="dark"] .results-table-container,
[data-theme="dark"] .summary-stats-container { background: var(--bg-card); }

[data-theme="dark"] .input-group label { color: var(--fg); }
[data-theme="dark"] .input-help { color: var(--fg-muted); }
[data-theme="dark"] .stat-label { color: var(--fg-muted); }
[data-theme="dark"] .stat-value { color: var(--fg-heading); }
[data-theme="dark"] .result-value { color: var(--fg-heading); }
[data-theme="dark"] .result-interpretation { color: var(--fg); }
[data-theme="dark"] .result-title { color: var(--fg-heading); }
[data-theme="dark"] .probability-result { color: var(--fg); }
[data-theme="dark"] .probability-result .value { color: var(--fg-heading); }
[data-theme="dark"] .interpretation-details { background: var(--bg-card); color: var(--fg); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .interpretation-section { border-bottom-color: var(--border); }
[data-theme="dark"] .interpretation-section h4,
[data-theme="dark"] .interpretation-section h5 { color: var(--fg-heading); }
[data-theme="dark"] .applications-grid .application-item { background: var(--bg-subtle); border-left-color: var(--accent); color: var(--fg); }
[data-theme="dark"] .application-item li { color: var(--fg); }
[data-theme="dark"] .info-section { background: var(--bg-subtle); color: var(--fg); }
[data-theme="dark"] .info-section .highlight { color: var(--fg-heading); }
[data-theme="dark"] .expected-frequencies h3,
[data-theme="dark"] .totals-section h3,
[data-theme="dark"] .totals-section h4 { color: var(--fg-heading); }
[data-theme="dark"] .totals-grid .row-totals,
[data-theme="dark"] .totals-grid .column-totals { color: var(--fg); }
[data-theme="dark"] .cell-data .observed { color: var(--fg); }
[data-theme="dark"] .cell-data .expected { color: var(--fg-muted); }
[data-theme="dark"] .cell-data .contribution { color: var(--accent); }
[data-theme="dark"] .conclusion-box { background: var(--accent-bg); color: var(--fg); border: 1px solid var(--accent); }
[data-theme="dark"] .reference-table th { background: #2d3748; color: var(--fg-heading); }
[data-theme="dark"] .effect-size-note,
[data-theme="dark"] .effect-size-note small { color: var(--fg-muted); }

[data-theme="dark"] .header-container .info-box { background: rgba(255,255,255,0.08); color: #e6edf3; }
[data-theme="dark"] .header-container .info-box p,
[data-theme="dark"] .header-container .info-box .info-content { color: #e6edf3; }
[data-theme="dark"] .header-container .info-box strong { color: #ffffff; }
[data-theme="dark"] .info-box .key-features li { color: var(--fg); }
[data-theme="dark"] .info-box .key-features li:before { color: var(--accent); }

[data-theme="dark"] .intro-card { background: linear-gradient(135deg, #1a2332 0%, #273142 100%); }

[data-theme="dark"] a { color: var(--accent); }
[data-theme="dark"] a:hover { color: var(--accent-dark); }

[data-theme="dark"] footer,
[data-theme="dark"] .footer-container { background: var(--bg-card); color: var(--fg-muted); }
[data-theme="dark"] .footer-container .footer-title { color: var(--fg); }

[data-theme="dark"] .feature-icon { background: rgba(255,255,255,0.18); }

[data-theme="dark"] .visualization-divider { background: linear-gradient(to right, transparent, var(--border), transparent); }

[data-theme="dark"] .probability-group { background: var(--bg-subtle); border-left-color: var(--accent); }

[data-theme="dark"] .predict-choices button { /* inherits from .primary-button etc. already overridden */ }

[data-theme="dark"] .check-question { color: var(--fg); }
[data-theme="dark"] .check-reveal { border-top-color: var(--border); color: var(--fg); }
[data-theme="dark"] .check-explain { color: var(--fg); }

[data-theme="dark"] .compare-tests .compare-card h4,
[data-theme="dark"] .epi-card h4 { color: var(--fg-heading); }
[data-theme="dark"] .compare-card .compare-note { color: var(--fg-muted); border-top-color: var(--border); }

[data-theme="dark"] .show-work-body { color: var(--fg); }
[data-theme="dark"] .show-work-body p { color: var(--fg); }
[data-theme="dark"] .three-level-body { color: var(--fg); }
[data-theme="dark"] .three-level-intro { color: var(--fg-muted); }

[data-theme="dark"] .trap-filter { background: var(--bg-card); border-color: var(--border); }

[data-theme="dark"] .guide-tree,
[data-theme="dark"] .guide-walkthrough p,
[data-theme="dark"] .guide-options li { color: var(--fg); }
[data-theme="dark"] .guide-question { color: var(--fg-heading); }

[data-theme="dark"] .compare-summary table td { color: var(--fg); border-bottom-color: var(--border); }
[data-theme="dark"] .compare-summary table tr:hover td,
[data-theme="dark"] .compare-summary table { background: var(--bg-card); }

/* ---- Dark mode: third pass — specific containers with hardcoded #fff ---- */
[data-theme="dark"] .calculator-container { background: var(--bg-card); color: var(--fg); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .probability-result { background: var(--bg-subtle); color: var(--fg); }
[data-theme="dark"] .probability-result .label { color: var(--fg-muted); }
[data-theme="dark"] .probability-result .value { color: var(--fg-heading); background: transparent; }
[data-theme="dark"] .result-interpretation { background: transparent; color: var(--fg); }
[data-theme="dark"] .visualization-wrapper { background: var(--bg-card); color: var(--fg); }
[data-theme="dark"] .visualization-wrapper h3 { color: var(--fg-heading); }
[data-theme="dark"] .visualization-box { background: var(--bg-main); }
[data-theme="dark"] svg.normal-curve { background: var(--bg-card); }
[data-theme="dark"] svg.normal-curve polyline { stroke: var(--fg); }
[data-theme="dark"] svg.normal-curve path { fill: var(--accent); fill-opacity: 0.45; }
[data-theme="dark"] svg.normal-curve line[stroke="black"] { stroke: var(--fg-muted); }
[data-theme="dark"] svg.normal-curve text { fill: var(--fg); }
[data-theme="dark"] svg.normal-curve text[fill="#1976d2"] { fill: var(--fg-heading); }
[data-theme="dark"] svg.sim-histogram { background: var(--bg-card); }
[data-theme="dark"] svg.sim-histogram line[stroke="#333"] { stroke: var(--fg); }
[data-theme="dark"] svg.qq-plot { background: var(--bg-card); }
[data-theme="dark"] svg.qq-plot line[stroke="#333"] { stroke: var(--fg); }

[data-theme="high-contrast"] svg.normal-curve,
[data-theme="high-contrast"] svg.sim-histogram,
[data-theme="high-contrast"] svg.qq-plot { background: #ffffff; }
[data-theme="high-contrast"] svg.normal-curve text { fill: #000000; }
[data-theme="high-contrast"] svg.normal-curve line { stroke: #000000; }
[data-theme="high-contrast"] svg.normal-curve polyline { stroke: #000000; }
[data-theme="high-contrast"] svg.normal-curve path { fill: #0000cc; fill-opacity: 0.5; }

/* ================================================================
   Visual polish (dark + light shared refinements).
   Reduces nested-box feel, tones down over-saturated accents,
   softens header ornamentation, improves spacing rhythm.
   ================================================================ */

/* Softer accent that doesn't hit the eye as hard in either theme */
[data-theme="dark"] {
    --accent: #58a6ff;      /* GitHub-like dark-mode blue: warmer, less neon */
    --accent-dark: #79bbff;
    --accent-deep: #a6d2ff;
    --accent-bg: rgba(88, 166, 255, 0.12);
    --fg-heading: #7fb3ff;  /* slightly warmer than the previous icy blue */
}

/* Tone down the header: kill the diagonal stripe pattern in dark, soften
   the gradient, make the on-header info-box feel integrated rather than
   floating in glass. */
[data-theme="dark"] .header-container {
    background: linear-gradient(140deg, #132033 0%, #1a2a44 50%, #20354f 100%);
    box-shadow: none;
}

[data-theme="dark"] .header-container::before {
    opacity: 0.08;        /* was fully visible; drops the harshness */
}

[data-theme="dark"] .header-container h1 {
    color: #a6d2ff;       /* less neon than pure accent on the hero */
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .header-container p {
    color: #d0dce9;
}

[data-theme="dark"] .header-container .info-box {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}

/* Make `main` blend into the page instead of being its own island.
   Dark mode looks much calmer without a strong main-level border/shadow. */
[data-theme="dark"] main {
    background: transparent;
    box-shadow: none;
    padding: 20px 0;
}

/* Section containers inherit the full visual weight instead of main. */
[data-theme="dark"] section,
[data-theme="dark"] .section {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    padding: 22px;
    margin-bottom: 20px;
}

/* .calculator-cards is a section but stays a grid layout, not a card. */
[data-theme="dark"] section.calculator-cards {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 15px;
}

/* Intro-card on the landing page: flatten to a single-depth card so it
   doesn't feel like a bright box nested inside a dark main. */
[data-theme="dark"] .intro-card {
    background: linear-gradient(135deg, #132033 0%, #1f3355 100%);
    border: 1px solid #2a4268;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .intro-card h2 {
    color: #e0ebf7;
}

[data-theme="dark"] .intro-card p {
    color: #c7d4e6;
}

/* Calc cards on landing — slightly lifted, with a hover accent. */
[data-theme="dark"] .calc-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

[data-theme="dark"] .calc-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.2);
    transform: translateY(-2px);
}

/* Quiet down the section-heading blue in dark mode — it was too loud. */
[data-theme="dark"] .section h2,
[data-theme="dark"] .instruction-panel h3,
[data-theme="dark"] .section h3:first-child,
[data-theme="dark"] .guide-walkthrough h3 {
    color: #a6d2ff;
    font-weight: 600;
}

/* Instruction panels get a subtler look — a thin accent bar, no heavy fill. */
[data-theme="dark"] .instruction-panel {
    background: rgba(88, 166, 255, 0.04);
    border-left: 3px solid var(--accent);
    padding: 12px 16px;
}

/* Learning-mode toggle: smaller, less box-like */
[data-theme="dark"] .learning-mode-toggle {
    background: rgba(88, 166, 255, 0.06);
    border: 1px solid rgba(88, 166, 255, 0.2);
    padding: 6px 12px;
    border-radius: 6px;
}

[data-theme="dark"] .learning-mode-switch {
    color: var(--accent);
    font-size: 0.9em;
}

/* Primary button: solid accent with a subtle glow on hover instead of gradient */
[data-theme="dark"] .primary-button {
    background: var(--accent);
    color: #0d1117;
    font-weight: 600;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .primary-button:hover {
    background: var(--accent-dark);
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.4);
    transform: translateY(-1px);
}

/* Navigation: softer shadow, slightly rounded corners, integrated feel */
[data-theme="dark"] nav {
    background: linear-gradient(180deg, #1a2432 0%, #151e2a 100%);
    border: 1px solid #2a3441;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .nav-bar li a.active {
    background: rgba(88, 166, 255, 0.15);
    box-shadow: inset 0 -3px 0 var(--accent);
    color: #fff;
}

/* Tables — reduce border weight in dark */
[data-theme="dark"] .notation-table,
[data-theme="dark"] .compact-results-table {
    box-shadow: none;
}

[data-theme="dark"] .notation-table thead th,
[data-theme="dark"] .compact-results-table th {
    background: #1d2938;
    border-bottom: 1px solid var(--accent);
    color: #a6d2ff;
    font-weight: 600;
}

[data-theme="dark"] .notation-table td {
    border-bottom: 1px solid #242e3a;
}

/* Result / card internals: rely on slightly-lighter bg for depth rather than heavy borders */
[data-theme="dark"] .result-box,
[data-theme="dark"] .probability-result,
[data-theme="dark"] .conclusion-box,
[data-theme="dark"] .result-interpretation {
    border: none;
    box-shadow: none;
}

[data-theme="dark"] .stat-item {
    background: rgba(88, 166, 255, 0.04);
    border: 1px solid rgba(88, 166, 255, 0.1);
}

[data-theme="dark"] .compare-card,
[data-theme="dark"] .epi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    transition: border-color 0.2s ease;
}

[data-theme="dark"] .compare-card:hover,
[data-theme="dark"] .epi-card:hover {
    border-color: rgba(88, 166, 255, 0.4);
}

/* Footer: quieter */
[data-theme="dark"] footer,
[data-theme="dark"] .footer-container {
    background: transparent;
    border-top: 1px solid var(--border);
    box-shadow: none;
    color: var(--fg-muted);
    padding: 20px 0;
}

/* Light mode polish: reduce over-use of shadows that made the original feel heavy */
:root:not([data-theme="dark"]):not([data-theme="high-contrast"]) .section,
[data-theme="light"] .section {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(25, 118, 210, 0.08);
}

/* Subtle body gradient in dark for some depth without being distracting */
[data-theme="dark"] body {
    background: radial-gradient(ellipse at top, #121821 0%, #0a0e15 70%);
    min-height: 100vh;
}

/* Override card-prose text colours that were hardcoded to #333 */
[data-theme="dark"] .compare-card p,
[data-theme="dark"] .compare-divergence p,
[data-theme="dark"] .epi-card p,
[data-theme="dark"] .guide-case p,
[data-theme="dark"] .guide-walkthrough p,
[data-theme="dark"] .assm-verdict p,
[data-theme="dark"] .predict-form p,
[data-theme="dark"] .predict-reveal p,
[data-theme="dark"] .error-trap p,
[data-theme="dark"] .ds-context,
[data-theme="dark"] .dataset-context-banner .banner-context,
[data-theme="dark"] .three-level-body p,
[data-theme="dark"] .show-work-body p,
[data-theme="dark"] .dataset-card p,
[data-theme="dark"] .self-check-card p,
[data-theme="dark"] .check-question,
[data-theme="dark"] .check-explain { color: var(--fg); }

[data-theme="dark"] .compare-divergence h3,
[data-theme="dark"] .epi-card h4,
[data-theme="dark"] .compare-card h4,
[data-theme="dark"] .guide-case h4,
[data-theme="dark"] .guide-walkthrough h3,
[data-theme="dark"] .dataset-card h3,
[data-theme="dark"] .assm-verdict h3,
[data-theme="dark"] .error-trap h3 { color: var(--fg-heading); }

/* Error trap card tiles (scenario/looks-right/what's-wrong/fix) text */
[data-theme="dark"] .error-trap .trap-scenario,
[data-theme="dark"] .error-trap .trap-scenario strong,
[data-theme="dark"] .error-trap .trap-looks-right,
[data-theme="dark"] .error-trap .trap-looks-right strong,
[data-theme="dark"] .error-trap .trap-whats-wrong,
[data-theme="dark"] .error-trap .trap-whats-wrong strong,
[data-theme="dark"] .error-trap .trap-fix,
[data-theme="dark"] .error-trap .trap-fix strong { color: var(--fg); }

/* Instruction panels (bulleted lists on each page) */
[data-theme="dark"] .instruction-panel { background: var(--bg-subtle); color: var(--fg); border-left: 3px solid var(--accent); }
[data-theme="dark"] .instruction-panel h3 { color: var(--fg-heading); }
[data-theme="dark"] .instruction-panel li { color: var(--fg); }

/* "How to read this" box-style info-boxes in main body */
[data-theme="dark"] main .info-box { background: var(--bg-subtle); color: var(--fg); border-left: 3px solid var(--accent); }
[data-theme="dark"] main .info-box p,
[data-theme="dark"] main .info-box .info-content { color: var(--fg); }
[data-theme="dark"] main .info-box strong { color: var(--fg-heading); }

/* ---- High-contrast: third pass ---- */
[data-theme="high-contrast"] .calculator-container,
[data-theme="high-contrast"] .probability-result,
[data-theme="high-contrast"] .result-interpretation,
[data-theme="high-contrast"] .visualization-wrapper,
[data-theme="high-contrast"] .visualization-box,
[data-theme="high-contrast"] .instruction-panel,
[data-theme="high-contrast"] main .info-box { background: #ffffff; color: #000000; border: 2px solid #000000; }

[data-theme="high-contrast"] .probability-result .value { color: #0000cc; }

[data-theme="high-contrast"] .compare-card p,
[data-theme="high-contrast"] .compare-divergence p,
[data-theme="high-contrast"] .compare-divergence h3,
[data-theme="high-contrast"] .epi-card p,
[data-theme="high-contrast"] .guide-case p,
[data-theme="high-contrast"] .guide-walkthrough p,
[data-theme="high-contrast"] .predict-form p,
[data-theme="high-contrast"] .error-trap p,
[data-theme="high-contrast"] .ds-context,
[data-theme="high-contrast"] .three-level-body p,
[data-theme="high-contrast"] .show-work-body p,
[data-theme="high-contrast"] .dataset-card p,
[data-theme="high-contrast"] .instruction-panel li,
[data-theme="high-contrast"] main .info-box p { color: #000000; }

/* ---- High-contrast: second pass ---- */
[data-theme="high-contrast"] section,
[data-theme="high-contrast"] .section,
[data-theme="high-contrast"] .example-box,
[data-theme="high-contrast"] .info-panel,
[data-theme="high-contrast"] .report-preview-text,
[data-theme="high-contrast"] pre,
[data-theme="high-contrast"] table,
[data-theme="high-contrast"] .interpretation-details,
[data-theme="high-contrast"] .info-section,
[data-theme="high-contrast"] .conclusion-box,
[data-theme="high-contrast"] .probability-group,
[data-theme="high-contrast"] .application-item,
[data-theme="high-contrast"] .compare-summary table,
[data-theme="high-contrast"] .results-table,
[data-theme="high-contrast"] .results-table-container,
[data-theme="high-contrast"] .summary-stats-container,
[data-theme="high-contrast"] .trap-filter,
[data-theme="high-contrast"] .feature-icon { background: #ffffff; color: #000000; border: 2px solid #000000; }

[data-theme="high-contrast"] table th,
[data-theme="high-contrast"] .reference-table th { background: #000000; color: #ffffff; }
[data-theme="high-contrast"] table td { color: #000000; }

[data-theme="high-contrast"] #input-table input { background: #ffffff; color: #000000; border: 2px solid #000000; }

[data-theme="high-contrast"] .intro-card { background: #ffffff; color: #000000; border: 2px solid #000000; }
[data-theme="high-contrast"] .intro-card h2,
[data-theme="high-contrast"] .intro-card p { color: #000000; }

[data-theme="high-contrast"] a { color: #0000cc; text-decoration: underline; }
[data-theme="high-contrast"] a:hover { color: #000066; }

[data-theme="high-contrast"] .stat-label,
[data-theme="high-contrast"] .input-help,
[data-theme="high-contrast"] .ds-citation,
[data-theme="high-contrast"] .trap-citation,
[data-theme="high-contrast"] .sim-runtime,
[data-theme="high-contrast"] .sim-note,
[data-theme="high-contrast"] .compare-note,
[data-theme="high-contrast"] .three-level-intro { color: #000000; }

[data-theme="high-contrast"] .stat-value,
[data-theme="high-contrast"] .result-value,
[data-theme="high-contrast"] .probability-result .value,
[data-theme="high-contrast"] .interpretation-section h4,
[data-theme="high-contrast"] .guide-question,
[data-theme="high-contrast"] .result-title { color: #0000cc; }

[data-theme="high-contrast"] .conclusion-box { background: #ffff99; border: 2px solid #000000; }
[data-theme="high-contrast"] .cell-data .observed,
[data-theme="high-contrast"] .cell-data .expected,
[data-theme="high-contrast"] .cell-data .contribution { color: #000000; }

[data-theme="high-contrast"] footer,
[data-theme="high-contrast"] .footer-container { background: #000000; color: #ffffff; }
[data-theme="high-contrast"] .footer-container a { color: #ffffff; }

[data-theme="high-contrast"] .header-container .info-box { background: #ffff99; color: #000000; border: 2px solid #000000; }
[data-theme="high-contrast"] .header-container .info-box * { color: #000000; }

[data-theme="high-contrast"] .qq-plot circle { fill: #000000 !important; stroke: #000000 !important; }
[data-theme="high-contrast"] .sim-histogram rect { fill: #000000 !important; stroke: #000000 !important; }
[data-theme="high-contrast"] .qq-plot text,
[data-theme="high-contrast"] .sim-histogram text,
[data-theme="high-contrast"] .normal-curve text { fill: #000000; }

/* ================================================================
   High-contrast overrides (WCAG AAA).
   Pure black/white + strong blue accent; no gradients; bold borders.
   ================================================================ */
[data-theme="high-contrast"] body { background: var(--bg-page); color: var(--fg); }
[data-theme="high-contrast"] main { background: var(--bg-main); color: var(--fg); border: 2px solid var(--border); box-shadow: none; }

[data-theme="high-contrast"] h1, [data-theme="high-contrast"] h2, [data-theme="high-contrast"] h3,
[data-theme="high-contrast"] h4, [data-theme="high-contrast"] h5, [data-theme="high-contrast"] h6 { color: var(--fg-heading); }

[data-theme="high-contrast"] nav { background: var(--nav-bg); box-shadow: none; border: 2px solid var(--border); }
[data-theme="high-contrast"] .nav-bar li a { color: var(--nav-fg); }
[data-theme="high-contrast"] .nav-bar li a.active { background: #ffffff; color: #000000; box-shadow: inset 0 -3px 0 #000; }
[data-theme="high-contrast"] .nav-bar li a:not(.active):hover { background: var(--accent); }
[data-theme="high-contrast"] .nav-toggle { color: var(--nav-fg); }

[data-theme="high-contrast"] .header-container { background: var(--fg); color: var(--bg-main); }
[data-theme="high-contrast"] .header-container::before { display: none; }

[data-theme="high-contrast"] .info-box,
[data-theme="high-contrast"] .instruction-panel,
[data-theme="high-contrast"] .calc-card,
[data-theme="high-contrast"] .result-box,
[data-theme="high-contrast"] .stat-item,
[data-theme="high-contrast"] .visualization-box,
[data-theme="high-contrast"] .summary-stats-container,
[data-theme="high-contrast"] .compare-card,
[data-theme="high-contrast"] .compare-summary,
[data-theme="high-contrast"] .sim-summary,
[data-theme="high-contrast"] .sim-plot,
[data-theme="high-contrast"] .epi-card,
[data-theme="high-contrast"] .assm-stats,
[data-theme="high-contrast"] .assm-plot,
[data-theme="high-contrast"] .assm-conditions,
[data-theme="high-contrast"] .self-checks,
[data-theme="high-contrast"] .self-check-card,
[data-theme="high-contrast"] .three-level,
[data-theme="high-contrast"] .three-level-section,
[data-theme="high-contrast"] .guide-tree,
[data-theme="high-contrast"] .guide-case,
[data-theme="high-contrast"] .guide-walkthrough,
[data-theme="high-contrast"] .dataset-card,
[data-theme="high-contrast"] .error-trap,
[data-theme="high-contrast"] details.show-work { background: var(--bg-card); color: var(--fg); border: 2px solid var(--border); box-shadow: none; }

[data-theme="high-contrast"] input,
[data-theme="high-contrast"] textarea,
[data-theme="high-contrast"] select { background: var(--bg-main); color: var(--fg); border: 2px solid var(--border); }
[data-theme="high-contrast"] input:focus,
[data-theme="high-contrast"] textarea:focus { outline: 3px solid var(--accent); outline-offset: 1px; }

[data-theme="high-contrast"] .primary-button { background: var(--accent); color: #fff; border: 2px solid #000; }
[data-theme="high-contrast"] .secondary-button { background: #fff; color: #000; border: 2px solid #000; }
[data-theme="high-contrast"] .action-button { background: #fff; color: #000; border: 2px solid #000; box-shadow: none; }
[data-theme="high-contrast"] .card-button { background: var(--accent); color: #fff; border: 2px solid #000; }
[data-theme="high-contrast"] .trap-filter-btn { background: #fff; color: #000; border: 2px solid #000; }
[data-theme="high-contrast"] .trap-filter-btn.active { background: #000; color: #fff; }

[data-theme="high-contrast"] .verdict.reject { background: #ccffcc; color: #000; border: 2px solid #006600; }
[data-theme="high-contrast"] .verdict.fail { background: #ffffcc; color: #000; border: 2px solid #994400; }
[data-theme="high-contrast"] .assm-verdict.green { background: #ccffcc; color: #000; border: 2px solid #006600; }
[data-theme="high-contrast"] .assm-verdict.yellow { background: #ffffcc; color: #000; border: 2px solid #994400; }
[data-theme="high-contrast"] .assm-verdict.red { background: #ffcccc; color: #000; border: 2px solid #990000; }

[data-theme="high-contrast"] .notation-table thead th,
[data-theme="high-contrast"] .compact-results-table th { background: #000000; color: #ffffff; border-bottom: 3px solid #000; }
[data-theme="high-contrast"] .notation-table td,
[data-theme="high-contrast"] .compact-results-table td { border-bottom: 1px solid #000; color: #000; }
[data-theme="high-contrast"] .notation-table tr:hover td { background: #ffff99; }
[data-theme="high-contrast"] .notation-table td.sym { color: #000; }

[data-theme="high-contrast"] .ci-banner { background: #ccffcc; color: #000; border-left: 4px solid #006600; }
[data-theme="high-contrast"] .dataset-context-banner { background: #ffff99; color: #000; border-left: 4px solid #000; }
[data-theme="high-contrast"] .warning-message { background: #ffff99; color: #000; border-left: 4px solid #994400; }
[data-theme="high-contrast"] .compare-divergence { background: #ffff99; color: #000; border-left: 4px solid #000; }

[data-theme="high-contrast"] .error-trap .trap-scenario { background: #ffff99; color: #000; border-left: 4px solid #994400; }
[data-theme="high-contrast"] .error-trap .trap-looks-right { background: #ffffcc; color: #000; border-left: 4px solid #994400; }
[data-theme="high-contrast"] .error-trap .trap-whats-wrong { background: #ffcccc; color: #000; border-left: 4px solid #990000; }
[data-theme="high-contrast"] .error-trap .trap-fix { background: #ccffcc; color: #000; border-left: 4px solid #006600; }

[data-theme="high-contrast"] .three-level-section summary,
[data-theme="high-contrast"] .show-work-toggle { background: #000; color: #fff; border-radius: 0; }
[data-theme="high-contrast"] .show-work-math { background: #f0f0f0; color: #000; border: 1px solid #000; }
[data-theme="high-contrast"] .show-work-note { background: #ffff99; color: #000; border-left: 4px solid #000; }

/* Theme switcher (shown in nav). Visible on all themes. */
.theme-switcher {
    padding: 8px 12px;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: var(--nav-fg);
    font-size: 0.92em;
}

.theme-switcher select {
    background: transparent;
    color: var(--nav-fg);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.9em;
    min-height: 32px;
    cursor: pointer;
}

.theme-switcher select option {
    background: #fff;
    color: #000;
}

[data-theme="dark"] .theme-switcher select option { background: #161b22; color: #e6edf3; }
[data-theme="high-contrast"] .theme-switcher select option { background: #fff; color: #000; }

@media (max-width: 600px) {
    .theme-switcher {
        display: block;
        padding: 12px 20px;
        border-top: 1px solid rgba(255,255,255,0.15);
    }

    .theme-switcher select {
        width: 100%;
        min-height: 44px;
        margin-top: 6px;
    }
}

/* Print styles — produce a clean homework-submission view */
@media print {
    .no-print,
    nav,
    .button-group,
    .loading-spinner,
    .notification,
    .predict-panel,
    .self-check-card .check-reveal,
    .show-work-toggle,
    .instruction-panel,
    .info-box,
    .input-help {
        display: none !important;
    }

    body {
        padding: 0;
        margin: 0;
        color: #000;
        background: #fff;
        font-size: 11pt;
    }

    main {
        padding: 0 10mm;
    }

    h1, h2, h3, h4 {
        color: #000;
        page-break-after: avoid;
    }

    .header-container {
        border-bottom: 1px solid #000;
        padding-bottom: 5mm;
        margin-bottom: 5mm;
    }

    .results-table,
    .compact-results-table,
    .expected-table,
    .stats-grid,
    .result-box,
    .summary-stats-container,
    .interpretation-details,
    .show-work,
    .totals-section {
        page-break-inside: avoid;
    }

    .show-work {
        border: 1px solid #000;
        padding: 3mm;
        margin-top: 3mm;
        background: #f9f9f9;
    }

    .results-flex-container {
        display: block;
    }

    .visualization-box,
    .probability-group {
        box-shadow: none;
        border: 1px solid #999;
        background: #fff;
    }

    .normal-curve {
        max-width: 90mm;
    }

    .footer-container {
        border-top: 1px solid #000;
        margin-top: 10mm;
        padding-top: 3mm;
        font-size: 9pt;
    }

    a {
        color: #000;
        text-decoration: none;
    }

    /* Print URL after external links only */
    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 9pt;
    }

    .warning-message {
        border: 1px solid #e65100;
        background: #fff3e0;
        page-break-inside: avoid;
    }
}

/* Loading indicator */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.loading:after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #2196F3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Responsive enhancements */
@media (max-width: 768px) {
    .button-group {
        flex-direction: column;
    }

    .button-group button {
        width: 100%;
    }

    .results-table td {
        padding: 5px;
        font-size: 0.9em;
    }
}

/* Additional styles for new elements */
.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    color: #333;
    font-weight: 500;
}

.action-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fff;
    color: #333;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.action-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

.button-icon {
    font-size: 1.2em;
}

.warning {
    background: #fff3e0;
    color: #e65100;
}

.warning:hover {
    background: #ffe0b2;
}

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #2196F3;
    font-weight: 500;
}

.loading-spinner::after {
    content: '';
    width: 20px;
    height: 20px;
    margin-left: 10px;
    border: 2px solid #2196F3;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.info-panel {
    background: #e3f2fd;
    border-radius: 4px;
    padding: 15px;
    margin-top: 15px;
    display: none;
}

.info-panel.visible {
    display: block;
}

.table-container {
    overflow-x: auto;
    margin: 15px 0;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.primary-button {
    background: linear-gradient(to right, #2196F3, #64b5f6);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.primary-button:hover {
    background: linear-gradient(to right, #1976D2, #42A5F5);
    transform: translateY(-2px);
}

.secondary-button {
    background: #fff;
    color: #2196F3;
    border: 2px solid #2196F3;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-button:hover {
    background: #e3f2fd;
}

/* Styles for contingency info display */
.info-section {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.info-section .highlight {
    color: #1976d2;
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 10px;
}

.expected-frequencies {
    margin-top: 20px;
}

.expected-frequencies h3 {
    color: #1976d2;
    margin-bottom: 15px;
}

.table-wrapper {
    overflow-x: auto;
    margin: 15px 0;
}

.expected-table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.expected-table th,
.expected-table td {
    padding: 10px;
    border: 1px solid #dee2e6;
    text-align: center;
}

.expected-table th {
    background-color: #e3f2fd;
    color: #1976d2;
    font-weight: bold;
}

.totals-section {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
}

.totals-section h3 {
    color: #1976d2;
    margin-bottom: 15px;
}

.totals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 15px;
}

.row-totals,
.column-totals {
    background-color: white;
    padding: 15px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.row-totals h4,
.column-totals h4 {
    color: #1976d2;
    margin-bottom: 10px;
}

.row-totals ul,
.column-totals ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.row-totals li,
.column-totals li {
    padding: 5px 0;
    border-bottom: 1px solid #dee2e6;
}

.row-totals li:last-child,
.column-totals li:last-child {
    border-bottom: none;
}

/* Flex container for side-by-side layout */
.results-flex-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin-top: 20px;
}

.results-table-container {
    flex: 3;
    min-width: 0;
    /* Allows proper flex shrinking */
}

.summary-stats-container {
    flex: 2;
    min-width: 250px;
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Compact table styles */
.compact-results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    background-color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.compact-results-table th,
.compact-results-table td {
    padding: 8px;
    border: 1px solid #dee2e6;
    text-align: center;
}

.compact-results-table th {
    background-color: #e3f2fd;
    color: #1976d2;
    font-weight: bold;
    white-space: nowrap;
}

.cell-data {
    padding: 4px !important;
}

.cell-data .observed {
    font-weight: bold;
    color: #2196F3;
}

.cell-data .expected {
    font-size: 0.85em;
    color: #666;
}

.cell-data .contribution {
    font-size: 0.85em;
    color: #1976d2;
}

.conclusion-box {
    margin-top: 15px;
    padding: 10px;
    background-color: #e3f2fd;
    border-radius: 4px;
    color: #1976d2;
}

/* Responsive design */
@media (max-width: 768px) {
    .results-flex-container {
        flex-direction: column;
    }

    .summary-stats-container {
        width: 100%;
    }

    .compact-results-table {
        font-size: 0.8em;
    }
}

/* Legend for table values */
.results-legend {
    font-size: 0.8em;
    color: #666;
    margin-top: 10px;
    text-align: left;
}

.results-legend span {
    margin-right: 15px;
}

/* Instruction panels */
.instruction-panel {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #2196F3;
}

.instruction-panel h3 {
    color: #1976d2;
    margin-top: 0;
    margin-bottom: 10px;
}

.instruction-panel ul {
    margin: 0;
    padding-left: 20px;
}

.instruction-panel li {
    margin-bottom: 5px;
}

/* Example and info boxes */
.example-box,
.data-tips,
.significance-info,
.interpretation-guide {
    background-color: #e3f2fd;
    padding: 12px;
    border-radius: 6px;
    margin-top: 15px;
}

.info-box {
    background-color: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Input help text */
.input-help {
    display: block;
    font-size: 0.85em;
    color: #666;
    margin-top: 4px;
}






/* Tooltips */
[title] {
    position: relative;
    cursor: help;
}

/* Section transitions */
.section {
    transition: all 0.3s ease;
}

.section:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Footer notes */
.footer-notes {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}

.footer-notes ul {
    columns: 2;
    column-gap: 40px;
    margin: 10px 0;
    padding-left: 0;
    list-style-position: inside;
    /* Ensures bullets align with text */
}

.footer-notes li {
    margin-bottom: 8px;
    padding-left: 1.5em;
    /* Creates space for the bullet point */
    text-indent: -1.5em;
    /* Pulls the bullet point into the padding space */
    break-inside: avoid;
    /* Prevents items from breaking across columns */
}

/* For smaller screens, switch to single column */
@media (max-width: 768px) {
    .footer-notes ul {
        columns: 1;
    }

    .footer-notes li {
        margin-bottom: 10px;
    }
}

/* Footer container - ensure proper contrast */
.footer-container {
    background-color: #333;
    color: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    margin-top: 30px;
    font-size: 0.9em;
}

.footer-container p {
    margin: 10px 0;
    font-weight: 200;
    font-size: 1em;
}

/* Make the note text stand out */
.footer-notes p strong {
    color: #fff;
    font-weight: 600;
}

/* Calculator container styles */
.calculator-container {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
}

.result-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #1976d2;
    margin: 10px 0;
}

.result-interpretation {
    color: #555;
    line-height: 1.6;
    margin-top: 10px;
}

/* Input validation styles */
input:invalid {
    border-color: #dc3545;
}

input:invalid+.input-help {
    color: #dc3545;
}

/* Reference table styles */
.reference-table {
    margin-top: 20px;
}

.reference-table th {
    background-color: #e3f2fd;
}

.reference-table td {
    text-align: center;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .calculator-container {
        padding: 15px;
    }

    .result-value {
        font-size: 1.2em;
    }
}

/* Updated visualization container styles for vertical layout */
.visualizations-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 20px auto;
    max-width: 500px;
    /* Control maximum width for better readability */
}

.visualization-box {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.visualization-box h4 {
    color: #1976d2;
    margin: 0 0 10px 0;
    font-size: 1.1em;
    font-weight: 500;
}

.visualization-box p {
    margin: 10px 0 0 0;
    color: #555;
    font-weight: 500;
}

.normal-curve {
    background-color: #fff;
    border-radius: 4px;
    margin: 10px auto;
    display: block;
    width: 100%;
    max-width: 400px;
    height: auto;
}

/* Container for each visualization group */
.probability-group {
    border-left: 3px solid #1976d2;
    padding-left: 15px;
    margin: 10px 0;
    background-color: #f8f9fa;
    border-radius: 0 8px 8px 0;
}

/* Add dividers between visualizations */
.visualization-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, #e0e0e0, transparent);
    margin: 10px 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .visualizations-container {
        padding: 10px;
    }

    .visualization-box {
        padding: 15px;
    }
}

/* Optional: Add smooth transitions for any updates */
.visualization-box {
    transition: all 0.3s ease;
}

/* Optional: Hover effect for visualization boxes */
.visualization-box:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

/* Results section styling */
.results-section {
    margin-top: 20px;
}

.result-group {
    margin-bottom: 20px;
}

.result-box {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.result-title {
    color: #1976d2;
    margin: 0 0 15px 0;
    font-size: 1.2em;
    font-weight: 600;
}

.probability-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 10px 0;
    padding: 10px;
    background-color: white;
    border-radius: 4px;
}

.probability-result .label {
    font-weight: 500;
    color: #333;
}

.probability-result .value {
    font-size: 1.2em;
    font-weight: 600;
    color: #1976d2;
}

.result-interpretation {
    margin-top: 15px;
    padding: 15px;
    background-color: white;
    border-radius: 4px;
    line-height: 1.6;
}

/* Visualization section */
.visualization-wrapper {
    margin-top: 30px;
}

.visualization-wrapper h3 {
    color: #1976d2;
    margin-bottom: 20px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .probability-result {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .probability-result .value {
        align-self: flex-end;
    }
}

/* Enhanced interpretation styles */
.interpretation-details {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
}

.interpretation-section {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.interpretation-section:last-child {
    border-bottom: none;
}

.interpretation-section h4 {
    color: #1976d2;
    margin: 0 0 15px 0;
    font-size: 1.1em;
    font-weight: 600;
}

.interpretation-section h5 {
    color: #333;
    margin: 0 0 10px 0;
    font-size: 1em;
    font-weight: 600;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.stat-item {
    background-color: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-label {
    color: #666;
    font-size: 0.9em;
    font-weight: 500;
}

.stat-value {
    color: #1976d2;
    font-weight: 600;
    font-size: 1.1em;
}

.applications-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 15px;
}

.application-item {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border-left: 3px solid #1976d2;
}

.application-item ul {
    margin: 10px 0 0 0;
    padding-left: 20px;
}

.application-item li {
    margin: 5px 0;
    color: #555;
}

/* List styling */
.interpretation-section ul {
    margin: 0;
    padding-left: 20px;
}

.interpretation-section li {
    margin: 8px 0;
    color: #555;
    line-height: 1.4;
}

/* Responsive adjustments */
@media (max-width: 768px) {

    .stats-grid,
    .applications-grid {
        grid-template-columns: 1fr;
    }

    .interpretation-section {
        padding: 15px;
    }

    .stat-item {
        padding: 10px;
    }
}

/* Highlight important values */
.highlight-value {
    color: #1976d2;
    font-weight: 600;
}

/* Add these styles to your existing CSS */

/* Introduction Card Styles */
.intro-card {
    grid-column: 1 / -1;
    /* Spans full width */
    background: linear-gradient(135deg, #1976d2, #64b5f6);
    color: white;
    padding: 25px;
}

.intro-card h2 {
    color: white;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.feature-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    text-align: left;
}

.feature-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.feature-icon {
    font-size: 1.5em;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
}

.feature-item p {
    margin: 0;
    line-height: 1.4;
    padding-top: 8px;
}

/* Enhanced Calculator Cards */
.calculator-cards {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    /* Reduced from 280px */
    gap: 15px;
    /* Reduced from 20px */
    padding: 15px;
    /* Reduced from 20px */
    max-width: 1200px;
    margin: 0 auto;
}

.calc-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.calc-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.calc-card h2 {
    color: #1976d2;
    margin: 0 0 15px 0;
    font-size: 1.2em;
}

.calc-card p {
    color: #666;
        margin-bottom: 15px;
        /* Reduced from 20px */
    line-height: 1.4;
    /* Reduced from 1.5 */
    font-size: 0.9em;
    /* Added to reduce text size */
}

.card-button {
    display: inline-block;
    padding: 10px 20px;
    background: #1976d2;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.3s ease;
    font-weight: 500;
    font-size: 0.9em;
    /* Added to reduce button text size */
    margin-top: 10px;
    /* Added to control spacing */
}

.card-button:hover {
    background: #1565c0;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .feature-list {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .intro-card {
        padding: 20px;
    }
}

/* Add these styles to your existing info-box section */
.info-box .key-features {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(25, 118, 210, 0.1);
}

.info-box .key-features ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.info-box .key-features li {
    position: relative;
    padding-left: 24px;
    margin-bottom: 8px;
    color: #333;
    font-size: 0.95em;
    line-height: 1.4;
}

.info-box .key-features li:before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #1976d2;
    font-weight: bold;
}

.info-box .info-content {
    display: block;
    margin-bottom: 12px;
    color: #666;
    line-height: 1.5;
}

/* ===== Compare page ===== */
.compare-grid {
    display: grid;
    gap: 20px;
}

.compare-summary {
    padding: 15px;
    background: #fbfbfd;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
}

.compare-summary h3 {
    margin: 0 0 10px 0;
    color: #1976d2;
}

.compare-meta {
    margin: 10px 0 0 0;
    font-size: 0.93em;
    color: #444;
}

.compare-tests {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 15px;
}

.compare-card {
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.compare-card h4 {
    margin: 0 0 8px 0;
    color: #1976d2;
    font-size: 1em;
    font-weight: 600;
}

.compare-card p {
    margin: 5px 0;
    line-height: 1.45;
    color: #333;
}

.compare-card .compare-note {
    margin-top: 10px;
    font-size: 0.88em;
    color: #666;
    border-top: 1px dashed #e0e0e0;
    padding-top: 8px;
}

.verdict {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.95em;
}

.verdict.reject {
    background: #e8f5e9;
    color: #1b5e20;
    border: 1px solid #a5d6a7;
}

.verdict.fail {
    background: #fff3e0;
    color: #bf360c;
    border: 1px solid #ffcc80;
}

.compare-divergence {
    padding: 14px 16px;
    background: #f1f8ff;
    border-left: 4px solid #1976d2;
    border-radius: 0 8px 8px 0;
}

.compare-divergence h3 {
    margin: 0 0 8px 0;
    color: #1565c0;
    font-size: 1.05em;
}

.compare-divergence p {
    margin: 8px 0;
    line-height: 1.55;
    color: #333;
}

/* ===== Simulation page ===== */
.sim-result {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.4fr);
    gap: 20px;
    margin-top: 10px;
}

@media (max-width: 800px) {
    .sim-result {
        grid-template-columns: 1fr;
    }
}

.sim-summary {
    padding: 14px 16px;
    background: #fbfbfd;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
}

.sim-summary h3 {
    margin: 0 0 10px 0;
    color: #1976d2;
    font-size: 1.05em;
}

.sim-runtime {
    margin: 10px 0 0 0;
    color: #888;
    font-size: 0.85em;
    font-style: italic;
}

.sim-note {
    margin: 4px 0 10px 0;
    color: #555;
    line-height: 1.4;
}

/* Dataset library cards */
.dataset-list {
    display: grid;
    gap: 20px;
}

.dataset-card {
    padding: 18px 20px;
    background: #fbfbfd;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.dataset-card h3 {
    margin: 0 0 4px 0;
    color: #1976d2;
    font-size: 1.08em;
}

.ds-year {
    color: #888;
    font-weight: 400;
    font-size: 0.9em;
    margin-left: 6px;
}

.ds-tag {
    display: inline-block;
    padding: 1px 6px;
    background: #fff3e0;
    color: #bf360c;
    font-size: 0.75em;
    font-weight: 600;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 4px;
}

.ds-citation {
    color: #666;
    font-size: 0.9em;
    margin: 4px 0 10px 0;
}

.ds-context {
    color: #333;
    line-height: 1.55;
    margin: 8px 0;
}

.ds-learn {
    margin: 10px 0;
    padding: 8px 12px;
    background: #f1f8ff;
    border-left: 3px solid #1976d2;
    border-radius: 0 4px 4px 0;
    color: #1565c0;
    font-size: 0.95em;
}

.dataset-card .button-group {
    margin-top: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

/* Assumption Coach */
.assm-result {
    display: grid;
    grid-template-columns: minmax(320px, 1.1fr) minmax(300px, 1fr);
    gap: 20px;
}

@media (max-width: 820px) {
    .assm-result {
        grid-template-columns: 1fr;
    }
}

.assm-plot {
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    padding: 10px;
}

.qq-plot {
    display: block;
    width: 100%;
    max-width: 560px;
    height: auto;
    margin: 0 auto;
}

.assm-stats, .assm-conditions {
    padding: 14px 16px;
    background: #fbfbfd;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    margin-top: 14px;
}

.assm-stats:first-child, .assm-left > .assm-stats {
    margin-top: 14px;
}

.assm-stats h3, .assm-conditions h3 {
    margin: 0 0 8px 0;
    color: #1976d2;
    font-size: 1em;
}

.assm-verdict {
    padding: 14px 16px;
    border-radius: 8px;
    border-left: 4px solid;
}

.assm-verdict h3 {
    margin: 0 0 6px 0;
    font-size: 1.05em;
}

.assm-verdict.green {
    background: #e8f5e9;
    border-left-color: #2e7d32;
    color: #1b5e20;
}

.assm-verdict.yellow {
    background: #fff8e1;
    border-left-color: #f57f17;
    color: #6d4c00;
}

.assm-verdict.red {
    background: #ffebee;
    border-left-color: #c62828;
    color: #9a1012;
}

.assm-conditions ul {
    margin: 6px 0 0 0;
    padding-left: 22px;
    line-height: 1.5;
}

/* Notation Translator tables */
.notation-table-wrap {
    overflow-x: auto;
    margin: 12px 0;
    border-radius: 8px;
    border: 1px solid #e1e4e8;
}

.notation-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 0.92em;
}

.notation-table thead th {
    position: sticky;
    top: 0;
    background: #e3f2fd;
    color: #0d47a1;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #1976d2;
}

.notation-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #eaecef;
    vertical-align: top;
    line-height: 1.45;
}

.notation-table tr:hover td {
    background: #f7faff;
}

.notation-table td.sym {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.15em;
    color: #0d47a1;
    font-weight: 600;
    min-width: 70px;
}

.notation-table code {
    background: #f0f4f8;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.9em;
}

/* Error Traps page */
.trap-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 12px 14px;
    background: #fbfbfd;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
}

.trap-filter-btn {
    padding: 6px 12px;
    border: 1px solid #c5cdd6;
    background: #fff;
    color: #1976d2;
    font-size: 0.9em;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.trap-filter-btn:hover {
    background: #e3f2fd;
}

.trap-filter-btn.active {
    background: #1976d2;
    color: #fff;
    border-color: #1565c0;
}

.trap-list {
    display: grid;
    gap: 16px;
    margin-top: 14px;
}

.error-trap {
    padding: 16px 18px;
    background: #fff;
    border: 1px solid #e1e4e8;
    border-left: 4px solid #c62828;
    border-radius: 0 8px 8px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.error-trap h3 {
    margin: 0 0 10px 0;
    color: #9a1012;
    font-size: 1.05em;
}

.error-trap p {
    margin: 6px 0;
    line-height: 1.55;
    color: #333;
}

.error-trap .trap-scenario { background: #fff3e0; padding: 8px 10px; border-radius: 4px; border-left: 3px solid #f57f17; }
.error-trap .trap-looks-right { background: #fffde7; padding: 8px 10px; border-radius: 4px; border-left: 3px solid #fbc02d; }
.error-trap .trap-whats-wrong { background: #ffebee; padding: 8px 10px; border-radius: 4px; border-left: 3px solid #c62828; }
.error-trap .trap-fix { background: #e8f5e9; padding: 8px 10px; border-radius: 4px; border-left: 3px solid #2e7d32; }

.error-trap .trap-citation {
    font-size: 0.85em;
    color: #666;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed #e0e0e0;
}

/* Three-Level Interpretation */
.three-level {
    margin-top: 16px;
    padding: 14px 18px;
    background: #fbfbfd;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
}

.three-level h3 {
    margin: 0 0 4px 0;
    color: #1976d2;
    font-size: 1.05em;
}

.three-level-intro {
    margin: 0 0 12px 0;
    color: #666;
    font-size: 0.92em;
}

.three-level-section {
    margin: 8px 0;
    padding: 0;
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
}

.three-level-section summary {
    cursor: pointer;
    padding: 10px 14px;
    background: #eef4fa;
    color: #0d47a1;
    border-radius: 6px;
    user-select: none;
    list-style: none;
}

.three-level-section summary::-webkit-details-marker {
    display: none;
}

.three-level-section summary small {
    color: #666;
    font-weight: 400;
    margin-left: 6px;
    font-size: 0.85em;
}

.three-level-section[open] summary {
    border-radius: 6px 6px 0 0;
}

.three-level-body {
    padding: 10px 16px 14px 16px;
    line-height: 1.55;
    color: #333;
}

.three-level-body p {
    margin: 6px 0;
}

/* Inline dataset-context banner (shown at the top of a calculator after dataset handoff) */
.dataset-context-banner {
    position: relative;
    margin: 10px 0 18px 0;
    padding: 14px 44px 14px 18px;
    background: linear-gradient(135deg, #e3f2fd 0%, #f3faff 100%);
    border-left: 4px solid #1976d2;
    border-radius: 0 8px 8px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.dataset-context-banner .banner-kicker {
    text-transform: uppercase;
    font-size: 0.72em;
    letter-spacing: 0.05em;
    color: #1565c0;
    font-weight: 700;
    margin-bottom: 2px;
}

.dataset-context-banner .banner-title {
    margin: 0 0 6px 0;
    color: #0d47a1;
    font-size: 1.05em;
}

.dataset-context-banner .banner-citation {
    margin: 2px 0 8px 0;
    color: #666;
    font-size: 0.88em;
}

.dataset-context-banner .banner-context {
    margin: 6px 0;
    color: #1a1a1a;
    line-height: 1.5;
    font-size: 0.95em;
}

.dataset-context-banner .banner-learn {
    margin: 8px 0 0 0;
    padding: 8px 10px;
    background: rgba(25, 118, 210, 0.09);
    border-radius: 4px;
    color: #0d47a1;
    font-size: 0.9em;
    line-height: 1.45;
}

.banner-dismiss {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #1565c0;
    font-size: 1.4em;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
}

.banner-dismiss:hover {
    background: rgba(13, 71, 161, 0.1);
}

/* Guide page */
.guide-tree {
    padding: 14px 16px;
    background: #fbfbfd;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
}

.guide-question {
    color: #1976d2;
    font-size: 1.05em;
    margin-bottom: 10px;
}

.guide-branch {
    display: grid;
    gap: 14px;
}

.guide-case {
    padding: 12px 14px;
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    border-left: 3px solid #1976d2;
}

.guide-case h4 {
    margin: 0 0 6px 0;
    color: #1976d2;
    font-size: 1em;
}

.guide-case h4 small {
    color: #666;
    font-weight: 400;
    font-size: 0.88em;
    margin-left: 4px;
}

.guide-case p { margin: 6px 0; line-height: 1.5; color: #333; }

.guide-options {
    margin: 8px 0 0 0;
    padding-left: 20px;
    line-height: 1.6;
}

.guide-walkthrough {
    padding: 14px 18px;
    margin: 14px 0;
    background: #fbfbfd;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
}

.guide-walkthrough h3 {
    margin: 0 0 8px 0;
    color: #1976d2;
    font-size: 1.08em;
}

.guide-walkthrough ol { line-height: 1.6; margin: 6px 0; padding-left: 22px; }

.guide-walkthrough p { margin: 8px 0; line-height: 1.55; color: #333; }

.guide-walkthrough details { margin: 10px 0; }

/* CI-first banner on the t-calculator when raw data is provided */
.ci-banner {
    background: #e8f5e9;
    border-left: 4px solid #2e7d32;
    padding: 10px 14px;
    margin: 10px 0;
    border-radius: 0 6px 6px 0;
    color: #1b5e20;
}

.sim-plot {
    padding: 10px;
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.sim-histogram {
    display: block;
    width: 100%;
    max-width: 640px;
    height: auto;
    margin: 0 auto;
}

/* ===== Epidemiology 2×2 page ===== */
.epi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.epi-card {
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.epi-card h4 {
    margin: 0 0 6px 0;
    color: #1976d2;
    font-size: 1em;
    font-weight: 600;
}

.epi-card p {
    margin: 4px 0;
    color: #333;
    line-height: 1.45;
}

.epi-card .epi-value {
    font-weight: 600;
    color: #1b5e20;
    font-size: 1.05em;
}

.epi-card .epi-value small {
    color: #666;
    font-weight: 400;
}

.epi-card .epi-note {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px dashed #e0e0e0;
    font-size: 0.88em;
    color: #666;
}

/* Warning banner for low expected frequencies (chi-square assumption) */
.warning-message {
    margin-top: 15px;
    padding: 12px 15px;
    background-color: #fff3e0;
    border-left: 4px solid #e65100;
    border-radius: 4px;
    color: #5a2a00;
    font-size: 0.95em;
    line-height: 1.5;
}

.warning-message strong {
    color: #e65100;
}

/* Embed mode — hide chrome when loaded inside an LMS iframe (?embed=1) */
body.embed-mode nav,
body.embed-mode > footer,
body.embed-mode .footer-container,
body.embed-mode .header-container {
    display: none;
}

body.embed-mode main {
    padding-top: 10px;
}

/* ===== Phase 1: Learning Mode toggle ===== */
.learning-mode-toggle {
    display: inline-block;
    margin: 10px 0;
    padding: 8px 12px;
    background: #f1f8ff;
    border: 1px solid #b5d4fb;
    border-radius: 6px;
    font-size: 0.95em;
}

.learning-mode-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #1565c0;
}

.learning-mode-switch input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ===== Phase 1: Predict-Then-Reveal dialog ===== */
dialog.predict-dialog {
    border: none;
    border-radius: 10px;
    padding: 0;
    max-width: 520px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    color: #222;
}

dialog.predict-dialog::backdrop {
    background: rgba(0, 0, 0, 0.45);
}

.predict-form {
    padding: 22px 24px;
}

.predict-form h3 {
    margin: 0 0 10px 0;
    color: #1976d2;
}

.predict-form p {
    margin: 8px 0;
    color: #333;
    line-height: 1.45;
}

.predict-question {
    background: #f7faff;
    border-left: 3px solid #1976d2;
    padding: 10px 12px;
    border-radius: 0 4px 4px 0;
}

.predict-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 16px 0 8px 0;
}

.predict-footnote {
    font-size: 0.85em;
    color: #666;
    margin-top: 14px;
    border-top: 1px dashed #ddd;
    padding-top: 10px;
}

.predict-reveal {
    margin: 12px 0;
    padding: 12px 14px;
    border-radius: 6px;
    border-left: 4px solid transparent;
}

.predict-reveal.matched {
    background: #e8f5e9;
    border-left-color: #2e7d32;
}

.predict-reveal.mismatched {
    background: #fff3e0;
    border-left-color: #e65100;
}

.predict-reveal p {
    margin: 4px 0;
}

.predict-prompt {
    color: #555;
    font-style: italic;
}

/* ===== Phase 1: Formative self-check cards ===== */
.self-checks {
    margin-top: 24px;
    padding: 16px 18px;
    background: #fafbfd;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
}

.self-checks h3 {
    margin: 0 0 6px 0;
    color: #1976d2;
    font-size: 1.05em;
}

.self-check-intro {
    margin: 0 0 14px 0;
    color: #666;
    font-size: 0.9em;
}

.self-check-card {
    padding: 12px 14px;
    margin-bottom: 10px;
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
}

.self-check-card:last-child {
    margin-bottom: 0;
}

.self-check-card.correct {
    border-color: #a5d6a7;
    background: #f1f8f2;
}

.self-check-card.incorrect {
    border-color: #ffcc80;
    background: #fff8f1;
}

.check-question {
    margin: 0 0 10px 0;
    color: #333;
    line-height: 1.45;
}

.check-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.check-buttons button {
    min-width: 90px;
}

.check-buttons button.is-correct-answer {
    border-color: #2e7d32 !important;
    background: #c8e6c9 !important;
    color: #1b5e20;
}

.check-buttons button.is-wrong-answer {
    border-color: #e65100 !important;
    background: #ffccbc !important;
    color: #bf360c;
}

.check-reveal {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #ddd;
    color: #333;
    font-size: 0.93em;
    line-height: 1.5;
}

.check-reveal p {
    margin: 4px 0;
}

.check-source {
    color: #777;
    font-size: 0.85em;
}

/* ===== Phase 1: Show-Work mode ===== */
details.show-work {
    margin-top: 18px;
    padding: 0;
    background: #fbfbfd;
    border: 1px solid #d8d8e0;
    border-radius: 8px;
    overflow: hidden;
}

details.show-work[open] {
    background: #fff;
}

.show-work-toggle {
    cursor: pointer;
    padding: 10px 14px;
    background: #eef2f9;
    color: #1976d2;
    font-weight: 600;
    user-select: none;
    list-style: none;
}

.show-work-toggle::-webkit-details-marker {
    display: none;
}

.show-work-toggle::before {
    content: "▶ ";
    display: inline-block;
    transform: rotate(0deg);
    transition: transform 0.2s ease;
}

details[open] .show-work-toggle::before {
    transform: rotate(90deg);
}

.show-work-body {
    padding: 14px 18px;
}

.show-work-body h4 {
    color: #1976d2;
    margin: 14px 0 6px 0;
    font-size: 1em;
}

.show-work-body h4:first-child {
    margin-top: 0;
}

.show-work-body p {
    margin: 6px 0;
    line-height: 1.55;
    color: #333;
}

.show-work-math {
    margin: 10px 0;
    padding: 6px 10px;
    background: #f5f5f8;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 1.05em;
}

.show-work-list {
    margin: 6px 0 10px 20px;
}

.show-work-note {
    margin-top: 12px;
    padding: 8px 10px;
    background: #fff9e6;
    border-left: 3px solid #ffb300;
    border-radius: 0 4px 4px 0;
    font-size: 0.93em;
    color: #5a4400;
}

/* ===== Phase 1: Report (APA / AMA) buttons ===== */
.report-buttons {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.report-preview {
    flex: 1 1 100%;
    margin-top: 6px;
    font-size: 0.9em;
    color: #555;
}

.report-preview summary {
    cursor: pointer;
    color: #1976d2;
}

.report-preview-text {
    white-space: pre-wrap;
    background: #f5f5f8;
    padding: 10px;
    border-radius: 4px;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.9em;
    margin-top: 6px;
    line-height: 1.5;
}

@media (max-width: 520px) {
    .predict-choices {
        flex-direction: column;
    }

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

/* ------------------------------------------------------------------ *
 * corrections.html — Multiple-comparisons corrections + inflation viz
 * ------------------------------------------------------------------ */

.corrections-table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.corrections-table th,
.corrections-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.95em;
}

.corrections-table th {
    background: var(--bg-subtle, #f5f7fa);
    color: var(--fg-heading);
    font-weight: 600;
}

.corrections-table td.cell-reject {
    background: rgba(46, 125, 50, 0.10);
    color: #1b5e20;
    font-weight: 600;
}

.corrections-table td.cell-retain {
    color: var(--fg);
}

.corrections-table td.cell-methods {
    color: var(--fg-muted);
    font-size: 0.88em;
}

[data-theme="dark"] .corrections-table th {
    background: var(--bg-subtle);
    color: var(--fg-heading);
}

[data-theme="dark"] .corrections-table td.cell-reject {
    background: rgba(102, 187, 106, 0.18);
    color: #a5d6a7;
}

[data-theme="high-contrast"] .corrections-table td.cell-reject {
    background: #000;
    color: #ffff00;
    outline: 2px solid #ffff00;
    outline-offset: -2px;
}

.legend-chip {
    display: inline-block;
    width: 14px;
    height: 14px;
    vertical-align: middle;
    border-radius: 3px;
    margin: 0 4px 0 8px;
}

.legend-chip.legend-sig {
    background: rgba(46, 125, 50, 0.35);
}

.legend-chip.legend-uncorrected {
    background: #d32f2f;
}

.legend-chip.legend-bonf {
    background: #1976d2;
}

.legend-chip.legend-marker {
    background: #ffb300;
    border-radius: 50%;
}

.section-summary {
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--accent-bg);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
    color: var(--fg);
}

.viz-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin-bottom: 12px;
    padding: 10px 14px;
    background: var(--bg-subtle, #f5f7fa);
    border-radius: 6px;
}

.viz-controls label {
    font-weight: 600;
    color: var(--fg-heading);
}

.viz-controls input[type="range"] {
    flex: 1 1 200px;
    min-width: 160px;
    max-width: 360px;
    accent-color: var(--accent);
}

.viz-controls output {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--accent-deep);
    min-width: 48px;
}

.viz-legend {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    font-size: 0.9em;
    color: var(--fg-muted);
}

[data-theme="dark"] .viz-controls {
    background: var(--bg-subtle);
}

[data-theme="dark"] .viz-controls output {
    color: var(--accent-deep);
}

.viz-chart-wrap {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
}

#inflationChart {
    width: 100%;
    height: auto;
    display: block;
}

.chart-bg {
    fill: var(--bg-card);
    stroke: var(--border);
    stroke-width: 1;
}

.chart-grid {
    stroke: var(--border);
    stroke-width: 1;
    stroke-dasharray: 2 3;
    opacity: 0.6;
}

.chart-label-x,
.chart-label-y,
.chart-axis-title {
    fill: var(--fg-muted);
    font-size: 12px;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.chart-axis-title {
    fill: var(--fg);
    font-weight: 600;
}

.chart-curve {
    fill: none;
    stroke-width: 2.5;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.chart-curve-uncorrected {
    stroke: #d32f2f;
}

.chart-curve-bonf {
    stroke: #1976d2;
}

[data-theme="dark"] .chart-curve-uncorrected {
    stroke: #ef5350;
}

[data-theme="dark"] .chart-curve-bonf {
    stroke: #64b5f6;
}

.chart-alpha-line {
    stroke: var(--fg-subtle);
    stroke-width: 1;
    stroke-dasharray: 5 4;
}

.chart-alpha-label {
    fill: var(--fg-muted);
    font-size: 11px;
    font-style: italic;
}

.chart-user-marker {
    fill: #ffb300;
    stroke: #fff;
    stroke-width: 2;
}

.chart-user-line {
    stroke: #ffb300;
    stroke-width: 1;
    stroke-dasharray: 3 3;
    opacity: 0.7;
}

.chart-user-label {
    fill: #ff8f00;
    font-size: 12px;
    font-weight: 600;
}

[data-theme="dark"] .chart-user-marker {
    fill: #ffca28;
    stroke: var(--bg-card);
}

[data-theme="dark"] .chart-user-label {
    fill: #ffca28;
}

[data-theme="high-contrast"] .chart-curve-uncorrected {
    stroke: #ff6666;
}

[data-theme="high-contrast"] .chart-curve-bonf {
    stroke: #66d9ff;
}

[data-theme="high-contrast"] .chart-user-marker {
    fill: #ffff00;
    stroke: #000;
}

.viz-caption {
    margin-top: 10px;
    color: var(--fg-muted);
    font-size: 0.92em;
}

.method-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin: 16px 0;
}

.method-card {
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 6px;
}

.method-card h3 {
    margin: 0 0 8px 0;
    color: var(--fg-heading);
    font-size: 1.05em;
}

.method-card p {
    margin: 4px 0;
    font-size: 0.92em;
    line-height: 1.45;
    color: var(--fg);
}

.method-card .method-formula {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    padding: 6px 8px;
    background: var(--bg-subtle, #f5f7fa);
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--fg-heading);
}

[data-theme="dark"] .method-card .method-formula {
    background: var(--bg-subtle);
}

.inline-math {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    padding: 1px 6px;
    background: var(--accent-bg);
    border-radius: 3px;
    color: var(--accent-deep);
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}

.input-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 10px 0;
}

.input-group-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-group-inline label {
    margin: 0;
    white-space: nowrap;
}

@media (max-width: 520px) {
    .viz-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .viz-legend {
        justify-content: center;
    }
}

/* ------------------------------------------------------------------ *
 * AI Interpreter (opt-in, feature-detected, shown inline with results)
 * ------------------------------------------------------------------ */

.ai-interpret-block {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}

.ai-interpret-button {
    background: linear-gradient(135deg, #7b1fa2 0%, #4527a0 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 0.92em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ai-interpret-button:hover:not([disabled]) {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(123, 31, 162, 0.3);
}

.ai-interpret-button[disabled] {
    background: var(--fg-subtle);
    cursor: not-allowed;
    opacity: 0.6;
}

.ai-interpret-body {
    margin-top: 10px;
}

.ai-interpret-body[hidden] {
    display: none;
}

.ai-interpret-loading {
    color: var(--fg-muted);
    font-style: italic;
}

.ai-interpret-result {
    padding: 14px 16px;
    background: rgba(123, 31, 162, 0.05);
    border: 1px solid rgba(123, 31, 162, 0.2);
    border-left: 4px solid #7b1fa2;
    border-radius: 6px;
    color: var(--fg);
}

.ai-interpret-result p {
    margin: 6px 0;
    line-height: 1.5;
}

.ai-interpret-badge {
    display: inline-block;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #7b1fa2;
    background: rgba(123, 31, 162, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.ai-interpret-note {
    margin-top: 10px !important;
    font-size: 0.85em;
    color: var(--fg-muted);
    font-style: italic;
}

.ai-interpret-error {
    padding: 10px 14px;
    background: rgba(198, 40, 40, 0.08);
    border-left: 3px solid #c62828;
    border-radius: 4px;
    color: #b71c1c;
}

[data-theme="dark"] .ai-interpret-result {
    background: rgba(186, 104, 200, 0.08);
    border-color: rgba(186, 104, 200, 0.3);
    border-left-color: #ba68c8;
}

[data-theme="dark"] .ai-interpret-badge {
    color: #ce93d8;
    background: rgba(186, 104, 200, 0.18);
}

[data-theme="dark"] .ai-interpret-button {
    background: linear-gradient(135deg, #9c4dcc 0%, #6a1b9a 100%);
}

[data-theme="dark"] .ai-interpret-error {
    background: rgba(239, 83, 80, 0.12);
    color: #ef9a9a;
    border-left-color: #ef5350;
}

[data-theme="high-contrast"] .ai-interpret-button {
    background: #000;
    color: #ffff00;
    border: 2px solid #ffff00;
}

[data-theme="high-contrast"] .ai-interpret-result {
    background: #000;
    color: #ffff00;
    border: 2px solid #ffff00;
}

[data-theme="high-contrast"] .ai-interpret-badge {
    background: #ffff00;
    color: #000;
}

/* ------------------------------------------------------------------ *
 * Student problem overlay (shown when ?problem=<token> is present)
 * ------------------------------------------------------------------ */

.problem-overlay {
    position: sticky;
    top: 0;
    z-index: 90;
    margin: 0 auto 16px auto;
    max-width: 960px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--accent-border);
    border-left: 5px solid var(--accent);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.problem-overlay-hidden {
    display: none;
}

.problem-overlay-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
}

.problem-overlay-title {
    font-weight: 700;
    color: var(--fg-heading);
    font-size: 1.05em;
}

.problem-overlay-badge {
    font-size: 0.72em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 8px;
    border-radius: 10px;
    background: var(--bg-subtle, #f5f7fa);
    color: var(--fg-muted);
}

.problem-overlay-badge.badge-verified {
    background: rgba(46, 125, 50, 0.15);
    color: #1b5e20;
}

.problem-overlay-badge.badge-unsigned,
.problem-overlay-badge.badge-offline {
    background: rgba(245, 127, 23, 0.15);
    color: #e65100;
}

.problem-overlay-badge.badge-mismatch {
    background: rgba(198, 40, 40, 0.15);
    color: #b71c1c;
}

[data-theme="dark"] .problem-overlay-badge.badge-verified {
    background: rgba(102, 187, 106, 0.20);
    color: #a5d6a7;
}

[data-theme="dark"] .problem-overlay-badge.badge-unsigned,
[data-theme="dark"] .problem-overlay-badge.badge-offline {
    background: rgba(255, 167, 38, 0.20);
    color: #ffb74d;
}

[data-theme="dark"] .problem-overlay-badge.badge-mismatch {
    background: rgba(239, 83, 80, 0.20);
    color: #ef9a9a;
}

.problem-overlay-close {
    margin-left: auto;
    background: transparent;
    border: none;
    font-size: 1.5em;
    line-height: 1;
    color: var(--fg-muted);
    cursor: pointer;
    padding: 4px 8px;
}

.problem-overlay-close:hover {
    color: var(--fg);
}

.problem-overlay-prompt {
    margin: 6px 0 12px 0;
    color: var(--fg);
    line-height: 1.5;
}

.problem-overlay-answer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--accent-bg);
    border-radius: 6px;
}

.problem-overlay-answer label {
    margin: 0;
    white-space: nowrap;
}

.problem-overlay-answer input {
    flex: 1 1 140px;
    min-width: 120px;
    max-width: 200px;
}

.problem-overlay-result {
    flex: 1 1 100%;
    margin-top: 6px;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 0.92em;
}

.problem-overlay-result.correct {
    background: rgba(46, 125, 50, 0.12);
    color: #1b5e20;
    border-left: 3px solid #2e7d32;
}

.problem-overlay-result.incorrect {
    background: rgba(198, 40, 40, 0.1);
    color: #b71c1c;
    border-left: 3px solid #c62828;
}

[data-theme="dark"] .problem-overlay {
    border-color: var(--accent-border);
    border-left-color: var(--accent);
    background: var(--bg-card);
}

[data-theme="dark"] .problem-overlay-result.correct {
    background: rgba(102, 187, 106, 0.16);
    color: #a5d6a7;
    border-left-color: #66bb6a;
}

[data-theme="dark"] .problem-overlay-result.incorrect {
    background: rgba(239, 83, 80, 0.14);
    color: #ef9a9a;
    border-left-color: #ef5350;
}

/* ------------------------------------------------------------------ *
 * Backend status line on instructor.html
 * ------------------------------------------------------------------ */

.status-line {
    font-size: 0.9em;
    color: var(--fg-muted);
    margin-top: 8px;
}

.status-line span.status-ok { color: #2e7d32; font-weight: 600; }
.status-line span.status-warn { color: #e65100; font-weight: 600; }

[data-theme="dark"] .status-line span.status-ok { color: #81c784; }
[data-theme="dark"] .status-line span.status-warn { color: #ffb74d; }

.status-signed { color: #2e7d32; }
.status-unsigned { color: #e65100; }

[data-theme="dark"] .status-signed { color: #81c784; }
[data-theme="dark"] .status-unsigned { color: #ffb74d; }

/* ------------------------------------------------------------------ *
 * Grouped nav with dropdowns (Calculate / Study / Reference + Teach)
 * ------------------------------------------------------------------ */

.nav-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 2px;
    overflow: visible;
}

.nav-group {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.nav-group-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 14px 20px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: inherit;
    font-family: inherit;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.25s ease;
}

.nav-group-toggle:hover,
.nav-group-toggle:focus-visible {
    background: #1565c0;
    transform: translateY(-2px);
    outline: none;
}

.nav-group-toggle.active {
    background: rgba(255, 255, 255, 0.1);
    font-weight: 500;
    box-shadow: inset 0 -3px 0 #fff;
}

.nav-group-toggle .nav-caret {
    font-size: 0.7em;
    transition: transform 0.2s ease;
}

.nav-group.open > .nav-group-toggle .nav-caret {
    transform: rotate(180deg);
}

.nav-submenu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    min-width: 220px;
    margin: 4px 0 0 0;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
    list-style: none;
    display: none;
}

.nav-group.open > .nav-submenu,
.nav-group:hover > .nav-submenu,
.nav-group:focus-within > .nav-submenu {
    display: block;
}

.nav-submenu li {
    display: block;
    margin: 0;
}

.nav-submenu li a {
    display: block;
    padding: 10px 14px;
    color: var(--fg);
    text-decoration: none;
    border-radius: 4px;
    transform: none;
    box-shadow: none;
    font-weight: 400;
    text-align: left;
    transition: background 0.15s ease;
}

.nav-submenu li a:hover,
.nav-submenu li a:focus-visible {
    background: var(--accent-bg);
    color: var(--accent-deep);
    transform: none;
    outline: none;
}

.nav-submenu li a.active {
    background: var(--accent);
    color: #fff;
    box-shadow: none;
}

.nav-submenu li a.active:hover {
    background: var(--accent-dark);
    color: #fff;
}

/* Teach corner — visually separated from the primary task nav. */
.nav-teach {
    margin-left: auto;
    padding-left: 14px;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.nav-teach a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.92em;
    transition: all 0.2s ease;
}

.nav-teach a:hover,
.nav-teach a:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    outline: none;
}

.nav-teach.active a {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-weight: 600;
}

.nav-teach-icon {
    font-size: 0.85em;
    color: rgba(255, 215, 64, 0.95);
}

/* Dark theme overrides */
[data-theme="dark"] .nav-submenu {
    background: var(--bg-card);
    border-color: var(--border);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .nav-submenu li a {
    color: var(--fg);
}

[data-theme="dark"] .nav-submenu li a:hover,
[data-theme="dark"] .nav-submenu li a:focus-visible {
    background: var(--accent-bg);
    color: var(--accent-deep);
}

[data-theme="dark"] .nav-submenu li a.active {
    background: var(--accent);
    color: var(--bg-card);
}

[data-theme="dark"] .nav-group-toggle { color: var(--nav-fg); }
[data-theme="dark"] .nav-group-toggle:hover,
[data-theme="dark"] .nav-group-toggle:focus-visible { background: #0d47a1; }
[data-theme="dark"] .nav-group-toggle.active { background: rgba(255,255,255,0.12); box-shadow: inset 0 -3px 0 var(--accent); }

[data-theme="dark"] .nav-teach a { color: rgba(230, 237, 243, 0.9); background: rgba(100, 181, 246, 0.15); }
[data-theme="dark"] .nav-teach a:hover { background: rgba(100, 181, 246, 0.25); color: #fff; }

[data-theme="high-contrast"] .nav-submenu {
    background: #000;
    border: 2px solid #ffff00;
}

[data-theme="high-contrast"] .nav-submenu li a {
    color: #ffff00;
}

[data-theme="high-contrast"] .nav-submenu li a:hover,
[data-theme="high-contrast"] .nav-submenu li a.active {
    background: #ffff00;
    color: #000;
}

[data-theme="high-contrast"] .nav-group-toggle {
    color: #ffff00;
}

[data-theme="high-contrast"] .nav-teach a {
    background: #000;
    color: #ffff00;
    border: 1px solid #ffff00;
}

/* Mobile: collapse dropdowns inline inside the hamburger menu */
@media (max-width: 768px) {
    .nav-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .nav-group {
        display: block;
    }

    .nav-group-toggle {
        display: flex;
        width: 100%;
        justify-content: space-between;
        padding: 12px 16px;
    }

    .nav-submenu {
        position: static;
        display: none;
        min-width: 0;
        margin: 0;
        padding: 0 0 0 20px;
        background: transparent;
        border: none;
        box-shadow: none;
    }

    .nav-group.open > .nav-submenu {
        display: block;
    }

    /* Disable hover-to-open on touch devices to prevent accidental opens */
    .nav-group:hover > .nav-submenu,
    .nav-group:focus-within > .nav-submenu {
        display: none;
    }

    .nav-group.open > .nav-submenu {
        display: block;
    }

    .nav-submenu li a {
        padding: 10px 16px;
        color: #fff;
    }

    .nav-submenu li a:hover,
    .nav-submenu li a.active {
        background: rgba(255, 255, 255, 0.15);
        color: #fff;
    }

    .nav-teach {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.15);
        margin-top: 4px;
        padding-top: 4px;
    }

    .nav-teach a {
        display: block;
        text-align: center;
        border-radius: 4px;
    }
}

/* ------------------------------------------------------------------ *
 * Landing page sections (Calculate / Study / Reference + Teach)
 * ------------------------------------------------------------------ */

.landing-section {
    margin: 24px 0;
}

.landing-section-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent-bg);
}

.landing-section-header h2 {
    margin: 0;
    color: var(--fg-heading);
    font-size: 1.4em;
    padding: 0;
    border: none;
}

.landing-section-header p {
    margin: 0;
    color: var(--fg-muted);
    font-size: 0.95em;
    flex: 1 1 300px;
    font-style: italic;
}

.landing-section .calculator-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    padding: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

.landing-section .calc-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 16px;
}

.landing-section .calc-card h3 {
    margin: 0 0 8px 0;
    color: var(--fg-heading);
    font-size: 1.1em;
    padding: 0;
    border: none;
}

.landing-section .calc-card p {
    margin: 0 0 14px 0;
    color: var(--fg);
    font-size: 0.93em;
    line-height: 1.45;
}

/* Teach card — set apart from the three task sections */
.teach-card {
    margin: 32px 0 16px 0;
    padding: 20px 24px;
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.06) 0%, rgba(25, 118, 210, 0.04) 100%);
    border: 1px dashed var(--accent-border);
    border-radius: 10px;
}

.teach-card-body {
    max-width: 720px;
}

.teach-card-badge {
    display: inline-block;
    font-size: 0.75em;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #ff8f00;
    background: rgba(255, 193, 7, 0.15);
    padding: 3px 10px;
    border-radius: 12px;
    margin-bottom: 10px;
}

.teach-card h2 {
    margin: 0 0 8px 0;
    color: var(--fg-heading);
    font-size: 1.2em;
    padding: 0;
    border: none;
}

.teach-card p {
    color: var(--fg);
    line-height: 1.55;
    margin: 0 0 14px 0;
}

.teach-card-button {
    background: #ff8f00;
    color: #fff;
}

.teach-card-button:hover {
    background: #e65100;
}

[data-theme="dark"] .teach-card {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.06) 0%, rgba(100, 181, 246, 0.04) 100%);
    border-color: var(--accent-border);
}

[data-theme="dark"] .teach-card-badge {
    color: #ffc107;
    background: rgba(255, 193, 7, 0.15);
}

[data-theme="dark"] .teach-card-button {
    background: #ffa726;
    color: #1f2937;
}

[data-theme="dark"] .teach-card-button:hover {
    background: #fb8c00;
    color: #1f2937;
}

[data-theme="high-contrast"] .teach-card {
    background: #000;
    border: 2px dashed #ffff00;
}

[data-theme="high-contrast"] .teach-card-badge,
[data-theme="high-contrast"] .teach-card h2,
[data-theme="high-contrast"] .teach-card p {
    color: #ffff00;
}

[data-theme="high-contrast"] .teach-card-button {
    background: #ffff00;
    color: #000;
    border: 2px solid #ffff00;
}

/* ------------------------------------------------------------------ *
 * Instructor token gate (shown on instructor.html before the builder)
 * ------------------------------------------------------------------ */

.token-gate {
    border-left: 4px solid #ff8f00;
    background: rgba(255, 167, 38, 0.05);
}

.token-gate h2 {
    color: #ff8f00;
}

[data-theme="dark"] .token-gate {
    background: rgba(255, 167, 38, 0.07);
    border-left-color: #ffa726;
}

[data-theme="dark"] .token-gate h2 {
    color: #ffa726;
}

.token-status {
    border-left: 3px solid var(--accent);
    background: var(--accent-bg);
    padding: 10px 14px;
    margin-bottom: 16px;
}

.token-status-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.token-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.95em;
    color: #fff;
}

.token-status-badge.ok { background: #2e7d32; }
.token-status-badge.warn { background: #ff8f00; }

[data-theme="dark"] .token-status-badge.ok { background: #66bb6a; color: #1f2937; }
[data-theme="dark"] .token-status-badge.warn { background: #ffa726; color: #1f2937; }

.token-status-line > span:nth-child(2) {
    flex: 1 1 auto;
}
