:root {
    --primary: #4f6df5;
    --primary-dark: #3a54d6;
    --secondary: #7c8db5;
    --success: #2fb380;
    --warning: #f0a12e;
    --danger: #e5484d;
    --background: #f5f7fb;
    --surface: #ffffff;
    --surface-alt: #eef1f8;
    --text: #1c2333;
    --text-muted: #6b7488;
    --border: #e3e7f0;
    --radius: 16px;
    --shadow: 0 4px 20px rgba(31, 45, 90, 0.06);
}

[data-bs-theme="dark"] {
    --primary: #6d86ff;
    --background: #12141c;
    --surface: #1c1f2b;
    --surface-alt: #242838;
    --text: #eef1f8;
    --text-muted: #9aa3bd;
    --border: #2c3142;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
    background: var(--background);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
}

/* ---------- Auth ---------- */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #4f6df5 0%, #7c4df5 100%);
    padding: 1rem;
}
.auth-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}
.auth-card h1 { font-size: 1.6rem; margin-bottom: .25rem; }

/* ---------- App-skal ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 1040;
    transition: transform .25s ease;
}
.sidebar-brand { font-weight: 800; font-size: 1.3rem; margin-bottom: 1.5rem; color: var(--primary); }
.sidebar-nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: .65rem;
    padding: .6rem .8rem; border-radius: 12px;
    color: var(--text); text-decoration: none; font-weight: 500;
}
.nav-item:hover { background: var(--surface-alt); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon { width: 1.4rem; text-align: center; }
.sidebar-user { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; }
.user-name { font-weight: 700; }
.user-meta { font-size: .82rem; color: var(--text-muted); }

.main-area { flex: 1; margin-left: 250px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem 1.5rem; background: var(--surface);
    border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1030;
}
.topbar-title { font-weight: 700; font-size: 1.1rem; }
.content { padding: 1.75rem; max-width: 1100px; width: 100%; }

/* ---------- Kort ---------- */
.card-soft {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}
.card-soft h2, .card-soft h3 { margin-top: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem; text-align: center; box-shadow: var(--shadow);
}
.stat .num { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat .label { color: var(--text-muted); font-size: .9rem; }

/* ---------- Progressbar ---------- */
.progress-track { background: var(--surface-alt); border-radius: 999px; height: 12px; overflow: hidden; }
.progress-fill { background: var(--primary); height: 100%; border-radius: 999px; transition: width .4s ease; }
.progress-fill.success { background: var(--success); }

/* ---------- Modul/lektionslista ---------- */
.module-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem; border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: .75rem; background: var(--surface);
    text-decoration: none; color: var(--text);
}
.module-item.locked { opacity: .55; }
.module-status { font-size: 1.4rem; }
.lesson-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: .6rem .5rem; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text);
}
.lesson-row:last-child { border-bottom: none; }
.lesson-row:hover { background: var(--surface-alt); }

.badge-soft { background: var(--surface-alt); color: var(--text-muted); border-radius: 999px; padding: .2rem .7rem; font-size: .8rem; }

/* ---------- Lektionsblock ---------- */
.block { margin-bottom: 1.25rem; line-height: 1.65; }
.block-heading { font-size: 1.4rem; font-weight: 700; margin: 1.5rem 0 .5rem; }
.block-fact { background: #eef4ff; border-left: 4px solid var(--primary); padding: 1rem 1.25rem; border-radius: 10px; }
.block-warning { background: #fff6e9; border-left: 4px solid var(--warning); padding: 1rem 1.25rem; border-radius: 10px; }
.block-example { background: var(--surface-alt); border-radius: 10px; padding: 1rem 1.25rem; }
.block-term {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: .9rem 1.1rem; box-shadow: var(--shadow);
}
.block-term .term-front { font-weight: 700; }
[data-bs-theme="dark"] .block-fact { background: #1d2740; }
[data-bs-theme="dark"] .block-warning { background: #33280f; }

/* ---------- Flashcards ---------- */
.flashcard {
    perspective: 1200px; max-width: 480px; margin: 1rem auto; height: 260px; cursor: pointer;
}
.flashcard-inner { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; }
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face {
    position: absolute; inset: 0; backface-visibility: hidden;
    display: flex; align-items: center; justify-content: center; text-align: center; padding: 1.5rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); font-size: 1.2rem;
}
.flashcard-back { transform: rotateY(180deg); }

/* ---------- Quiz ---------- */
.quiz-option { display: block; padding: .85rem 1.1rem; border: 2px solid var(--border); border-radius: 12px; margin-bottom: .6rem; cursor: pointer; }
.quiz-option:hover { border-color: var(--primary); }
.quiz-option input { margin-right: .6rem; }
.answer-correct { border-color: var(--success) !important; background: #eafaf3; }
.answer-wrong { border-color: var(--danger) !important; background: #fdeaea; }
.feedback-box { padding: 1rem 1.25rem; border-radius: 12px; margin-top: .5rem; }
.feedback-correct { background: #eafaf3; border: 1px solid var(--success); }
.feedback-wrong { background: #fdeaea; border: 1px solid var(--danger); }

.answer-template { background: var(--surface-alt); border-radius: 12px; padding: 1rem 1.25rem; }

.hint-box { border-left: 4px solid var(--warning); background: #fff6e9; border-radius: 10px; padding: .5rem .9rem; }
.hint-box > summary { cursor: pointer; font-weight: 600; color: #a6690a; list-style: none; }
.hint-box > summary::-webkit-details-marker { display: none; }
.hint-box[open] > summary { margin-bottom: .5rem; }

/* ---------- Responsivt ---------- */
@media (max-width: 767.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; }
}

.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
a { color: var(--primary); }

/* Skolmodul: kalenderrutnät */
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
