:root {
    --bg: #fbfaf7;
    --surface: #ffffff;
    --text: #1d1d1f;
    --muted: #6b6b6b;
    --accent: #b03a2e;
    --accent-soft: #faedeb;
    --border: #e3dfd6;
    --callout-sv: #eef4fb;
    --callout-sv-border: #4a6ea9;
    --callout-vt: #fbf3e3;
    --callout-vt-border: #c08a2e;
    --callout-utt: #eef7ee;
    --callout-utt-border: #4a8a4e;
    --code-bg: #f3efe8;
    --turkish: #8a3a1f;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Charter", "Georgia", "Times New Roman", serif;
    line-height: 1.6;
    font-size: 17px;
}

.layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1.25rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar h1 {
    font-size: 1.1rem;
    margin: 0 0 0.25rem 0;
    color: var(--accent);
    letter-spacing: 0.02em;
}

.sidebar .subtitle {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0 0 1.5rem 0;
}

.sidebar h2 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin: 1.25rem 0 0.5rem 0;
    font-weight: 600;
    font-family: "Helvetica Neue", "Arial", sans-serif;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar li { margin: 0.2rem 0; }

.sidebar a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    display: block;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

.sidebar a:hover { background: var(--accent-soft); color: var(--accent); }

.sidebar a.current {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.sidebar .ch-num {
    display: inline-block;
    width: 1.8rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    font-family: "Helvetica Neue", "Arial", sans-serif;
    font-size: 0.85rem;
}

.sidebar a.current .ch-num { color: var(--accent); }

.sidebar .checkpoint .ch-num {
    color: var(--accent);
    font-weight: 600;
}

.sidebar .upcoming {
    color: #b0b0b0;
    cursor: not-allowed;
}

.sidebar .upcoming:hover {
    background: transparent;
    color: #b0b0b0;
}

main {
    padding: 3rem 4rem 5rem 4rem;
    max-width: 920px;
}

.crumbs {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 1.5rem;
    font-family: "Helvetica Neue", "Arial", sans-serif;
}

.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

h1.chapter-title {
    font-size: 2.1rem;
    margin: 0 0 0.5rem 0;
    color: var(--text);
    line-height: 1.2;
}

h2 {
    font-size: 1.4rem;
    margin: 2.5rem 0 0.8rem 0;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.3rem;
}

h3 {
    font-size: 1.1rem;
    margin: 1.8rem 0 0.6rem 0;
    color: var(--text);
}

h4 {
    font-size: 1rem;
    margin: 1.2rem 0 0.5rem 0;
    color: var(--muted);
    font-family: "Helvetica Neue", "Arial", sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

p { margin: 0.7rem 0; }

ul, ol { padding-left: 1.6rem; }
li { margin: 0.3rem 0; }

em.tr, .tr {
    color: var(--turkish);
    font-style: italic;
}

strong { color: var(--text); }

table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0 1.5rem 0;
    background: var(--surface);
    font-size: 0.95rem;
}

th, td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    text-align: left;
    vertical-align: top;
}

th {
    background: var(--code-bg);
    font-family: "Helvetica Neue", "Arial", sans-serif;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 600;
}

code, .mono {
    font-family: "JetBrains Mono", "Menlo", "Consolas", monospace;
    background: var(--code-bg);
    padding: 0 0.25rem;
    border-radius: 3px;
    font-size: 0.92em;
}

.callout {
    border-left: 4px solid;
    padding: 0.8rem 1.1rem;
    margin: 1.2rem 0;
    border-radius: 0 6px 6px 0;
}

.callout .label {
    font-family: "Helvetica Neue", "Arial", sans-serif;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    display: block;
    margin-bottom: 0.3rem;
}

.callout.sv { background: var(--callout-sv); border-color: var(--callout-sv-border); }
.callout.sv .label { color: var(--callout-sv-border); }

.callout.vt { background: var(--callout-vt); border-color: var(--callout-vt-border); }
.callout.vt .label { color: var(--callout-vt-border); }

.callout.utt { background: var(--callout-utt); border-color: var(--callout-utt-border); }
.callout.utt .label { color: var(--callout-utt-border); }

.callout p:first-of-type { margin-top: 0; }
.callout p:last-of-type { margin-bottom: 0; }

.exercise {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.3rem 1.6rem;
    margin: 1.5rem 0;
}

.exercise h3 {
    margin-top: 0;
    color: var(--accent);
    font-size: 1.15rem;
}

.exercise h4 {
    color: var(--text);
    text-transform: none;
    letter-spacing: 0;
    font-family: "Charter", "Georgia", serif;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 1rem;
}

.instr {
    font-style: italic;
    color: var(--muted);
    margin: 0.3rem 0 0.8rem 0;
}

.example {
    background: var(--accent-soft);
    padding: 0.5rem 0.8rem;
    border-radius: 4px;
    font-style: italic;
    margin: 0.4rem 0 0.8rem 0;
    font-size: 0.95rem;
}

.example::before {
    content: "Exempel: ";
    font-weight: 600;
    color: var(--accent);
    font-style: normal;
}

ol.items {
    list-style: decimal;
    padding-left: 1.8rem;
}

ol.items li {
    margin: 0.45rem 0;
    padding-left: 0.3rem;
}

.choice {
    margin-left: 0.5rem;
    color: var(--muted);
    font-size: 0.92em;
}

.footer-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    font-family: "Helvetica Neue", "Arial", sans-serif;
    font-size: 0.95rem;
}

.footer-nav a {
    color: var(--accent);
    text-decoration: none;
    display: inline-flex;
    flex-direction: column;
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
}

.footer-nav a:hover { background: var(--accent-soft); }

.footer-nav .nav-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.footer-nav .nav-prev { text-align: left; }
.footer-nav .nav-next { text-align: right; }
.footer-nav .placeholder { color: transparent; }

.goal-list li::marker { color: var(--accent); }

.answer-bare { font-weight: 600; color: var(--accent); }
.answer-note { color: var(--muted); font-style: italic; font-size: 0.92em; }

.note-after {
    font-style: italic;
    color: var(--muted);
    text-align: center;
    margin-top: 2rem;
    font-size: 0.93rem;
}

.vocab-new {
    margin-top: 3rem;
}

.vocab-new h2 {
    margin-top: 0;
}

table.vocab-table td.word {
    font-family: "Charter", "Georgia", serif;
    color: var(--turkish);
    font-style: italic;
    white-space: nowrap;
}

table.vocab-table td.pos {
    font-family: "Helvetica Neue", "Arial", sans-serif;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    white-space: nowrap;
}

table.vocab-table td.notes {
    color: var(--muted);
    font-size: 0.92rem;
}

.vocab-new .more-link {
    font-family: "Helvetica Neue", "Arial", sans-serif;
    font-size: 0.9rem;
    color: var(--muted);
    margin-top: 0.5rem;
}

.vocab-new .more-link a {
    color: var(--accent);
    text-decoration: none;
}

.vocab-new .more-link a:hover { text-decoration: underline; }

.hero-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 2rem;
    margin: 2rem 0;
}

.hero-card h2 {
    border: none;
    margin-top: 0;
    padding: 0;
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin: 0.6rem 0;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    width: 3.5%;
}

/* --- Mobile drawer chrome (hidden on desktop, activated by media query) --- */

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 0.6rem;
    left: 0.6rem;
    z-index: 1001;
    width: 2.5rem;
    height: 2.5rem;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    padding: 0;
}

.sidebar-toggle svg { width: 1.3rem; height: 1.3rem; stroke: var(--text); }
.sidebar-toggle:hover { background: var(--accent-soft); }
.sidebar-toggle:hover svg { stroke: var(--accent); }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    -webkit-tap-highlight-color: transparent;
}

/* --- Tablet / small laptop --- */

@media (max-width: 1000px) {
    main { padding: 2.5rem 2rem 4rem 2rem; }
}

/* --- Phone & narrow tablet: sidebar becomes an off-canvas drawer --- */

@media (max-width: 850px) {
    .layout { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.12);
        padding: 3.5rem 1.25rem 1.5rem 1.25rem;
    }

    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    body.sidebar-open { overflow: hidden; }

    .sidebar-toggle { display: inline-flex; }

    main {
        padding: 3.75rem 1.1rem 3rem 1.1rem;
        max-width: 100%;
    }

    h1.chapter-title { font-size: 1.7rem; }
    h2 { font-size: 1.2rem; margin: 2rem 0 0.7rem 0; }
    h3 { font-size: 1.05rem; }

    .hero-card { padding: 1.3rem; }
    .exercise { padding: 1rem 1.1rem; }
    .callout { padding: 0.7rem 0.9rem; }

    /* Long tables (vocabulary, paradigms, schedule) scroll horizontally
       instead of overflowing the viewport. */
    table {
        display: block;
        overflow-x: auto;
        max-width: 100%;
    }

    .footer-nav { gap: 0.5rem; }
    .footer-nav a { padding: 0.45rem 0.6rem; }

    ul, ol { padding-left: 1.3rem; }
    ol.items { padding-left: 1.5rem; }
}

/* --- Very small phones --- */

@media (max-width: 480px) {
    html, body { font-size: 16px; }
    main { padding: 3.5rem 0.85rem 2.5rem 0.85rem; }
    h1.chapter-title { font-size: 1.5rem; }
    .hero-card { padding: 1.1rem; }
    .exercise { padding: 0.9rem 1rem; }
    th, td { padding: 0.4rem 0.55rem; }
}
