:root {
    /* Colors */
    --bg: #fff8dc;
    --card-bg: #fff;
    --accent-bg: #f0f4f8;
    --border: #ddd;
    --border-accent: #d0d8e0;
    --border-light: #eee;
    --text: #3a3530;
    --muted: #888;
    --muted-dark: #666;
    --link: #2266aa;
    --link-hover: #1a5090;
    --green: #2a7a2a;
    --green-dark: #1f5f1f;
    --green-muted: #6a8a6a;
    --green-muted-dark: #557055;
    --red: #a03030;
    --red-dark: #802020;
    --yellow: #c0a020;
    --correct-bg: #d4edda;
    --correct-border: #b7dfc3;
    --correct-text: #1a5928;
    --incorrect-bg: #f8d7da;
    --incorrect-border: #f0b8be;
    --incorrect-text: #721c24;

    /* Spacing */
    --space-1: 0.25em;
    --space-2: 0.5em;
    --space-3: 0.8em;
    --space-4: 1em;
    --space-5: 1.5em;
    --space-6: 2em;

    /* Font sizes */
    --text-xs: 0.8em;
    --text-sm: 0.9em;
    --text-md: 0.95em;
    --text-base: 1em;
    --text-lg: 1.1em;
    --text-xl: 1.3em;
    --text-2xl: 1.6em;
    --text-3xl: 2em;

    /* Radii */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;

    /* Shadows */
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);

    /* Motion */
    --transition-fast: 0.15s;
    --transition-med: 0.3s;

    /* Layout — default (phones) */
    --container-max: 100%;
    --auth-max: 400px;
}

/* Tablet / iPad */
@media (min-width: 600px) {
    :root { --container-max: 720px; }
}

/* Desktop */
@media (min-width: 1024px) {
    :root { --container-max: 960px; }
}

/* Wide desktop */
@media (min-width: 1440px) {
    :root { --container-max: 1120px; }
}

/* Base */

body {
    font-family: Georgia, serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
}

.container {
    max-width: var(--container-max);
    margin: var(--space-6) auto;
    padding: 0 var(--space-4);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

a { color: var(--link); }
a:hover { color: var(--link-hover); text-decoration: underline; }

/* Card: shared boxed-content pattern, used by several semantic names. */

.card,
.question-box,
.step-box,
.week-section,
.auth-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin: var(--space-4) 0;
}

.auth-box {
    max-width: var(--auth-max);
    margin: var(--space-6) auto;
    padding: var(--space-6);
}

/* Breadcrumb */

.breadcrumb { font-size: var(--text-sm); color: var(--muted); }
.breadcrumb a { color: var(--muted); }

/* Buttons */

.btn {
    display: inline-block;
    padding: 0.7em 2em;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    cursor: pointer;
    text-decoration: none;
    color: #fff;
    background: var(--link);
}

.btn:hover { background: var(--link-hover); }
.btn-true { background: var(--green); }
.btn-true:hover { background: var(--green-dark); }
.btn-false { background: var(--red); }
.btn-false:hover { background: var(--red-dark); }
.btn-secondary { background: var(--green-muted); }
.btn-secondary:hover { background: var(--green-muted-dark); }
.btn-small { padding: 0.4em 1.2em; font-size: var(--text-sm); }
.step-feedback:has(.btn-selected) .btn-small:not(.btn-selected) { opacity: 0.4; }
.btn-selected { box-shadow: 0 0 0 2px var(--text); }
.tf-cell[data-tooltip] { cursor: pointer; position: relative; }
.tf-cell[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 6px;
    padding: var(--space-1) var(--space-2);
    background: var(--text);
    color: #fff;
    font-size: var(--text-xs);
    font-weight: normal;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
}

.nav-buttons, .answer-buttons, .answer-buttons form {
    display: flex;
    gap: var(--space-4);
    margin: var(--space-5) 0;
}

/* Result feedback */

.result {
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    margin: var(--space-4) 0;
    font-size: var(--text-lg);
}

.result.correct {
    background: var(--correct-bg);
    border: 1px solid var(--correct-border);
    color: var(--correct-text);
}

.result.incorrect {
    background: var(--incorrect-bg);
    border: 1px solid var(--incorrect-border);
    color: var(--incorrect-text);
}

/* Solution box */

.solution-box {
    background: var(--accent-bg);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin: var(--space-4) 0;
    line-height: 1.6;
}

/* Text */

.claim, .step-question {
    font-size: var(--text-lg);
    line-height: 1.6;
    overflow-x: auto;
}

.step-question { margin-bottom: var(--space-4); }

/* Landing header */

.landing-header {
    position: relative;
    text-align: center;
    margin: var(--space-6) 0 var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 2px solid var(--border);
}

.landing-header h1 { font-size: var(--text-3xl); margin-bottom: 0.1em; }

.subtitle { font-size: var(--text-lg); color: var(--muted); font-style: italic; margin-top: 0; }

.header-row { display: flex; align-items: center; justify-content: center; gap: var(--space-5); }
.header-img { height: 80px; width: 120px; object-fit: cover; border-radius: var(--radius-lg); }
.header-text h1 { margin: 0; }
.header-text .subtitle { margin: 0.2em 0 0; }

/* Hamburger menu */

.menu-wrapper { position: absolute; top: 0; right: 0; }

.menu-btn {
    background: none;
    border: none;
    font-size: var(--text-xl);
    cursor: pointer;
    color: var(--muted-dark);
    padding: 0.2em 0.4em;
}

.menu-btn:hover { color: var(--link); }

.menu-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 2em;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 140px;
    z-index: 10;
}

.menu-dropdown.open { display: block; }
.menu-dropdown a {
    display: block;
    padding: 0.6em 1em;
    color: var(--text);
    text-decoration: none;
    font-size: var(--text-md);
}
.menu-dropdown a:hover { background: var(--accent-bg); }

/* Landing content */

.landing-intro, .exercise-intro {
    background: var(--accent-bg);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    margin: var(--space-4) 0;
    line-height: 1.6;
}

.exercise-intro { border: 1px solid var(--border-accent); }

.disclaimer {
    margin-top: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-left: 4px solid #ffc107;
    border-radius: var(--radius-md);
    color: #664d03;
    font-size: var(--text-base, 1rem);
    line-height: 1.5;
}

.week-section h2 { margin: 0 0 var(--space-2); font-size: var(--text-xl); color: var(--text); }
.week-contents { list-style: none; padding: 0; margin: 0; }
.week-contents li {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}
.week-contents li:hover { background: var(--accent-bg); }
.item-count { color: var(--muted); font-size: var(--text-sm); }

/* Auth forms */

.auth-box label {
    display: block;
    margin-top: var(--space-4);
    margin-bottom: 0.3em;
    font-weight: bold;
    font-size: var(--text-md);
}

.auth-box input[type="email"],
.auth-box input[type="password"] {
    width: 100%;
    padding: 0.6em;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--text-base);
    box-sizing: border-box;
}

.auth-box .btn { width: 100%; margin-top: var(--space-5); }
.auth-link { text-align: center; margin-top: var(--space-4); font-size: var(--text-sm); }
.show-password {
    display: block;
    font-weight: normal;
    font-size: 0.85em;
    color: var(--muted-dark);
    margin-top: 0.4em;
}

/* Exercise steps */

.step-completed { border-left: 4px solid var(--green); }

.step-feedback {
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.step-feedback span { font-size: var(--text-md); color: var(--muted-dark); }

/* Details toggles */

.step-details { margin-top: var(--space-2); }

.step-details summary,
.step-details-inner summary {
    cursor: pointer;
    color: var(--link);
    font-size: var(--text-md);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.step-details summary:hover,
.step-details-inner summary:hover { color: var(--link-hover); background: var(--accent-bg); }

.step-details-inner { margin-top: 0.3em; margin-left: var(--space-4); }

/* Progress */

.progress-table { width: 100%; border-collapse: collapse; margin: var(--space-4) 0; }
.progress-table th,
.progress-table td {
    padding: var(--space-2) var(--space-3);
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.progress-table th { background: var(--accent-bg); font-size: var(--text-sm); }

.progress-bar {
    position: relative;
    background: var(--border);
    border-radius: var(--radius-sm);
    height: 1.4em;
    min-width: 80px;
}
.progress-fill { height: 100%; border-radius: var(--radius-sm); transition: width var(--transition-med); }
.progress-fill.good { background: var(--green); }
.progress-fill.ok { background: var(--yellow); }
.progress-fill.low { background: var(--red); }
.progress-pct {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--text-xs);
    font-weight: bold;
    color: var(--text);
    line-height: 1.4em;
}

/* Status grid (T/F overview + exercise steps) */

.tf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(3em, 1fr));
    gap: var(--space-2);
    margin: var(--space-4) 0;
}

.tf-grid-tight { margin-bottom: var(--space-2); }

.note-extra {
    font-style: italic;
    color: var(--color-muted, #666);
    margin: 0 0 var(--space-2) 0;
}

.tf-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 3em;
    border-radius: var(--radius-md);
    font-weight: bold;
    text-decoration: none;
    font-size: var(--text-base);
    transition: opacity var(--transition-fast);
}

.tf-open { background: var(--card-bg); border: 1px solid var(--border); color: var(--text); }
.tf-open:hover { background: var(--text); color: var(--card-bg); }
.tf-correct { background: var(--correct-bg); border: 1px solid var(--correct-border); color: var(--correct-text); }
.tf-correct:hover { background: var(--green-dark); color: #fff; }
.tf-wrong { background: var(--incorrect-bg); border: 1px solid var(--incorrect-border); color: var(--incorrect-text); }

/* Code blocks (pygmentized) */
.highlight pre, pre {
    background: #f6f8fa;
    border: 1px solid var(--border, #e1e4e8);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    overflow-x: auto;
    font-size: 0.9em;
    line-height: 1.45;
}
.highlight { margin: var(--space-3) 0; }

/* Old-exam cards */
.exercise-card {
    background: var(--bg);
    border: 1px solid var(--border, #e1e4e8);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    margin: var(--space-3) 0;
}
.exercise-number {
    font-weight: bold;
    color: var(--text-muted, #666);
    margin-bottom: var(--space-2);
}
.exercise-body ol.org-ol { padding-left: 1.5em; }
