:root {
    --bg: #ffffff;
    --bg-soft: #f6f9fc;
    --panel: #ffffff;
    --panel-2: #fbfeff;
    --text: #0f172a;
    --muted: #475569;
    --brand: #2563eb;
    --brand-2: #16a34a;
    --border: #e5e7eb;
    --code-bg: #0f172a;
    --shadow: 0 0.5rem 1.5rem rgba(2, 8, 23, 0.07);
    --radius: 1rem;
    --footer-height: 2.1rem;
    --nav-height: 3.2rem;
    --foot-height: 3.5rem;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    margin: 0;
    background: linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
    color: var(--text);
    font: 400 1rem/1.6 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", "Helvetica Neue", Arial;
}

.material-symbols-rounded {
    font-family: "Material Symbols Rounded";
    font-weight: normal;
    font-style: normal;
    font-size: 1.25rem;
    display: inline-block;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
}

header.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    backdrop-filter: saturate(1.1) blur(0.625rem);
    background: linear-gradient(90deg, #0c1118 0%, #192334 50%, #0c1118 100%);
    border-bottom: 1px solid rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.625rem 1.125rem;
    color: #e5e7eb;
    box-shadow: 0 0.125rem 0.5rem rgba(15, 23, 42, 0.15);
    height: var(--nav-height);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-weight: 700;
}

.brand .logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.875rem;
    height: 1.875rem;
    border-radius: 999px;
    background:
        radial-gradient(circle at 0% 0%, #22c55e 0%, #bbf7d0 30%, transparent 60%),
        radial-gradient(circle at 100% 100%, #38bdf8 0%, #bfdbfe 30%, transparent 60%),
        linear-gradient(135deg, #1d4ed8, #0ea5e9);
    box-shadow: 0 0.25rem 0.875rem rgba(15, 23, 42, 0.45);
}

.brand .logo i {
    width: 1rem;
    height: 1rem;
    border-radius: 0.375rem;
    background: #ffffff;
    box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #2563eb;
}

.brand .logo i::before {
    content: ">";
}

.brand strong {
    color: #f9fafb;
    font-size: 0.9375rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.nav-spacer {
    flex: 1;
}

.progress {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.8125rem;
    color: #e5e7eb;
    white-space: nowrap;
}

.bar {
    width: 11.25rem;
    height: 0.5rem;
    border-radius: 0.625rem;
    background: rgba(15, 23, 42, 0.35);
    border: 1px solid rgba(15, 23, 42, 0.45);
    overflow: hidden;
}

.bar>i {
    display: block;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #22c55e 50%);
    border-radius: 0.5625rem;
    transition: width 0.3s ease;
}

.about-btn {
    border: none;
    background: rgba(15, 23, 42, 0.16);
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #e5e7eb;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin-right: 0.5rem;
    box-shadow: 0 0.125rem 0.5rem rgba(15, 23, 42, 0.45);
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
}

.about-btn:hover {
    background: rgba(15, 23, 42, 0.28);
    box-shadow: 0 0.25rem 0.875rem rgba(15, 23, 42, 0.6);
    transform: translateY(-0.0625rem);
}

.lang-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(15, 23, 42, 0.22);
    padding: 0.125rem;
    border-radius: 999px;
    margin-right: 0.75rem;
}

.lang-btn {
    border: none;
    background: transparent;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #e5e7eb;
    cursor: pointer;
}

.lang-btn.active {
    background: #ffffff;
    color: var(--brand);
    box-shadow: 0 0.0625rem 0.25rem rgba(15, 23, 42, 0.35);
}

.wrap {
    width: 100%;
    max-width: none;
    margin: 0 auto;
    height: 100vh;
    min-height: 100vh;
    padding-top: var(--nav-height);
}

.grid {
    display: grid;
    height: 100%;
    grid-template-columns: 15rem 1fr;
    gap: 0;
}

aside.sidebar {
    position: relative;
    background: var(--panel);
    border-right: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    height: calc(100vh - var(--nav-height) - var(--footer-height));
}

.side-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.side-head .material-symbols-rounded {
    color: var(--brand);
}

.topics {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.375rem;
    margin: 0;
    height: 100%;
    flex: 1;
}

.topic {
    list-style: none;
}

.topic button {
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: 0.75rem;
    padding: 0.625rem 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    color: var(--text);
}

.topic button:hover {
    background: #f3f4f6;
}

.topic button.active {
    background: #e6f2ff;
    border-left: 0.1875rem solid var(--brand);
}

.topic button.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.topic .icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.375rem;
}

.topic .title {
    font-weight: 600;
}

.topic small {
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
    margin-top: 0.125rem;
}

.badge-done {
    color: #16a34a;
}

section.card {
    background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
    border-left: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

.card-head {
    padding: 0.875rem 1.125rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: space-between;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.lesson-title {
    font-size: clamp(1.125rem, 2.2vw, 1.625rem);
    font-weight: 700;
}

.lesson-meta {
    color: var(--muted);
    font-size: 0.8125rem;
}

.content {
    padding: clamp(1rem, 3vw, 1.75rem);
    padding-bottom: calc(var(--foot-height) + var(--footer-height) + 1rem);
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.content p {
    margin: 0 0 0.875rem;
}

.content ul,
.content ol {
    margin: 0 0 0.875rem 1.25rem;
}

.content pre {
    background: var(--code-bg);
    color: #e5e7eb;
    border: 1px solid #0b1220;
    border-radius: 0.75rem;
    padding: 0.875rem 1rem;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: hidden;
}

.tip {
    border-left: 0.25rem solid var(--brand);
    background: #eef6ff;
    padding: 0.75rem 0.875rem;
    border-radius: 0.625rem;
    color: #0b294e;
    margin: 0.75rem 0 1.125rem;
}

.foot {
    position: fixed;
    bottom: var(--footer-height);
    left: 15rem;
    right: 0;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 1rem;
    border-top: 1px solid var(--border);
    background: #ffffff;
    z-index: 950;
    box-shadow: 0 -0.25rem 0.75rem rgba(15, 23, 42, 0.08);
    height: var(--foot-height);
}

.hint {
    color: var(--muted);
    font-size: 0.8125rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.hint-text {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

#keyboardHint {
    font-size: 0.75rem;
    opacity: 0.9;
}

.btn-row {
    display: flex;
    gap: 0.625rem;
    align-items: center;
}

.btn {
    appearance: none;
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--text);
    padding: 0.5rem 0.875rem;
    border-radius: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.06s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-shadow: var(--shadow);
    user-select: none;
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
    height: 2.5rem;
    font-size: 0.9375rem;
}

.btn.brand {
    --glow: 0 0.625rem 1.75rem rgba(37, 99, 235, 0.38), 0 1rem 2.625rem rgba(22, 163, 74, 0.28);
    background:
        radial-gradient(140% 140% at 10% 10%, rgba(37, 99, 235, 0.15), transparent 40%),
        linear-gradient(90deg, var(--brand) 0%, var(--brand-2) 100%);
    color: #ffffff;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 999px;
    box-shadow: var(--glow);
}

.btn.brand:disabled {
    opacity: 0.6;
    box-shadow: none;
    cursor: not-allowed;
}

.btn:active {
    transform: translateY(0.0625rem);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    padding: 1rem;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--panel);
    padding: 1.75rem 2rem;
    border-radius: var(--radius);
    box-shadow: 0 0.625rem 1.875rem rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 34.375rem;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-overlay.visible .modal-content {
    transform: scale(1);
}

.modal-content h2 {
    margin: 0 0 0.75rem;
    color: var(--brand);
    font-size: 1.5rem;
}

.modal-content h3 {
    margin: 1.25rem 0 0.5rem;
    font-size: 1rem;
}

.modal-content ul {
    padding-left: 1.25rem;
}

.modal-content li {
    margin-bottom: 0.375rem;
}

.modal-close {
    position: absolute;
    top: 0.625rem;
    right: 0.875rem;
    background: transparent;
    border: none;
    font-size: 1.75rem;
    cursor: pointer;
    color: var(--muted);
}

.modal-close:hover {
    color: var(--text);
}

.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-top: 1px solid #e5e7eb;
    background: rgba(248, 250, 252, 0.96);
    backdrop-filter: blur(0.5rem);
    padding: 0.25rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
    box-shadow: 0 -0.1875rem 0.5rem rgba(15, 23, 42, 0.06);
    height: var(--footer-height);
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    max-width: 30rem;
    width: 100%;
    font-size: 0.6875rem;
    color: var(--muted);
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.875rem;
    width: 100%;
}

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    text-decoration: none;
    color: var(--muted);
    font-weight: 600;
    transition: color 0.15s ease, transform 0.1s ease;
    font-size: 0.6875rem;
}

.footer-link:hover {
    color: #111827;
    transform: translateY(-0.0625rem);
}

.footer-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 0.875rem;
    height: 0.875rem;
}

.footer-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

@media (max-width: 61.25rem) {
    .grid {
        grid-template-columns: 13.125rem 1fr;
    }

    aside.sidebar {
        height: calc(100vh - var(--nav-height) - var(--footer-height));
    }

    .foot {
        left: 13.125rem;
    }

    .bar {
        width: 9.375rem;
    }
}

@media (max-width: 47.5rem) {
    header.navbar {
        flex-wrap: nowrap;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        padding: 0.5rem 0.625rem;
    }

    .brand .logo {
        display: none;
    }

    .brand strong {
        font-size: 0.8125rem;
    }

    .nav-spacer {
        display: none;
    }

    #aboutLabel {
        display: none;
    }

    .about-btn {
        padding: 0.5rem;
        margin-right: 0.25rem;
    }

    .lang-toggle {
        margin-right: 0.375rem;
    }

    .progress {
        margin-left: auto;
        gap: 0.375rem;
        font-size: 0.6875rem;
        flex-shrink: 0;
    }

    .bar {
        width: 4.5rem;
        height: 0.375rem;
    }

    #progressText {
        font-size: 0.6875rem;
        min-width: 2.25rem;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    aside.sidebar {
        display: none;
    }

    section.card {
        order: 2;
    }

    .content {
        padding: 1rem 0.875rem;
        padding-bottom: calc(var(--foot-height) + var(--footer-height) + 1rem);
    }

    #keyboardHint {
        display: none;
    }

    .foot {
        left: 0;
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }

    .hint {
        font-size: 0.75rem;
        flex: 1;
        min-width: 0;
    }

    .hint-text {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .btn-row {
        justify-content: flex-end;
        gap: 0.5rem;
        flex-shrink: 0;
    }

    .btn {
        padding: 0.5rem 0.75rem;
        border-radius: 999px;
        font-size: 0.875rem;
        box-shadow: 0 0.25rem 0.75rem rgba(15, 23, 42, 0.16);
        height: 2.25rem;
    }

    .btn.brand {
        padding: 0.5rem 1rem;
        font-size: 0.9375rem;
        background: linear-gradient(90deg, var(--brand) 0%, var(--brand-2) 100%);
        box-shadow: 0 0.25rem 0.75rem rgba(37, 99, 235, 0.35);
    }

    .modal-overlay {
        padding: 0.75rem;
    }

    .modal-content {
        padding: 1.25rem 1rem;
        max-height: 90vh;
        width: 95%;
    }

    .modal-content h2 {
        font-size: 1.25rem;
        margin: 0 0 0.625rem;
        padding-right: 1.5rem;
    }

    .modal-content h3 {
        font-size: 0.9375rem;
        margin: 1rem 0 0.375rem;
    }

    .modal-content p {
        font-size: 0.9375rem;
        line-height: 1.5;
    }

    .modal-content ul {
        font-size: 0.9375rem;
        padding-left: 1rem;
    }

    .modal-content li {
        margin-bottom: 0.25rem;
    }

    .modal-close {
        top: 0.5rem;
        right: 0.5rem;
        font-size: 1.5rem;
        width: 2rem;
        height: 2rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}