:root {
    color-scheme: dark;

    --bg: #090A0D;
    --surface: #13151A;
    --surface-2: #191C23;
    --surface-3: #222630;

    --text: #F7F8FA;
    --muted: #8C929D;
    --muted-2: #606773;

    --accent: #A78BFA;
    --accent-2: #8060D9;
    --cyan: #67DCEB;
    --success: #50D49A;
    --warning: #F5C56B;
    --danger: #FF7777;

    --border: rgba(255,255,255,.075);

    --radius: 22px;
    --radius-small: 14px;

    --nav-height: 76px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;

    background:
        radial-gradient(
            ellipse at 50% -20%,
            rgba(120,90,210,.13),
            transparent 60%
        ),
        var(--bg);

    color: var(--text);

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        sans-serif;

    font-size: 14px;
    line-height: 1.5;
}

button,
input,
textarea {
    font: inherit;
}

button {
    color: inherit;
}

.app-shell {
    width: 100%;
    max-width: 560px;
    min-height: 100vh;
    min-height: 100dvh;

    margin: 0 auto;

    padding:
        env(safe-area-inset-top, 0px)
        18px
        calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 24px);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 12px 0 26px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
}

.brand-icon {
    width: 42px;
    height: 42px;

    display: grid;
    place-items: center;

    border-radius: 14px;

    background: linear-gradient(
        145deg,
        #A78BFA,
        #6844BA
    );

    color: #FFFFFF;

    font-weight: 900;
    font-size: 23px;

    box-shadow: 0 6px 24px rgba(139,92,246,.25);
}

.brand-name {
    font-weight: 800;
    font-size: 13px;
    letter-spacing: 1.2px;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 3px;
}

.header-user {
    width: 40px;
    height: 40px;
}

.avatar {
    width: 40px;
    height: 40px;

    display: grid;
    place-items: center;

    border-radius: 50%;

    background: var(--surface-3);
    border: 1px solid var(--border);

    color: var(--accent);
    font-weight: 700;
}

.page-container {
    min-height: 65vh;
    animation: page-in .28s ease both;
}

@keyframes page-in {
    from {
        opacity: 0;
        transform: translateY(7px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: .55;
    }

    50% {
        opacity: 1;
    }
}

.loading-screen {
    min-height: 45vh;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    gap: 14px;

    color: var(--muted);
}

.loader {
    width: 34px;
    height: 34px;

    border: 3px solid var(--surface-3);
    border-top-color: var(--accent);

    border-radius: 50%;

    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.eyebrow {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.8px;
    text-transform: uppercase;
}

h1, h2, h3, p {
    margin-top: 0;
}

h1 {
    font-size: clamp(27px, 7vw, 36px);
    line-height: 1.12;
    letter-spacing: -.9px;
    margin: 8px 0;
}

h2 {
    font-size: 21px;
    letter-spacing: -.4px;
    margin-bottom: 14px;
}

h3 {
    font-size: 15px;
    margin-bottom: 7px;
}

.subtitle {
    color: var(--muted);
    line-height: 1.6;
    font-size: 13px;
}

.section {
    margin-top: 25px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 13px;
}

.section-heading h2 {
    margin: 0;
}

.card {
    background: var(--surface);

    border: 1px solid var(--border);

    border-radius: var(--radius);

    padding: 19px;

    box-shadow: 0 8px 28px rgba(0,0,0,.12);
}

.card + .card {
    margin-top: 12px;
}

.hero-card {
    position: relative;
    overflow: hidden;

    min-height: 220px;

    display: flex;
    flex-direction: column;
    justify-content: space-between;

    padding: 23px;

    border: 1px solid rgba(167,139,250,.18);
    border-radius: 26px;

    background:
        radial-gradient(
            circle at 95% 8%,
            rgba(167,139,250,.24),
            transparent 48%
        ),
        linear-gradient(
            145deg,
            #211B32,
            #14151D 72%
        );
}

.hero-card h1 {
    max-width: 290px;
}

.hero-card p {
    max-width: 270px;
    color: #A9A5B8;
}

.hero-decoration {
    position: absolute;
    right: 17px;
    top: 20px;

    font-size: 76px;

    opacity: .13;
    pointer-events: none;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
    width: 100%;
    min-height: 48px;

    padding: 13px 17px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    border: 0;
    border-radius: 15px;

    cursor: pointer;

    font-weight: 700;

    transition:
        transform .18s ease,
        background .18s ease,
        opacity .18s ease;
}

.primary-btn {
    background: #F4F1FA;
    color: #111018;
}

.secondary-btn {
    background: var(--surface-3);
    color: var(--text);
}

.ghost-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.primary-btn:active,
.secondary-btn:active,
.ghost-btn:active {
    transform: scale(.98);
}

button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.progress-card {
    margin-top: 15px;
}

.progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;

    margin-bottom: 12px;
}

.progress-number {
    font-weight: 800;
    font-size: 26px;
}

.progress-track {
    width: 100%;
    height: 7px;

    overflow: hidden;

    background: #30333B;
    border-radius: 20px;
}

.progress-fill {
    height: 100%;

    background: linear-gradient(
        90deg,
        #8060D9,
        #C4A7FF
    );

    border-radius: inherit;

    transition: width .5s ease;
}

.progress-caption {
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px;
}

.stat-card {
    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 19px;

    padding: 16px;
}

.stat-icon {
    font-size: 22px;
    margin-bottom: 13px;
}

.stat-value {
    font-size: 23px;
    font-weight: 800;
    line-height: 1.2;
}

.stat-label {
    color: var(--muted);
    font-size: 11px;
    margin-top: 5px;
}

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

.lesson-card {
    width: 100%;

    display: flex;
    align-items: center;
    gap: 13px;

    padding: 15px;

    text-align: left;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;

    cursor: pointer;

    transition:
        background .2s ease,
        transform .2s ease;
}

.lesson-card:active {
    transform: scale(.985);
}

.lesson-number {
    flex: 0 0 40px;

    width: 40px;
    height: 40px;

    display: grid;
    place-items: center;

    background: var(--surface-3);
    border-radius: 13px;

    font-weight: 800;
}

.lesson-info {
    flex: 1;
    min-width: 0;
}

.lesson-title {
    font-size: 13px;
    font-weight: 700;
}

.lesson-description {
    margin-top: 3px;

    color: var(--muted);
    font-size: 11px;
}

.lesson-status {
    color: var(--muted);
    font-size: 17px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 5px 10px;

    border-radius: 100px;

    font-size: 10px;
    font-weight: 800;
}

.badge.success {
    background: rgba(80,212,154,.12);
    color: var(--success);
}

.badge.warning {
    background: rgba(245,197,107,.12);
    color: var(--warning);
}

.badge.neutral {
    background: var(--surface-3);
    color: #B3B8C2;
}

.feature-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;

    padding: 17px;

    border-radius: 18px;

    background: var(--surface);
    border: 1px solid var(--border);
}

.feature-icon {
    flex: 0 0 42px;

    width: 42px;
    height: 42px;

    display: grid;
    place-items: center;

    border-radius: 13px;
    background: var(--surface-3);

    font-size: 20px;
}

.feature-content {
    flex: 1;
}

.feature-content p {
    margin: 4px 0 0;

    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 15px;
}

.profile-avatar {
    width: 58px;
    height: 58px;
    flex-shrink: 0;

    display: grid;
    place-items: center;

    border-radius: 19px;

    background: linear-gradient(
        145deg,
        #7553BA,
        #302341
    );

    font-size: 23px;
    font-weight: 800;
}

.data-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    padding: 13px 0;

    border-bottom: 1px solid var(--border);
}

.data-row:last-child {
    border-bottom: 0;
}

.data-label {
    color: var(--muted);
    font-size: 12px;
}

.data-value {
    text-align: right;
    font-weight: 700;
    font-size: 12px;
}

.chat-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    text-align: center;

    min-height: 250px;
    padding: 25px;
}

.chat-icon {
    display: grid;
    place-items: center;

    width: 68px;
    height: 68px;

    margin-bottom: 17px;

    border-radius: 22px;

    background: rgba(167,139,250,.13);

    font-size: 30px;
}

.notice {
    padding: 13px 15px;

    border-radius: 14px;

    color: #C1B4E9;
    background: rgba(139,92,246,.10);

    border: 1px solid rgba(139,92,246,.15);

    font-size: 12px;
    line-height: 1.5;
}

.empty-state {
    padding: 24px 16px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;

    text-align: center;
    color: var(--muted);
    font-size: 12px;
}

.bottom-nav {
    position: fixed;

    left: 50%;
    bottom: 0;

    z-index: 100;

    transform: translateX(-50%);

    width: 100%;
    max-width: 560px;

    min-height: var(--nav-height);

    display: grid;
    grid-template-columns: repeat(4, 1fr);

    padding:
        9px 8px
        calc(9px + env(safe-area-inset-bottom, 0px));

    background: rgba(13,15,20,.94);

    border-top: 1px solid var(--border);

    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    gap: 4px;

    color: var(--muted-2);

    background: none;
    border: none;

    font-size: 9px;
    font-weight: 600;

    cursor: pointer;
}

.nav-icon {
    font-size: 22px;
    line-height: 1.2;
}

.nav-item.active {
    color: #C3A8FF;
}

.nav-item.active .nav-icon {
    filter: drop-shadow(0 0 9px rgba(167,139,250,.3));
}

.toast {
    position: fixed;

    z-index: 200;

    left: 50%;
    bottom: calc(var(--nav-height) + 22px);

    transform: translate(-50%, 15px);

    width: max-content;
    max-width: calc(100% - 36px);

    padding: 12px 17px;

    border-radius: 13px;

    color: #FFFFFF;
    background: #292D36;

    text-align: center;
    font-size: 12px;

    opacity: 0;
    pointer-events: none;

    transition:
        opacity .2s ease,
        transform .2s ease;
}

.toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.connection-banner {
    margin-bottom: 18px;
}

@media (min-width: 480px) {
    .app-shell {
        padding-left: 24px;
        padding-right: 24px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

.lesson-block {
    margin-top: 14px;
}

.lesson-text {
    color: #D5D8DF;
    white-space: pre-wrap;
    line-height: 1.8;
    font-size: 14px;
}

.lesson-block ul {
    padding-left: 20px;
    color: #C7CBD4;
    line-height: 1.8;
}

.lesson-block li {
    padding-left: 4px;
    margin: 6px 0;
}

.lesson-image {
    margin: 14px 0;
    overflow: hidden;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.lesson-image img {
    width: 100%;
    display: block;
    object-fit: cover;
}

.lesson-image figcaption {
    padding: 11px 14px;
    color: var(--muted);
    font-size: 11px;
}

.lesson-code {
    display: block;
    overflow-x: auto;
    white-space: pre;
    color: #C4B5FD;
    font-size: 12px;
    line-height: 1.7;
}

.lesson-link {
    text-decoration: none;
    color: var(--text);
}

.lesson-link:active {
    transform: scale(.985);
}

.lesson-block img {
    max-width: 100%;
}

.lesson-block strong {
    color: #FFFFFF;
}

/* ADMIN PANEL */

.admin-form-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.admin-label {
    display: flex;
    flex-direction: column;
    gap: 8px;

    color: #D9DCE3;
    font-size: 12px;
    font-weight: 700;
}

.admin-input {
    width: 100%;
    min-height: 45px;

    padding: 12px 14px;

    color: #F7F8FA;
    background: #0D1016;

    border: 1px solid rgba(255,255,255,.09);
    border-radius: 13px;

    outline: none;

    font-size: 13px;

    transition:
        border-color .2s ease,
        background .2s ease;
}

.admin-input:focus {
    border-color: #A78BFA;
    background: #111520;
}

.admin-textarea {
    min-height: 100px;
    resize: vertical;

    line-height: 1.65;
}

.admin-block {
    margin-bottom: 12px;
    background: #171A22;
}

.admin-block-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 17px;
}

.admin-block .admin-label + .admin-label {
    margin-top: 15px;
}

.admin-lesson-card {
    display: flex;
    flex-direction: column;
    gap: 13px;
}

.admin-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.admin-actions button {
    min-height: 40px;
    padding: 9px;
    font-size: 11px;
}

.admin-actions button:last-child:nth-child(3) {
    grid-column: 1 / -1;
}

.danger-text {
    color: #FF8585 !important;
}

.danger-text:hover {
    background: rgba(255,100,100,.1);
}

.admin-block-heading .danger-text {
    width: auto;
    min-height: 34px;
    padding: 7px 12px;
    border: 1px solid rgba(255,100,100,.2);
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    font-size: 11px;
}

.lesson-image {
    margin: 15px 0;
}

.lesson-image img {
    width: 100%;
    height: auto;
    border-radius: 18px;
}



/* Дополнительные секции личного кабинета */
.profile-list {
    overflow: hidden;
}

.profile-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,.08));
}

.profile-item:last-child {
    border-bottom: 0;
}

.profile-item-icon {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(255,255,255,.06);
    font-size: 18px;
}

.profile-item-content {
    min-width: 0;
    flex: 1;
}

.profile-item-title {
    color: var(--text-primary, #fff);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.profile-item-meta {
    margin-top: 4px;
    color: var(--text-secondary, #999);
    font-size: 12px;
}

.profile-item-value {
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.profile-item-value.positive {
    color: #62d69b;
}

.profile-item-value.negative {
    color: #ff8585;
}

.profile-empty {
    padding: 16px 4px;
    color: var(--text-secondary, #999);
    font-size: 13px;
    line-height: 1.5;
}

.profile-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 8px;
    background: rgba(255,255,255,.08);
    color: var(--text-secondary, #aaa);
    font-size: 11px;
    vertical-align: middle;
}

.profile-review {
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,.08));
}

.profile-review:last-child {
    border-bottom: 0;
}

.profile-review-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.profile-review-rating {
    color: #f5c451;
    white-space: nowrap;
    letter-spacing: 1px;
}

.profile-review-comment {
    margin-top: 9px;
    color: var(--text-secondary, #bbb);
    font-size: 13px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}
