/* ПДД Тест — дизайн-система в стиле неоморфизма: тёплый молочный фон, мягкие объёмные тени,
   вдавленные поля и «тактильные» кнопки. Светлая тема — молоко и графит, тёмная — графит.
   Цвета и тени задаются переменными, поэтому любой компонент сам подстраивается под тему. */

:root {
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    /* Onest: все буквы казахского алфавита есть в самом шрифте */
    --font-display: "Onest", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --ease: cubic-bezier(.2, .8, .2, 1);
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    --ease-io: cubic-bezier(.65, 0, .35, 1);
    --spring: cubic-bezier(.34, 1.56, .64, 1);
    --r-sm: 10px;
    --r: 14px;
    --r-lg: 22px;
    --r-xl: 28px;

    color-scheme: light;
    --bg: #ECE7DF;
    --bg-image:
        radial-gradient(1000px 620px at 6% -12%, rgba(247, 244, 239, .95) 0%, rgba(247, 244, 239, 0) 62%),
        radial-gradient(900px 700px at 108% 112%, rgba(222, 214, 202, .9) 0%, rgba(222, 214, 202, 0) 60%);
    --surface: #ECE7DF;
    --surface-2: #E4DED5;
    --surface-3: #D9D2C7;
    --hover: rgba(90, 76, 58, .05);
    --press: rgba(90, 76, 58, .09);
    --fill: rgba(90, 76, 58, .06);
    --fill-2: rgba(90, 76, 58, .1);
    --border: rgba(70, 60, 45, .1);
    --border-strong: rgba(70, 60, 45, .22);
    --text: #2B2C29;
    --text-2: #5D5E58;
    --text-3: #8A8880;
    --sage: #8AA68E;
    --accent: #5E7C65;
    --accent-soft: rgba(110, 145, 116, .16);
    --accent-ring: rgba(110, 145, 116, .45);
    --primary-bg: #2F302C;
    --primary-fg: #F6F2EC;
    --primary-hover: #1F201D;
    --primary-grad: linear-gradient(150deg, #42433E 0%, #262724 100%);
    --primary-grad-hover: linear-gradient(150deg, #4A4B46 0%, #2B2C28 100%);
    --success: #4E7A57;
    --success-soft: rgba(110, 145, 116, .18);
    --danger: #A94436;
    --danger-soft: rgba(169, 68, 54, .09);
    --warning: #93601F;
    --warning-soft: rgba(196, 140, 60, .14);

    /* Свет падает слева сверху: светлая тень сверху-слева, тёмная — справа-снизу */
    --sh-dark: #CBC3B6;
    --sh-light: #FFFFFF;
    --raise-xs: 3px 3px 6px var(--sh-dark), -3px -3px 6px var(--sh-light);
    --raise-sm: 4px 4px 10px var(--sh-dark), -4px -4px 10px var(--sh-light);
    --raise: 8px 8px 18px var(--sh-dark), -8px -8px 18px var(--sh-light);
    --raise-lg: 18px 18px 44px var(--sh-dark), -18px -18px 44px var(--sh-light);
    --in-sm: inset 3px 3px 7px var(--sh-dark), inset -3px -3px 7px var(--sh-light);
    --in: inset 6px 6px 13px var(--sh-dark), inset -6px -6px 13px var(--sh-light);
    --btn-shadow: 8px 8px 18px rgba(150, 138, 120, .6), -7px -7px 16px var(--sh-light), inset 1px 1px 1px rgba(255, 255, 255, .13);
    --btn-shadow-hover: 11px 12px 24px rgba(150, 138, 120, .65), -8px -8px 18px var(--sh-light), inset 1px 1px 1px rgba(255, 255, 255, .15);
    --btn-shadow-press: inset 4px 4px 10px rgba(0, 0, 0, .5), inset -2px -2px 6px rgba(255, 255, 255, .08);
    --shadow: var(--raise);
    --shadow-lg: var(--raise-lg);
    --bar-bg: rgba(236, 231, 223, .86);
    --bar-shadow: 0 8px 24px rgba(150, 138, 120, .2);
    --bar-shadow-up: 0 -8px 24px rgba(150, 138, 120, .2);
    --backdrop: rgba(70, 60, 45, .28);

    --heat-0: #DCD5CA;
    --heat-1: #C5D5C2;
    --heat-2: #9BB79F;
    --heat-3: #6F9277;
    --heat-4: #4C6B54;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #2A2B28;
    --bg-image:
        radial-gradient(900px 600px at 0% -10%, rgba(54, 55, 50, .9) 0%, rgba(54, 55, 50, 0) 60%),
        radial-gradient(800px 600px at 110% 110%, rgba(30, 31, 28, .9) 0%, rgba(30, 31, 28, 0) 60%);
    --surface: #2A2B28;
    --surface-2: #32332F;
    --surface-3: #3C3D38;
    --hover: rgba(255, 255, 255, .04);
    --press: rgba(255, 255, 255, .08);
    --fill: rgba(255, 255, 255, .05);
    --fill-2: rgba(255, 255, 255, .09);
    --border: rgba(255, 255, 255, .08);
    --border-strong: rgba(255, 255, 255, .18);
    --text: #EDEAE4;
    --text-2: #B5B2AA;
    --text-3: #8E8C85;
    --sage: #9DBDA3;
    --accent: #9DBDA3;
    --accent-soft: rgba(157, 189, 163, .15);
    --accent-ring: rgba(157, 189, 163, .45);
    --primary-bg: #E9E5DE;
    --primary-fg: #24251F;
    --primary-hover: #FFFFFF;
    --primary-grad: linear-gradient(150deg, #F4F1EB 0%, #D8D3CA 100%);
    --primary-grad-hover: linear-gradient(150deg, #FFFFFF 0%, #E3DED5 100%);
    --success: #8CC096;
    --success-soft: rgba(140, 192, 150, .15);
    --danger: #E8826F;
    --danger-soft: rgba(232, 130, 111, .13);
    --warning: #E0B060;
    --warning-soft: rgba(224, 176, 96, .14);
    --sh-dark: #1D1E1B;
    --sh-light: #373834;
    --btn-shadow: 6px 6px 14px var(--sh-dark), -5px -5px 12px var(--sh-light), inset 1px 1px 1px rgba(255, 255, 255, .6);
    --btn-shadow-hover: 8px 8px 18px var(--sh-dark), -6px -6px 14px var(--sh-light), inset 1px 1px 1px rgba(255, 255, 255, .7);
    --btn-shadow-press: inset 3px 3px 8px rgba(0, 0, 0, .35), inset -2px -2px 5px rgba(255, 255, 255, .5);
    --bar-bg: rgba(42, 43, 40, .88);
    --bar-shadow: 0 8px 24px rgba(0, 0, 0, .35);
    --bar-shadow-up: 0 -8px 24px rgba(0, 0, 0, .35);
    --backdrop: rgba(0, 0, 0, .5);
    --heat-0: #232420;
    --heat-1: #3B5040;
    --heat-2: #557560;
    --heat-3: #78A082;
    --heat-4: #A6CBAE;
}

/* ---------- Основа ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: -.011em;
    color: var(--text);
    background: var(--bg-image), var(--bg);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    transition: background-color .35s var(--ease), color .35s var(--ease);
}
h1, h2, h3, h4, p, figure { margin: 0; }
a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input, select, textarea { font: inherit; color: inherit; }
img, video, svg { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }
/* Иконка без заданного размера не должна растягиваться на всю ширину блока.
   :where() — нулевая специфичность, поэтому размер из любого контекста (.btn svg и т. п.) важнее */
:where(.ic) { width: 20px; height: 20px; flex: none; }
::selection { background: var(--accent-soft); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 10px; }

/* ---------- Раскладка ---------- */

.page { max-width: 1080px; margin: 0 auto; padding: 28px 16px 120px; }
.page.narrow { max-width: 760px; }
@media (min-width: 900px) { .page { padding: 44px 24px 72px; } }

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-sm { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.shrink-0 { flex-shrink: 0; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) {
    .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 900px) { .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 20px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.w-full { width: 100%; }
.center { text-align: center; }
.right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.only-mobile { display: initial; }
.only-desktop { display: none !important; }
@media (min-width: 900px) {
    .only-mobile { display: none !important; }
    .only-desktop { display: initial !important; }
}

/* ---------- Текст ---------- */

.display { font-family: var(--font-display); font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -.03em; }
.title { font-family: var(--font-display); font-size: 27px; line-height: 1.18; font-weight: 600; letter-spacing: -.025em; }
.h2 { font-family: var(--font-display); font-size: 19px; line-height: 1.3; font-weight: 600; letter-spacing: -.018em; }
.h3 { font-size: 16px; line-height: 1.35; font-weight: 600; }
@media (min-width: 900px) { .display { font-size: 44px; } .title { font-size: 32px; } }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.strong { font-weight: 600; }
.bold { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.link { color: var(--accent); font-weight: 600; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.ok-text { color: var(--success); }
.bad-text { color: var(--danger); }
.warn-text { color: var(--warning); }

/* ---------- Поверхности: выпуклые карточки и вдавленные «колодцы» ---------- */

.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--raise); transition: background-color .35s var(--ease), box-shadow .35s var(--ease); }
.card-pad { padding: 22px; }
@media (min-width: 900px) { .card-pad { padding: 26px; } }
.sep { height: 1px; background: var(--border); border: 0; margin: 0; }
.well { background: var(--surface); border-radius: 18px; padding: 14px 16px; box-shadow: var(--in-sm); }

/* ---------- Кнопки: выпуклые, при нажатии вдавливаются ---------- */

.btn {
    position: relative; overflow: hidden; isolation: isolate;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 46px; padding: 0 20px; border-radius: var(--r);
    font-size: 15px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap;
    user-select: none; -webkit-user-select: none;
    transition: transform .2s var(--ease-out), box-shadow .25s var(--ease-out), background-color .2s, color .2s, opacity .2s;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(.985); transition-duration: .08s; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--primary-grad); color: var(--primary-fg); box-shadow: var(--btn-shadow); }
.btn-primary:hover:not(:disabled) { background: var(--primary-grad-hover); box-shadow: var(--btn-shadow-hover); transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { box-shadow: var(--btn-shadow-press); transform: translateY(1px); }
.btn-accent { background: var(--accent); color: var(--surface); box-shadow: var(--raise-sm); }
.btn-accent:hover:not(:disabled) { filter: brightness(1.06); }
.btn-secondary, .btn-soft { background: var(--surface); color: var(--text); box-shadow: var(--raise-sm); }
.btn-secondary:hover:not(:disabled), .btn-soft:hover:not(:disabled) { background: var(--surface); box-shadow: var(--raise); }
.btn-secondary:active:not(:disabled), .btn-soft:active:not(:disabled) { box-shadow: var(--in-sm); }
.btn-outline { background: transparent; box-shadow: inset 0 0 0 1px var(--border-strong); }
.btn-outline:hover:not(:disabled) { background: var(--hover); }
.btn-ghost { background: transparent; color: var(--accent); padding: 0 10px; }
.btn-ghost:hover:not(:disabled) { background: var(--accent-soft); }
.btn-danger { background: var(--surface); color: var(--danger); box-shadow: var(--raise-sm); }
.btn-danger:hover:not(:disabled) { box-shadow: var(--raise); }
.btn-danger:active:not(:disabled) { box-shadow: var(--in-sm); }
.btn-success { background: var(--success); color: var(--surface); box-shadow: var(--raise-sm); }
.btn-success:hover:not(:disabled) { filter: brightness(1.06); }
.btn-success:active:not(:disabled) { box-shadow: var(--in-sm); }
.btn-telegram { background: linear-gradient(150deg, #3BA6DD, #1F88C0); color: #fff; box-shadow: var(--raise-sm); }
.btn-telegram:hover:not(:disabled) { box-shadow: var(--raise); }
.btn-telegram:active:not(:disabled) { box-shadow: inset 3px 3px 8px rgba(0, 0, 0, .3); }
.btn-lg { height: 54px; padding: 0 24px; font-size: 16px; border-radius: 17px; }
.btn-sm { height: 36px; padding: 0 13px; font-size: 13.5px; border-radius: 11px; }
.btn-sm svg { width: 16px; height: 16px; }
.btn-block { width: 100%; }
.btn-pill { border-radius: 999px; }

.icon-btn {
    position: relative; overflow: hidden;
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 13px; color: var(--text-2); flex: none;
    transition: box-shadow .25s var(--ease-out), color .2s, background-color .2s;
}
.icon-btn:hover { color: var(--text); background: var(--surface); box-shadow: var(--raise-sm); }
.icon-btn:active { box-shadow: var(--in-sm); }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.icon-btn svg { width: 20px; height: 20px; }

/* Волна от нажатия (её добавляет ui.js) */
.ripple {
    position: absolute; border-radius: 50%; pointer-events: none; z-index: -1;
    background: currentColor; opacity: .12; transform: scale(0);
    animation: ripple .6s var(--ease) forwards;
}
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

.spinner {
    width: 18px; height: 18px; border-radius: 50%; display: inline-block;
    border: 2px solid currentColor; border-right-color: transparent; opacity: .7;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Поля: вдавленные ---------- */

.label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin: 0 0 8px 4px; }
.input {
    width: 100%; height: 50px; padding: 0 16px; border-radius: 15px;
    background-color: var(--surface); border: 0; box-shadow: var(--in-sm);
    font-size: 16px; color: var(--text); outline: none;
    transition: box-shadow .25s var(--ease-out), background-color .25s;
}
.input::placeholder { color: var(--text-3); opacity: .85; }
.input:hover { box-shadow: var(--in); }
.input:focus { box-shadow: var(--in-sm), 0 0 0 3px var(--accent-ring); }
.input:focus-visible { outline: none; }
.input.invalid { box-shadow: var(--in-sm), 0 0 0 2px var(--danger); }
.input.on-bg { background-color: var(--surface); }
.input:disabled { opacity: .5; }
textarea.input { height: auto; min-height: 92px; padding: 12px 16px; line-height: 1.45; resize: vertical; }
select.input {
    appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A8880' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; background-size: 16px;
}
.field-hint { font-size: 12.5px; color: var(--text-3); margin: 8px 0 0 4px; }

/* Сообщения с иконкой */
.form-error, .form-success {
    display: flex; gap: 10px; align-items: flex-start;
    border-radius: 16px; padding: 12px 15px; font-size: 14px; font-weight: 500; line-height: 1.45;
    animation: msg-in .45s var(--ease-out);
}
.form-error::before, .form-success::before {
    content: ''; flex: none; width: 18px; height: 18px; margin-top: 1px; background: currentColor;
    -webkit-mask: var(--msg-icon) center / contain no-repeat; mask: var(--msg-icon) center / contain no-repeat;
}
.form-error {
    background: var(--danger-soft); color: var(--danger);
    --msg-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Cpath d='M12 7.5v5.2M12 16.2v.3'/%3E%3C/svg%3E");
}
.form-success {
    background: var(--success-soft); color: var(--success);
    --msg-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Cpath d='m8.3 12.3 2.5 2.5 5-5'/%3E%3C/svg%3E");
}
@keyframes msg-in { from { opacity: 0; transform: translateY(-4px); } }

.password-wrap { position: relative; }
.password-wrap .input { padding-right: 58px; }
.password-toggle {
    position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
    width: 38px; height: 38px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface); color: var(--text-3); box-shadow: var(--raise-sm);
    transition: box-shadow .25s var(--ease-out), color .2s;
}
.password-toggle:hover { color: var(--text); }
.password-toggle:active, .password-toggle[aria-pressed="true"] { box-shadow: var(--in-sm); color: var(--accent); }
.password-toggle svg { width: 19px; height: 19px; }

.check-row { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 15px; color: var(--text-2); user-select: none; }
.check-row input {
    appearance: none; -webkit-appearance: none; flex: none; width: 24px; height: 24px; margin: 0; border-radius: 8px; cursor: pointer;
    background: var(--surface) center / 14px no-repeat; box-shadow: var(--in-sm); transition: background-color .25s, box-shadow .25s;
}
.check-row input:checked {
    background-color: var(--accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E");
    box-shadow: inset 2px 2px 5px rgba(0, 0, 0, .22), 2px 2px 6px var(--sh-dark);
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

/* ---------- Мелкие элементы ---------- */

.badge {
    display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px;
    border-radius: 8px; font-size: 12px; font-weight: 600; white-space: nowrap;
    background: var(--surface-2); color: var(--text-2);
}
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.dark { background: var(--text); color: var(--bg); }
/* старые названия (админка) */
.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 8px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.chip-green { background: var(--success-soft); color: var(--success); }
.chip-amber { background: var(--warning-soft); color: var(--warning); }
.chip-red { background: var(--danger-soft); color: var(--danger); }
.chip-blue { background: var(--accent-soft); color: var(--accent); }
.chip-gray { background: var(--surface-2); color: var(--text-2); }
.chip-dark { background: var(--text); color: var(--bg); }

/* Полоса прогресса: вдавленный жёлоб, нейтральная заливка (зелёным не красим) */
.progress {
    height: 8px; border-radius: 999px; overflow: hidden; background: var(--surface);
    box-shadow: inset 2px 2px 4px var(--sh-dark), inset -2px -2px 4px var(--sh-light);
}
.progress > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--text-3), var(--text-2)); border-radius: inherit; transition: width .8s var(--ease); }
.progress.accent > span, .progress.green > span { background: linear-gradient(90deg, var(--sage), var(--accent)); }
.progress.thin { height: 6px; }

/* Сегменты: вдавленная дорожка, выбранный пункт — выпуклый */
.seg, .lang-switch { display: inline-flex; background: var(--surface); box-shadow: var(--in-sm); border-radius: 13px; padding: 4px; gap: 4px; }
.seg button, .lang-switch button {
    height: 30px; padding: 0 12px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text-3);
    transition: box-shadow .3s var(--ease-out), color .2s;
}
.lang-switch button { min-width: 40px; padding: 0 8px; font-size: 12.5px; font-weight: 700; }
.seg button:hover, .lang-switch button:hover { color: var(--text); }
.seg button.active, .lang-switch button.active { background: var(--surface); color: var(--text); box-shadow: var(--raise-sm); }

.kbd { font-family: var(--mono); font-size: 12px; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); }

.skeleton {
    border-radius: var(--r-lg); background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
    background-size: 200% 100%; animation: shimmer 1.3s infinite linear;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.empty { text-align: center; padding: 36px 16px; color: var(--text-3); font-weight: 500; }

/* ---------- Верхнее меню и нижние вкладки ---------- */

.topbar {
    position: sticky; top: 0; z-index: 40; height: 66px;
    background: var(--bar-bg); box-shadow: var(--bar-shadow);
    backdrop-filter: saturate(140%) blur(18px); -webkit-backdrop-filter: saturate(140%) blur(18px);
}
.topbar-inner { max-width: 1080px; height: 100%; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 26px; }
@media (min-width: 900px) { .topbar-inner { padding: 0 24px; } }
.topbar.wide .topbar-inner { max-width: 1180px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.02em; flex: none; }
.brand .logo-mark { width: 32px; height: 32px; border-radius: 9px; box-shadow: var(--raise-xs); }
.brand .brand-sub { font-weight: 500; color: var(--text-2); }
.nav-links { display: none; align-items: center; gap: 8px; }
@media (min-width: 900px) { .nav-links { display: flex; } }
.nav-link {
    position: relative; height: 38px; padding: 0 15px; border-radius: 12px;
    display: inline-flex; align-items: center; font-size: 14.5px; font-weight: 500; color: var(--text-2);
    transition: color .2s, box-shadow .3s var(--ease-out);
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); font-weight: 600; background: var(--surface); box-shadow: var(--raise-sm); }
.nav-link .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); margin-left: 6px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.avatar {
    width: 40px; height: 40px; border-radius: 50%; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: var(--text);
    background: var(--surface); box-shadow: var(--raise-sm);
    transition: box-shadow .25s var(--ease-out);
}
button.avatar:hover { box-shadow: var(--raise); }
button.avatar:active { box-shadow: var(--in-sm); }
.avatar.lg { width: 68px; height: 68px; font-size: 22px; box-shadow: var(--raise); }

.menu-wrap { position: relative; }
.menu {
    position: absolute; right: 0; top: calc(100% + 12px); z-index: 60; width: 280px;
    background: var(--surface); border-radius: 20px; box-shadow: var(--raise-lg);
    padding: 8px; transform-origin: top right; animation: menu-in .22s var(--ease);
}
@keyframes menu-in { from { opacity: 0; transform: scale(.94) translateY(-4px); } to { opacity: 1; transform: none; } }
.menu-head { padding: 10px 10px 8px; }
.menu-item {
    width: 100%; display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 10px;
    border-radius: 12px; font-size: 14.5px; text-align: left; color: var(--text);
    transition: background-color .15s, box-shadow .2s;
}
.menu-item:hover { background: var(--hover); }
.menu-item:active { box-shadow: var(--in-sm); background: transparent; }
.menu-item svg { width: 18px; height: 18px; color: var(--text-2); }
.menu-item.danger, .menu-item.danger svg { color: var(--danger); }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; font-size: 14px; color: var(--text-2); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }

.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; gap: 6px;
    background: var(--bar-bg); box-shadow: var(--bar-shadow-up);
    backdrop-filter: saturate(140%) blur(18px); -webkit-backdrop-filter: saturate(140%) blur(18px);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
}
@media (min-width: 900px) { .tabbar { display: none; } }
.tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
    font-size: 10.5px; font-weight: 600; color: var(--text-3); border-radius: 14px;
    transition: color .2s, box-shadow .3s var(--ease-out);
}
.tab svg { width: 23px; height: 23px; }
.tab.active { color: var(--text); background: var(--surface); box-shadow: var(--raise-sm); }
.tab:active { box-shadow: var(--in-sm); }

/* ---------- Список (как таблица задач на LeetCode) ---------- */

.list { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--raise); overflow: hidden; }
.list-row {
    position: relative; display: flex; align-items: center; gap: 14px; padding: 15px 20px; width: 100%; text-align: left;
    transition: background-color .15s;
}
.list-row + .list-row { border-top: 1px solid var(--border); }
a.list-row:hover, button.list-row:hover { background: var(--hover); }
a.list-row:active, button.list-row:active { background: var(--press); }
.list-row .chev { width: 18px; height: 18px; color: var(--text-3); flex: none; transition: transform .2s var(--ease); }
a.list-row:hover .chev { transform: translateX(2px); }
.row-num { width: 28px; flex: none; font-size: 14px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.status-mark { width: 22px; height: 22px; flex: none; display: flex; align-items: center; justify-content: center; color: var(--text-3); }
.status-mark svg { width: 18px; height: 18px; }
.status-mark.done { color: var(--text-2); }

/* ---------- Статистика ---------- */

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--raise); }
.stats > * { padding: 18px 16px; min-width: 0; }
.stats > * + * { border-left: 1px solid var(--border); }
@media (min-width: 900px) { .stats > * { padding: 22px 26px; } }
.stat-value { font-family: var(--font-display); font-size: 27px; font-weight: 700; letter-spacing: -.025em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 15px; font-weight: 600; color: var(--text-3); margin-left: 2px; }
.stat-label { font-size: 13px; color: var(--text-2); margin-top: 2px; }
a.stat-link:hover .stat-label, button.stat-link:hover .stat-label { color: var(--accent); }
/* старое название (админка) */
.stat { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--raise); padding: 18px; }
.stat .stat-value { font-size: 25px; }

/* ---------- Карта активности ---------- */

.heatmap { overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.heatmap::-webkit-scrollbar { display: none; }
.hm-inner { position: relative; width: max-content; padding-top: 18px; margin-left: auto; }
.hm-months { position: absolute; top: 0; left: 0; right: 0; height: 16px; font-size: 11px; color: var(--text-3); }
.hm-months span { position: absolute; top: 0; white-space: nowrap; }
.hm-grid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px); grid-auto-columns: 12px; gap: 3px; }
.hm-cell { width: 12px; height: 12px; border-radius: 3.5px; background: var(--heat-0); transition: transform .15s var(--ease); }
.hm-cell:hover { transform: scale(1.35); }
.hm-cell.future { background: transparent; }
.hm-cell.l1 { background: var(--heat-1); }
.hm-cell.l2 { background: var(--heat-2); }
.hm-cell.l3 { background: var(--heat-3); }
.hm-cell.l4 { background: var(--heat-4); }
.hm-cell.today { box-shadow: inset 0 0 0 1.5px var(--text-2); }
.hm-legend { display: flex; align-items: center; gap: 3px; font-size: 11.5px; color: var(--text-3); }
.hm-legend .hm-cell { width: 11px; height: 11px; }
.hm-legend .hm-cell:hover { transform: none; }
.hm-tip {
    position: fixed; z-index: 90; pointer-events: none; transform: translate(-50%, calc(-100% - 8px));
    background: var(--text); color: var(--bg); font-size: 12px; font-weight: 500; line-height: 1.35;
    padding: 6px 9px; border-radius: 8px; white-space: nowrap; box-shadow: var(--raise-sm);
}

/* ---------- Уведомления и окна ---------- */

.toast-wrap {
    position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 100;
    display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(92vw, 420px); pointer-events: none;
}
@media (min-width: 900px) { .toast-wrap { bottom: 28px; } }
.toast {
    background: var(--text); color: var(--bg); padding: 12px 17px; border-radius: 16px;
    font-size: 14.5px; font-weight: 500; box-shadow: var(--raise); max-width: 100%;
    animation: toast-in .35s var(--spring);
}
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--success); color: var(--surface); }
.toast.leaving { animation: toast-out .25s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }

.modal-backdrop {
    position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-end; justify-content: center;
    background: var(--backdrop); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    animation: fade-in .2s var(--ease);
}
@media (min-width: 640px) { .modal-backdrop { align-items: center; padding: 24px; } }
.modal {
    width: 100%; max-width: 540px; max-height: 92vh; overflow: auto;
    background: var(--surface); border-radius: 28px 28px 0 0; box-shadow: var(--raise-lg);
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
    animation: sheet-in .38s var(--ease);
}
@media (min-width: 640px) { .modal { border-radius: 28px; padding: 28px; animation: pop-in .3s var(--spring); } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.modal-title { font-family: var(--font-display); font-size: 21px; font-weight: 600; letter-spacing: -.02em; }
.modal-backdrop.leaving { animation: fade-out .2s var(--ease) forwards; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes sheet-in { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
@keyframes pop-in { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Тарифы и оплата ---------- */

.tariffs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 560px) { .tariffs { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tariff {
    position: relative; overflow: hidden; text-align: left; width: 100%;
    background: var(--surface); border-radius: 18px; box-shadow: var(--raise-sm); padding: 14px 14px 12px;
    transition: box-shadow .3s var(--ease-out), transform .2s var(--ease-out);
}
.tariff:hover { box-shadow: var(--raise); transform: translateY(-1px); }
.tariff:active { transform: scale(.98); }
.tariff.selected { box-shadow: var(--in), 0 0 0 2px var(--accent-ring); transform: none; }
.tariff-days { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.tariff-price { font-size: 16px; font-weight: 600; margin-top: 2px; }
.tariff-per { font-size: 12.5px; color: var(--text-3); }
.tariff-tag { display: inline-block; margin-bottom: 6px; font-size: 11px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--accent); }
.tariff-check {
    position: absolute; top: 12px; right: 12px; width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface); box-shadow: var(--in-sm); color: var(--surface);
    transition: background-color .2s, box-shadow .2s, transform .3s var(--spring);
}
.tariff.selected .tariff-check { background: var(--accent); box-shadow: 2px 2px 5px var(--sh-dark); transform: scale(1.06); }
.tariff-check svg { width: 12px; height: 12px; opacity: 0; transition: opacity .2s; }
.tariff.selected .tariff-check svg { opacity: 1; }

.pay-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface); box-shadow: var(--in-sm); border-radius: 18px; padding: 12px 14px; }
.pay-value { font-size: 19px; font-weight: 700; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.steps { counter-reset: step; display: grid; gap: 12px; }
.steps li { counter-increment: step; display: flex; gap: 12px; align-items: flex-start; font-size: 15px; }
.steps li::before {
    content: counter(step); flex: none; width: 26px; height: 26px; border-radius: 50%; margin-top: -1px;
    background: var(--surface); box-shadow: var(--raise-xs); color: var(--accent); font-weight: 700; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
}

/* ---------- Тест: варианты ответа — выпуклые плитки, выбранный вдавлен ---------- */

.option {
    position: relative; overflow: hidden; width: 100%; display: flex; align-items: flex-start; gap: 12px; text-align: left;
    background: var(--surface); border-radius: 18px; box-shadow: var(--raise-sm);
    padding: 15px 16px; font-size: 16px; line-height: 1.45;
    transition: box-shadow .25s var(--ease-out), background-color .2s var(--ease), transform .15s var(--ease);
}
.option:hover { box-shadow: var(--raise); }
.option:active { transform: scale(.99); }
.option .letter {
    flex: none; width: 28px; height: 28px; border-radius: 9px; margin-top: -2px;
    background: var(--surface); box-shadow: var(--in-sm); color: var(--text-2); font-weight: 700; font-size: 13px;
    display: flex; align-items: center; justify-content: center; transition: background-color .2s, color .2s, box-shadow .2s;
}
.option .mark { margin-left: auto; flex: none; width: 20px; height: 20px; }
.option.selected { box-shadow: var(--in), 0 0 0 2px var(--accent-ring); }
.option.selected .letter { background: var(--accent); color: var(--surface); box-shadow: none; }
.option.correct { background: var(--success-soft); box-shadow: var(--in-sm), 0 0 0 2px var(--success); }
.option.correct .letter { background: var(--success); color: var(--surface); box-shadow: none; }
.option.correct .mark { color: var(--success); }
.option.wrong { background: var(--danger-soft); box-shadow: var(--in-sm), 0 0 0 2px var(--danger); }
.option.wrong .letter { background: var(--danger); color: #fff; box-shadow: none; }
.option.wrong .mark { color: var(--danger); }
.option.locked { cursor: default; }
.option.locked:hover { box-shadow: var(--raise-sm); }
.option.locked.selected:hover { box-shadow: var(--in), 0 0 0 2px var(--accent-ring); }
.option.locked.correct:hover { box-shadow: var(--in-sm), 0 0 0 2px var(--success); }
.option.locked.wrong:hover { box-shadow: var(--in-sm), 0 0 0 2px var(--danger); }
.option.locked:active { transform: none; }

.qnav { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 8px 6px; scroll-behavior: smooth; }
.qnav::-webkit-scrollbar { display: none; }
.qnav button {
    flex: none; min-width: 36px; height: 36px; padding: 0 6px; border-radius: 11px;
    font-size: 13.5px; font-weight: 600; color: var(--text-2); background: var(--surface); box-shadow: var(--raise-xs);
    font-variant-numeric: tabular-nums; transition: background-color .2s, color .2s, box-shadow .2s, transform .15s;
}
.qnav button:active { transform: scale(.94); }
.qnav button.answered { box-shadow: var(--in-sm); color: var(--text); }
.qnav button.correct { background: var(--success-soft); color: var(--success); box-shadow: var(--in-sm); }
.qnav button.wrong { background: var(--danger-soft); color: var(--danger); box-shadow: var(--in-sm); }
.qnav button.current { box-shadow: var(--raise-xs), inset 0 0 0 2px var(--text); color: var(--text); }
.qnav button.current.answered, .qnav button.current.correct, .qnav button.current.wrong { box-shadow: var(--in-sm), inset 0 0 0 2px var(--text); }

/* Защита материалов: без выделения, перетаскивания и сохранения */
.protected { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.protected img, .protected video { -webkit-user-drag: none; user-drag: none; pointer-events: none; }
.media-box { position: relative; overflow: hidden; border-radius: var(--r-lg); background: var(--surface-2); box-shadow: var(--in-sm); }
.media-shield { position: absolute; inset: 0; z-index: 2; }
.watermark { position: absolute; inset: 0; z-index: 3; pointer-events: none; background-repeat: repeat; opacity: .55; }
.privacy-blur { filter: blur(16px); transition: filter .2s; }
@media print {
    body * { visibility: hidden !important; }
    body::after { content: 'ПДД Тест'; visibility: visible; }
}

/* ---------- Админка (вкладки, фильтры, таблицы) ---------- */

.tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 8px 6px 10px; margin-left: -6px; margin-right: -6px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
    position: relative; overflow: hidden; flex: none; display: inline-flex; align-items: center; gap: 8px;
    height: 40px; padding: 0 15px; border-radius: 13px; font-size: 14px; font-weight: 600; color: var(--text-2);
    transition: color .2s, box-shadow .3s var(--ease-out);
}
.tabs button svg { width: 17px; height: 17px; }
.tabs button:hover { color: var(--text); }
.tabs button:active { box-shadow: var(--in-sm); }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--raise-sm); }
.tabs .badge-count, .badge-count {
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff;
    font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.filter-chip {
    position: relative; overflow: hidden; height: 34px; padding: 0 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
    color: var(--text-2); background: var(--surface); box-shadow: var(--raise-xs);
    transition: color .2s, box-shadow .25s var(--ease-out);
}
.filter-chip:hover { color: var(--text); }
.filter-chip.active { color: var(--text); box-shadow: var(--in-sm); }

.table-wrap { overflow: auto; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--raise); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 600; color: var(--text-2); padding: 11px 12px; font-size: 13px; white-space: nowrap; }
.table td { padding: 11px 12px; vertical-align: top; border-top: 1px solid var(--border); }

/* ---------- Появление ---------- */

.rise { animation: rise .4s var(--ease) both; }
.rise-2 { animation: rise .4s .04s var(--ease) both; }
.rise-3 { animation: rise .4s .08s var(--ease) both; }
.rise-4 { animation: rise .4s .12s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* Когда страница уже показана, повторная отрисовка (свежие данные, смена языка) не мигает анимацией */
.settled .rise, .settled .rise-2, .settled .rise-3, .settled .rise-4 { animation: none; }

/* ---------- Переход между страницами ----------
   Chrome, Edge и Safari 18+ плавно сменяют страницы, а верхнее меню и нижние вкладки остаются на месте */

@view-transition { navigation: auto; }
.topbar { view-transition-name: topbar; }
.tabbar { view-transition-name: tabbar; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .22s; animation-timing-function: var(--ease); }

@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
    *, *::before, *::after {
        animation-duration: .001ms !important; animation-iteration-count: 1 !important;
        transition-duration: .001ms !important; scroll-behavior: auto !important;
    }
}
