/* ────────────────────────────────────────────
   ОГЭ Математика — Telegram WebApp Styles
   ──────────────────────────────────────────── */

:root {
    --bg: var(--tg-theme-bg-color, #05080f);
    --bg-secondary: var(--tg-theme-secondary-bg-color, #0b1222);
    --text: var(--tg-theme-text-color, #eef2ff);
    --text-hint: var(--tg-theme-hint-color, #7a8aa8);
    --accent: var(--tg-theme-button-color, #1e6fff);
    --accent-text: var(--tg-theme-button-text-color, #ffffff);
    --link: var(--tg-theme-link-color, #60a5fa);

    --accent-strong: #0047ff;
    --accent-soft:   #4d9eff;

    --card-bg: rgba(30, 111, 255, 0.06);
    --card-border: rgba(77, 158, 255, 0.14);
    --success: #00b894;
    --error: #e17055;
    --warning: #fdcb6e;

    --radius: 16px;
    --radius-sm: 10px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    /* --app-vh is set from JS to Telegram's viewportStableHeight; falls back
       to 100vh when running outside a WebApp (admin pages, dev). */
    min-height: var(--app-vh, 100vh);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    /* --app-safe-top / --app-safe-bottom come from Telegram's
       contentSafeAreaInset + safeAreaInset (set in app.js). They push our UI
       below Telegram's own chrome (close pill, bot-info row) when launched as
       a Direct Link Mini App from the main chat list. Fallback to env() for
       non-WebApp / older clients. */
    padding-top:    var(--app-safe-top, env(safe-area-inset-top, 0px));
    padding-right:  16px;
    padding-bottom: calc(32px + var(--app-safe-bottom, env(safe-area-inset-bottom, 0px)));
    padding-left:   16px;
}

/* ── Screens ── */

.screen {
    display: none;
}
.screen.active {
    display: block;
}

/* Home screen: cascading fade-in on the VERY FIRST load only.
   Blocks start hidden (opacity:0 + visibility:hidden). Once the initial
   data is fetched we add .home-ready — the animation runs once with
   fill-mode forwards, leaving blocks visible. On subsequent returns to
   home (via showScreen / back / swipe) we skip the cascade entirely
   because .home-first-load stays on forever and #screen-home.home-shown
   overrides the hidden state. */
#screen-home > .header,
#screen-home > #btn-go-leaderboard,
#screen-home > .overview-card,
#screen-home > .stats-row,
#screen-home > #btn-go-solve,
#screen-home > #btn-go-mistakes,
#screen-home > #btn-go-manual {
    opacity: 0;
    visibility: hidden;
}
#screen-home.home-shown > .header,
#screen-home.home-shown > #btn-go-leaderboard,
#screen-home.home-shown > .overview-card,
#screen-home.home-shown > .stats-row,
#screen-home.home-shown > #btn-go-solve,
#screen-home.home-shown > #btn-go-mistakes,
#screen-home.home-shown > #btn-go-manual {
    opacity: 1;
    visibility: visible;
}
#screen-home.home-first-load > .header,
#screen-home.home-first-load > #btn-go-leaderboard,
#screen-home.home-first-load > .overview-card,
#screen-home.home-first-load > .stats-row,
#screen-home.home-first-load > #btn-go-solve,
#screen-home.home-first-load > #btn-go-mistakes,
#screen-home.home-first-load > #btn-go-manual {
    animation: homeBlockIn 0.55s ease-out both;
}
#screen-home.home-first-load > .header            { animation-delay: 0.00s; }
#screen-home.home-first-load > #btn-go-leaderboard{ animation-delay: 0.08s; }
#screen-home.home-first-load > .overview-card     { animation-delay: 0.18s; }
#screen-home.home-first-load > .stats-row         { animation-delay: 0.32s; }
#screen-home.home-first-load > #btn-go-solve      { animation-delay: 0.44s; }
#screen-home.home-first-load > #btn-go-mistakes   { animation-delay: 0.52s; }
#screen-home.home-first-load > #btn-go-manual     { animation-delay: 0.60s; }

/* «Работа над ошибками» button */
.btn-mistakes {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.btn-mistakes .mistakes-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 22px;
    padding: 0 8px;
    border-radius: 11px;
    background: var(--error);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}
body.theme-light .btn-mistakes .mistakes-count { color: #fff; }

/* «Продолжить задачу» — quiet resume CTA pinned above the primary button.
   Shown only when a pending task is stashed in localStorage. */
.btn-resume {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-bottom: 10px;
    padding: 12px 14px;
    border: 1px solid var(--accent, #37aee2);
    border-radius: 14px;
    background: color-mix(in srgb, var(--accent, #37aee2) 10%, transparent);
    color: var(--text, #fff);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.05s ease;
}
.btn-resume:active { transform: scale(0.99); }
.btn-resume:hover  { background: color-mix(in srgb, var(--accent, #37aee2) 16%, transparent); }
.btn-resume .resume-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent, #37aee2);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}
.btn-resume .resume-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.btn-resume .resume-title {
    font-size: 15px;
    font-weight: 600;
}
.btn-resume .resume-sub {
    font-size: 12px;
    opacity: 0.7;
}

/* Orange leaderboard button on home — subtle crown pattern over gradient */
.btn-leaderboard {
    position: relative;
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #ff9a4d, #ff6a2f);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 18px color-mix(in srgb, #ff7a33 35%, transparent);
    transition: transform 0.1s ease, box-shadow 0.15s ease;
    margin-bottom: 12px;
    overflow: hidden;
    isolation: isolate;
}
.btn-leaderboard::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 44 44'><g fill='rgba(255,255,255,0.16)'><path d='M4 10l3 4 4-6 4 5 4-5 4 6 3-4v9H4z'/><path d='M26 28l2 3 3-4 3 3 3-3 3 4 2-3v7H26z'/></g></svg>");
    background-repeat: repeat;
    background-size: 44px 44px;
    z-index: 0;
    mix-blend-mode: soft-light;
}
.btn-leaderboard > * { position: relative; z-index: 1; }
.btn-leaderboard:active {
    transform: scale(0.98);
    box-shadow: 0 3px 10px color-mix(in srgb, #ff7a33 25%, transparent);
}
/* Locked state — dimmed, crossed out, with hint below */
.btn-leaderboard.locked {
    background: linear-gradient(135deg, #8a8a8a, #6a6a6a);
    box-shadow: none;
    cursor: not-allowed;
    flex-wrap: wrap;
    row-gap: 4px;
}
.btn-leaderboard.locked .btn-svg { opacity: 0.55; }
.btn-leaderboard.locked::after {
    content: '';
    position: absolute;
    left: 14%;
    right: 14%;
    top: 50%;
    height: 2px;
    background: rgba(255,255,255,0.85);
    transform: rotate(-4deg);
    z-index: 2;
    pointer-events: none;
    border-radius: 2px;
}
.btn-leaderboard-hint {
    flex-basis: 100%;
    font-size: 11px;
    font-weight: 500;
    opacity: 0.85;
    text-align: center;
    margin-top: 2px;
    text-decoration: none;
}

/* Buttons with inline SVG icon — align icon + label */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ── Leaderboard ───────────────────────────────────────────────────────────── */
.lb-tabs {
    display: flex;
    gap: 8px;
    margin: 8px 0 16px;
}
.lb-tab {
    flex: 1;
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    background: var(--card-bg, rgba(255,255,255,0.06));
    color: var(--text, #fff);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}
.lb-tab:active { transform: scale(0.97); }
.lb-tab.active {
    background: var(--primary, #5b8cff);
    color: #fff;
}
/* Friends tab — always orange to visually separate the social mode */
.lb-tab-friends {
    background: color-mix(in srgb, #ff8a3d 18%, transparent);
    color: #ff8a3d;
}
.lb-tab-friends.active {
    background: #ff8a3d;
    color: #fff;
}
/* Friends panel — visible only on the friends tab */
.lb-friends-panel {
    background: color-mix(in srgb, #ff8a3d 10%, transparent);
    border: 1px solid color-mix(in srgb, #ff8a3d 35%, transparent);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.lb-friends-row {
    display: flex;
    gap: 8px;
}
.lb-friends-row input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, #ff8a3d 40%, transparent);
    background: var(--card-bg, rgba(255,255,255,0.04));
    color: var(--text, #fff);
    font-size: 15px;
    outline: none;
}
.lb-friends-row input:focus { border-color: #ff8a3d; }
.lb-friends-add {
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    background: #ff8a3d;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.1s ease, opacity 0.15s ease;
}
.lb-friends-add:active { transform: scale(0.97); }
.lb-friends-add:disabled { opacity: 0.6; cursor: default; }
.lb-friends-copy {
    padding: 11px 14px;
    border: 1px dashed color-mix(in srgb, #ff8a3d 55%, transparent);
    border-radius: 10px;
    background: transparent;
    color: #ff8a3d;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}
.lb-friends-copy:active { transform: scale(0.98); }
.lb-friends-copy:hover {
    background: color-mix(in srgb, #ff8a3d 12%, transparent);
}
.lb-invite-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.lb-invite-row .lb-friends-copy {
    justify-content: center;
    width: 100%;
}
.lb-invite-tg {
    --accent: #37aee2;
    border-color: color-mix(in srgb, #37aee2 55%, transparent);
    color: #37aee2;
}
.lb-invite-tg:hover { background: color-mix(in srgb, #37aee2 12%, transparent); }
.lb-invite-max {
    --accent: #ff8a3d;
    border-color: color-mix(in srgb, #ff8a3d 55%, transparent);
    color: #ff8a3d;
}
.max-logo {
    display: inline-block;
    width: 18px;
    height: 18px;
    background: url('https://maxicons.ru/icons/Max_logo_black.svg') center/contain no-repeat;
}
.theme-dark .max-logo { filter: invert(1); }
.lb-friends-copy-link {
    padding: 10px 14px;
    border: 1px solid color-mix(in srgb, #ff8a3d 30%, transparent);
    border-radius: 10px;
    background: transparent;
    color: color-mix(in srgb, #ff8a3d 85%, var(--text, #fff));
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}
.lb-friends-copy-link:active { transform: scale(0.98); }
.friend-result {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
}
.friend-result-ok  { background: color-mix(in srgb, #4ade80 15%, transparent); color: #4ade80; }
.friend-result-err { background: color-mix(in srgb, var(--error, #ff5a5a) 15%, transparent); color: var(--error, #ff5a5a); }
.lb-me-card {
    background: var(--card-bg, rgba(255,255,255,0.06));
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 16px;
    border: 1px solid var(--primary, #5b8cff);
}
.lb-me-label {
    font-size: 12px;
    opacity: 0.7;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.lb-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.lb-loading, .lb-empty {
    text-align: center;
    padding: 32px 16px;
    opacity: 0.6;
    font-size: 14px;
    line-height: 1.5;
}
.lb-row {
    display: grid;
    grid-template-columns: 36px 40px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--card-bg, rgba(255,255,255,0.06));
    border-radius: 12px;
    min-height: 56px;
}
.lb-row-me, .lb-row-me-inline {
    background: color-mix(in srgb, var(--primary, #5b8cff) 20%, transparent);
    border: 1px solid color-mix(in srgb, var(--primary, #5b8cff) 50%, transparent);
}
.lb-pos {
    font-size: 15px;
    font-weight: 700;
    opacity: 0.65;
    text-align: center;
}
.lb-pos-medal {
    font-size: 22px;
    opacity: 1;
}
.lb-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    background-color: var(--primary, #5b8cff);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
}
.lb-avatar-initials { background: linear-gradient(135deg, #5b8cff, #8a6cff); }
.lb-info { min-width: 0; }
.lb-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lb-you {
    font-size: 10px;
    font-weight: 700;
    background: var(--primary, #5b8cff);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}
.lb-meta {
    font-size: 12px;
    opacity: 0.6;
    margin-top: 2px;
}
.lb-score {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary, #5b8cff);
    min-width: 40px;
    text-align: right;
}

/* Swipe-back: the active screen being dragged */
.screen.swiping-drag {
    /* Stay in normal flow — preserves document scroll, no jump on release. */
    position: relative;
    background: var(--bg);
    z-index: 2;
    animation: none !important;
    will-change: transform;
    box-shadow: -12px 0 32px rgba(0, 0, 0, 0.35);
    min-height: var(--app-vh, 100vh);
}
.screen.swiping-drag > *,
.screen.swiping-behind > * {
    animation: none !important;
}

/* Swipe-back: the previous screen revealed underneath */
.screen.swiping-behind {
    display: block !important;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px 32px;
    overflow-y: auto;
    background: var(--bg);
    z-index: 1;
    animation: none !important;
    will-change: transform;
    pointer-events: none;
    -webkit-overflow-scrolling: touch;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translate3d(0, 8px, 0); }
    to   { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes screenContentIn {
    from { opacity: 0; transform: translate3d(0, 10px, 0); }
    to   { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes homeBlockIn {
    0%   { opacity: 0; visibility: visible; transform: translate3d(0, 4px, 0); }
    60%  { opacity: 0.7; visibility: visible; }
    100% { opacity: 1; visibility: visible; transform: translate3d(0, 0, 0); }
}

/* ── Header ── */

.header {
    padding: 20px 0 8px;
}

.user-greeting {
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    overflow: hidden;
}
.avatar.has-photo { background-image: none; }

/* Onboarding tour */
body.tour-active { overflow: hidden !important; touch-action: none !important; overscroll-behavior: contain; }
.tour-overlay {
    position: fixed;
    inset: 0;
    z-index: 9996;
    pointer-events: auto;
    touch-action: none;
}
.tour-overlay * { touch-action: auto; }
.tour-hole {
    position: absolute;
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.75);
    border: 2px solid var(--accent);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}
.tour-tooltip {
    position: absolute;
    background: #1a1f2e;
    border: 1px solid var(--accent);
    border-radius: 14px;
    padding: 16px 16px 14px;
    width: 320px;
    max-width: calc(100vw - 32px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    color: #fff;
    transition: top 0.35s cubic-bezier(0.4, 0, 0.2, 1), left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1 !important;
    --arrow-x: 50%;
}
/* Arrow pointing toward target */
.tour-tooltip::before,
.tour-tooltip::after {
    content: '';
    position: absolute;
    left: var(--arrow-x);
    transform: translateX(-50%);
    width: 0; height: 0;
    border: 10px solid transparent;
}
.tour-tooltip[data-dir="up"]::before   { top: -20px;    border-bottom-color: var(--accent); }
.tour-tooltip[data-dir="up"]::after    { top: -18px;    border-bottom-color: #1a1f2e; }
.tour-tooltip[data-dir="down"]::before { bottom: -20px; border-top-color: var(--accent); }
.tour-tooltip[data-dir="down"]::after  { bottom: -18px; border-top-color: #1a1f2e; }
.tour-mascot {
    display: block;
    width: 72px;
    height: 72px;
    object-fit: contain;
    margin: 0 auto 10px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    padding: 4px;
}
.tour-step {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.tour-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
}
.tour-text {
    font-size: 13px;
    line-height: 1.5;
    opacity: 0.9;
    margin-bottom: 12px;
}
.tour-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.tour-skip {
    background: transparent;
    border: none;
    color: var(--text);
    opacity: 0.6;
    font-size: 13px;
    cursor: pointer;
    padding: 6px 8px;
}
.tour-next {
    background: var(--accent);
    color: #fff;
    border: none;
    font-weight: 600;
    font-size: 14px;
    padding: 9px 18px;
    border-radius: 10px;
    cursor: pointer;
}
.tour-next:active { transform: scale(0.96); }

.tg-gate {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg, #0f1419);
    padding: 24px; z-index: 10000;
}
.tg-gate-card {
    max-width: 360px; text-align: center;
    background: var(--card-bg, #1a1f26);
    border: 1px solid var(--card-border, #2a2f36);
    border-radius: 16px; padding: 28px 22px;
    color: var(--text, #fff);
    box-shadow: 0 12px 32px rgba(0,0,0,0.3);
}
.tg-gate-icon { width: 88px; height: 88px; margin: 0 auto 14px; }
.tg-gate-icon svg { width: 100%; height: 100%; display: block; }
.tg-gate-title { font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.tg-gate-text  { font-size: 14px; line-height: 1.5; opacity: 0.85; margin-bottom: 18px; }
.tg-gate-btn {
    display: inline-block;
    background: #37aee2;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    padding: 12px 24px;
    border-radius: 12px;
    transition: transform 0.15s, background 0.15s;
}
.tg-gate-btn:hover   { background: #2a9bcb; }
.tg-gate-btn:active  { transform: scale(0.97); }

.user-name {
    font-size: 20px;
    font-weight: 700;
}

.user-subtitle {
    font-size: 13px;
    color: var(--text-hint);
    margin-top: 2px;
}

/* ── Cards ── */

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 20px;
    margin: 16px 0;
    backdrop-filter: blur(10px);
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-hint);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
}

/* ── Predict card ── */
.predict-card { padding-bottom: 18px; }
/* Merged overview card — predict + spider chart side-by-side on one screen */
.overview-card { overflow: visible; padding-bottom: 14px; }
.overview-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    margin: 4px 0 8px;
}
.overview-left  { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.overview-right { display: flex; justify-content: center; align-items: center; min-width: 0; }
.chart-container-compact { padding: 0; width: 100%; }
/* Tighten predict block when living inside the grid */
.overview-grid .predict-row { gap: 10px; margin: 0; }
.overview-grid .predict-grade { width: 58px; height: 58px; border-radius: 16px; font-size: 32px; }
.overview-grid .predict-score { font-size: 22px; }
.overview-grid .predict-max   { font-size: 13px; }
.overview-grid .predict-label { font-size: 10px; letter-spacing: 0.4px; }
.overview-card .predict-bar   { margin-top: 2px; }
.predict-grade-name { font-size: 10px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-hint); margin-top: 4px; }
.predict-grade-name:empty { display: none; }
.overview-card .predict-hint  { margin-top: 8px; }
.overview-card .chart-legend  { margin-top: 8px; gap: 6px; }
.overview-card .legend-item   { font-size: 10px; }
@media (max-width: 360px) {
    .overview-grid { grid-template-columns: 1fr; }
    .overview-right { order: -1; }
    .chart-container-compact #spider-chart { max-width: 200px; }
}

.predict-row { display: flex; align-items: center; gap: 16px; margin: 4px 0 12px; }
.predict-grade {
    width: 72px; height: 72px; border-radius: 20px;
    background: linear-gradient(135deg, var(--accent-strong) 0%, var(--accent-soft) 100%);
    color: #fff; font-size: 40px; font-weight: 800; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 20px rgba(108, 92, 231, 0.35);
}
.predict-grade.g2 { background: linear-gradient(135deg, #eb5757 0%, #f2994a 100%); box-shadow: 0 8px 20px rgba(235, 87, 87, 0.35); }
.predict-grade.g3 { background: linear-gradient(135deg, #f2994a 0%, #f2c94c 100%); box-shadow: 0 8px 20px rgba(242, 153, 74, 0.35); }
.predict-grade.g4 { background: linear-gradient(135deg, #2f80ed 0%, #56ccf2 100%); box-shadow: 0 8px 20px rgba(47, 128, 237, 0.35); }
.predict-grade.g5 { background: linear-gradient(135deg, #27ae60 0%, #6fcf97 100%); box-shadow: 0 8px 20px rgba(39, 174, 96, 0.35); }
.predict-meta { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.predict-score { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; letter-spacing: -1px; }
.predict-max { font-size: 16px; color: var(--text-hint); font-weight: 600; margin-left: 2px; }
.predict-label { font-size: 12px; color: var(--text-hint); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
.predict-bar { width: 100%; height: 8px; background: rgba(255,255,255,0.06); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.predict-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #eb5757 0%, #f2994a 25%, #f2c94c 50%, #2f80ed 75%, #27ae60 100%); border-radius: 999px; transition: width 0.6s ease; }
.predict-hint { margin-top: 10px; font-size: 12px; color: var(--text-hint); text-align: center; }

/* ── Spider Chart ── */

.chart-container {
    display: flex;
    justify-content: center;
    padding: 8px 0;
    overflow: visible;
}
.chart-card { overflow: visible; }

#spider-chart {
    max-width: 360px;
    max-height: 360px;
    display: block;
    margin: 0 auto;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-hint);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* ── Stats Row ── */

.stats-row {
    display: flex;
    gap: 10px;
    margin: 16px 0;
}

.stat-box {
    flex: 1;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 14px 10px;
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    font-size: 11px;
    color: var(--text-hint);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Buttons ── */

.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
    color: var(--accent-text);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.15s;
    margin-top: 8px;
}

.btn-primary:active {
    transform: scale(0.97);
    opacity: 0.9;
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Primary CTA — highlighted blue with soft pulse */
#btn-go-solve {
    padding: 18px 24px;
    font-size: 17px;
    background: linear-gradient(135deg, #1e6fff 0%, #3d8bff 50%, #5aa3ff 100%);
    color: #fff;
    box-shadow:
        0 6px 18px rgba(30, 111, 255, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.08) inset;
    position: relative;
    overflow: hidden;
    animation: solve-pulse 2.4s ease-in-out infinite;
}
@keyframes solve-pulse {
    0%, 100% { box-shadow: 0 6px 18px rgba(30, 111, 255, 0.45), 0 0 0 1px rgba(255,255,255,0.08) inset; }
    50%      { box-shadow: 0 8px 26px rgba(30, 111, 255, 0.65), 0 0 0 1px rgba(255,255,255,0.12) inset; }
}
body.theme-light #btn-go-solve {
    box-shadow: 0 6px 18px rgba(30, 111, 255, 0.35), 0 0 0 1px rgba(255,255,255,0.3) inset;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon svg { width: 20px; height: 20px; }
.stat-ico { width: 28px; height: 28px; color: var(--accent-soft); }
.stat-streak-value { display: inline-flex; align-items: center; gap: 4px; }
.stat-flame { width: 32px; height: 32px; transform-origin: 50% 90%; animation: flame-body 1.6s ease-in-out infinite; }
.stat-flame .flame-outer { transform-origin: 50% 95%; animation: flame-outer 0.6s ease-in-out infinite alternate; }
.stat-flame .flame-mid   { transform-origin: 50% 95%; animation: flame-outer 0.45s ease-in-out infinite alternate; }
.stat-flame .flame-inner { transform-origin: 50% 95%; animation: flame-inner 0.32s ease-in-out infinite alternate; }

/* blue (cold): streak < 3 */
.stat-streak-value.flame-blue  .stat-flame   { filter: drop-shadow(0 0 6px rgba(47, 128, 237, 0.55)); }
.stat-streak-value.flame-blue  .flame-outer  { fill: #1e5fc7; }
.stat-streak-value.flame-blue  .flame-mid    { fill: #2f80ed; }
.stat-streak-value.flame-blue  .flame-inner  { fill: #8ec5ff; }
/* orange (warm): 3..7 */
.stat-streak-value.flame-orange .stat-flame  { filter: drop-shadow(0 0 7px rgba(255, 145, 0, 0.65)); }
.stat-streak-value.flame-orange .flame-outer { fill: #ff6d00; }
.stat-streak-value.flame-orange .flame-mid   { fill: #ff9a26; }
.stat-streak-value.flame-orange .flame-inner { fill: #ffd54f; }
/* red (hot): >= 8 */
.stat-streak-value.flame-red    .stat-flame  { animation: flame-body 0.9s ease-in-out infinite, flame-glow 1.2s ease-in-out infinite; }
.stat-streak-value.flame-red    .flame-outer { fill: #e53935; }
.stat-streak-value.flame-red    .flame-mid   { fill: #ff6d00; }
.stat-streak-value.flame-red    .flame-inner { fill: #ffee58; }

@keyframes flame-body {
    0%, 100% { transform: translateY(0) scale(1, 1); }
    50%      { transform: translateY(-1px) scale(1.04, 1.08); }
}
@keyframes flame-outer {
    from { transform: skewX(-3deg) scaleY(1); }
    to   { transform: skewX(3deg)  scaleY(1.06); }
}
@keyframes flame-inner {
    from { transform: skewX(4deg)  scaleY(0.94); opacity: 0.8; }
    to   { transform: skewX(-4deg) scaleY(1.08); opacity: 1; }
}
@keyframes flame-glow {
    0%, 100% { filter: drop-shadow(0 0 7px rgba(255, 61, 0, 0.65)); }
    50%      { filter: drop-shadow(0 0 16px rgba(255, 82, 0, 0.95)); }
}

.btn-back {
    background: var(--accent);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(47, 128, 237, 0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.btn-back:active {
    transform: scale(0.94);
    background: var(--accent-soft, var(--accent));
}

/* ── Screen Header ── */

.screen-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 0 16px;
}

.screen-header h2 {
    font-size: 20px;
    font-weight: 700;
}

/* ── Category Grid ── */

.category-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.category-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 20px 14px;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
    text-align: center;
}

.category-card:active {
    transform: scale(0.96);
}

.cat-part1    { border-left: 3px solid var(--accent-soft); }
.cat-part2    { border: 2px solid #ef4444; }
.cat-part2 .cat-icon { color: #ef4444; }
.cat-practical { border-left: 3px solid #cfe4ff; }
.cat-algebra  { border-left: 3px solid #cfe4ff; }
.cat-geometry { border-left: 3px solid #10b981; }
.cat-geometry .cat-icon { color: #10b981; }

.cat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-soft);
    margin-bottom: 8px;
}
.cat-icon svg { width: 28px; height: 28px; }

.cat-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
}

.cat-desc {
    font-size: 12px;
    color: var(--text-hint);
}

/* ── Divider ── */

.divider-text {
    text-align: center;
    color: var(--text-hint);
    font-size: 13px;
    margin: 20px 0 16px;
    position: relative;
}

.divider-text::before,
.divider-text::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 28%;
    height: 1px;
    background: var(--card-border);
}
.divider-text::before { left: 0; }
.divider-text::after  { right: 0; }

/* ── Task Number Grid ── */

.task-number-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.task-num-btn {
    aspect-ratio: 1;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.task-num-btn:active {
    transform: scale(0.92);
}

.task-num-btn.part2 {
    border: 2px solid #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

.task-num-btn .progress-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.progress-dot.green  { background: var(--success); }
.progress-dot.yellow { background: var(--warning); }
.progress-dot.red    { background: var(--error); }

/* ── Tasks List ── */

.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.task-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: transform 0.15s;
}

.task-card:active {
    transform: scale(0.98);
}

.task-card-text {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-line;
}

.task-card-badge {
    display: inline-block;
    margin-top: 10px;
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    background: rgba(108, 92, 231, 0.2);
    color: var(--link);
}

/* ── Solve Screen ── */

.solve-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.task-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 11px;
}
.task-points {
    background: rgba(77, 158, 255, 0.15);
    color: var(--accent-soft);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.task-source {
    color: var(--text-hint);
    font-style: italic;
}

.solution-box {
    margin-top: 12px;
    padding: 14px 16px;
    background: rgba(77, 158, 255, 0.06);
    border: 1px solid rgba(77, 158, 255, 0.2);
    border-radius: var(--radius-sm);
    font-size: 15px;
    line-height: 1.6;
    text-align: left;
    white-space: pre-line;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
    box-sizing: border-box;
}
.solution-box .katex-display {
    margin: 0.5em 0;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
}
.solution-box .katex-display > .katex {
    white-space: nowrap;
}
.solution-box .katex {
    max-width: 100%;
    white-space: normal;
}
.btn-solution { margin-top: 8px; }
.btn-giveup { margin-top: 8px; width: 100%; font-size: 14px; }
.solution-img {
    display: block;
    max-width: 100%;
    margin: 10px 0 2px;
    border-radius: var(--radius-sm);
    cursor: zoom-in;
}

.task-text {
    font-size: 16px;
    line-height: 1.7;
    white-space: pre-line;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.task-image {
    margin: 14px -20px 0;  /* break out of card padding for full width */
    border-radius: 0;
    overflow: hidden;
}

.task-image img {
    width: 100%;
    border-radius: 0;
}
.task-img-zoom { background: #fff; min-height: 260px; }
.task-img-zoom .pinch-img {
    width: 100%;
    height: auto;
    max-height: 80vh;
    object-fit: contain;
    display: block;
}

/* ── Options ── */

.options-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.option-btn {
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    color: var(--text);
    font-size: 15px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}

.option-btn:active {
    transform: scale(0.98);
}

.option-btn.selected {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.15);
}

.option-btn.correct {
    border-color: var(--success);
    background: rgba(0, 184, 148, 0.15);
}

.option-btn.wrong {
    border-color: var(--error);
    background: rgba(225, 112, 85, 0.15);
}

/* ── Answer Input ── */

.answer-container {
    margin-bottom: 16px;
}

.input-label {
    display: block;
    font-size: 14px;
    color: var(--text-hint);
    margin-bottom: 8px;
}

.answer-input-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}
.answer-sign-btn {
    flex: 0 0 52px;
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.08s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.answer-sign-btn:active { transform: scale(0.96); }
.answer-sign-btn.active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}
body.theme-light .answer-sign-btn.active { color: #fff; }

.answer-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 14px 16px;
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 18px;
    font-weight: 600;
    outline: none;
    transition: border-color 0.2s;
}

.answer-input:focus {
    border-color: var(--accent);
}

.answer-input::placeholder {
    color: var(--text-hint);
    font-weight: 400;
}

/* ── Upload ── */

.upload-container {
    margin-bottom: 16px;
}

.upload-area {
    border: 2px dashed var(--card-border);
    border-radius: var(--radius);
    padding: 32px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.upload-area:active {
    border-color: var(--accent);
}

.upload-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-soft);
    margin-bottom: 8px;
}
.upload-icon svg { width: 40px; height: 40px; }

.upload-text {
    font-size: 14px;
    color: var(--text);
    margin-bottom: 4px;
}

.upload-hint {
    font-size: 12px;
    color: var(--text-hint);
}

.file-preview {
    margin-top: 12px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--card-border);
}

.file-preview img {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
}

.file-name {
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-hint);
    background: var(--card-bg);
}

/* ── Result ── */

.result-container {
    text-align: center;
    padding: 24px 0;
    animation: fadeSlideIn 0.4s ease;
}

.result-icon {
    font-size: 64px;
    margin-bottom: 12px;
}
.result-icon .result-gif {
    width: 140px;
    height: 140px;
    object-fit: contain;
    filter: drop-shadow(0 6px 16px rgba(30, 111, 255, 0.3));
}

.result-text {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.result-answer {
    font-size: 14px;
    color: var(--text-hint);
    margin-bottom: 20px;
}

/* ── Submit Button ── */

.btn-submit {
    margin-top: 12px;
}

/* ── KaTeX overrides ── */

.task-text .katex-display {
    margin: 12px 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.task-text .katex {
    font-size: 1.1em;
    color: var(--text);
}

/* ── Secondary button ── */

.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 13px 24px;
    background: var(--card-bg);
    color: var(--text-hint);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.15s;
}
.btn-secondary:active { background: rgba(255,255,255,0.1); }

/* ── All-solved banner ── */

.all-solved-banner {
    background: linear-gradient(135deg, rgba(253,203,110,0.15), rgba(253,203,110,0.05));
    border: 1px solid rgba(253,203,110,0.3);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 14px;
    color: var(--warning);
    margin-bottom: 12px;
    text-align: center;
}

/* ── Loading overlay ── */

#loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(10px) saturate(0.6);
    -webkit-backdrop-filter: blur(10px) saturate(0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: overlay-fade 0.2s ease;
}

.loading-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 28px 36px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    min-width: 220px;
}

.loading-mascot {
    width: 96px;
    height: 96px;
    object-fit: contain;
    image-rendering: auto;
    /* GIF has its own animation — no bounce needed */
}
/* Emoji fallback if the GIF fails to load */
.loading-mascot-fallback {
    font-size: 44px;
    line-height: 1;
    animation: mascot-bounce 1.2s ease-in-out infinite;
}

.loading-dots {
    display: flex;
    gap: 7px;
}
.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-soft);
    animation: dot-pulse 1.1s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.18s; }
.loading-dots span:nth-child(3) { animation-delay: 0.36s; }

.loading-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    opacity: 0.88;
    text-align: center;
    letter-spacing: 0.2px;
}

@keyframes overlay-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes mascot-bounce {
    0%, 100% { transform: translateY(0)    scale(1); }
    50%      { transform: translateY(-6px) scale(1.05); }
}
@keyframes dot-pulse {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40%           { transform: scale(1.15); opacity: 1;   }
}

/* Keep the old class for back-compat if anything references it */
.loading-spinner { display: none; }

/* ── Toast ── */

#toast {
    position: fixed;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
    transform: translate(-50%, 120%);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100% - 32px);
    padding: 12px 18px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    z-index: 9998;
    transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.2, 1),
                opacity 0.2s ease;
}
#toast.visible {
    transform: translate(-50%, 0);
    opacity: 1;
}

.toast-icon { font-size: 18px; line-height: 1; flex-shrink: 0; }
.toast-text { flex: 1; min-width: 0; }

/* Tone per type — subtle left border, icon hue */
.toast-warn    { border-left: 3px solid var(--warning); }
.toast-error   { border-left: 3px solid var(--error);   }
.toast-success { border-left: 3px solid var(--success); }
.toast-info    { border-left: 3px solid var(--accent);  }

/* ── Shake animation for emphasising an input ── */
.shake {
    animation: shake-x 0.38s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
@keyframes shake-x {
    10%, 90%  { transform: translateX(-2px); }
    20%, 80%  { transform: translateX( 4px); }
    30%, 50%, 70% { transform: translateX(-6px); }
    40%, 60%  { transform: translateX( 6px); }
}

/* ── Утилиты ── */

.hidden { display: none !important; }

/* Адаптивность для мелких экранов */
@media (max-width: 360px) {
    .task-number-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .stats-row {
        gap: 6px;
    }
    .stat-value {
        font-size: 20px;
    }
}

/* ── Manual (Об экзамене) ── */

.manual-hero {
    margin: 16px 0;
    padding: 24px 20px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent-strong) 0%, var(--accent-soft) 100%);
    color: #fff;
    text-align: center;
    box-shadow: 0 10px 30px rgba(108, 92, 231, 0.35);
}
.hero-big { font-size: 56px; font-weight: 800; line-height: 1; letter-spacing: -2px; }
.hero-lbl { margin-top: 6px; font-size: 12px; opacity: 0.9; text-transform: uppercase; letter-spacing: 1.2px; }
.hero-sub { margin-top: 10px; font-size: 14px; font-weight: 600; opacity: 0.95; }

.exam-date-card { text-align: center; }
.exam-date-row { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0; }
.exam-date-big { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }
.exam-date-sub { font-size: 13px; font-weight: 600; color: var(--accent-strong); background: rgba(108, 92, 231, 0.1); padding: 6px 14px; border-radius: 999px; }
.exam-date-sub.urgent { color: var(--error); background: rgba(235, 87, 87, 0.12); }
.exam-date-sub.past { color: var(--text-hint); background: var(--card-border); }

.ref-toggle-btn { width: 100%; margin-top: 16px; }
.reference-materials { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.reference-img { width: 100%; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--card-border); background: #fff; cursor: zoom-in; }

.criteria-block { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.criteria-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-sm); padding: 12px; }
.criteria-head { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 8px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.criteria-topic { font-size: 11px; font-weight: 500; color: var(--text-hint); text-transform: uppercase; letter-spacing: 0.6px; }
.criteria-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.criteria-table th, .criteria-table td { border: 1px solid var(--card-border); padding: 6px 8px; text-align: left; vertical-align: top; color: var(--text); }
.criteria-table th { background: rgba(108, 92, 231, 0.08); font-weight: 700; }
.criteria-table th:last-child, .criteria-table td:last-child { text-align: center; width: 48px; font-weight: 700; }
.criteria-table .crit-max td { font-style: italic; background: rgba(108, 92, 231, 0.05); }

.img-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.95); z-index: 9999; overflow: hidden; }
.img-lightbox-viewport {
    position: absolute; inset: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pinch-zoom;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.img-lightbox-viewport img {
    max-width: 100%; max-height: 100%;
    width: auto; height: auto;
    border-radius: 8px;
    background: #fff;
    transform-origin: center center;
    transition: transform 0.2s;
    touch-action: pinch-zoom;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
}
.img-lightbox-close {
    position: absolute; top: 14px; right: 14px; z-index: 2;
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(0,0,0,0.6); color: #fff; border: 1px solid rgba(255,255,255,0.3);
    font-size: 18px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

/* Floating "Справочный материал" tab on solve screen */
.ref-fab {
    position: fixed;
    right: 0;
    top: 45%;
    transform: translateY(-50%);
    z-index: 60;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px 0 0 10px;
    padding: 14px 6px;
    font-size: 12px;
    line-height: 1.1;
    font-weight: 600;
    letter-spacing: 0.3px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    cursor: pointer;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    text-align: center;
    white-space: nowrap;
}
.ref-fab-label { display: inline; }
.ref-fab-label br { display: none; }
.ref-fab:active { transform: translateY(-50%) scale(0.96); }

.ref-drawer {
    position: fixed;
    inset: 0;
    background: var(--bg, #0f1419);
    z-index: 9998;
    display: none;
}
.ref-drawer.open { display: block; }
.ref-drawer-panel {
    background: var(--bg, #0f1419);
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 16px 14px 24px;
    animation: ref-slide 0.22s ease-out;
    -webkit-overflow-scrolling: touch;
}
@keyframes ref-slide { from { transform: translateX(100%); } to { transform: translateX(0); } }
.ref-section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin: 12px 0 8px;
    opacity: 0.9;
    text-align: center;
}
.ref-section-title:first-child { margin-top: 4px; }
.ref-drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 12px;
    color: var(--text);
}
.ref-drawer-close {
    background: var(--accent);
    border: none;
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.ref-drawer-close:active { transform: scale(0.94); }
.ref-drawer-body { display: flex; flex-direction: column; gap: 12px; }
.ref-zoom {
    width: 100%;
    overflow: hidden;
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
    background: #fff;
    touch-action: pan-y pinch-zoom;
    position: relative;
}
.ref-zoom .pinch-img {
    display: block;
    width: 100%;
    height: auto;
    transform-origin: 0 0;
    will-change: transform;
    user-select: none;
    -webkit-user-drag: none;
    cursor: default;
    border: none;
    border-radius: 0;
    background: transparent;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 12px 0 16px;
}
.info-tile {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 12px 6px;
    text-align: center;
}
.info-tile.forbid { opacity: 0.75; }
.info-tile.forbid .info-ico { color: var(--error); }
.info-ico {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-soft);
    margin-bottom: 2px;
}
.info-ico svg { width: 26px; height: 26px; }
.info-val { margin-top: 4px; font-size: 15px; font-weight: 700; color: var(--text); }
.info-lbl { font-size: 11px; color: var(--text-hint); margin-top: 2px; }

.section-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--card-border);
}
.section-row:last-child { border-bottom: none; padding-bottom: 4px; }
.section-row:first-of-type { padding-top: 4px; }
.sec-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.sec-alg  { background: #cfe4ff; }
.sec-geo  { background: #10b981; }
.sec-alg2 { background: #7fb6ff; }
.sec-geo2 { background: #047857; }
.sec-body { flex: 1; min-width: 0; }
.sec-name { font-size: 14px; font-weight: 600; color: var(--text); }
.sec-desc { font-size: 12px; color: var(--text-hint); margin-top: 2px; }

.pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    background: rgba(207, 228, 255, 0.2);
    color: #cfe4ff;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}
.pill.pill-2 { background: rgba(16, 185, 129, 0.22); color: #34d399; }

.score-table {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}
.score-cell {
    background: rgba(207, 228, 255, 0.14);
    border: 1px solid rgba(207, 228, 255, 0.3);
    border-radius: var(--radius-sm);
    padding: 10px 4px;
    text-align: center;
}
.score-cell.sc-geometry:not(.sc-part2) {
    background: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.38);
}
.score-cell.sc-part2 {
    background: rgba(127, 182, 255, 0.2);
    border-color: rgba(127, 182, 255, 0.42);
}
.score-cell.sc-part2.sc-geometry {
    background: rgba(4, 120, 87, 0.28);
    border-color: rgba(4, 120, 87, 0.5);
}
.sc-num { font-size: 15px; font-weight: 700; color: var(--text); }
.sc-pts { font-size: 11px; color: var(--text-hint); margin-top: 2px; }

.score-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-top: 14px;
    font-size: 11px;
    color: var(--text-hint);
}
.lg-item { display: inline-flex; align-items: center; gap: 6px; }
.lg-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.lg-a1 { background: rgba(207, 228, 255, 0.7); }
.lg-g1 { background: rgba(16, 185, 129, 0.75); }
.lg-a2 { background: rgba(127, 182, 255, 0.8); }
.lg-g2 { background: rgba(4, 120, 87, 0.85); }

.grade-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--card-border);
}
.grade-row:last-of-type { border-bottom: none; }
.grade-row:first-of-type { padding-top: 4px; }
.grade {
    display: inline-flex;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 19px;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.grade {
    background: var(--bg);
    border: 2px solid transparent;
    box-shadow: none;
}
.grade.g2 { border-color: #ef4444; color: #ef4444; }
.grade.g3 { border-color: #2563eb; color: #2563eb; }
.grade.g4 { border-color: #2563eb; color: #2563eb; }
.grade.g5 { border-color: #10b981; color: #10b981; }
.grade-body { flex: 1; }
.grade-range { font-size: 14px; font-weight: 600; color: var(--text); }
.grade-hint { font-size: 12px; color: var(--text-hint); margin-top: 2px; }

.manual-note {
    margin-top: 14px;
    padding: 12px 14px;
    background: rgba(253, 203, 110, 0.12);
    border-left: 3px solid var(--warning);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
}

.step-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--card-border);
}
.step-row:last-child { border-bottom: none; padding-bottom: 4px; }
.step-row:first-child { padding-top: 4px; }
.step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    margin-top: 2px;
}
.step-body {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
}

.tip-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--card-border);
    font-size: 14px;
    line-height: 1.5;
}
.tip-row:last-child { border-bottom: none; padding-bottom: 4px; }
.tip-row:first-child { padding-top: 4px; }
.tip-ico {
    flex-shrink: 0;
    width: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-soft);
    margin-top: 1px;
}
.tip-ico svg { width: 22px; height: 22px; }

/* ── Markdown tables in task text ── */
.task-table-wrap {
    margin: 12px -12px;            /* slight bleed past card padding for more room */
    padding: 0 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.task-text .task-table {
    width: max-content;            /* content-sized; overflow handled by wrapper */
    min-width: 100%;               /* but fill card when content is narrow */
    border-collapse: collapse;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    overflow: hidden;
    table-layout: auto;
}
.task-text .task-table th,
.task-text .task-table td {
    padding: 8px 10px;
    border: 1px solid var(--card-border);
    text-align: left;
    vertical-align: top;
    min-width: 70px;             /* prevent single-char columns */
    word-break: normal;          /* break only at word boundaries */
    overflow-wrap: break-word;   /* wrap long words only when needed */
    hyphens: none;
}
.task-text .task-table th {
    background: rgba(108, 92, 231, 0.2);
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
}
.task-text .task-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}
.task-text b { color: var(--text); font-weight: 700; }

/* Zoomable task images + lightbox */
.task-image img.zoomable { cursor: zoom-in; transition: transform 0.15s; }
.task-image img.zoomable:hover { transform: scale(1.02); }

.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: lightbox-fade 0.18s ease-out;
    cursor: zoom-out;
}

/* Skills chart fullscreen modal */
#spider-chart-wrap { cursor: zoom-in; position: relative; }
#spider-chart-wrap:active { transform: scale(0.98); transition: transform 0.1s; }
.chart-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg, #0b0d12);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: lightbox-fade 0.18s ease-out;
}
.chart-modal-title {
    color: var(--text, #fff);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    opacity: 0.85;
    margin-bottom: 12px;
    text-align: center;
}
.chart-modal-inner {
    width: 100%;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.chart-modal-inner canvas { max-width: 100%; height: auto; }
.chart-modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 44px;
    height: 44px;
    border: none;
    background: var(--card-bg, rgba(255, 255, 255, 0.12));
    color: var(--text, #fff);
    font-size: 28px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
@keyframes lightbox-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.image-lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    user-select: none;
    -webkit-user-drag: none;
}
.lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.25); }

/* ── Mascot (rabbit) ─────────────────────────────────────── */
.mascot {
    position: absolute;
    right: -8px;
    bottom: -44px;
    width: 58px;
    height: 82px;
    z-index: 5;
    cursor: pointer;
    transition: transform 0.35s cubic-bezier(.2,.9,.3,1.3), bottom 0.35s cubic-bezier(.2,.9,.3,1.3);
    filter: drop-shadow(0 4px 10px rgba(0, 71, 255, 0.3));
    animation: mascot-idle 2.4s ease-in-out infinite;
}
@keyframes mascot-idle {
    0%, 100% { transform: translateY(0) rotate(-1deg); }
    50%      { transform: translateY(-2px) rotate(1deg); }
}
.mascot:hover {
    animation: none;
    transform: translateY(-4px) rotate(-3deg);
}
.mascot.active {
    animation: none;
    bottom: -6px;
    transform: translateY(0) scale(1.4);
}
.mascot.active .m-arms { transform: translate(3px, -4px) rotate(-6deg); }
.mascot.active .m-ruler { transform: translate(-16px, -10px) rotate(-24deg); }

.mascot-svg { width: 100%; height: 100%; overflow: visible; display: block; }

.m-ears {
    transform-origin: 50px 38px;
    animation: ear-wiggle 4.2s ease-in-out infinite;
}
@keyframes ear-wiggle {
    0%, 90%, 100% { transform: rotate(0); }
    93% { transform: rotate(-7deg); }
    96% { transform: rotate(6deg); }
}
.m-eyes {
    transform-origin: 50px 66px;
    animation: blink 5s ease-in-out infinite;
}
@keyframes blink {
    0%, 93%, 100% { transform: scaleY(1); }
    96% { transform: scaleY(0.15); }
}
.m-arms {
    transform-origin: 50px 80px;
    transition: transform 0.4s cubic-bezier(.2,.9,.3,1.3);
}
.m-ruler {
    transform-origin: 82px 105px;
    transform: translate(0, 0) rotate(0);
    transition: transform 0.4s cubic-bezier(.2,.9,.3,1.3);
}

.mascot-bubble {
    position: absolute;
    right: 100%;
    bottom: 70%;
    margin-right: 16px;
    min-width: 180px;
    max-width: 240px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #0b1222, #111a33);
    border: 1.5px solid var(--accent);
    color: var(--text);
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    opacity: 0;
    transform: translateY(6px) scale(0.9);
    transform-origin: right bottom;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
    box-shadow: 0 10px 30px rgba(0, 71, 255, 0.35);
    white-space: pre-line;
    font-family: 'SF Mono', 'JetBrains Mono', Menlo, monospace;
}
.mascot-bubble::after {
    content: '';
    position: absolute;
    right: -7px;
    bottom: 18px;
    width: 12px;
    height: 12px;
    background: #111a33;
    border-right: 1.5px solid var(--accent);
    border-bottom: 1.5px solid var(--accent);
    transform: rotate(-45deg);
}
.mascot-bubble.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ── Correct-answer celebration overlay ───────────────────── */
.correct-celebration {
    position: fixed;
    inset: 0;
    z-index: 9500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 8, 15, 0.55);
    backdrop-filter: blur(4px);
    animation: cc-fade-in 0.2s ease-out;
    pointer-events: none;
}
.correct-celebration.closing { animation: cc-fade-out 0.3s ease-in forwards; }
@keyframes cc-fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes cc-fade-out { from { opacity: 1; } to { opacity: 0; } }

.correct-celebration-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    animation: cc-pop 0.4s cubic-bezier(.2,.9,.3,1.5);
}
@keyframes cc-pop {
    0%   { transform: scale(0.4) rotate(-8deg); opacity: 0; }
    60%  { transform: scale(1.08) rotate(3deg); opacity: 1; }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

.correct-celebration-inner img {
    width: 220px;
    height: 220px;
    object-fit: contain;
    filter: drop-shadow(0 10px 30px rgba(30, 111, 255, 0.5));
}
.correct-celebration-text {
    font-size: 28px;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 4px 20px rgba(30, 111, 255, 0.8);
    letter-spacing: 0.5px;
}

/* Home screen mascot gif (next to student name) */
.user-greeting-text { flex: 1; min-width: 0; }
.home-mascot-gif {
    width: 64px;
    height: 64px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 4px 10px rgba(30, 111, 255, 0.35));
}

/* ────────────────────────────────────────────
   LIGHT THEME (Telegram colorScheme === 'light')
   ──────────────────────────────────────────── */
body.theme-light {
    --bg:           var(--tg-theme-bg-color, #ffffff);
    --bg-secondary: var(--tg-theme-secondary-bg-color, #f1f4f9);
    --text:         var(--tg-theme-text-color, #0b1222);
    --text-hint:    var(--tg-theme-hint-color, #6b7a99);
    --accent:       var(--tg-theme-button-color, #1e6fff);
    --accent-text:  var(--tg-theme-button-text-color, #ffffff);
    --link:         var(--tg-theme-link-color, #1e6fff);

    --card-bg:     rgba(30, 111, 255, 0.05);
    --card-border: rgba(30, 111, 255, 0.18);
}

/* Tour tooltip — solid card on light background */
body.theme-light .tour-tooltip { background: #ffffff; color: #0b1222; }
body.theme-light .tour-tooltip[data-dir="up"]::after    { border-bottom-color: #ffffff; }
body.theme-light .tour-tooltip[data-dir="down"]::after  { border-top-color: #ffffff; }
body.theme-light .tour-mascot { background: rgba(30, 111, 255, 0.08); }

/* Hole overlay — slightly darker dim on white pages */
body.theme-light .tour-hole { box-shadow: 0 0 0 9999px rgba(15, 25, 45, 0.55); }

/* Progress / bars / subtle surfaces */
body.theme-light .predict-bar { background: rgba(15, 25, 45, 0.08); }
body.theme-light .btn-secondary:active { background: rgba(15, 25, 45, 0.08); }
body.theme-light .btn-secondary { border-color: rgba(15, 25, 45, 0.12); }

/* Chips / pills / soft-blue panels used as table-of-categories */
body.theme-light [style*="rgba(77, 158, 255, 0.06)"],
body.theme-light .category-card,
body.theme-light .info-card {
    background: rgba(30, 111, 255, 0.04);
    border-color: rgba(30, 111, 255, 0.14);
}

/* Lightbox / ref drawer close button contrast */
body.theme-light .ref-drawer { background: var(--bg); color: var(--text); }
body.theme-light .ref-drawer-head { background: var(--bg-secondary); color: var(--text); }

/* Result toasts / cards that relied on dark background */
body.theme-light .task-card,
body.theme-light .stat-card,
body.theme-light .journal-item,
body.theme-light .option-item {
    background: #ffffff;
    border: 1px solid rgba(15, 25, 45, 0.08);
    box-shadow: 0 1px 2px rgba(15, 25, 45, 0.04);
}

/* Scoreboard gradient row (login/home mascot area) */
body.theme-light .stat-flame,
body.theme-light .home-mascot-gif {
    filter: drop-shadow(0 4px 10px rgba(30, 111, 255, 0.22));
}

/* Inputs */
body.theme-light input[type="text"],
body.theme-light input[type="number"],
body.theme-light textarea {
    background: #ffffff;
    color: var(--text);
    border: 1px solid rgba(15, 25, 45, 0.15);
}
body.theme-light input::placeholder,
body.theme-light textarea::placeholder { color: var(--text-hint); }

/* Light-theme images generally have white backgrounds; mix-blend helps black line-art look native */
body.theme-light .task-image img,
body.theme-light .ref-zoom img { background: #ffffff; }

/* Onboarding gate card */
body.theme-light .tg-gate-card { background: #ffffff; color: #0b1222; }

/* Gradients that were tuned for dark theme */
body.theme-light .result-overlay,
body.theme-light .hero-card {
    background: linear-gradient(135deg, #eaf1ff, #f7faff);
    color: #0b1222;
}

/* ────────────────────────────────────────────
   Report-a-task link + modal + toast
   ──────────────────────────────────────────── */
.task-report-link {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 14px 0 0 auto;       /* push to the right edge */
    width: fit-content;
    padding: 6px 12px;
    background: rgba(225, 112, 85, 0.10);
    border: 1px solid rgba(225, 112, 85, 0.35);
    color: #e17055;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 999px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.task-report-link:hover,
.task-report-link:active {
    background: rgba(225, 112, 85, 0.18);
    border-color: #e17055;
    color: #d45a3c;
}
body.theme-light .task-report-link {
    background: rgba(225, 112, 85, 0.08);
    border-color: rgba(225, 112, 85, 0.35);
    color: #c94a2e;
}

.report-modal {
    position: fixed; inset: 0; z-index: 10000;
    display: flex; align-items: flex-end; justify-content: center;
}
.report-backdrop {
    position: absolute; inset: 0;
    background: rgba(5, 10, 20, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.report-dialog {
    position: relative;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    background: var(--bg-secondary);
    color: var(--text);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 20px 18px 24px;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.4);
    animation: reportSlideUp 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes reportSlideUp {
    from { transform: translateY(40px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.report-close {
    position: absolute; top: 10px; right: 12px;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: transparent;
    border: 0;
    color: var(--text-hint);
    font-size: 22px; line-height: 1;
    cursor: pointer;
}
.report-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.report-subtitle { color: var(--text-hint); font-size: 13px; margin-bottom: 14px; }
.report-reasons {
    display: flex; flex-direction: column; gap: 6px;
    margin-bottom: 14px;
}
.report-reason {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    cursor: pointer;
    font-size: 14px;
    user-select: none;
}
.report-reason.selected {
    background: rgba(30,111,255,0.15);
    border-color: var(--accent);
}
.report-reason input[type="radio"] { accent-color: var(--accent); }
.report-label {
    display: block;
    font-size: 12px;
    color: var(--text-hint);
    margin-bottom: 6px;
}
.report-comment {
    width: 100%;
    min-height: 72px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--card-border);
    font: inherit;
    font-size: 14px;
    resize: vertical;
    margin-bottom: 14px;
    -webkit-appearance: none;
}
.report-submit { width: 100%; }
.report-submit:disabled { opacity: 0.5; cursor: not-allowed; }

body.theme-light .report-dialog { background: #ffffff; }
body.theme-light .report-backdrop { background: rgba(15, 25, 45, 0.45); }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10100;
    padding: 12px 18px;
    border-radius: 999px;
    background: #1a1f2e;
    color: #fff;
    font-size: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    animation: toastIn 0.2s ease-out;
    max-width: calc(100vw - 32px);
    text-align: center;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--error); }
@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}
body.theme-light .toast { background: #0b1222; }
body.theme-light .toast.success { background: #00b894; }
body.theme-light .toast.error   { background: #e17055; }
