:root {
    --navy: #12163a;
    --navy-2: #1a2048;
    --blue: #1d4ed8;
    --yellow: #F6E936;
    --ink: #16181d;
    --muted: #5c6570;
    --line: #e2e6ef;
    --bg: #eef1f8;
    --white: #ffffff;
    --green: #157a3a;
    --red: #b42318;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --top-h: 56px;
    --tab-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html, body.app-body {
    height: 100%;
    height: 100dvh;
    height: var(--app-h, 100dvh);
    overflow: hidden;
}
body.app-body {
    background: #070b1c;
    color: var(--ink);
    font-family: Manrope, "Segoe UI", system-ui, sans-serif;
    display: flex;
    justify-content: center;
    align-items: stretch;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
    width: 100%;
    position: fixed;
    inset: 0;
}
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
img { max-width: 100%; }

.app-shell {
    width: 100%;
    max-width: 430px;
    height: 100%;
    height: 100dvh;
    height: var(--app-h, 100dvh);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

@media (min-width: 768px) {
    html, body.app-body {
        position: relative;
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }
    body.app-body {
        align-items: center;
        padding: 28px 16px;
        inset: auto;
        width: auto;
        background:
            radial-gradient(ellipse 80% 50% at 50% 0%, #1a2458 0%, transparent 55%),
            #070b1c;
    }
    .app-shell {
        height: min(844px, calc(100vh - 56px));
        min-height: 0;
        max-height: min(844px, calc(100vh - 56px));
        border-radius: 42px;
        box-shadow:
            0 0 0 11px #12163a,
            0 0 0 13px #3d456e,
            0 30px 80px rgba(0, 0, 0, 0.45);
    }
    .app-shell::before {
        content: "";
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 118px;
        height: 22px;
        background: #070b1c;
        border-radius: 14px;
        z-index: 40;
        pointer-events: none;
    }
}

@media (max-width: 767.98px) {
    .app-shell {
        position: fixed;
        inset: 0;
        width: 100%;
        max-width: none;
        height: var(--app-h, 100dvh);
    }
}

.app-top {
    height: calc(var(--top-h) + var(--safe-top));
    padding: var(--safe-top) 10px 0;
    background: var(--navy);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex: 0 0 auto;
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}
.app-top strong {
    font-size: 16px;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: #fff;
    background: rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.app-icon-btn.ghost { background: transparent; color: var(--yellow); }
.app-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--yellow);
    color: var(--navy);
    font-weight: 800;
    display: grid;
    place-items: center;
    font-size: 14px;
}

.app-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 16px 16px 18px;
    touch-action: pan-y;
}
.app-scroll.no-tabs {
    padding-bottom: calc(18px + var(--safe-bottom));
}

.app-tabs {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    flex: 0 0 auto;
    height: calc(var(--tab-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: #fff;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    z-index: 30;
    box-shadow: 0 -8px 24px rgba(18, 22, 58, 0.08);
}
.app-tabs a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #8b93a7;
    font-size: 11px;
    font-weight: 700;
    min-height: 100%;
    padding: 8px 4px 0;
}
.app-tabs a i { font-size: 18px; }
.app-tabs a.on { color: var(--navy); }
.app-tabs a.on i { color: var(--blue); }

.hero-block {
    background: linear-gradient(160deg, var(--navy) 0%, #1d2a6b 100%);
    color: #fff;
    border-radius: 22px;
    padding: 20px 18px 18px;
    margin: -4px 0 16px;
    position: relative;
    overflow: hidden;
}
.hero-block::after {
    content: "";
    position: absolute;
    right: -30px;
    top: -40px;
    width: 140px;
    height: 140px;
    background: rgba(246, 233, 54, 0.16);
    border-radius: 50%;
}
.hero-block .kicker {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--yellow);
    margin-bottom: 6px;
}
.hero-block h1 {
    margin: 0 0 8px;
    font-size: 24px;
    line-height: 1.2;
    letter-spacing: -0.03em;
}
.hero-block p {
    margin: 0 0 16px;
    color: #c9d0e8;
    font-size: 14px;
}
.hero-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.hero-stats div {
    background: rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 10px 8px;
    text-align: center;
}
.hero-stats b { display: block; font-size: 16px; }
.hero-stats span { font-size: 11px; color: #b8c0d6; }

.section-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 8px 0 10px;
}
.section-row h2 {
    margin: 0;
    font-size: 17px;
    letter-spacing: -0.02em;
}
.section-row a { font-size: 13px; font-weight: 700; }

.exam-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 8px;
}
.exam-tile {
    background: #fff;
    border-radius: 18px;
    padding: 16px 14px;
    box-shadow: 0 8px 24px rgba(18, 22, 58, 0.06);
    color: inherit;
    min-height: 132px;
}
.exam-tile i {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    margin-bottom: 10px;
    color: var(--navy);
}
.exam-tile.theory i { background: #fff3a0; }
.exam-tile.life i { background: #dbe4ff; }
.exam-tile h3 { margin: 0 0 4px; font-size: 15px; }
.exam-tile p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.4; }

.chip-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    margin: 0 -16px 12px;
    padding-left: 16px;
    padding-right: 16px;
    scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
    flex: 0 0 auto;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 700;
}
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }

.list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.list-item {
    background: #fff;
    border-radius: 16px;
    padding: 14px;
    display: block;
    color: inherit;
    box-shadow: 0 6px 18px rgba(18, 22, 58, 0.05);
}
.list-item h3 {
    margin: 0 0 6px;
    font-size: 15px;
    line-height: 1.35;
}
.list-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 10px;
}
.list-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.cat-label {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--blue);
    margin: 0 0 4px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 14px;
    border: 0;
    cursor: pointer;
    text-decoration: none;
}
.btn-block { width: 100%; }
.btn-yellow { background: var(--yellow); color: #111; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-ghost {
    background: #fff;
    color: var(--navy);
    border: 1px solid var(--line);
}
.btn-danger { background: #fff1f0; color: var(--red); }
.btn:disabled { opacity: 0.45; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 800;
    border-radius: 999px;
    padding: 3px 8px;
}
.badge-lock { background: #fff3cd; color: #7a5b00; }
.badge-free { background: #e8f8ee; color: var(--green); }
.badge-paid { background: #eef2ff; color: var(--blue); }
.badge-pass { background: #e8f8ee; color: var(--green); }
.badge-fail { background: #fdecea; color: var(--red); }
.badge-exam { background: #e8eeff; color: var(--blue); }
.badge-practice { background: #fff8d6; color: #6b5900; }

.search-box {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.search-box input,
.search-box select,
.field {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0 14px;
    background: #fff;
    font-size: 16px;
}
.search-box select { max-width: 140px; }
label.field-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin: 12px 0 6px;
}
.alert {
    background: #fdecea;
    color: var(--red);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}
.alert.ok { background: #e8f8ee; color: var(--green); }
.empty {
    text-align: center;
    padding: 32px 12px;
    color: var(--muted);
    font-size: 14px;
}

.mode-stack { display: flex; flex-direction: column; gap: 12px; }
.mode-card {
    background: #fff;
    border-radius: 18px;
    padding: 16px;
    display: block;
    color: inherit;
    box-shadow: 0 8px 24px rgba(18, 22, 58, 0.06);
}
.mode-card.is-locked { opacity: 0.88; }
.mode-card h3 { margin: 8px 0 4px; font-size: 17px; }
.mode-card p { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.mode-card ul { margin: 0 0 14px; padding: 0; list-style: none; }
.mode-card li { font-size: 13px; padding: 3px 0; color: #334155; }
.mode-card li i { color: var(--green); margin-right: 6px; }
.mode-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: #eef2ff;
    color: var(--blue);
}
.brief-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 14px;
}
.brief-stat {
    background: #fff;
    border-radius: 14px;
    padding: 10px 4px;
    text-align: center;
}
.brief-stat b { display: block; font-size: 13px; }
.brief-stat span { font-size: 10px; color: var(--muted); font-weight: 700; }
.lock-note {
    background: #fff8d6;
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 13px;
    margin-bottom: 12px;
}

.quiz-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}
.timer-box {
    background: var(--navy);
    color: #fff;
    border-radius: 12px;
    padding: 8px 12px;
    font-weight: 800;
    min-width: 72px;
    text-align: center;
}
.timer-box.warn { background: #b45309; }
.timer-box.danger { background: var(--red); }
.q-chip-row {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 4px 0 12px;
    scrollbar-width: none;
}
.q-chip-row::-webkit-scrollbar { display: none; }
.q-chip {
    flex: 0 0 34px;
    height: 34px;
    border-radius: 10px;
    border: 0;
    background: #fff;
    font-weight: 800;
    font-size: 12px;
    color: var(--ink);
}
.q-chip.current { background: var(--navy); color: #fff; }
.q-chip.answered { background: #dbeafe; color: var(--blue); }
.q-chip.flagged { background: #fde68a; color: #7a5b00; }
.progress-track {
    height: 6px;
    background: #dce2ef;
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 14px;
}
.progress-fill { height: 100%; width: 0; background: var(--yellow); }
.question-title { margin: 0 0 12px; font-size: 18px; line-height: 1.35; }
.option-grid { display: flex; flex-direction: column; gap: 8px; }
.option-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #fff;
    border: 2px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    cursor: pointer;
}
.option-label input { display: none; }
.option-letter {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: #eef1f8;
    display: grid;
    place-items: center;
    font-weight: 800;
    flex-shrink: 0;
}
.option-label.selected { border-color: var(--blue); background: #eef4ff; }
.option-label.correct { border-color: var(--green); background: #e8f8ee; }
.option-label.incorrect { border-color: var(--red); background: #fdecea; }
.option-label img { max-height: 90px; object-fit: contain; }
.quiz-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 16px;
}
.quiz-nav .btn-yellow { grid-column: 1 / -1; }
.q-img { max-height: 180px; object-fit: contain; margin: 0 0 12px; display: block; }

.score-hero {
    background: #fff;
    border-radius: 22px;
    padding: 22px 16px;
    text-align: center;
    margin-bottom: 14px;
}
.score-ring {
    --p: 0%;
    width: 120px;
    height: 120px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: conic-gradient(var(--yellow) var(--p), #e6eaf4 0);
    display: grid;
    place-items: center;
}
.score-ring span {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    background: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 22px;
}
.result-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin: 14px 0;
}
.result-stats div {
    background: var(--bg);
    border-radius: 12px;
    padding: 8px 4px;
}
.result-stats b { display: block; font-size: 13px; }
.result-stats span { font-size: 10px; color: var(--muted); font-weight: 700; }
.review-item {
    background: #fff;
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 8px;
    border-left: 4px solid var(--line);
    text-align: left;
}
.review-item.ok { border-left-color: var(--green); }
.review-item.bad { border-left-color: var(--red); }
.review-item p { margin: 6px 0 0; font-size: 13px; color: #334155; }

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}
.stat-tile {
    background: #fff;
    border-radius: 16px;
    padding: 14px;
}
.stat-tile h3 { margin: 0 0 2px; font-size: 22px; }
.stat-tile p { margin: 0; font-size: 12px; color: var(--muted); font-weight: 700; }

.plan-card {
    background: #fff;
    border-radius: 18px;
    padding: 16px;
    margin-bottom: 10px;
}
.plan-card .price { font-size: 26px; font-weight: 800; margin: 4px 0; }
.account-head {
    background: #fff;
    border-radius: 18px;
    padding: 16px;
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}
.account-head .big-av {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: var(--yellow);
    color: var(--navy);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 22px;
}
.account-head h2 { margin: 0; font-size: 18px; }
.account-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.auth-logo {
    display: block;
    height: 42px;
    margin: 8px auto 16px;
    background: var(--yellow);
    border-radius: 10px;
    padding: 6px 10px;
}
.muted { color: var(--muted); font-size: 13px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 14px; }
.mb-0 { margin-bottom: 0; }
.text-center { text-align: center; }
