:root {
    --background: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #eef3ff;
    --text: #202538;
    --muted: #687087;
    --primary: #5865d8;
    --primary-dark: #414db7;
    --accent: #f2a65a;
    --border: #dfe4ef;
    --shadow: 0 12px 32px rgba(42, 49, 82, 0.08);
    --radius-large: 24px;
    --radius-medium: 16px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 17px;
    line-height: 1.6;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
select {
    cursor: pointer;
}

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

h1 {
    margin-bottom: 0;
    font-size: clamp(2rem, 5vw, 3.75rem);
    line-height: 1.12;
    letter-spacing: -0.035em;
}

h2 {
    margin-bottom: 24px;
    font-size: clamp(1.5rem, 3vw, 2.15rem);
    line-height: 1.25;
}

h3 {
    font-size: 1.25rem;
}

.home-page,
.topic-page {
    width: min(1160px, calc(100% - 40px));
    margin: 0 auto;
}

.home-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 40px 0;
}

.home-card {
    width: min(760px, 100%);
    padding: clamp(32px, 7vw, 72px);
    border: 1px solid var(--border);
    border-radius: var(--radius-large);
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: center;
}

.home-card h1 {
    margin-bottom: 32px;
}

.topic-page {
    padding: 48px 0 64px;
}

.topic-header {
    padding: clamp(30px, 6vw, 64px);
    border-radius: var(--radius-large);
    background: linear-gradient(135deg, #e9edff 0%, #fff4e8 100%);
    box-shadow: var(--shadow);
}

.eyebrow {
    margin-bottom: 10px;
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.lesson-section {
    margin-top: 28px;
    padding: clamp(24px, 5vw, 48px);
    border: 1px solid var(--border);
    border-radius: var(--radius-large);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.infographic-placeholder {
    min-height: 260px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px;
    border: 2px dashed #aeb8e8;
    border-radius: var(--radius-medium);
    background: var(--surface-soft);
    text-align: center;
}

.infographic-placeholder strong {
    font-size: clamp(1.3rem, 3vw, 2rem);
}

.infographic-placeholder span,
.helper-text {
    color: var(--muted);
}

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

.rule-card,
.exceptions-card,
.exercise-card,
.dictation-card {
    border-radius: var(--radius-medium);
}

.rule-card {
    padding: 26px;
}

.rule-card h3 {
    margin-bottom: 12px;
}

.rule-card ul,
.exceptions-card ul {
    margin: 0;
    padding-left: 22px;
}

.rule-card-one {
    background: #fff4e8;
}

.rule-card-two {
    background: #e9edff;
}

.exceptions-card {
    margin-top: 20px;
    padding: 24px 26px;
    border-left: 5px solid var(--accent);
    background: #fffaf4;
}

.exceptions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 32px;
}

.section-heading {
    margin-bottom: 24px;
}

.section-heading h2 {
    margin-bottom: 0;
}

.section-number {
    display: block;
    margin-bottom: 5px;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 800;
    text-transform: uppercase;
}

.exercise-grid {
    display: grid;
    gap: 16px;
}

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

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

.exercise-card {
    padding: 20px;
    border: 1px solid var(--border);
    background: #fafbfe;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.exercise-card label {
    display: block;
    margin-bottom: 12px;
    font-size: 1.2rem;
    font-weight: 750;
}

select,
textarea {
    width: 100%;
    border: 1px solid #cbd2e1;
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
}

select {
    min-height: 48px;
    padding: 10px 38px 10px 12px;
}

textarea {
    display: block;
    min-height: 180px;
    padding: 16px;
    resize: vertical;
}

select:focus,
textarea:focus,
input:focus,
button:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(88, 101, 216, 0.25);
    outline-offset: 2px;
}

.fill-word {
    display: flex;
    align-items: baseline;
    justify-content: center;
    min-height: 88px;
    font-size: 1.25rem;
    font-weight: 700;
    white-space: nowrap;
}

.fill-word-card {
    min-height: 118px;
}

.fill-word input {
    width: 2.6em;
    height: 2.2em;
    margin: 0 3px;
    border: 0;
    border-bottom: 3px solid var(--primary);
    border-radius: 6px 6px 0 0;
    background: #edf0ff;
    color: var(--text);
    font-weight: 800;
    text-align: center;
    text-transform: uppercase;
}

.dictation-card {
    padding: clamp(20px, 4vw, 32px);
    background: #f7f8ff;
}

.dictation-card .helper-text {
    margin: 14px 0 24px;
}

.dictation-card label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

.button,
.choice-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 11px 20px;
    border-radius: 12px;
    font-weight: 750;
    line-height: 1.25;
    text-decoration: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.button:hover,
.choice-button:hover {
    transform: translateY(-1px);
}

.button-primary {
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #ffffff;
}

.button-primary:hover {
    background: var(--primary-dark);
}

.button-secondary {
    border: 1px solid var(--primary);
    background: var(--surface);
    color: var(--primary-dark);
}

.exam-table-wrap {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-medium);
}

.exam-table {
    width: 100%;
    border-collapse: collapse;
}

.exam-table th,
.exam-table td {
    padding: 18px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.exam-table thead {
    background: var(--surface-soft);
}

.exam-table tbody tr:last-child th,
.exam-table tbody tr:last-child td {
    border-bottom: 0;
}

.exam-table tbody th {
    letter-spacing: 0.03em;
}

.answer-buttons {
    display: flex;
    gap: 8px;
}

.choice-button {
    min-height: 42px;
    padding: 8px 14px;
    border: 1px solid #cbd2e1;
    background: var(--surface);
    color: var(--text);
}

.choice-button:hover {
    border-color: var(--primary);
    color: var(--primary-dark);
}

.exercise-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.exercise-result {
    display: none;
    margin: 18px 0 0;
    padding: 14px 18px;
    border-radius: 12px;
    background: #edf0ff;
    color: #35419c;
    font-size: 1.08rem;
    font-weight: 800;
}

.exercise-result.is-visible {
    display: block;
}

.feedback-hint {
    min-height: 1.5em;
    margin: 10px 0 0;
    font-size: 0.9rem;
    font-weight: 700;
}

.correct {
    border-color: #78ad8b !important;
    background-color: #edf8f0 !important;
}

.incorrect {
    border-color: #d58b8b !important;
    background-color: #fff1f1 !important;
}

.correct .feedback-hint,
.feedback-hint.correct {
    color: #327047;
}

.incorrect .feedback-hint,
.feedback-hint.incorrect {
    color: #9b4545;
}

.choice-button.selected {
    border-color: var(--primary);
    background: #e9edff;
    color: var(--primary-dark);
    box-shadow: 0 0 0 2px rgba(88, 101, 216, 0.13);
}

.choice-button.correct {
    border-color: #78ad8b !important;
    background: #dff1e4 !important;
    color: #28623c;
}

.choice-button.incorrect {
    border-color: #d58b8b !important;
    background: #f9dddd !important;
    color: #8c3939;
}

.topic-footer {
    padding-top: 32px;
    text-align: center;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 760px) {
    body {
        font-size: 16px;
    }

    .home-page,
    .topic-page {
        width: min(100% - 24px, 1160px);
    }

    .topic-page {
        padding: 20px 0 40px;
    }

    .rule-grid,
    .rule-choice-grid,
    .letter-grid {
        grid-template-columns: 1fr;
    }

    .infographic-placeholder {
        min-height: 210px;
        padding: 22px;
    }

    .exceptions-list {
        display: block;
    }

    .exam-table-wrap {
        overflow: visible;
        border: 0;
    }

    .exam-table,
    .exam-table tbody,
    .exam-table tr,
    .exam-table th,
    .exam-table td {
        display: block;
        width: 100%;
    }

    .exam-table thead {
        display: none;
    }

    .exam-table tr {
        margin-bottom: 16px;
        padding: 18px;
        border: 1px solid var(--border);
        border-radius: var(--radius-medium);
        background: #fafbfe;
    }

    .exam-table th,
    .exam-table td {
        padding: 6px 0;
        border: 0;
    }

    .exam-table th::before,
    .exam-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 2px;
        color: var(--muted);
        font-size: 0.78rem;
        font-weight: 700;
        text-transform: uppercase;
    }

    .answer-buttons {
        margin-top: 8px;
    }

    .choice-button {
        flex: 1;
    }

    .topic-footer .button {
        width: 100%;
    }

    .exercise-actions {
        flex-direction: column;
    }

    .exercise-actions .button {
        width: 100%;
    }
}

@media (max-width: 390px) {
    .lesson-section,
    .topic-header {
        padding: 22px 18px;
    }

    .answer-buttons {
        flex-direction: column;
    }
}
