        /* ===== СТИЛІ ===== */
        :root {
            --navy: #0F2A3D;
            --teal: #2FA89B;
            --teal-dim: #1F7A70;
            --amber: #E8A33D;
            --rose: #D9765B;
            --cream: #F3EFE4;
            --frost: #FBFCFA;
            --ink: #12232B;
            --ink-soft: #3F5866;
            --line: rgba(15,42,61,0.14);
            --line-soft: rgba(15,42,61,0.08);
            --radius: 16px;
            --shadow: 0 8px 28px rgba(15,42,61,0.10);
            --shadow-lg: 0 20px 48px rgba(15,42,61,0.18);
            --green: #2e7d32;
            --red: #c62828;
        }
        * { box-sizing: border-box; }
        html, body { margin: 0; padding: 0; overflow-x: hidden; height: 100%; }
        body {
            font-family: 'Inter', system-ui, sans-serif;
            background: var(--frost);
            color: var(--ink);
            -webkit-font-smoothing: antialiased;
            line-height: 1.5;
            min-height: 100vh;
        }
        h1,h2,h3,h4 { font-family: 'Fraunces', serif; font-weight: 600; margin: 0 0 .4em 0; color: var(--navy); letter-spacing: -.01em; }
        .mono { font-family: 'JetBrains Mono', monospace; }
        button { font-family: inherit; cursor: pointer; }
        ::selection { background: var(--teal); color: white; }
        .hidden { display: none !important; }

        /* ===== AUTH ===== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: radial-gradient(130% 170% at 15% -10%, #1E4258 0%, var(--navy) 55%, #0A1D2B 100%);
}
.auth-box {
    background: var(--frost);
    border-radius: var(--radius);
    padding: 40px 32px;
    max-width: 420px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}
.auth-box .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--navy);
    justify-content: center;
    margin-bottom: 24px;
}
.auth-box .brand .mark { width: 32px; height: 32px; }
.auth-box h2 { text-align: center; margin-bottom: 20px; }
.auth-box .field { margin-bottom: 16px; }
.auth-box .field label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
.auth-box .field input {
    width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line);
    font-size: .95rem; font-family: inherit;
}
.auth-box .field input:focus { border-color: var(--teal); outline: none; }
.auth-box .btn {
    width: 100%; padding: 12px; border-radius: 999px; border: none;
    font-weight: 700; font-size: 1rem; transition: background .15s, color .15s, border-color .15s;
    cursor: pointer;
}
.auth-box .btn-primary { background: var(--teal); color: var(--navy); }
.auth-box .btn-primary:hover { background: var(--teal-dim); color: white; }

/* ===== ВИПРАВЛЕНА КНОПКА ГОСТЯ ===== */
.auth-box .btn-guest {
    background: transparent;
    color: var(--navy);                /* темний текст – видно на білому тлі */
    border: 2px solid var(--teal);     /* яскрава рамка в кольорі бренду */
    margin-top: 10px;
    display: inline-flex;              /* для вирівнювання логотипу та тексту */
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.auth-box .btn-guest:hover {
    background: var(--teal);           /* заливка при наведенні */
    color: var(--frost);               /* білий текст на зеленому */
    border-color: var(--teal-dim);
}
.auth-box .btn-guest .mark {
    display: inline-block;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
.auth-box .btn-guest .mark svg {
    display: block;
    width: 100%;
    height: 100%;
}

.auth-box .toggle-link { text-align: center; margin-top: 16px; font-size: .9rem; color: var(--ink-soft); }
.auth-box .toggle-link span { color: var(--teal); cursor: pointer; font-weight: 600; }
.auth-box .toggle-link span:hover { text-decoration: underline; }
.auth-error { color: var(--rose); font-size: .85rem; margin-top: 8px; text-align: center; min-height: 1.4em; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--ink-soft); font-size: .8rem; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

        /* ===== APP LAYOUT ===== */
        #app { min-height: 100vh; display: none; flex-direction: column; }
        #app.active { display: flex; }
        .topbar {
            position: sticky; top: 0; z-index: 40;
            background: var(--navy); color: var(--frost);
            padding: 0 16px;
            display: flex; align-items: center; justify-content: space-between;
            height: 60px;
            box-shadow: 0 2px 14px rgba(0,0,0,.18);
        }
        .topbar .brand {
            display: flex; align-items: center; gap: 8px;
            font-family: 'Fraunces', serif; font-weight: 700; font-size: 1.1rem;
            color: var(--frost);
        }
        .topbar .brand .mark { width: 26px; height: 26px; }
        .topbar .nav { display: flex; gap: 2px; flex-wrap: wrap; }
        .topbar .nav button {
            background: transparent; border: none;
            color: rgba(251,252,250,.7);
            padding: 6px 10px; border-radius: 999px;
            font-size: .75rem; font-weight: 500;
            transition: background .15s, color .15s;
            white-space: nowrap;
        }
        .topbar .nav button:hover { background: rgba(255,255,255,.08); color: var(--frost); }
        .topbar .nav button.active { background: var(--teal); color: var(--navy); font-weight: 700; }
        .topbar .user-area { display: flex; align-items: center; gap: 10px; }
        .lang-chip { padding: 4px 8px !important; font-size: .68rem !important; min-width: auto; }
        .topbar .user-area .username { font-size: .8rem; font-weight: 500; color: rgba(251,252,250,.8); }
        .topbar .user-area .logout-btn {
            background: transparent; border: 1px solid rgba(251,252,250,.2);
            color: var(--frost); padding: 4px 12px; border-radius: 999px;
            font-size: .7rem; font-weight: 600; transition: background .15s;
        }
        .topbar .user-area .logout-btn:hover { background: rgba(255,255,255,.1); }
        .hamburger { display: none; background: transparent; border: none; color: var(--frost); font-size: 1.4rem; padding: 4px 8px; }

        main { flex: 1; max-width: 1120px; width: 100%; margin: 0 auto; padding: 24px 16px 60px; }
        .view { animation: fadein .35s ease; }
        @keyframes fadein { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }

        /* ===== CARDS ===== */
        .card {
            background: var(--frost);
            border: 1px solid var(--line);
            border-radius: var(--radius);
            padding: 20px 22px;
            box-shadow: var(--shadow);
            transition: box-shadow .2s, transform .15s;
        }
        .card:hover { box-shadow: var(--shadow-lg); }

        /* ===== TROLL & GAMIFICATION ===== */
        .troll-bubble {
            position: relative;
            background: var(--frost);
            border: 1.5px solid var(--line);
            border-radius: 14px;
            padding: 12px 16px;
            font-size: .9rem;
            color: var(--ink);
            max-width: 320px;
        }
        .troll-bubble::before {
            content: "";
            position: absolute;
            left: -8px;
            top: 50%;
            transform: translateY(-50%);
            border-width: 8px 8px 8px 0;
            border-style: solid;
            border-color: transparent var(--line) transparent transparent;
        }
        .troll-bubble::after {
            content: "";
            position: absolute;
            left: -6.5px;
            top: 50%;
            transform: translateY(-50%);
            border-width: 7px 7px 7px 0;
            border-style: solid;
            border-color: transparent var(--frost) transparent transparent;
        }
        .xp-bar-track { height: 12px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
        .xp-bar-fill { height: 100%; background: linear-gradient(90deg, var(--teal), var(--amber)); border-radius: 999px; transition: width .5s ease; }
        .troll-level-badge {
            display: inline-flex; align-items: center; gap: 6px;
            background: var(--navy); color: var(--frost); padding: 4px 12px; border-radius: 999px;
            font-family: 'JetBrains Mono', monospace; font-size: .78rem; font-weight: 700;
        }
        .gear-row { display: flex; gap: 8px; flex-wrap: wrap; }
        .gear-badge {
            display: flex; align-items: center; justify-content: center;
            width: 40px; height: 40px; border-radius: 10px; overflow: hidden;
            background: var(--line-soft); border: 1.5px solid transparent; position: relative;
        }
        .gear-badge svg { width: 34px; height: 34px; border-radius: 8px; }
        .gear-badge.locked { opacity: .35; filter: grayscale(1); }
        .gear-badge.equipped { border-color: var(--teal); background: rgba(47,168,155,0.12); }
        .gear-badge:not(.locked) { cursor: pointer; }
        .ach-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(140px,1fr)); gap: 10px; }
        .ach-item {
            border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; font-size: .8rem;
        }
        .ach-item.unlocked { border-color: var(--amber); background: rgba(232,163,61,0.08); }
        .ach-item.locked { opacity: .4; }
        .ach-item .ach-icon { font-size: 1.6rem; margin-bottom: 4px; }

        /* ===== AI ASSISTANT CHAT ===== */
        .chat-shell {
            display: flex; flex-direction: column;
            height: min(640px, 70vh);
            border: 1px solid var(--line); border-radius: var(--radius);
            background: var(--frost); box-shadow: var(--shadow); overflow: hidden;
        }
        .chat-log {
            flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px;
        }
        .chat-row { display: flex; gap: 10px; align-items: flex-end; max-width: 100%; }
        .chat-row.user { flex-direction: row-reverse; }
        .chat-avatar { flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; overflow: hidden; background: var(--line-soft); }
        .chat-avatar svg { display: block; width: 100%; height: 100%; }
        .chat-bubble {
            max-width: 72%; padding: 10px 14px; border-radius: 16px; font-size: .9rem; line-height: 1.45;
            white-space: pre-wrap; word-break: break-word;
        }
        .chat-row.bot .chat-bubble { background: var(--line-soft); color: var(--ink); border-bottom-left-radius: 4px; }
        .chat-row.user .chat-bubble { background: var(--teal); color: white; border-bottom-right-radius: 4px; }
        .chat-row.bot.error .chat-bubble { background: rgba(217,118,91,.12); color: var(--rose); }
        .chat-typing { display: inline-flex; gap: 4px; padding: 2px 4px; }
        .chat-typing span {
            width: 6px; height: 6px; border-radius: 50%; background: var(--ink-soft); opacity: .5;
            animation: chatTypingBlink 1.1s infinite ease-in-out;
        }
        .chat-typing span:nth-child(2) { animation-delay: .15s; }
        .chat-typing span:nth-child(3) { animation-delay: .3s; }
        @keyframes chatTypingBlink { 0%,80%,100%{ opacity:.25; transform: translateY(0); } 40%{ opacity:.9; transform: translateY(-3px); } }
        .chat-input-bar {
            display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--frost);
        }
        .chat-input-bar textarea {
            flex: 1; resize: none; border: 1px solid var(--line); border-radius: 14px;
            padding: 10px 14px; font-family: inherit; font-size: .9rem; max-height: 100px; min-height: 42px;
        }
        .chat-input-bar textarea:focus { outline: none; border-color: var(--teal); }
        .chat-send-btn {
            border: none; background: var(--teal); color: var(--navy); border-radius: 999px;
            width: 44px; height: 44px; flex-shrink: 0; font-size: 1.1rem; font-weight: 700;
            display: flex; align-items: center; justify-content: center;
        }
        .chat-send-btn:hover { background: var(--teal-dim); color: white; }
        .chat-send-btn:disabled { opacity: .5; cursor: default; }
        .chat-suggest-row { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 12px 12px; }
        .chat-suggest-chip {
            border: 1px solid var(--line); background: transparent; color: var(--ink-soft);
            border-radius: 999px; padding: 5px 12px; font-size: .78rem;
        }
        .chat-suggest-chip:hover { background: var(--line-soft); color: var(--navy); }

        .grid { display: grid; gap: 16px; }
        .grid.cols-2 { grid-template-columns: 1fr 1fr; }
        .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
        .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
        @media(max-width:820px){ .grid.cols-2,.grid.cols-3,.grid.cols-4 { grid-template-columns: 1fr 1fr; } }
        @media(max-width:560px){ .grid.cols-2,.grid.cols-3,.grid.cols-4 { grid-template-columns: 1fr; } }

        .btn {
            display: inline-flex; align-items: center; justify-content: center; gap: 8px;
            border-radius: 999px; border: 1px solid transparent;
            padding: 10px 18px; font-weight: 600; font-size: .9rem;
            transition: transform .1s, box-shadow .15s, background .15s;
        }
        .btn:active { transform: scale(.97); }
        .btn-primary { background: var(--teal); color: var(--navy); }
        .btn-primary:hover { background: var(--teal-dim); color: white; }
        .btn-ghost { background: transparent; border-color: var(--line); color: var(--navy); }
        .btn-ghost:hover { background: var(--line-soft); }
        .btn-amber { background: var(--amber); color: var(--navy); }
        .btn-amber:hover { filter: brightness(1.08); }
        .btn-danger { background: transparent; border-color: var(--rose); color: var(--rose); }
        .btn-danger:hover { background: rgba(217,118,91,.1); }
        .btn-sm { padding: 6px 14px; font-size: .78rem; }
        .btn-block { width: 100%; }

        .tag {
            display: inline-block; padding: 3px 10px; border-radius: 999px;
            font-size: .7rem; font-weight: 700;
            background: var(--line-soft); color: var(--ink-soft);
            text-transform: uppercase; letter-spacing: .04em;
        }
        .tag.level-A1 { background: #DCEFEC; color: #1F7A70; }
        .tag.level-A2 { background: #DCEFEC; color: #166358; }
        .tag.level-B1 { background: #FDEBD3; color: #9C6414; }
        .tag.level-B2 { background: #FDEBD3; color: #7A4E0F; }
        .tag.level-C1 { background: #F6DAD1; color: #A34123; }
        .tag.level-C2 { background: #F6DAD1; color: #7C2E13; }

        .progress-track { height: 6px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
        .progress-fill { height: 100%; background: linear-gradient(90deg, var(--teal), var(--amber)); border-radius: 999px; transition: width .6s ease; }

        /* ===== HERO ===== */
        .hero {
            position: relative; border-radius: 18px; overflow: hidden;
            padding: 32px 24px; margin-bottom: 24px;
            background: radial-gradient(130% 170% at 15% -10%, #1E4258 0%, var(--navy) 55%, #0A1D2B 100%);
            color: var(--frost);
        }
        .hero .eyebrow { font-family: 'JetBrains Mono', monospace; color: var(--teal); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 8px; }
        .hero h1 { color: var(--frost); font-size: 1.6rem; max-width: 660px; }
        .hero p { color: rgba(251,252,250,.78); max-width: 540px; margin-bottom: 16px; font-size: .95rem; }
        .sunarc-wrap { position: absolute; right: -30px; top: -30px; width: 240px; height: 240px; opacity: .8; pointer-events: none; }
        @media(max-width:820px){ .sunarc-wrap { display: none; } }
        .homepick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
        .homepick .btn { background: rgba(255,255,255,.08); color: var(--frost); border-color: rgba(255,255,255,.2); font-size: .82rem; padding: 8px 14px; }
        .homepick .btn:hover { background: rgba(255,255,255,.18); }

        .dailyword { display: flex; align-items: center; gap: 14px; }
        .dailyword .word-no { font-family: 'Fraunces', serif; font-size: 1.4rem; font-weight: 600; color: var(--navy); }
        .dailyword .word-uk { color: var(--ink-soft); font-size: .95rem; }
        .soundbtn {
            width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
            background: var(--frost);
            display: flex; align-items: center; justify-content: center;
            flex: none; font-size: .95rem; color: var(--navy);
            transition: background .15s, transform .1s;
        }
        .soundbtn:hover { background: var(--line-soft); transform: scale(1.05); }

        .calendar-strip { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
        .calendar-strip .day {
            width: 30px; height: 30px; border-radius: 6px; background: var(--line-soft);
            display: flex; align-items: center; justify-content: center;
            font-size: .65rem; color: var(--ink-soft); font-family: 'JetBrains Mono', monospace;
        }
        .calendar-strip .day.active { background: var(--teal); color: white; font-weight: 700; }
        .calendar-strip .day.today { border: 2px solid var(--amber); }

        /* ===== LEVELS ===== */
        .level-card { cursor: pointer; transition: transform .15s, box-shadow .15s; position: relative; }
        .level-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
        .level-card.current { border: 2px solid var(--teal); }
        .level-card h3 { margin-bottom: 4px; font-size: 1.1rem; }
        .level-card .lname { color: var(--ink-soft); font-size: .8rem; margin-bottom: 10px; }
        .level-topics { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
        .level-topics span { font-size: .65rem; background: var(--line-soft); padding: 2px 8px; border-radius: 999px; color: var(--ink-soft); }

        /* ===== FLASHCARDS ===== */
        .deckpicker { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 20px; }
        .chip {
            padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
            background: var(--frost); font-size: .8rem; font-weight: 600; color: var(--ink-soft);
            transition: all .15s;
        }
        .chip.active { background: var(--navy); color: var(--frost); border-color: var(--navy); }
        .chip:hover { border-color: var(--teal); transform: translateY(-1px); }

        .flash-stage { display: flex; flex-direction: column; align-items: stretch; padding: 12px 0; }
        .flash-card-holder { width: 100%; display: flex; flex-direction: column; align-items: center; }
        .flash-progress { width: 100%; max-width: 560px; margin-bottom: 18px; }
        .flash-progress .meta { display: flex; justify-content: space-between; font-size: .75rem; color: var(--ink-soft); margin-bottom: 4px; font-family: 'JetBrains Mono', monospace; }

        .flip-card { width: 100%; max-width: 560px; height: 340px; perspective: 1400px; margin-bottom: 20px; touch-action: manipulation; }
        .flip-inner { position: relative; width: 100%; height: 100%; transition: transform .5s cubic-bezier(.4,.2,.2,1); transform-style: preserve-3d; cursor: pointer; border-radius: 20px; }
        .flip-inner.flipped { transform: rotateY(180deg); }
        .flip-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px 20px; text-align: center; box-shadow: var(--shadow-lg); border: 1px solid var(--line); overflow: hidden; background: var(--frost); }
        .flip-back { background: var(--navy); color: var(--frost); transform: rotateY(180deg); }
        .flip-face .no-word { font-family: 'Fraunces', serif; font-size: 2.6rem; font-weight: 700; color: var(--navy); line-height: 1.2; max-width: 100%; overflow-wrap: break-word; word-break: keep-all; hyphens: none; text-align: center; }
        .flip-back .no-word { color: var(--frost); }
        .flip-face .uk-word { font-size: 2rem; font-weight: 700; max-width: 100%; overflow-wrap: break-word; word-break: keep-all; hyphens: none; text-align: center; }
        .flip-face .example { font-size: .95rem; color: var(--ink-soft); font-style: italic; max-width: 90%; line-height: 1.5; }
        .flip-back .example { color: rgba(251,252,250,.8); }
        .flip-hint { font-size: .7rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; font-family: 'JetBrains Mono', monospace; max-width: 90%; margin-top: 4px; }
        .flip-back .flip-hint { color: rgba(251,252,250,.5); }

        .grade-row { display: flex; gap: 8px; width: 100%; max-width: 560px; }
        .grade-row .btn { flex: 1; font-size: .82rem; padding: 10px 12px; }

        .mc-options { display: grid; gap: 8px; width: 100%; max-width: 500px; }
        .mc-opt {
            padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line);
            background: var(--frost); text-align: left; font-size: .95rem; font-weight: 500;
            transition: border-color .15s, background .15s; word-break: break-word;
        }
        .mc-opt:hover { border-color: var(--teal); }
        .mc-opt.correct { background: #DCEFEC; border-color: var(--teal-dim); color: var(--teal-dim); font-weight: 700; }
        .mc-opt.wrong { background: #F6DAD1; border-color: var(--rose); color: #A34123; font-weight: 700; }
        .mc-opt[disabled] { pointer-events: none; }

        .type-input {
            width: 100%; max-width: 500px; padding: 12px 16px; border-radius: 12px;
            border: 1.5px solid var(--line); font-size: 1rem; font-family: 'JetBrains Mono', monospace;
            text-align: center; margin-bottom: 12px;
        }
        .type-input:focus { border-color: var(--teal); }
        .feedback-banner { width: 100%; max-width: 500px; padding: 10px 16px; border-radius: 12px; margin-bottom: 12px; font-weight: 600; font-size: .88rem; }
        .feedback-banner.ok { background: #DCEFEC; color: var(--teal-dim); }
        .feedback-banner.bad { background: #F6DAD1; color: #A34123; }

        .session-end { text-align: center; padding: 30px 16px; }
        .session-end .bignum { font-family: 'JetBrains Mono', monospace; font-size: 2.6rem; color: var(--teal); font-weight: 700; }

        /* ===== TESTS ===== */
        .test-type-card { display: flex; flex-direction: column; gap: 8px; height: 100%; }
        .test-type-card .icon { font-size: 1.6rem; }
        .test-type-card p { color: var(--ink-soft); font-size: .85rem; flex: 1; }
        .cloze-sentence { font-size: 1.15rem; line-height: 1.8; margin: 16px 0; font-family: 'Fraunces', serif; }
        .order-tokens { display: flex; flex-wrap: wrap; gap: 6px; min-height: 44px; padding: 10px; border: 1.5px dashed var(--line); border-radius: 12px; margin-bottom: 12px; }
        .order-pool { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
        .token { padding: 8px 12px; border-radius: 8px; background: var(--navy); color: var(--frost); font-weight: 600; font-size: .88rem; }

        /* ===== GRAMMAR ===== */
        .gram-item { border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; overflow: hidden; background: var(--frost); }
        .gram-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; cursor: pointer; }
        .gram-head h3 { margin: 0; font-size: 1rem; }
        .gram-body { padding: 0 18px 18px; display: none; }
        .gram-body.open { display: block; }
        .gram-body table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: .85rem; }
        .gram-body th,.gram-body td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
        .gram-body th { background: var(--cream); font-family: 'JetBrains Mono', monospace; font-size: .72rem; text-transform: uppercase; }

        /* ===== VOCABULARY ===== */
        .vocab-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
        .vocab-table th { text-align: left; padding: 8px 6px; border-bottom: 2px solid var(--line); font-family: 'JetBrains Mono', monospace; font-size: .7rem; text-transform: uppercase; color: var(--ink-soft); }
        .vocab-table td { padding: 6px 6px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
        .vocab-table .status { font-size: .65rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
        .vocab-table .status.new { background: var(--line-soft); color: var(--ink-soft); }
        .vocab-table .status.due { background: var(--amber); color: var(--navy); }
        .vocab-table .status.mastered { background: var(--teal); color: white; }

        /* ===== PROFILE ===== */
        .stat-box { text-align: center; padding: 14px 8px; }
        .stat-box .num { font-family: 'JetBrains Mono', monospace; font-size: 1.6rem; font-weight: 700; color: var(--teal-dim); }
        .stat-box .label { font-size: .72rem; color: var(--ink-soft); margin-top: 2px; }
        .calendar-grid { display: grid; grid-template-columns: repeat(15, 1fr); gap: 4px; margin-top: 10px; }
        .calendar-grid .cell { aspect-ratio: 1; border-radius: 4px; background: var(--line-soft); }
        .calendar-grid .cell.on { background: var(--teal); }

        .field { margin-bottom: 14px; }
        .field label { display: block; font-size: .78rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
        .field input,.field select { width: 100%; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); font-family: inherit; font-size: .9rem; }

        .empty-state { text-align: center; padding: 40px 16px; color: var(--ink-soft); }
        .empty-state h3 { color: var(--navy); }

        .toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: var(--frost); padding: 10px 20px; border-radius: 999px; font-size: .84rem; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 100; animation: toastin .25s ease; }
        @keyframes toastin { from { opacity:0; transform:translate(-50%,10px); } to { opacity:1; transform:translate(-50%,0); } }

        footer.appfoot { text-align: center; padding: 18px; color: var(--ink-soft); font-size: .7rem; }

        /* ===== TEST NAVIGATION ===== */
        .test-nav { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 16px; }
        .test-nav .dot {
            width: 36px; height: 36px; border-radius: 50%;
            display: flex; align-items: center; justify-content: center;
            font-size: .7rem; font-weight: 700;
            color: var(--ink-soft); background: var(--line-soft);
            border: 2px solid transparent; transition: all .2s;
            cursor: pointer; user-select: none;
        }
        .test-nav .dot.active { border-color: var(--teal); background: var(--frost); color: var(--navy); }
        .test-nav .dot.correct { background: var(--green); color: white; }
        .test-nav .dot.wrong { background: var(--rose); color: white; }
        .test-nav .dot.correct.active, .test-nav .dot.wrong.active { border-color: var(--amber); transform: scale(1.1); }
        .test-controls { display: flex; gap: 12px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

        /* ===== NORSKPRØVE ACADEMY ===== */
        .exam-card {
            border: 1px solid var(--line);
            border-radius: var(--radius);
            padding: 20px;
            background: var(--frost);
            transition: box-shadow .2s;
            cursor: pointer;
        }
        .exam-card:hover { box-shadow: var(--shadow-lg); }
        .exam-card .exam-icon { font-size: 2rem; margin-bottom: 8px; }
        .exam-card .exam-tag {
            display: inline-block; padding: 2px 10px; border-radius: 999px;
            font-size: .6rem; font-weight: 700; text-transform: uppercase;
            background: var(--amber); color: var(--navy);
        }
        .exam-card .exam-level { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .6rem; font-weight: 700; background: var(--teal); color: white; }
        .exam-result { text-align: center; padding: 20px; }
        .exam-result .big-score { font-family: 'JetBrains Mono', monospace; font-size: 3rem; font-weight: 700; color: var(--teal); }

        /* ===== MOBILE ===== */
        @media(max-width:760px) {
            .topbar .nav { position: fixed; top: 60px; left: 0; right: 0; background: var(--navy); flex-direction: column; padding: 8px 16px; display: none; box-shadow: var(--shadow-lg); z-index: 50; gap: 2px; }
            .topbar .nav.open { display: flex; }
            .topbar .nav button { text-align: left; padding: 8px 14px; font-size: .85rem; }
            .hamburger { display: block; }
            .hero h1 { font-size: 1.4rem; }
            .hero { padding: 24px 18px; }
            .homepick .btn { font-size: .78rem; padding: 7px 12px; }
            .card { padding: 16px 18px; }
            main { padding: 16px 12px 40px; }
            .flip-card { height: 300px; max-width: 100%; }
            .flip-face .no-word { font-size: 2.2rem; }
            .flip-face .uk-word { font-size: 1.6rem; }
            .flip-face .example { font-size: .85rem; }
            .grade-row .btn { font-size: .78rem; padding: 8px 10px; }
            .mc-opt { font-size: .88rem; padding: 10px 14px; }
            .type-input { font-size: .95rem; padding: 10px 14px; }
            .test-nav .dot { width: 30px; height: 30px; font-size: .6rem; }
        }
        @media(max-width:480px) {
            .topbar .username { display: none; }
            .topbar .user-area { gap: 6px; }
            .topbar .logout-btn { padding: 4px 8px; font-size: .7rem; }
            .flip-card { height: 260px; }
            .flip-face .no-word { font-size: 1.8rem; }
            .flip-face .uk-word { font-size: 1.4rem; }
            .flip-face .example { font-size: .78rem; }
            .flip-hint { font-size: .6rem; }
            .grade-row { flex-wrap: wrap; }
            .grade-row .btn { min-width: 80px; }
            .soundbtn { width: 36px; height: 36px; font-size: .85rem; }
            .dailyword .word-no { font-size: 1.2rem; }
            .grid.cols-2,.grid.cols-3,.grid.cols-4 { grid-template-columns: 1fr; }
            .deckpicker .chip { font-size: .72rem; padding: 5px 10px; }
            .hero h1 { font-size: 1.2rem; }
            .hero p { font-size: .85rem; }
            .topbar { height: 56px; padding: 0 12px; }
            .topbar .brand { font-size: 1rem; }
            .topbar .brand .mark { width: 24px; height: 24px; }
            .calendar-strip .day { width: 26px; height: 26px; font-size: .55rem; }
            .vocab-table { font-size: .78rem; }
            .vocab-table th,.vocab-table td { padding: 4px 4px; }
            .auth-box { padding: 30px 20px; }
            .test-nav .dot { width: 26px; height: 26px; font-size: .55rem; }
        }
        @media(max-width:380px) {
            .flip-card { height: 220px; }
            .flip-face .no-word { font-size: 1.5rem; }
            .flip-face .uk-word { font-size: 1.1rem; }
            .flip-face .example { font-size: .7rem; }
            .flip-hint { font-size: .55rem; }
            .grade-row .btn { font-size: .7rem; padding: 6px 8px; }
        }


/* =====================================================================
   AI-ПОМІЧНИК: ПЛАВАЮЧА КНОПКА (FAB) + БІЧНА ПАНЕЛЬ
   Раніше "Помічник" був окремою вкладкою в меню — клік по ній повністю
   перезавантажував <main>. Тепер це кругла кнопка, яка "плаває" поверх
   ВСІХ вкладок (вона лежить у #app, а не в <main>, тож не зникає під час
   навігації), а клік по ній відкриває чат збоку, не змінюючи поточну
   сторінку/маршрут.
   ===================================================================== */
.assistant-fab {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 70;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    background: var(--teal);
    color: var(--navy);
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    transition: transform .15s ease, background .15s ease, color .15s ease;
}
.assistant-fab:hover { background: var(--teal-dim); color: white; transform: scale(1.07); }
.assistant-fab:active { transform: scale(.96); }
.assistant-fab-avatar { display: flex; align-items: center; justify-content: center; width: 46px; height: 46px; line-height: 0; }
.assistant-fab-avatar svg { width: 100%; height: 100%; }
.assistant-fab .fab-dot {
    position: absolute; top: -2px; right: -2px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--amber); border: 2px solid var(--frost);
    display: none;
}

.assistant-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,42,61,.35);
    z-index: 65;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}
.assistant-overlay.open { opacity: 1; pointer-events: auto; }

.assistant-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: min(400px, 92vw);
    background: var(--frost);
    box-shadow: var(--shadow-lg);
    z-index: 71;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .28s ease;
}
.assistant-panel.open { transform: translateX(0); }
.assistant-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    background: var(--navy);
    color: var(--frost);
    flex-shrink: 0;
}
.assistant-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: 1.05rem;
}
.assistant-panel-title .mini-avatar { width: 28px; height: 28px; border-radius: 50%; overflow: hidden; background: rgba(255,255,255,.12); }
.assistant-panel-title .mini-avatar svg { display: block; width: 100%; height: 100%; }
.assistant-close-btn {
    background: transparent;
    border: 1px solid rgba(251,252,250,.25);
    color: var(--frost);
    width: 30px; height: 30px;
    border-radius: 50%;
    font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.assistant-close-btn:hover { background: rgba(255,255,255,.12); }
.assistant-panel-sub {
    padding: 8px 16px;
    font-size: .78rem;
    color: var(--ink-soft);
    border-bottom: 1px solid var(--line-soft);
    flex-shrink: 0;
}
.assistant-chat-shell {
    flex: 1;
    min-height: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    height: auto;
}
.assistant-panel-footer {
    padding: 8px 14px 12px;
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
    border-top: 1px solid var(--line-soft);
}

@media (max-width: 640px) {
    .assistant-panel { width: 100vw; }
    .assistant-fab { right: 16px; bottom: 16px; }
}

/* ---- Leaderboard row (перенесено з окремого <script>-інжекту у CSS) ---- */
.leaderboard-row { display: flex; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line-soft); font-size: .85rem; }
.leaderboard-row .rank { width: 30px; font-weight: 700; color: var(--ink-soft); font-family: 'JetBrains Mono', monospace; }
.leaderboard-row .name { flex: 1; }
.leaderboard-row .pts { font-weight: 600; color: var(--teal-dim); font-family: 'JetBrains Mono', monospace; }
.leaderboard-row.you { background: rgba(47,168,155,0.08); border-radius: 8px; }
.leaderboard-row.you .rank { color: var(--teal); }
.leaderboard-row.you .name { font-weight: 700; }
.leaderboard-row.you .pts { color: var(--teal); }
