/* Вход, рейтинг, кабинет, работа над ошибками. Основа — style.css */

/* ===== Шапка страниц (рейтинг, тесты) ===== */

.page-hero { padding-top: 64px; padding-bottom: 40px; }
.page-hero-title { font-size: clamp(34px, 5vw, 56px); margin-bottom: 18px; }
.page-hero-lead { max-width: 560px; margin-bottom: 36px; }
.page-hero-lead:last-child { margin-bottom: 0; }

.empty-state { text-align: center; padding: 48px 24px; }
.empty-state h2 { font-family: var(--font-display); font-weight: 600; font-size: 22px; margin-bottom: 10px; }
.empty-state p { margin-bottom: 24px; }

/* ===== Вход ===== */

.auth-screen {
    min-height: calc(100vh - var(--header-h) - 130px);
    display: grid;
    place-items: center;
    padding: 48px 16px;
    border-bottom: 0;
}
.auth-screen::before { background: radial-gradient(ellipse 50% 50% at 50% 50%, transparent 0%, var(--bg) 80%); }

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.8);
}
.auth-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 28px;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-bottom: 14px;
}
.auth-text { font-size: 15px; line-height: 1.55; color: var(--text-2); margin-bottom: 28px; }
.auth-text:last-child { margin-bottom: 0; }
.auth-note {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    padding: 14px;
    border-radius: 10px;
    background: var(--bg);
    border: 1px solid var(--line);
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-2);
}
.auth-error {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--bad-soft);
    color: var(--bad-text);
    font-size: 14px;
}
.auth-divider { height: 1px; background: var(--line); margin: 28px 0 20px; }
.auth-skip { font-size: 14px; font-weight: 500; }

/* ===== Рейтинг ===== */

.rating-controls { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }

.rating-page { padding-top: 40px; padding-bottom: 140px; }

.podium {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
    margin-bottom: 24px;
}
.podium-place { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; min-width: 0; }
.podium-avatar { position: relative; }
.podium-avatar .avatar {
    width: 60px;
    height: 60px;
    font-family: var(--font-display);
    font-size: 18px;
    background: var(--chip);
    color: var(--ring);
    border: 2px solid var(--ring);
}
.podium-1 .podium-avatar .avatar { width: 76px; height: 76px; }
.podium-rank {
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    background: var(--ring);
    color: var(--bg);
}
.podium-name { font-weight: 600; font-size: 15px; margin-top: 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-block {
    width: 100%;
    height: 96px;
    border: 1px solid var(--line-2);
    border-bottom: 0;
    border-radius: 14px 14px 0 0;
    background: var(--bg-2);
    padding-top: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.podium-value { font-family: var(--font-display); font-weight: 600; font-size: clamp(22px, 3vw, 32px); color: var(--text-soft); }
.podium-1 { --ring: #F4C352; }
.podium-2 { --ring: #BDC5D1; }
.podium-3 { --ring: #DA915F; }
.podium-1 .podium-block { height: 150px; background: linear-gradient(180deg, rgba(106, 153, 255, 0.18), var(--bg-2)); }
.podium-1 .podium-value { color: var(--text); }
.podium-2 .podium-block { height: 116px; }
.podium-place.is-me .podium-name { color: var(--link); }

.table-card { padding: 0; overflow: hidden; }

.rating-grid {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 110px 70px;
    gap: 16px;
    align-items: center;
    padding: 14px 20px;
}
.rating-head { padding-top: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.rating-row { border-bottom: 1px solid var(--line); }
.rating-row:last-child { border-bottom: 0; }
.rating-row:hover { background: var(--surface-hover); }
.rating-row.is-me { background: var(--accent-soft); }
.rating-rank { font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: var(--text-2); }
.rating-who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.rating-who .avatar { width: 36px; height: 36px; }
.avatar-muted { background: var(--line); color: var(--text-soft); }
.rating-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rating-name small { font-weight: 500; font-size: 12px; color: var(--link); margin-left: 4px; }
.rating-extra { font-size: 13px; color: var(--text-2); }
.rating-value { text-align: right; font-family: var(--font-display); font-weight: 600; font-size: 17px; }
.rating-head .rating-value { font-family: var(--font-mono); font-size: 11px; font-weight: 400; }

.me-bar-wrap { position: fixed; left: 0; right: 0; bottom: 16px; z-index: 50; padding: 0 16px; pointer-events: none; }
.me-bar {
    max-width: 912px;
    margin: 0 auto;
    pointer-events: auto;
    border: 1px solid rgba(106, 153, 255, 0.6);
    border-radius: 16px;
    background: rgba(22, 24, 34, 0.94);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.9);
}
.me-hint { font-size: 12px; color: var(--text-2); }
.me-bar-text {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 12px 20px;
    border-color: var(--line-2);
    background: rgba(17, 19, 24, 0.94);
    font-size: 15px;
}

@media (max-width: 600px) {
    .page-hero { padding-top: 40px; padding-bottom: 32px; }
    .rating-controls .seg { width: 100%; }
    .rating-controls .seg-item { flex: 1; justify-content: center; }
    .rating-grid { grid-template-columns: 28px minmax(0, 1fr) 56px; gap: 10px; padding: 12px 14px; }
    .rating-extra { display: none; }
    .podium-name { font-size: 13px; }
    .podium-avatar .avatar { width: 48px; height: 48px; font-size: 15px; }
    .podium-1 .podium-avatar .avatar { width: 60px; height: 60px; }
    .me-bar-text .btn { width: 100%; }
    .auth-card { padding: 28px 22px; }
}

/* ===== Оболочка кабинета ===== */

.app { display: flex; min-height: 100vh; background: linear-gradient(90deg, var(--bg-2) 247px, var(--line) 247px, var(--line) 248px, transparent 248px); }

.app-side {
    width: 248px;
    flex: none;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding: 20px 16px;
}
.app-side .brand { padding: 0 8px; }

.app-nav { display: flex; flex-direction: column; gap: 2px; }
.app-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-2);
}
.app-nav a:hover { color: var(--text); }
.app-nav a.is-active { background: var(--chip); color: var(--text); }
.app-nav i { width: 6px; height: 6px; border-radius: 2px; background: var(--line-3); flex: none; }
.app-nav a.is-active i { background: var(--accent); }
.app-nav span { flex: 1; }
.app-nav em { font-style: normal; font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }

.app-lang { margin-top: auto; padding: 0 8px; }
.app-user { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.app-user-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; }
.app-user-name div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-user-name small { display: block; font-size: 12px; font-weight: 400; color: var(--text-3); }
.app-logout { border: 0; background: none; font-family: var(--font-mono); font-size: 11px; color: var(--text-3); cursor: pointer; }
.app-logout:hover { color: var(--text); }

.app-main { flex: 1; min-width: 0; padding: 32px clamp(20px, 3vw, 40px) 64px; }
.app-inner { max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }

.app-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 16px; margin-bottom: 16px; }
.app-head .label-mono { margin-bottom: 8px; }
.app-head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.back-link { font-size: 14px; }

.small { font-size: 13px; line-height: 1.5; }
.admin-note .card-title { margin-bottom: 6px; }

/* Плитки: балл, серия, следующий шаг */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 16px; }
.tile { display: flex; flex-direction: column; gap: 14px; }
.tile-big { display: flex; align-items: baseline; gap: 10px; }
.tile-big span { font-family: var(--font-display); font-weight: 600; font-size: 60px; line-height: 1; letter-spacing: -0.03em; }
.tile-big small { font-size: 15px; color: var(--text-3); }
.tile-big-sm span { font-size: 40px; }
.tile-big-sm small { font-size: 16px; font-weight: 500; color: var(--text-2); }
.tile-note { font-size: 13px; color: var(--text-2); }
.tile-empty { font-size: 14px; line-height: 1.5; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 44px; }
.bars i { flex: 1; max-width: 40px; border-radius: 3px; background: var(--line-2); }
.bars i.is-last { background: var(--accent); }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: auto; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.week-day i { width: 100%; aspect-ratio: 1; max-width: 40px; border-radius: 6px; border: 1px solid var(--line-2); }
.week-day.is-done i { background: rgba(78, 213, 137, 0.85); border-color: transparent; }
.week-day.is-today i { border-color: var(--line-hover); }
.week-day span { font-family: var(--font-mono); font-size: 10px; color: var(--text-3); }

.tile-accent { background: var(--accent); color: var(--bg); border-radius: var(--radius); padding: 24px; gap: 12px; }
.tile-accent:hover { color: var(--bg); background: var(--accent-hover); }
.tile-accent .label-mono { color: var(--bg); font-weight: 600; }
.tile-accent-title { font-family: var(--font-display); font-weight: 600; font-size: 20px; line-height: 1.25; flex: 1; }
.tile-accent-sub { font-size: 13px; opacity: 0.75; }
.tile-accent-btn { align-self: flex-start; background: var(--bg); color: var(--text); border-radius: 10px; padding: 11px 18px; font-size: 14px; font-weight: 600; }

/* Разделы и ошибки */
.cabinet-row { display: flex; flex-wrap: wrap; gap: 16px; }
.cabinet-sections { flex: 1 1 min(440px, 100%); min-width: 0; }
.cabinet-mistakes { flex: 1 1 min(360px, 100%); min-width: 0; display: flex; flex-direction: column; }
.cabinet-mistakes .card-head { margin-bottom: 6px; }
.cabinet-mistakes .btn { margin-top: auto; }

.progress-list { display: flex; flex-direction: column; gap: 20px; }
.progress-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.progress-track { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress-track div { height: 100%; border-radius: 3px; background: var(--accent); }
.progress.level-ok .progress-track div { background: var(--ok); }
.progress.level-mid .progress-track div { background: var(--warn); }
.progress.level-low .progress-track div, .progress.is-weakest .progress-track div { background: var(--bad); }
.progress-note { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.progress.is-weakest .progress-note { color: var(--bad-text); }

.mistake-lines { margin: 6px 0 16px; }
.mistake-line { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); font-size: 14px; }
.mistake-line .label-mono { width: 84px; flex: none; }
.mistake-line span:last-child { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* История */
.history-title { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; }
.history-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) 100px; gap: 16px; padding: 14px 24px; align-items: center; border-top: 1px solid var(--line); }
.history-head { padding-top: 10px; padding-bottom: 10px; }
.history-row { color: var(--text); font-size: 14px; }
.history-row:hover { background: var(--surface-hover); color: var(--text); }
.history-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-score { text-align: right; color: var(--text-soft); }
.history-score b { color: var(--ok-text); font-weight: 600; }

/* Настройки */
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); gap: 16px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.setting .card-title { margin-bottom: 4px; }
.switch {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px 8px 8px;
    border-radius: 999px;
    border: 1px solid var(--line-2);
    background: var(--bg);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.switch i { width: 34px; height: 20px; border-radius: 10px; background: var(--line-3); position: relative; transition: background .15s; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-2); transition: transform .15s; }
.switch.is-on { color: var(--text); border-color: rgba(78, 213, 137, 0.4); }
.switch.is-on i { background: var(--ok); }
.switch.is-on i::after { transform: translateX(14px); background: var(--bg); }

/* ===== Работа над ошибками ===== */

.stat-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.stat-pair .tile-big span { font-size: 44px; }
.mistake-group { display: flex; flex-direction: column; gap: 14px; }
.mistake-group-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.mistake-group-head .card-title { margin-bottom: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-family: var(--font-mono); font-size: 12px; padding: 5px 9px; border-radius: 7px; background: var(--chip); color: var(--text-soft); }
.chip b { color: var(--bad-text); font-weight: 600; }

.practice-rows { display: flex; flex-direction: column; margin: 8px 0 20px; }
.practice-row { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); font-size: 14px; }
.practice-row .mono { width: 48px; flex: none; color: var(--text-2); }
.practice-row.is-fixed span:last-child { color: var(--ok-text); }
.practice-row b { color: var(--ok-text); }
.practice-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ===== Кабинет на телефоне ===== */

@media (max-width: 820px) {
    .app { flex-direction: column; background: none; }
    .app-side {
        position: sticky;
        top: 0;
        z-index: 50;
        width: auto;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
        padding: 12px 16px 10px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        background: rgba(14, 16, 20, 0.94);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
    }
    .app-side .brand { padding: 0; flex: 1; }
    .app-side .brand-name { font-size: 14px; }
    .app-user { order: 2; margin: 0; padding: 0; }
    .app-lang { order: 2; margin: 0; padding: 0; }
    .app-user-name { display: none; }
    .app-user .avatar { width: 32px; height: 32px; font-size: 12px; }
    .app-nav { order: 3; flex: 1 1 100%; flex-direction: row; gap: 4px; overflow-x: auto; scrollbar-width: none; }
    .app-nav::-webkit-scrollbar { display: none; }
    .app-nav a { flex: none; padding: 9px 14px; border-radius: 999px; }
    .app-nav i { display: none; }
    .app-main { padding: 24px 16px 56px; }
    .history-grid { grid-template-columns: minmax(0, 1fr) 70px 72px; padding: 14px 16px; }
    .history-type { display: none; }
    .history-title { padding: 16px; }
    .setting { flex-direction: column; align-items: flex-start; }
}
