/* ==========================================================================
   Svenska Portal — calm, Scandinavian-inspired design system
   Colour carries meaning: blue = Swedish/grammar, grey = English,
   green = practice/success, purple = rules/quiz, pink = phrases,
   yellow = daily topic, teal = review.
   ========================================================================== */

:root {
    --navy: #0c2a52;
    --navy-2: #133a6d;
    --blue: #1a6fe0;
    --blue-dark: #1459b8;
    --blue-soft: #eaf2fe;
    --yellow: #fecc02;
    --sv: #0b3d7a;
    --text: #1b2a41;
    --muted: #5b6b82;
    --line: #e1e8f1;
    --bg: #f4f7fb;
    --white: #fff;
    --ok: #1d7a46;
    --ok-soft: #e9f8ef;
    --no: #b3261e;
    --no-soft: #fdecea;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 42, 82, 0.04), 0 4px 14px rgba(16, 42, 82, 0.05);
    --sidebar: 240px;
    --topbar: 64px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-padding-top: calc(var(--topbar) + 12px);
}

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--blue-dark);
}

h1,
h2,
h3,
h4 {
    color: var(--navy);
    line-height: 1.25;
}

.icon {
    width: 20px;
    height: 20px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 100;
    background: var(--yellow);
    color: var(--navy);
    padding: 10px 14px;
    border-radius: 8px;
    font-weight: 700;
}

.skip-link:focus {
    top: 10px;
}

:focus-visible {
    outline: 3px solid var(--blue);
    outline-offset: 2px;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 0.875rem;
}

.lead {
    font-size: 1.05rem;
    color: var(--muted);
    margin: 4px 0 16px;
}

.h3 {
    font-size: 1.02rem;
    margin: 20px 0 8px;
}

.link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    text-decoration: none;
    margin-top: 8px;
}

.link .icon {
    width: 16px;
    height: 16px;
}

/* ---------- top bar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--topbar);
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 24px 0 20px;
    background: var(--white);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--navy);
    width: calc(var(--sidebar) - 20px);
    flex: none;
}

.brand .flag {
    width: 40px;
    height: 26px;
    border-radius: 3px;
    flex: none;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-text strong {
    font-size: 1.15rem;
}

.brand-text small {
    color: var(--muted);
    font-size: 0.75rem;
}

.search {
    flex: 1;
    min-width: 0;
    max-width: 520px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f8fafd;
    color: var(--muted);
}

.search:focus-within {
    border-color: var(--blue);
    background: var(--white);
}

.search input {
    flex: 1;
    border: 0;
    background: transparent;
    font: inherit;
    color: var(--text);
    outline: none;
    min-width: 0;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    flex: none;
    gap: 8px;
}

.chip-stat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--blue-soft);
    color: var(--navy);
    font-weight: 700;
    font-size: 0.875rem;
    text-decoration: none;
}

.chip-stat .icon {
    width: 16px;
    height: 16px;
    color: #d99a00;
}

/* ---------- shell & sidebar ---------- */
.shell {
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
    min-height: calc(100vh - var(--topbar));
}

.sidebar {
    position: sticky;
    top: var(--topbar);
    height: calc(100vh - var(--topbar));
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--navy) 0%, #0e3261 100%);
    color: #dbe6f5;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 16px 12px 8px;
}

.nav-list a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    margin-bottom: 2px;
    border-radius: 10px;
    color: #dbe6f5;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-list a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--white);
}

.nav-list a.active {
    background: var(--blue);
    color: var(--white);
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(26, 111, 224, 0.35);
}

.nav-list a:focus-visible {
    outline-color: var(--yellow);
}

.nav-label {
    margin: 14px 12px 4px;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8fa6c6;
}

.sidebar-motto {
    padding: 16px 20px 0;
    text-align: center;
    transform: rotate(-4deg);
}

.motto-sv {
    margin: 0;
    font-family: "Segoe Script", "Bradley Hand", "Snell Roundhand", "Comic Sans MS", cursive;
    font-size: 1.2rem;
    line-height: 1.35;
    color: var(--white);
}

.motto-en {
    margin: 6px 0 0;
    font-family: "Bradley Hand", "Segoe Script", cursive;
    font-size: 0.85rem;
    color: #b8c8de;
}

.sidebar-art {
    flex: 1;
    min-height: 200px;
    margin-top: 12px;
    background: url("assets/stockholm.jpg") center top / cover no-repeat;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 22%);
    mask-image: linear-gradient(to bottom, transparent 0%, #000 22%);
}

/* ---------- main layout ---------- */
.main {
    padding: 24px 28px 40px;
    min-width: 0;
}

.main:focus {
    outline: none;
}

.layout.with-rail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 24px;
    align-items: start;
}

.content {
    min-width: 0;
}

.rail {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.loading {
    padding: 60px;
    text-align: center;
    font-size: 1.1rem;
}

/* ---------- hero ---------- */
.hero {
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    padding: 28px 32px;
    min-height: 190px;
    margin-bottom: 20px;
    color: var(--white);
    background:
        linear-gradient(90deg, rgba(12, 42, 82, 0.97) 0%, rgba(19, 70, 140, 0.95) 50%, rgba(19, 70, 140, 0.6) 64%, rgba(19, 70, 140, 0) 88%),
        url("assets/stockholm.jpg") right 0 top 12% / 42% auto no-repeat,
        var(--navy-2);
}

.hero h1 {
    color: var(--white);
    font-size: clamp(1.5rem, 2.6vw, 2.1rem);
    margin: 10px 0 8px;
}

.hero h1:focus {
    outline: none;
}

.hero-body {
    max-width: 640px;
    position: relative;
}

.hero-badge {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 999px;
    background: var(--blue);
    color: var(--white);
    font-weight: 700;
    font-size: 0.85rem;
}

.hero-kicker {
    margin: 12px 0 0;
    color: var(--yellow);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.hero-sub {
    margin: 0;
    color: #e3ecf8;
    font-size: 1.02rem;
}

.hero-meta {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    padding: 0;
    margin: 16px 0 0;
    font-size: 0.9rem;
}

.hero-meta li {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hero-meta .icon {
    color: var(--yellow);
    width: 18px;
    height: 18px;
}

.hero-actions {
    margin-top: 20px;
}

.hero-daily {
    min-height: 240px;
}

/* ---------- buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 10px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.btn .icon {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--blue);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--blue-dark);
}

.btn-ghost {
    background: var(--white);
    color: var(--navy);
    border-color: #cfd9e8;
}

.btn-ghost:hover {
    border-color: var(--blue);
}

.btn-cta {
    background: var(--yellow);
    color: var(--navy);
    letter-spacing: 0.02em;
}

.btn-cta:hover {
    background: #ffd83a;
}

.btn-topic {
    background: #c98a00;
    color: var(--white);
}

.btn-topic:hover {
    background: #a87300;
}

.btn-phrases {
    background: var(--white);
    color: #9b2458;
    border-color: #efb8cf;
}

.btn-sm {
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.875rem;
}

.btn-lg {
    min-height: 52px;
    padding: 0 24px;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.btn.listening {
    background: var(--no);
}

.btn-audio {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 34px;
    height: 34px;
    margin-left: 8px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: var(--blue-soft);
    color: var(--blue);
    cursor: pointer;
    vertical-align: middle;
    flex: none;
}

.btn-audio:hover {
    background: #d5e5fd;
}

.btn-audio .icon {
    width: 17px;
    height: 17px;
}

.btn-audio.has-label {
    width: auto;
    padding: 0 14px;
    margin: 0 8px 0 0;
    font: inherit;
    font-weight: 700;
    font-size: 0.875rem;
    height: 38px;
}

/* ---------- section cards (numbered, tinted by meaning) ---------- */
.sec,
.card,
.step-body {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

.sec-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    margin: 0 0 12px;
}

.sec-title .icon {
    color: var(--blue);
}

.sec-num {
    color: var(--blue);
}

.tone-grammar {
    background: #f3f7ff;
    border-color: #d6e4fb;
}

.tone-practice {
    background: #f1faf5;
    border-color: #cfeedd;
}

.tone-practice .sec-title .icon,
.tone-practice .step-title .icon {
    color: var(--ok);
}

.tone-rules {
    background: #f7f3fd;
    border-color: #e2d8f6;
}

.tone-rules .sec-title .icon,
.tone-rules .step-title .icon {
    color: #6b3fc1;
}

.tone-phrases {
    background: #fdf3f7;
    border-color: #f5d5e2;
}

.tone-phrases .sec-title .icon,
.tone-phrases .rail-title .icon {
    color: #c2185b;
}

.tone-topic {
    background: #fff8e6;
    border-color: #f5e2a8;
}

.tone-topic .sec-title .icon,
.tone-topic .rail-title .icon {
    color: #b57800;
}

.tone-review {
    background: #eff8fa;
    border-color: #cbe8f0;
}

.tone-actions {
    background: #f3f7ff;
    border-color: #d6e4fb;
}

.tone-next {
    background: #f7f3fd;
    border-color: #e2d8f6;
}

.tone-next .rail-title .icon {
    color: #6b3fc1;
}

.note {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: #f1f6ff;
    border-left: 4px solid var(--blue);
    padding: 10px 14px;
    border-radius: 8px;
    margin: 12px 0;
}

.note .icon {
    color: var(--blue);
    margin-top: 3px;
}

.empty {
    text-align: center;
    padding: 36px 16px;
    color: var(--muted);
    background: var(--white);
    border: 1px dashed #cdd8e6;
    border-radius: var(--radius);
}

/* ---------- pill tabs ---------- */
.pill-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
    margin: 0 0 18px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 999px;
    width: fit-content;
    max-width: 100%;
}

.pill {
    padding: 7px 16px;
    border-radius: 999px;
    border: 0;
    background: transparent;
    color: var(--navy);
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    cursor: pointer;
    min-height: 36px;
}

.pill:hover {
    background: var(--blue-soft);
}

.pill.active {
    background: var(--blue);
    color: var(--white);
}

/* ---------- Swedish / English pairs ---------- */
.pair {
    margin: 10px 0;
}

.sv-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 6px;
    margin: 0;
}

.sv {
    color: var(--sv);
    font-weight: 600;
}

.pair.big .sv {
    font-size: 1.3rem;
}

.en-line {
    margin: 2px 0 0;
}

.en {
    color: var(--muted);
    font-size: 0.95rem;
}

.flag-emoji {
    font-size: 0.95rem;
    margin-right: 0.3em;
}

.emo,
.rail-big > span[aria-hidden],
.hero-badge > span[aria-hidden],
.lc-day > span[aria-hidden],
.sec-title > span[aria-hidden],
.quick-list a > span[aria-hidden] {
    margin-right: 0.35em;
}

.en-reveal {
    margin-top: 2px;
}

.en-reveal.inline {
    display: inline-block;
    margin-left: 6px;
}

.en-reveal summary,
.transcript summary {
    cursor: pointer;
    color: var(--blue-dark);
    font-weight: 600;
    font-size: 0.85rem;
    width: fit-content;
}

.transcript {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    background: #f8fafd;
}

/* ---------- chips, badges, lists ---------- */
.chips {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0;
    margin: 8px 0;
}

.chips li {
    display: inline-flex;
    align-items: center;
    background: #eef3fa;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.875rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: #eef3fa;
    color: var(--navy);
    white-space: nowrap;
}

.badge .icon {
    width: 12px;
    height: 12px;
}

.status-new {
    background: #eef1f5;
    color: #475569;
}

.status-learning {
    background: var(--blue-soft);
    color: var(--blue-dark);
}

.status-needs-review {
    background: #fff1dc;
    color: #8a4b00;
}

.status-almost-mastered {
    background: #efe7fc;
    color: #5b2fa8;
}

.status-mastered {
    background: var(--ok-soft);
    color: var(--ok);
}

.list {
    margin: 6px 0;
    padding-left: 20px;
}

.list li {
    margin: 4px 0;
}

.quick-list {
    list-style: none;
    padding: 0;
    margin: 8px 0;
}

.quick-list a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--white);
    color: var(--navy);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
}

.quick-list a:hover {
    border-color: var(--blue);
}

.quick-list .icon {
    color: var(--blue);
    width: 18px;
    height: 18px;
}

.quick-list .badge {
    margin-left: auto;
}

.quick-list.big a {
    padding: 16px;
    font-size: 1rem;
}

.crumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 6px;
}

.crumbs a {
    text-decoration: none;
    font-weight: 600;
}

.page-head h1 {
    margin: 0 0 4px;
    font-size: 1.8rem;
}

.page-head h1:focus,
.lesson-head h1:focus {
    outline: none;
}

/* ---------- progress ---------- */
.pbar {
    margin: 8px 0;
}

.pbar-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.pbar-track {
    height: 8px;
    background: #e3eaf5;
    border-radius: 999px;
    overflow: hidden;
}

.pbar-track span {
    display: block;
    height: 100%;
    background: var(--blue);
    border-radius: inherit;
}

.ring {
    position: relative;
    flex: none;
}

.ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring circle {
    fill: none;
    stroke-width: 10;
}

.ring-bg {
    stroke: #e3eaf5;
}

.ring-fg {
    stroke: var(--blue);
    stroke-linecap: round;
}

.ring span {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--navy);
}

.checklist {
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
}

.checklist li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid #eef2f7;
    font-size: 0.9rem;
}

.checklist li:last-child {
    border-bottom: 0;
}

.tick {
    width: 20px;
    height: 20px;
    border-radius: 999px;
    border: 2px solid #b9c6d8;
    display: grid;
    place-items: center;
    flex: none;
}

.checklist li.done .tick {
    background: var(--ok);
    border-color: var(--ok);
    color: var(--white);
}

.tick .icon {
    width: 12px;
    height: 12px;
    stroke-width: 3;
}

/* ---------- rail ---------- */
.rail-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}

.rail-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    margin: 0 0 12px;
}

.rail-title .icon {
    color: var(--blue);
}

.rail-ring {
    display: flex;
    align-items: center;
    gap: 14px;
}

.rail-ring p {
    margin: 2px 0 0;
}

.rail-sub {
    margin: 14px 0 0;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.rail-big {
    font-weight: 700;
    color: var(--navy);
    font-size: 1.05rem;
    margin: 0 0 6px;
}

.rail-phrases {
    list-style: none;
    padding: 0;
    margin: 0 0 12px;
}

.rail-phrases li {
    padding: 6px 0;
    border-bottom: 1px solid #f5dde8;
    font-weight: 600;
    color: var(--sv);
    font-size: 0.92rem;
}

.rail-phrases .en {
    display: block;
    font-weight: 400;
    font-size: 0.85rem;
}

.rail-phrases .btn-audio {
    width: 28px;
    height: 28px;
}

.step-list {
    list-style: none;
    padding: 0;
    margin: 12px 0 0;
}

.step-list a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
}

.step-list a:hover {
    background: #f3f7fc;
}

.step-list li.current a {
    background: var(--blue-soft);
    font-weight: 700;
    color: var(--navy);
}

.step-n {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: #e3eaf5;
    display: grid;
    place-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex: none;
}

.step-list li.done .step-n {
    background: var(--ok);
    color: var(--white);
}

.step-list li.current .step-n {
    background: var(--blue);
    color: var(--white);
}

.step-n .icon {
    width: 12px;
    height: 12px;
    stroke-width: 3;
}

/* ---------- home ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stat {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.stat-num {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--navy);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 600;
    margin: 0;
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 24px;
}

.skills-grid p {
    margin: 0;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.grid-2 > .sec {
    margin-bottom: 18px;
}

.phrase-big {
    display: flex;
    align-items: center;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--sv);
    margin: 0 0 6px;
}

.why {
    background: var(--white);
    border-radius: 10px;
    padding: 10px 14px;
    border: 1px solid var(--line);
}

.week-list {
    list-style: none;
    padding: 0;
    margin: 8px 0;
}

.week-list a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid #eef2f7;
    color: var(--text);
    text-decoration: none;
}

.week-list a:hover {
    background: #f6f9fd;
}

.wl-day {
    font-weight: 700;
    color: var(--blue-dark);
    font-size: 0.85rem;
    width: 64px;
    flex: none;
}

.wl-title {
    flex: 1;
}

.wl-state {
    color: var(--ok);
    font-size: 0.8rem;
    font-weight: 700;
}

.week-list li.current a {
    background: #fff8e1;
    border-radius: 8px;
}

.week-list li.current .wl-state {
    color: #a86b00;
}

.loop {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 18px;
}

.loop span:not([aria-hidden]) {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 2px 10px;
    font-weight: 600;
    color: var(--navy);
}

/* ---------- lesson cards & grids ---------- */
.lesson-card,
.level-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lesson-card.done {
    border-color: #bfe5cd;
}

.lc-day {
    margin: 0;
    font-weight: 700;
    color: var(--blue-dark);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lc-title {
    margin: 0;
    font-size: 1.08rem;
}

.lc-sv {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
}

.lc-meta {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.lc-goal {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--navy);
}

.lc-points {
    list-style: none;
    padding: 0;
    margin: 8px 0 10px;
    font-size: 0.9rem;
}

.lc-points li {
    display: flex;
    gap: 8px;
    margin: 4px 0;
}

.lc-points .icon {
    color: var(--ok);
    width: 18px;
    height: 18px;
    margin-top: 2px;
}

.lc-points.big {
    font-size: 1rem;
}

.lesson-card .btn {
    margin-top: auto;
    align-self: flex-start;
}

.level-grid,
.lesson-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.level-id {
    font-size: 2rem;
    font-weight: 800;
    color: var(--blue);
    margin: 0;
}

.level-card h2 {
    margin: 0;
}

.level-card .btn {
    align-self: flex-start;
    margin-top: 8px;
}

.topic-grid,
.scenario-grid,
.tile-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 8px;
}

.topic-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.scenario-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}

.tile-grid {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    margin-bottom: 18px;
}

.topic-card,
.scenario-card,
.tile-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    color: var(--navy);
    text-decoration: none;
    box-shadow: var(--shadow);
}

.topic-card:hover,
.scenario-card:hover,
.tile-card:hover {
    border-color: var(--blue);
}

.topic-card.learned {
    border-color: #bfe5cd;
    background: #f5fcf8;
}

.topic-card.planned {
    opacity: 0.65;
    border-style: dashed;
    box-shadow: none;
}

.topic-title,
.scenario-title,
.tile-title {
    font-weight: 700;
}

.topic-meta {
    color: var(--muted);
    font-size: 0.8rem;
}

.topic-state {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--blue-dark);
    margin-top: auto;
}

.topic-card.learned .topic-state {
    color: var(--ok);
}

.topic-state .icon {
    width: 14px;
    height: 14px;
}

.scenario-card {
    align-items: center;
    text-align: center;
}

.scenario-icon {
    font-size: 2rem;
}

.scenario-sv {
    color: var(--muted);
    font-size: 0.85rem;
}

.tile-card .icon {
    width: 28px;
    height: 28px;
    color: var(--blue);
}

/* ---------- vocabulary cards ---------- */
.vcard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.vcard {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
}

.vcard-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.vcard-word {
    margin: 0;
    font-size: 1.3rem;
    color: var(--sv);
}

.article {
    font-size: 0.9rem;
    color: var(--blue);
    font-weight: 700;
}

.vcard p {
    margin: 4px 0;
    font-size: 0.92rem;
}

.vcard-meta {
    color: var(--muted);
    font-size: 0.82rem !important;
}

.vcard-ex {
    border-top: 1px solid #eef2f7;
    margin-top: 8px;
    padding-top: 4px;
}

.word-list {
    columns: 2;
    padding-left: 20px;
}

/* ---------- grammar ---------- */
.rule-box {
    background: var(--white);
    border-left: 4px solid var(--blue);
    border-radius: 8px;
    padding: 10px 16px;
    margin: 12px 0;
}

.rule-box p {
    margin: 4px 0;
}

.rule-label {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--blue-dark);
}

.structure {
    display: grid;
    gap: 6px;
    margin: 10px 0;
}

.structure-row {
    display: flex;
    gap: 6px;
}

.structure-row > span {
    flex: 1;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 700;
    text-align: center;
}

.structure-row.head > span {
    padding: 0 12px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
}

.slot-0 {
    background: #e6f0fd;
    color: var(--sv);
}

.slot-1 {
    background: #fff1b8;
    color: #6b4b00;
}

.slot-2 {
    background: #e3f6ea;
    color: #185c36;
}

.slot-3 {
    background: #f0e9fc;
    color: #4d2890;
}

.slot-4 {
    background: #fde8f0;
    color: #8a1c4a;
}

.mistake p {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    margin: 6px 0;
}

.mistake .wrong {
    background: var(--no-soft);
    text-decoration: line-through;
    text-decoration-color: rgba(179, 38, 30, 0.5);
}

.mistake .right {
    background: var(--ok-soft);
    font-weight: 600;
}

.mistake .muted {
    background: none;
    padding: 0 12px;
}

.table-wrap {
    overflow-x: auto;
    margin: 10px 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    background: var(--white);
    border-radius: 10px;
    overflow: hidden;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}

.data-table th {
    background: #eef4fd;
    color: var(--navy);
}

.data-table td[lang="sv"] {
    font-weight: 600;
    color: var(--sv);
}

/* ---------- sentence explorer ---------- */
.explorer {
    background: #f7faff;
    border: 1px solid #d6e4fb;
    border-radius: 12px;
    padding: 16px 18px;
    margin: 14px 0;
}

.explorer-label {
    margin: 0;
    font-weight: 800;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--blue-dark);
}

.explorer-words {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}

.word-chip {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid #c9dcf8;
    background: var(--white);
    font: inherit;
    font-weight: 700;
    color: var(--sv);
    cursor: pointer;
    min-height: 44px;
}

.word-meaning {
    display: none;
    font-weight: 500;
    color: var(--muted);
    font-size: 0.85rem;
}

.word-chip.open {
    background: var(--blue-soft);
}

.word-chip.open .word-meaning {
    display: block;
}

.explorer-block h4 {
    margin: 12px 0 4px;
}

/* ---------- dialogue ---------- */
.dialogue {
    margin: 12px 0;
}

.dialogue-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.dialogue-head h3 {
    margin: 0;
    font-size: 1rem;
}

.bubbles {
    list-style: none;
    padding: 0;
    margin: 10px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    background: #f1f5fb;
    border: 1px solid var(--line);
}

.bubble.right {
    align-self: flex-end;
    background: var(--blue-soft);
}

.bubble.me {
    background: var(--ok-soft);
    border-color: #bfe5cd;
}

.who {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.rp-note {
    margin: 4px 0 0;
    font-size: 0.85rem;
    color: var(--muted);
}

.phrase-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.phrase-row .btn {
    margin-top: 10px;
    flex: none;
}

/* ---------- exercises ---------- */
.ex {
    background: var(--white);
    border: 1px solid var(--line);
    border-left: 4px solid #cfd9e8;
    border-radius: 12px;
    padding: 14px 16px;
    margin: 12px 0;
}

.ex.is-correct {
    border-left-color: var(--ok);
}

.ex.is-wrong {
    border-left-color: var(--no);
}

.ex-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 4px;
}

.ex-q {
    font-weight: 600;
    margin: 0 0 8px;
    padding: 0;
}

.ex-fieldset {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.options {
    display: grid;
    gap: 8px;
    margin: 8px 0;
}

.opt {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #d6e0ec;
    border-radius: 10px;
    cursor: pointer;
    background: var(--white);
}

.opt:hover {
    border-color: var(--blue);
}

.opt:has(input:checked) {
    border-color: var(--blue);
    background: var(--blue-soft);
}

.opt input {
    margin-top: 5px;
    accent-color: var(--blue);
    width: 18px;
    height: 18px;
    flex: none;
}

.ex-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #d3dee8;
    border-radius: 10px;
    font: inherit;
    font-size: 1rem;
    background: var(--white);
    color: var(--text);
}

.ex-input:focus {
    border-color: var(--blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(26, 111, 224, 0.15);
}

.ex-input.inline {
    display: inline-block;
    width: 11ch;
    padding: 4px 8px;
    margin: 0 6px;
}

.fill-line {
    line-height: 2.2;
}

.ex-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.ex-audio {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 6px 0 10px;
}

.ex-source {
    display: flex;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--sv);
}

.wrong-line {
    background: var(--no-soft);
    padding: 8px 12px;
    border-radius: 8px;
}

.hint {
    color: var(--muted);
    font-style: italic;
    font-size: 0.9rem;
}

.ex-feedback:empty {
    display: none;
}

.ex-feedback {
    margin-top: 10px;
}

.fb {
    margin: 4px 0;
}

.fb.ok {
    color: var(--ok);
}

.fb.no {
    color: var(--no);
}

.fb strong + strong,
.fb [lang="sv"] {
    color: var(--sv);
}

.fb-why {
    margin: 4px 0;
    color: var(--text);
}

.compare {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 6px 16px;
    margin: 8px 0;
    padding: 10px 14px;
    background: #f8fafd;
    border-radius: 10px;
}

.compare dt {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--muted);
}

.compare dd {
    margin: 0;
}

.self-check {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.tiles-answer {
    min-height: 54px;
    border: 2px dashed #c7d5e8;
    border-radius: 10px;
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.tiles-bank {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 0;
}

.tile {
    min-height: 40px;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid #c9dcf8;
    background: var(--blue-soft);
    color: var(--sv);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.tiles-answer .tile {
    background: #fff8d6;
    border-color: #f0dc8a;
}

.roleplay .rp-controls {
    border-top: 1px solid var(--line);
    padding-top: 10px;
}

.score {
    font-weight: 800;
    color: var(--navy);
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 14px;
    position: sticky;
    top: calc(var(--topbar) + 8px);
    z-index: 5;
}

/* ---------- lesson player ---------- */
.lesson-head {
    margin-bottom: 16px;
}

.lesson-head h1 {
    margin: 4px 0 10px;
    font-size: 1.8rem;
}

.stepper {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 16px;
}

.step-count {
    margin: 0 0 8px;
    font-size: 0.95rem;
}

.step-count span {
    color: var(--blue-dark);
    font-weight: 700;
}

.step-dots {
    list-style: none;
    display: flex;
    gap: 4px;
    padding: 0;
    margin: 0;
}

.step-dots li {
    flex: 1;
}

.step-dots a {
    display: block;
    height: 10px;
    border-radius: 999px;
    background: #dbe4f0;
}

.step-dots li.done a {
    background: #86b6f2;
}

.step-dots li.current a {
    background: var(--blue);
}

.step-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 6px;
    font-size: 1.35rem;
}

.step-title .icon {
    color: var(--blue);
    width: 24px;
    height: 24px;
}

.step-body.tone-plain {
    background: var(--white);
}

.step-nav {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin: 12px 0 24px;
}

.recall {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
    margin: 10px 0;
}

.flip {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
}

.flip summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--sv);
}

.flip p {
    margin: 6px 0 0;
    color: var(--muted);
    display: flex;
    align-items: center;
}

/* ---------- reading ---------- */
.reading-text {
    background: #fffdf6;
    border: 1px solid #f1e6c3;
    border-radius: 12px;
    padding: 16px 20px;
    font-size: 1.08rem;
    line-height: 1.8;
}

.reading-tools {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}

.word-help {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 6px 16px;
    margin: 8px 0;
}

.word-help div {
    display: flex;
    gap: 8px;
}

.word-help dt {
    font-weight: 700;
    color: var(--sv);
}

.word-help dd {
    margin: 0;
    color: var(--muted);
}

/* ---------- review ---------- */
.srs-states {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.srs-state {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.flashcard {
    max-width: 560px;
    margin: 0 auto;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 28px;
    text-align: center;
    box-shadow: var(--shadow);
}

.flashcard .ex-actions,
.flashcard .ex-audio {
    justify-content: center;
}

.fc-count {
    color: var(--muted);
    font-size: 0.85rem;
    margin: 0 0 16px;
}

.fc-front {
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--sv);
    margin: 8px 0;
    display: inline-block;
}

.fc-back {
    border-top: 1px solid var(--line);
    margin-top: 16px;
    padding-top: 12px;
}

.fc-en {
    font-size: 1.2rem;
    font-weight: 600;
}

.fc-back .pair {
    text-align: left;
}

.mistake-list {
    list-style: none;
    padding: 0;
}

.mistake-list a {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    padding: 12px 16px;
    margin-bottom: 10px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--navy);
    text-decoration: none;
}

.mistake-list a:hover {
    border-color: var(--blue);
}

.mistake-list .pbar {
    grid-column: 1 / -1;
    margin: 0;
}

.mistake-list .pbar-track span {
    background: #e07a1a;
}

.ml-title {
    font-weight: 700;
}

.ml-count {
    color: #8a4b00;
    font-weight: 700;
    font-size: 0.9rem;
}

/* ---------- footer, tab bar, toast ---------- */
.footer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px 32px;
    padding: 18px 28px 18px calc(var(--sidebar) + 28px);
    background: var(--white);
    border-top: 1px solid var(--line);
}

.brand-sm {
    width: auto;
}

.brand-sm .flag {
    width: 32px;
    height: 21px;
}

.footer-links {
    display: flex;
    gap: 18px;
    margin: 0 auto;
}

.footer-links a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9rem;
}

.footer-luck {
    margin: 0;
    font-family: "Segoe Script", "Bradley Hand", "Snell Roundhand", cursive;
    color: var(--navy);
    font-size: 1.1rem;
}

.tabbar {
    display: none;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 50;
    background: var(--navy);
    color: var(--white);
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    max-width: calc(100vw - 32px);
}

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
    .layout.with-rail {
        grid-template-columns: minmax(0, 1fr);
    }

    .rail {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }
}

@media (max-width: 900px) {
    :root {
        --topbar: 58px;
    }

    .shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .sidebar {
        display: none;
    }

    .topbar {
        gap: 12px;
        padding: 0 12px;
    }

    .brand {
        width: auto;
    }

    .brand-text small {
        display: none;
    }

    .main {
        padding: 16px 14px 96px;
    }

    .hero {
        padding: 22px 20px;
        background:
            linear-gradient(180deg, rgba(12, 42, 82, 0.95) 0%, rgba(19, 70, 140, 0.9) 100%),
            var(--navy-2);
    }

    .sec,
    .card,
    .step-body {
        padding: 16px;
    }

    .grid-2,
    .skills-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .footer {
        padding: 16px 16px 88px;
    }

    .footer-links {
        margin: 0;
    }

    .tabbar {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        background: var(--white);
        border-top: 1px solid var(--line);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .tabbar a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 8px 0 6px;
        min-height: 56px;
        color: var(--muted);
        text-decoration: none;
        font-size: 0.72rem;
        font-weight: 600;
    }

    .tabbar a.active {
        color: var(--blue);
    }

    .toast {
        bottom: 80px;
    }

    .step-nav {
        position: sticky;
        bottom: 64px;
        background: var(--bg);
        padding: 8px 0;
    }

    .step-nav .btn-lg {
        min-height: 48px;
        padding: 0 16px;
    }

    .word-list {
        columns: 1;
    }

    .bubble {
        max-width: 100%;
    }

    .compare {
        grid-template-columns: minmax(0, 1fr);
    }

    .pill-tabs {
        border-radius: 14px;
    }
}

@media (max-width: 520px) {
    .search input::placeholder {
        color: transparent;
    }

    .brand-text {
        display: none;
    }

    .page-head h1,
    .lesson-head h1 {
        font-size: 1.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
        scroll-behavior: auto !important;
    }
}
