
:root {
    color-scheme: light;
    --navy: #0f172a;
    --blue: #2563eb;
    --background: #f1f5f9;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #475569;
    --border: #dbe3ee;
    --success: #047857;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.6;
}
a { color: inherit; }
a:focus-visible {
    outline: 3px solid #60a5fa;
    outline-offset: 4px;
}
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    background: var(--navy);
    color: #e2e8f0;
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
}
.brand {
    font-weight: 800;
    font-size: 17px;
    letter-spacing: 1px;
}
.brand-sub {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
}
nav {
    display: grid;
    gap: 7px;
    margin-top: 42px;
}
nav a {
    padding: 11px 14px;
    text-decoration: none;
    border-radius: 9px;
}
nav a:hover, nav a:focus-visible {
    background: #1e293b;
}
nav a.active {
    background: var(--blue);
    color: white;
}
.sidebar footer {
    margin-top: auto;
    color: #94a3b8;
    font-size: 12px;
}
main {
    margin-left: 250px;
    padding: 40px;
    max-width: 1540px;
}
.eyebrow {
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-weight: 700;
}
h1 {
    font-size: clamp(26px, 3vw, 36px);
    line-height: 1.2;
    margin: 8px 0;
    letter-spacing: -1px;
}
h2 { font-size: 21px; margin: 0 0 16px; }
h3 { font-size: 15px; margin: 0; line-height: 1.45; }
p { margin: 6px 0; }
.muted { color: var(--muted); font-size: 13px; }
.notice {
    display: inline-block;
    background: #e2e8f0;
    color: #334155;
    padding: 5px 12px;
    border-radius: 30px;
    font-size: 11px;
    font-weight: 700;
}
header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 30px;
}
.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}
.stat, .panel, .module {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
}
.stat { padding: 20px; min-width: 0; }
.value {
    display: block;
    font-size: 29px;
    font-weight: 750;
    letter-spacing: -1px;
    margin: 5px 0;
}
.track {
    height: 6px;
    background: #e2e8f0;
    border-radius: 10px;
    margin-top: 14px;
    overflow: hidden;
}
.track span {
    display: block;
    width: 0%;
    height: 100%;
    background: var(--blue);
}
.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 20px;
    margin-top: 24px;
}
.hero {
    background: var(--navy);
    color: white;
    padding: 30px;
    border-radius: 16px;
}
.hero .eyebrow { color: #93c5fd; }
.hero h2 {
    font-size: clamp(22px, 2.5vw, 29px);
    line-height: 1.3;
    margin: 14px 0;
}
.hero p { color: #cbd5e1; }
.status {
    display: inline-block;
    background: #334155;
    color: #f1f5f9;
    border-radius: 9px;
    padding: 10px 15px;
    margin-top: 18px;
}
.panel { padding: 24px; }
.panel p { color: var(--muted); }
section { margin-top: 30px; scroll-margin-top: 20px; }
.module-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.module {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
}
.number {
    flex-shrink: 0;
    padding: 10px;
    background: #eff6ff;
    color: #1d4ed8;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 800;
}
.module-body { flex: 1; min-width: 0; }
.module p { font-size: 12px; color: var(--muted); }
.mobile-nav { display: none; }
@media (max-width: 1100px) {
    main { padding: 25px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .content-grid, .module-list { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .sidebar { display: none; }
    main {
        margin: 0;
        padding: 24px 16px 100px;
    }
    header { flex-wrap: wrap; }
    .stats { gap: 10px; }
    .stat { padding: 15px; }
    .value { font-size: 25px; }
    .hero { padding: 23px; }
    .mobile-nav {
        position: fixed;
        inset: auto 0 0;
        background: white;
        border-top: 1px solid var(--border);
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
        gap: 2px;
        z-index: 20;
    }
    .mobile-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        text-align: center;
        min-height: 56px;
        padding: 8px 4px;
        text-decoration: none;
        color: #334155;
        font-size: 11px;
        font-weight: 700;
        border-radius: 10px;
    }
    .mobile-nav a:hover,
    .mobile-nav a:focus-visible {
        background: #eff6ff;
        color: #1d4ed8;
    }
    .mobile-icon {
        display: inline-flex;
        width: 20px;
        height: 20px;
        align-items: center;
        justify-content: center;
    }
    .mobile-icon svg {
        width: 20px;
        height: 20px;
        stroke: currentColor;
        fill: none;
        stroke-width: 1.9;
        stroke-linecap: round;
        stroke-linejoin: round;
    }
    .mobile-label {
        line-height: 1.1;
        white-space: nowrap;
    }
}
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
}
.nav-icon {
    width: 21px;
    height: 21px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.mobile-nav a.active {
    color: #1d4ed8;
    background: #eff6ff;
}
.module-link {
    text-decoration: none;
    color: inherit;
}
.module-link:hover {
    border-color: #2563eb;
}
.block-list {
    display: grid;
    gap: 10px;
}
.block-row {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
}
.block-meta {
    color: var(--muted);
    font-size: 13px;
}
.back-link {
    color: #1d4ed8;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 18px;
}
@media (max-width: 760px) {
    main {
        padding-bottom: calc(105px + env(safe-area-inset-bottom));
    }
}

/* Academy authentication */
.login-page {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 20px;
}
.login-card {
    margin: 0;
    width: min(100%, 430px);
    padding: 32px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 18px;
}
.login-card form {
    display: grid;
    gap: 10px;
    margin: 25px 0;
}
.login-card input {
    width: 100%;
    padding: 13px;
    border: 1px solid #94a3b8;
    border-radius: 9px;
    font: inherit;
    font-size: 16px;
}
.primary-button, .logout-button {
    cursor: pointer;
    min-height: 44px;
    padding: 10px 18px;
    border-radius: 9px;
    font: inherit;
    font-weight: 600;
}
.primary-button {
    margin-top: 10px;
    border: 0;
    background: #2563eb;
    color: white;
}
.logout-button {
    border: 1px solid var(--border);
    background: white;
    color: #334155;
}
.login-error {
    color: #991b1b;
    background: #fef2f2;
    border-radius: 8px;
    padding: 12px;
}
button:focus-visible, input:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 3px;
}

/* Material reader */
.lesson-reader {
    max-width: 860px;
    font-size: 17px;
    line-height: 1.8;
    overflow-wrap: anywhere;
}
.lesson-reader h2,
.lesson-reader h3,
.lesson-reader h4 {
    margin-top: 24px;
    line-height: 1.35;
}
.lesson-reader p {
    color: var(--text);
    margin: 12px 0;
}
.lesson-reader li {
    margin-bottom: 8px;
}
.lesson-reader pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 18px;
    border-radius: 10px;
    overflow-x: auto;
    font-size: 14px;
    line-height: 1.65;
}
.lesson-link {
    display: block;
    padding: 8px 0;
    color: #1d4ed8;
    text-decoration: none;
}
.lesson-link:hover {
    text-decoration: underline;
}
.material-notice {
    background: #f1f5f9;
    padding: 16px;
    border-radius: 10px;
}
.markdown-table-line {
    white-space: pre-wrap;
    font-family: monospace;
    font-size: 13px;
}
@media (max-width: 760px) {
    .lesson-reader {
        padding: 20px;
        font-size: 16px;
    }
}

/* Study sessions */
.study-form {
    margin-top: 40px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
}
.study-form form {
    display: grid;
    gap: 12px;
}
.study-form input:not([type="checkbox"]),
.study-form select,
.study-form textarea {
    width: 100%;
    min-width: 0;
    padding: 12px;
    border: 1px solid #94a3b8;
    border-radius: 9px;
    font: inherit;
    font-size: 16px;
    background: white;
}
.study-form label {
    font-size: 14px;
    font-weight: 600;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
}
.checkbox-label input {
    width: 20px;
    height: 20px;
}
.session-note {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.study-form textarea:focus-visible,
.study-form select:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 3px;
}

/* Server-backed study timer */
.timer-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
    margin: 0 0 24px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: white;
}
.timer-clock {
    font-size: clamp(28px, 4vw, 40px);
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    letter-spacing: -1px;
}
.timer-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.timer-actions button {
    margin: 0;
}
.timer-actions button:disabled {
    opacity: .5;
    cursor: not-allowed;
}
.timer-start {
    margin: 20px 0 28px;
}
@media (max-width: 760px) {
    .timer-actions {
        width: 100%;
    }
    .timer-actions button {
        flex: 1 1 110px;
    }
    .timer-start button {
        width: 100%;
    }
}

.timer-summary {
    width: 100%;
    flex-basis: 100%;
    margin-top: 0;
}
.timer-discard {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: 22px;
}
