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

:root {
    --bg: #f4f6fa;
    --card: #ffffff;
    --ink: #1e2a38;
    --muted: #64748b;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --border: #e2e8f0;
    --tip: #fef9c3;
    --radius: 14px;
}

body {
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: min(960px, 100% - 2rem);
    margin: 0 auto;
}

.site-header {
    background: var(--ink);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 0;
    flex-wrap: wrap;
}

.brand {
    color: #fff;
    text-decoration: none;
    font-size: 1.35rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.nav a {
    color: #cbd5e1;
    text-decoration: none;
    padding: 0.35rem 0.7rem;
    border-radius: 8px;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

main {
    flex: 1;
    padding: 1.5rem 0 2.5rem;
}

.site-footer {
    background: var(--ink);
    color: #94a3b8;
    font-size: 0.9rem;
    padding: 1rem 0;
}

/* Hero */
.hero {
    background: linear-gradient(135deg, #1d4ed8, #3b82f6);
    color: #fff;
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    margin-bottom: 2rem;
}

.hero h1 {
    font-size: 2rem;
    margin-bottom: 0.6rem;
}

.hero p {
    max-width: 640px;
    font-size: 1.05rem;
    color: #dbeafe;
}

/* Titles */
.section-title {
    font-size: 1.3rem;
    margin: 2rem 0 1rem;
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
}

.lead {
    color: var(--muted);
    margin-bottom: 1.25rem;
}

/* Cards */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(30, 64, 175, 0.12);
    border-color: var(--accent);
}

.card-grade {
    align-items: center;
    text-align: center;
    padding: 1.75rem 1.25rem;
}

.grade-num {
    font-size: 3.2rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
}

.grade-label {
    font-weight: 700;
    font-size: 1.1rem;
}

.card-big {
    padding: 1.75rem;
}

.card-icon {
    font-size: 2rem;
    color: var(--accent);
}

.card-title {
    font-weight: 700;
    font-size: 1.05rem;
}

.card-sub {
    color: var(--muted);
    font-size: 0.9rem;
}

.card-meta {
    margin-top: auto;
    padding-top: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent);
}

/* Breadcrumbs */
.breadcrumbs {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 1rem;
}

.breadcrumbs a {
    color: var(--accent);
    text-decoration: none;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

/* Lessons list */
.lessons {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.lesson {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem 1.1rem;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.lesson:hover {
    background: #eff6ff;
    border-color: var(--accent);
    transform: translateX(3px);
}

.lesson-num {
    flex-shrink: 0;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
}

.lesson-body {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.lesson-title {
    font-weight: 600;
}

.lesson-sub {
    font-size: 0.82rem;
    color: var(--muted);
}

.lesson-go {
    color: var(--accent);
    font-size: 1.3rem;
    font-weight: 700;
}

/* Topic */
.topic-head {
    margin-bottom: 1.25rem;
}

.topic-badge {
    display: inline-block;
    background: #dbeafe;
    color: var(--accent-dark);
    font-weight: 600;
    font-size: 0.82rem;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    margin-bottom: 0.6rem;
}

.block {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem 1.5rem;
    margin-bottom: 1.25rem;
}

.block p {
    margin-bottom: 0.7rem;
}

.block p:last-child {
    margin-bottom: 0;
}

.block-tip {
    background: var(--tip);
    border-color: #fde047;
}

.hint {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* QA blocks */
.qa {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    margin-bottom: 0.7rem;
    background: #fbfcfe;
}

.qa-question {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    font-weight: 600;
}

.qa-tag {
    flex-shrink: 0;
    background: #f1f5f9;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
}

.qa-tag-task {
    background: #fee2e2;
    border-color: #fecaca;
    color: #b91c1c;
}

.qa-btn {
    margin-top: 0.7rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.45rem 1rem;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.qa-btn:hover {
    background: var(--accent-dark);
}

.qa-answer {
    margin-top: 0.7rem;
    padding: 0.8rem 1rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    color: #14532d;
}

/* Quiz */
.block-quiz {
    border-color: #bfdbfe;
}

.quiz-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.quiz-meta {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.quiz-score {
    font-weight: 600;
    color: var(--accent-dark);
    white-space: nowrap;
}

.btn-small {
    padding: 0.4rem 0.9rem;
    font-size: 0.88rem;
    border-color: var(--accent);
    color: var(--accent);
}

.btn-small:hover {
    background: var(--accent);
    color: #fff;
}

.btn-active,
.btn-active:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.quiz-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin: 0.6rem 0 1rem;
    padding: 0.6rem 0.9rem;
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.quiz-levels {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.quiz-levels-label {
    font-weight: 600;
    color: var(--ink-muted, #475569);
    margin-right: 0.2rem;
}

.quiz-levels .btn {
    max-width: none;
}

.quiz-toolbar .btn {
    max-width: none;
}

.quiz-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.9rem;
    background: #fbfcfe;
}

.quiz-q {
    display: flex;
    gap: 0.6rem;
    font-weight: 600;
    margin-bottom: 0.7rem;
}

.quiz-num {
    flex-shrink: 0;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: #dbeafe;
    color: var(--accent-dark);
    display: grid;
    place-items: center;
    font-size: 0.85rem;
    font-weight: 700;
}

.quiz-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.4rem;
    margin-bottom: 0.8rem;
}

.quiz-opt {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.quiz-opt:hover {
    border-color: var(--accent);
    background: #eff6ff;
}

.quiz-opt input {
    accent-color: var(--accent);
}

.quiz-input-row {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
}

.quiz-input {
    flex: 1;
    min-width: 200px;
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
}

.quiz-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.quiz-feedback {
    margin-top: 0.6rem;
    padding: 0.6rem 0.9rem;
    border-radius: 8px;
    font-weight: 600;
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.quiz-feedback.ok {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #14532d;
}

@media (max-width: 560px) {
    .quiz-head {
        flex-direction: column;
    }
}

/* Pager */
.pager {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn {
    display: inline-block;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.65rem 1.1rem;
    text-decoration: none;
    color: var(--ink);
    font-weight: 600;
    transition: border-color 0.15s, background 0.15s;
    max-width: 48%;
}

.btn:hover {
    border-color: var(--accent);
    background: #eff6ff;
}

.quiz-graph {
    margin: 10px 0 12px 38px;
    text-align: center;
}

.quiz-graph svg {
    max-width: 440px;
    width: 100%;
    height: auto;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

@media (max-width: 560px) {
    .hero h1 {
        font-size: 1.5rem;
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .pager {
        flex-direction: column;
    }

    .btn {
        max-width: none;
    }
}

/* User bar */
.nav-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.user-form {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
}

.user-input {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.35rem 0.6rem;
    font-size: 0.9rem;
    width: 9rem;
    background: #fff;
    color: var(--ink);
}

.user-badge {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
}

/* Auth */
.block-auth {
    max-width: 26rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin-top: 1rem;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-weight: 600;
    font-size: 0.95rem;
}

.auth-form input {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
    font-size: 1rem;
    background: #fff;
    color: var(--ink);
}

.auth-form .btn {
    max-width: none;
    align-self: flex-start;
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.auth-error {
    color: #b91c1c;
}

/* Teacher dashboard */
.teach-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.teach-table th,
.teach-table td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.7rem;
    text-align: left;
    vertical-align: top;
}

.teach-table th {
    background: var(--soft);
    font-weight: 600;
}

.teach-q {
    max-width: 26rem;
}

.ok-text {
    color: #15803d;
    font-weight: 600;
}

.mid-text {
    color: #b45309;
    font-weight: 600;
}

.bad-text {
    color: #b91c1c;
    font-weight: 600;
}

.quiz-feedback {
    margin-top: 6px;
}
