:root {
    --bg: #faf8f4;
    --surface: #ffffff;
    --surface-2: #f3efe7;
    --ink: #1b1f2a;
    --muted: #5e6472;
    --line: #e6e0d5;
    --accent: #0e6b5e;
    --on-accent: #ffffff;
    --tip: #fbf1dc;
    --tip-line: #c98a1b;
    --bad: #b3362b;
    --bad-soft: #fbe9e5;
    --good: #12704a;
    --good-soft: #e2f3ea;
    --shadow: 0 1px 2px rgb(27 31 42 / 5%), 0 8px 24px rgb(27 31 42 / 6%);
    --header-height: 68px;
    --gutter: clamp(16px, 2vw, 40px);
    --serif: "Fraunces", Georgia, "Times New Roman", serif;
    --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color-scheme: light;
    --scroll-thumb: rgb(27 31 42 / 18%);
    --scroll-thumb-hover: rgb(27 31 42 / 32%);
}

:root[data-theme="dark"] {
    --bg: #11141a;
    --surface: #181c24;
    --surface-2: #202530;
    --ink: #ece9e2;
    --muted: #a3a9b5;
    --line: #2c323e;
    --accent: #5fd0bb;
    --on-accent: #0c1f1b;
    --tip: #33291a;
    --tip-line: #d9a441;
    --bad: #ff9d8f;
    --bad-soft: #3a1f1c;
    --good: #74dda9;
    --good-soft: #17352a;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
    color-scheme: dark;
    --scroll-thumb: rgb(236 233 226 / 16%);
    --scroll-thumb-hover: rgb(236 233 226 / 30%);
}

[data-level="A1"] { --level: #0e6b5e; }
[data-level="A2"] { --level: #2563a8; }
[data-level="B1"] { --level: #96600f; }
[data-level="B2"] { --level: #a8345a; }
[data-level="C1"] { --level: #5f43b2; }

:root[data-theme="dark"] [data-level="A1"] { --level: #5fd0bb; }
:root[data-theme="dark"] [data-level="A2"] { --level: #7db4f0; }
:root[data-theme="dark"] [data-level="B1"] { --level: #e5b35c; }
:root[data-theme="dark"] [data-level="B2"] { --level: #f08bab; }
:root[data-theme="dark"] [data-level="C1"] { --level: #b5a0f5; }

*, *::before, *::after { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height) + 20px);
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: clamp(16.5px, 14.5px + 0.2vw, 19px);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

kbd {
    padding: 1px 7px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg);
    color: var(--muted);
    font-family: var(--sans);
    font-size: 12px;
    white-space: nowrap;
}

.reading-progress {
    position: fixed;
    inset: 0 0 auto;
    z-index: 30;
    height: 3px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
}

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(14px);
}

.site-header-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    height: var(--header-height);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: 700;
    letter-spacing: -0.01em;
    text-decoration: none;
}

.brand-logo {
    display: block;
    width: 36px;
    height: 36px;
    flex: none;
}

.search-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 1 340px;
    min-width: 0;
    height: 42px;
    margin-left: auto;
    padding: 0 10px 0 14px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface);
    color: var(--muted);
    font: inherit;
    font-size: 15px;
    cursor: pointer;
    transition: border-color .15s;
}

.search-trigger:hover { border-color: var(--accent); }

.search-trigger span {
    flex: 1;
    overflow: hidden;
    text-align: left;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-link {
    padding: 8px 12px;
    color: var(--ink);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
}

.header-link:hover { color: var(--accent); }

.icon-button {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
}

.icon-button:hover { border-color: var(--accent); }

.icon-moon, [data-theme="dark"] .icon-sun { display: none; }

[data-theme="dark"] .icon-moon { display: block; }

/* Account and chat entry points */
.header-chat {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 16px 0 13px;
    border-radius: 11px;
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: var(--accent);
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    transition: background .15s;
}

.header-chat:hover, .header-chat[aria-current="page"] {
    background: var(--accent);
    color: var(--on-accent);
}

.header-login {
    display: inline-flex;
    align-items: center;
    height: 42px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface);
    color: var(--ink);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
}

.header-login:hover { border-color: var(--accent); color: var(--accent); }

.header-account { display: block; border-radius: 50%; line-height: 0; }

.gender-male { --gender-color: #2563a8; --gender-soft: #e3edf9; --gender-gradient: linear-gradient(135deg, #3b82d6, #1f4f8f); }

.gender-neutral { --gender-color: #0e6b5e; --gender-gradient: linear-gradient(135deg, #2aa38f, #0e6b5e); }

.gender-female { --gender-color: #c2416f; --gender-soft: #fbe6ee; --gender-gradient: linear-gradient(135deg, #e5709a, #a8345a); }

:root[data-theme="dark"] .gender-male { --gender-color: #7db4f0; --gender-soft: #1b2b40; }

:root[data-theme="dark"] .gender-female { --gender-color: #f08bab; --gender-soft: #3a1f2b; }

.avatar {
    position: relative;
    display: inline-grid;
    place-items: center;
    flex: none;
    width: var(--avatar-size, 44px);
    height: var(--avatar-size, 44px);
    overflow: hidden;
    border-radius: 50%;
    background: var(--gender-gradient, var(--accent));
    color: #fff;
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in srgb, var(--gender-color, var(--accent)) 55%, transparent);
    line-height: 1;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }

.avatar-initials {
    font-size: calc(var(--avatar-size, 44px) * .38);
    font-weight: 700;
    letter-spacing: .02em;
}

.gender-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px 2px 7px;
    border-radius: 999px;
    background: var(--gender-soft);
    color: var(--gender-color);
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.5;
    white-space: nowrap;
}

.gender-badge > span { font-size: 1.1em; }

/* Shared */
.button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: 100%;
    padding: 13px 22px;
    border: 1px solid var(--accent);
    border-radius: 12px;
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none;
    transition: transform .15s, box-shadow .15s;
}

.button:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.button-quiet {
    border-color: var(--line);
    background: var(--surface);
    color: var(--ink);
}

.eyebrow {
    margin: 0 0 14px;
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .04em;
}

.level-code {
    display: inline-grid;
    place-items: center;
    min-width: 38px;
    padding: 2px 8px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--level) 13%, transparent);
    color: var(--level);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.6;
    text-decoration: none;
}

/* Hero */
.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 64px;
    align-items: center;
    margin: 0 auto;
    padding: 64px var(--gutter) 56px;
}

.hero h1 {
    margin: 0 0 20px;
    font-family: var(--serif);
    font-size: clamp(31px, 5.2vw, 66px);
    overflow-wrap: break-word;
    font-weight: 600;
    line-height: 1.06;
    letter-spacing: -0.02em;
}

.hero h1 em { color: var(--accent); font-style: italic; }

.hero-lead {
    max-width: 54ch;
    margin: 0 0 30px;
    color: var(--muted);
    font-size: 19px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.hero-stats {
    display: flex;
    gap: 44px;
    margin: 40px 0 0;
}

.hero-stats div { display: flex; flex-direction: column-reverse; }

.hero-stats dt { color: var(--muted); font-size: 15px; }

.hero-stats dd {
    margin: 0;
    font-family: var(--serif);
    font-size: 32px;
    font-weight: 600;
    line-height: 1.2;
}

.anatomy {
    margin: 0;
    padding: 30px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.anatomy figcaption {
    margin-bottom: 22px;
    color: var(--muted);
    font-size: 15px;
    font-weight: 600;
}

.anatomy-sentence {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.anatomy-sentence span {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--surface-2);
}

.anatomy-sentence b {
    font-family: var(--serif);
    font-size: 23px;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
}

.anatomy-sentence small { color: var(--muted); font-size: 13px; }

.anatomy-sentence .anatomy-verb { background: var(--accent); }

.anatomy-verb b, .anatomy-sentence .anatomy-verb small { color: var(--on-accent); }

.anatomy-translation {
    margin: 20px 0 8px;
    font-size: 18px;
    font-weight: 500;
}

.anatomy-note { margin: 0; color: var(--muted); font-size: 15px; }

/* Level overview */
.levels-overview, .level {
    margin: 0 auto;
    padding-left: var(--gutter);
    padding-right: var(--gutter);
}

.section-heading h2 {
    margin: 0 0 4px;
    font-family: var(--serif);
    font-size: 36px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.section-heading p { margin: 0 0 26px; color: var(--muted); }

.level-cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
}

.level-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    color: var(--ink);
    line-height: 1.35;
    text-decoration: none;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}

.level-card:hover {
    border-color: var(--level);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.level-card strong { margin-top: 8px; }

.level-card-count { color: var(--muted); font-size: 15px; }

.level { padding-top: 72px; }

.level-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 22px;
}

.level-header .level-code {
    min-width: 52px;
    padding: 7px 10px;
    border-radius: 12px;
    font-size: 19px;
}

.level-header > div { flex: 1; min-width: 0; }

.level-header h2 {
    margin: 0;
    font-family: var(--serif);
    font-size: 30px;
    font-weight: 600;
    line-height: 1.25;
}

.level-header p {
    max-width: 66ch;
    margin: 2px 0 0;
    color: var(--muted);
}

.level-progress {
    margin-left: auto;
    padding: 4px 12px;
    border-radius: 99px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.level-test-link {
    flex: none;
    margin-left: auto;
    padding: 7px 14px;
    border: 1px solid var(--level);
    border-radius: 10px;
    color: var(--level);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.level-progress + .level-test-link { margin-left: 0; }

.level-test-link:hover { background: color-mix(in srgb, var(--level) 10%, transparent); }

.lesson-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.lesson-card {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 100%;
    padding: 13px 16px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    transition: border-color .15s, box-shadow .15s;
}

.lesson-card:hover {
    border-color: var(--level);
    box-shadow: var(--shadow);
}

.lesson-card-number {
    flex: 0 0 26px;
    color: var(--level);
    font-family: var(--serif);
    font-size: 19px;
    font-weight: 600;
    text-align: center;
}

.lesson-card-text { flex: 1; min-width: 0; line-height: 1.35; }

.lesson-card-text strong {
    display: block;
    font-size: 16px;
    font-weight: 600;
}

.lesson-card-text span {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 14px;
}

.lesson-check { display: none; color: var(--good); }

.lesson-card.is-finished .lesson-check { display: block; }

/* Lesson layout */
.lesson-layout {
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr) 230px;
    gap: clamp(28px, 3vw, 56px);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.course-nav-inner, .toc-inner {
    position: sticky;
    top: var(--header-height);
    max-height: calc(100vh - var(--header-height));
    overflow-y: auto;
    padding: 28px 8px 28px 0;
}

.course-nav details { margin-bottom: 6px; }

.course-nav summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: 9px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.course-nav summary::-webkit-details-marker { display: none; }

.course-nav summary:hover { background: var(--surface-2); }

.course-nav ol {
    margin: 4px 0 12px 19px;
    padding: 0;
    border-left: 1px solid var(--line);
    list-style: none;
}

.course-nav li a {
    display: block;
    margin-left: -1px;
    padding: 5px 10px 5px 14px;
    border-left: 2px solid transparent;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.4;
    text-decoration: none;
}

.course-nav li a:hover { color: var(--ink); }

.course-nav li a.is-finished::after {
    content: " ✓";
    color: var(--good);
}

.course-nav li a[aria-current="page"] {
    border-left-color: var(--level);
    color: var(--level);
    font-weight: 600;
}

.toc-inner p {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 700;
}

.toc-inner ul { margin: 0; padding: 0; list-style: none; }

.toc-inner a {
    display: block;
    padding: 4px 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.4;
    text-decoration: none;
}

.toc-inner a:hover, .toc-inner a.is-active { color: var(--accent); }

.toc-inner a.is-active { font-weight: 600; }

.lesson {
    width: 100%;
    min-width: 0;
    margin: 0 auto;
    padding: 44px 0 16px;
}

.lesson-header {
    margin-bottom: 30px;
    padding-bottom: 26px;
    border-bottom: 1px solid var(--line);
}

.lesson-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 15px;
}

.lesson-header h1 {
    margin: 0 0 6px;
    font-family: var(--serif);
    font-size: clamp(34px, 4.6vw, 50px);
    font-weight: 600;
    line-height: 1.12;
    letter-spacing: -0.015em;
}

.lesson-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 20px;
}

.toc-mobile { display: none; }

/* Lesson content */
.prose h2 {
    margin: 46px 0 14px;
    font-family: var(--serif);
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.25;
}

.prose h3 { margin: 26px 0 10px; font-size: 19px; }

.prose p, .prose ul, .prose ol { margin: 0 0 16px; }

.prose li { margin-bottom: 6px; }

.prose li::marker { color: var(--accent); }

.prose strong { font-weight: 650; }

.table-wrap {
    overflow-x: auto;
    margin: 0 0 22px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    font-size: 16px;
    line-height: 1.5;
}

.prose th, .prose td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.prose th {
    background: var(--surface-2);
    font-size: 14px;
    font-weight: 600;
}

.prose tbody tr:last-child td { border-bottom: 0; }

.prose blockquote {
    margin: 22px 0;
    padding: 16px 20px;
    border-left: 3px solid var(--tip-line);
    border-radius: 0 14px 14px 0;
    background: var(--tip);
}

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

.formula {
    margin: 0 0 22px;
    padding: 6px 20px;
    border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
    border-radius: 14px;
    background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}

.formula-row {
    display: grid;
    grid-template-columns: clamp(130px, 14vw, 190px) minmax(0, 1fr);
    gap: 16px;
    padding: 11px 0;
    line-height: 1.5;
}

.formula-row + .formula-row {
    border-top: 1px solid color-mix(in srgb, var(--accent) 16%, var(--line));
}

.formula-label { color: var(--muted); font-size: 15px; }

.formula-pattern { font-weight: 500; overflow-wrap: anywhere; }

.formula strong, .examples strong { color: var(--accent); font-weight: 650; }

.examples {
    margin: 0 0 22px;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    list-style: none;
}

.prose .examples li, .word-examples .examples li {
    margin: 0;
    padding: 11px 18px;
}

.prose .examples li + li, .word-examples .examples li + li { border-top: 1px solid var(--line); }

.example-en { display: block; font-weight: 500; line-height: 1.5; }

.example-uz {
    display: block;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.5;
}

.mistakes { margin: 28px 0; }

.prose .mistakes-title {
    margin-bottom: 12px;
    font-weight: 650;
}

.mistake {
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow: hidden;
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    line-height: 1.5;
}

.prose .mistake p { margin: 0; padding: 10px 16px; }

.prose .mistake-wrong { background: var(--bad-soft); color: var(--bad); }

.prose .mistake-right { background: var(--good-soft); color: var(--good); font-weight: 600; }

.prose .mistake .mistake-reason {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 15px;
}

/* Pager */
.pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 52px;
}

.pager a {
    display: block;
    padding: 15px 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
    line-height: 1.35;
    text-decoration: none;
    transition: border-color .15s, box-shadow .15s;
}

.pager a:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.pager small {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 400;
}

.pager-next { grid-column: 2; text-align: right; }

/* Search */
.search-dialog {
    width: min(620px, calc(100vw - 32px));
    max-height: min(560px, 80vh);
    margin: 10vh auto auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 24px 70px rgb(0 0 0 / 30%);
}

.search-dialog[open] { display: flex; flex-direction: column; }

.search-dialog::backdrop {
    background: rgb(15 18 24 / 45%);
    backdrop-filter: blur(3px);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
}

.search-box input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
}

.search-box input::-webkit-search-cancel-button { display: none; }

.search-results {
    flex: 1;
    overflow-y: auto;
    margin: 0;
    padding: 8px;
    list-style: none;
}

.search-results a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--ink);
    line-height: 1.35;
    text-decoration: none;
}

.search-results a:hover, .search-results a.is-active { background: var(--surface-2); }

.search-results strong { display: block; font-size: 16px; font-weight: 600; }

.search-results small { color: var(--muted); font-size: 14px; }

.search-empty { padding: 24px 12px; color: var(--muted); text-align: center; }

/* Vocabulary */
.header-link[aria-current="page"] { color: var(--accent); }

.search-word-link { color: var(--accent) !important; font-size: 15px; font-weight: 600; }

.vocabulary-hero {
    margin: 0 auto;
    padding: 64px var(--gutter) 32px;
    text-align: center;
}

.vocabulary-hero h1 {
    margin: 0 0 14px;
    font-family: var(--serif);
    font-size: clamp(38px, 5vw, 60px);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.08;
}

.vocabulary-hero h1 em { color: var(--accent); font-style: italic; }

.vocabulary-hero .hero-lead { margin: 0 auto 28px; }

.word-search {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 7px 7px 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    color: var(--muted);
    box-shadow: var(--shadow);
    text-align: left;
}

.word-search:focus-within { border-color: var(--accent); }

.word-search input {
    flex: 1;
    min-width: 0;
    height: 44px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
}

.word-search input::-webkit-search-cancel-button { display: none; }

.word-search .button { padding: 10px 18px; cursor: pointer; font: inherit; font-weight: 600; }

.word-suggestions {
    position: absolute;
    inset: calc(100% + 6px) 0 auto;
    margin: 0;
    padding: 6px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
    list-style: none;
}

.word-suggestions a {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 12px;
    border-radius: 9px;
    color: var(--ink);
    text-decoration: none;
}

.word-suggestions a:hover, .word-suggestions a.is-active { background: var(--surface-2); }

.word-suggestions strong { font-weight: 600; }

.word-suggestions span { color: var(--muted); font-size: 15px; text-align: right; }

.word-search-error { margin: 14px 0 0; color: var(--bad); font-size: 15px; }

.vocabulary-section, .vocabulary-page {
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.vocabulary-section { padding-bottom: 44px; }

.word-of-day {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin: 0 auto;
    padding: 18px 24px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    transition: border-color .15s, box-shadow .15s;
}

.word-of-day:hover { border-color: var(--accent); box-shadow: var(--shadow); }

.word-of-day small { color: var(--accent); font-size: 14px; font-weight: 600; }

.word-of-day strong { font-family: var(--serif); font-size: 26px; font-weight: 600; line-height: 1.2; }

.word-of-day span { color: var(--muted); }

.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
    gap: 12px;
}

.topic-card {
    display: flex;
    flex-direction: column;
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    color: var(--ink);
    line-height: 1.4;
    text-decoration: none;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}

.topic-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.topic-card strong { font-weight: 600; }

.topic-card span { color: var(--muted); font-size: 15px; }

.topic-card small { margin-top: 10px; color: var(--accent); font-size: 14px; font-weight: 600; }

.vocabulary-page { padding-top: 32px; }

.breadcrumb { margin: 0 0 18px; color: var(--muted); font-size: 15px; }

.breadcrumb a { color: var(--muted); }

.page-title {
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(34px, 4.6vw, 48px);
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.15;
}

.page-subtitle { margin: 6px 0 28px; color: var(--muted); font-size: 18px; }

.word-grid-wide { grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)) !important; }

.word-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.word-card {
    display: block;
    height: 100%;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface);
    color: var(--ink);
    line-height: 1.4;
    text-decoration: none;
    transition: border-color .15s, box-shadow .15s;
}

.word-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }

.word-card strong { display: block; font-weight: 600; }

.word-card span { color: var(--muted); font-size: 15px; }

.word-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 22px;
    margin: 34px 0 30px;
    padding-bottom: 26px;
    border-bottom: 1px solid var(--line);
}

.word-header-phrase h1 { font-size: clamp(32px, 4.6vw, 48px); }

.word-header h1 {
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(40px, 6vw, 60px);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.word-phonetic { margin: 4px 0 0; color: var(--muted); font-size: 18px; }

.audio-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 15px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface);
    color: var(--accent);
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.audio-button:hover { border-color: var(--accent); }

.audio-button:disabled { opacity: .5; cursor: default; }

.word-translation {
    flex-basis: 100%;
    margin: 6px 0 0;
    color: var(--accent);
    font-family: var(--serif);
    font-size: 26px;
    font-weight: 600;
    line-height: 1.3;
}

.word-translation small {
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 7px;
    background: var(--tip);
    color: var(--muted);
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 500;
    vertical-align: middle;
}

.word-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(280px, 26vw, 420px);
    gap: clamp(28px, 3vw, 56px);
    align-items: start;
}

.meaning { margin-bottom: 32px; }

.word-examples { margin-bottom: 32px; }

.meaning h2, .word-examples h2 {
    margin: 0 0 12px;
    font-family: var(--serif);
    font-size: 24px;
    font-weight: 600;
    line-height: 1.3;
}

.meaning h2 small { color: var(--muted); font-family: var(--sans); font-size: 15px; font-weight: 400; }

.meaning ol { margin: 0; padding-left: 22px; }

.meaning li { margin-bottom: 12px; line-height: 1.55; }

.meaning li::marker { color: var(--accent); font-weight: 600; }

.meaning q {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-style: italic;
    quotes: none;
}

.word-side { position: sticky; top: calc(var(--header-height) + 20px); display: grid; gap: 14px; }

.related-words {
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
}

.related-words h2 { margin: 0; font-size: 17px; font-weight: 650; line-height: 1.4; }

.related-words p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }

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

.related-words ul {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.related-words a {
    display: block;
    padding: 4px 11px;
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--ink);
    font-size: 15px;
    font-weight: 500;
    line-height: 1.4;
    text-decoration: none;
}

.related-words a:hover { color: var(--accent); }

.related-words small { display: block; color: var(--muted); font-size: 13px; font-weight: 400; }

.word-notice {
    margin: 0 0 24px;
    padding: 14px 18px;
    border-radius: 14px;
    background: var(--tip);
}

.word-sources { margin: 36px 0 0; color: var(--muted); font-size: 14px; }

.suggestions-title { margin-bottom: 10px !important; }

.suggestion-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 0 0 26px;
    padding: 0;
    list-style: none;
}

.suggestion-list a {
    display: block;
    padding: 5px 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
}

/* Bottom navigation and lessons sheet (phones and tablets) */
.tabbar { display: none; }

.lessons-sheet {
    width: 100%;
    max-width: 640px;
    height: 88dvh;
    max-height: none;
    margin: auto auto 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 22px 22px 0 0;
    background: var(--surface);
    color: var(--ink);
}

.lessons-sheet[open] {
    display: flex;
    flex-direction: column;
    animation: sheet-up .22s ease both;
}

@keyframes sheet-up {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.lessons-sheet::backdrop {
    background: rgb(15 18 24 / 50%);
}

.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 8px;
}

.sheet-head strong {
    font-family: var(--serif);
    font-size: 23px;
    font-weight: 600;
}

.sheet-search {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 16px 10px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
    color: var(--muted);
}

.sheet-search input {
    flex: 1;
    min-width: 0;
    height: 46px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 16px;
}

.sheet-search input::-webkit-search-cancel-button { display: none; }

.sheet-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 12px calc(16px + env(safe-area-inset-bottom));
}

.sheet-level { border-bottom: 1px solid var(--line); }

.sheet-level summary {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 6px 4px;
    cursor: pointer;
    list-style: none;
}

.sheet-level summary::-webkit-details-marker { display: none; }

.sheet-level summary::after {
    content: "";
    width: 9px;
    height: 9px;
    margin-right: 6px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    transition: transform .15s;
}

.sheet-level[open] summary::after { transform: rotate(-135deg); }

.sheet-level-name { flex: 1; font-weight: 600; }

.sheet-level summary small { color: var(--muted); font-size: 14px; }

.sheet-level ol { margin: 0 0 8px; padding: 0; list-style: none; }

.sheet-lesson {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 7px 8px;
    border-radius: 12px;
    color: var(--ink);
    text-decoration: none;
}

.sheet-lesson[aria-current="page"] { background: color-mix(in srgb, var(--level) 12%, transparent); }

.sheet-number {
    flex: 0 0 28px;
    color: var(--level);
    font-family: var(--serif);
    font-size: 17px;
    font-weight: 600;
    text-align: center;
}

.sheet-text { flex: 1; min-width: 0; line-height: 1.3; }

.sheet-text strong { display: block; font-size: 16px; font-weight: 600; }

.sheet-text small { color: var(--muted); font-size: 14px; }

.sheet-lesson.is-finished::after {
    content: "✓";
    color: var(--good);
    font-weight: 700;
}

.sheet-empty { padding: 28px 8px; color: var(--muted); text-align: center; }

@media (max-width: 900px) {
    .header-link { display: none; }

    .tabbar {
        position: fixed;
        inset: auto 0 0;
        z-index: 25;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        padding-bottom: env(safe-area-inset-bottom);
        border-top: 1px solid var(--line);
        background: color-mix(in srgb, var(--surface) 92%, transparent);
        backdrop-filter: blur(14px);
    }

    .tabbar-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-height: 60px;
        color: var(--muted);
        font-size: 12px;
        font-weight: 600;
        text-decoration: none;
    }

    .tabbar-item svg { width: 23px; height: 23px; }

    .tabbar-item[aria-current="page"] { color: var(--accent); }

    body:has(.tabbar) { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }

    .site-footer { margin-top: 56px; }
}

/* Footer and 404 */
.site-footer {
    margin-top: 96px;
    border-top: 1px solid var(--line);
}

.site-footer-inner {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr));
    gap: 28px clamp(24px, 4vw, 64px);
    padding: 36px var(--gutter);
}

.footer-about p { margin: 12px 0 0; color: var(--muted); font-size: 15px; }

.site-footer nav { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }

.site-footer h2 {
    margin: 0 0 6px;
    font-family: var(--sans);
    font-size: 15px;
    font-weight: 700;
}

.site-footer nav a {
    padding: 3px 0;
    color: var(--muted);
    font-size: 15px;
    text-decoration: none;
}

.site-footer nav a:hover { color: var(--accent); }

.footer-telegram {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
    padding: 10px 18px 10px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--ink);
    text-decoration: none;
    transition: border-color .15s, background .15s;
}

.footer-telegram:hover { border-color: #2aabee; background: color-mix(in srgb, #2aabee 8%, transparent); }

.footer-telegram svg {
    flex: none;
    width: 36px;
    height: 36px;
    padding: 8px;
    border-radius: 50%;
    background: #2aabee;
    color: #fff;
    stroke-width: 1.8;
}

.footer-telegram span { display: grid; gap: 1px; }

.footer-telegram strong { font-size: 15px; }

.footer-telegram small { color: var(--muted); font-size: 13px; }


.faq { padding: 72px var(--gutter) 0; }

.faq .section-heading h2 { margin-bottom: 16px; }

.faq-list { display: grid; gap: 10px; }

.faq details {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
}

.faq summary {
    padding: 15px 20px;
    font-weight: 600;
    cursor: pointer;
}

.faq details p { margin: 0; padding: 0 20px 16px; color: var(--muted); }

.not-found {
    max-width: 560px;
    margin: 0 auto;
    padding: 110px 24px 40px;
    text-align: center;
}

.not-found h1 {
    margin: 0 0 10px;
    font-family: var(--serif);
    font-size: 44px;
    font-weight: 600;
    line-height: 1.15;
}

.not-found p:not(.eyebrow) { margin: 0 0 26px; color: var(--muted); }

/* Responsive */
@media (min-width: 1500px) {
    .prose .examples {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 1px;
        background: var(--line);
    }

    .prose .examples li { background: var(--surface); }

    .prose .examples li + li { border-top: 0; }

    .prose .examples li:nth-child(n + 3) { border-top: 1px solid var(--line); }

    .prose .examples li:last-child:nth-child(odd) { grid-column: 1 / -1; }

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

    .mistakes-title { grid-column: 1 / -1; }

    .mistake { margin-bottom: 0; align-content: start; }
}

@media (max-width: 1180px) {
    .lesson-layout {
        grid-template-columns: 250px minmax(0, 1fr);
        gap: 32px;
    }

    .toc { display: none; }

    .toc-mobile {
        display: block;
        margin-bottom: 26px;
        padding: 12px 18px;
        border: 1px solid var(--line);
        border-radius: 14px;
        background: var(--surface);
    }

    .toc-mobile summary { font-weight: 600; cursor: pointer; }

    .toc-mobile ul { margin: 10px 0 2px; padding-left: 20px; }

    .toc-mobile a { color: var(--ink); text-decoration: none; }

}

@media (max-width: 900px) {
    .hero {
        grid-template-columns: minmax(0, 1fr);
        gap: 40px;
        padding: 44px var(--gutter);
    }

    .lesson-layout { display: block; }

    .course-nav { display: none; }

    .level-cards { grid-template-columns: repeat(3, 1fr); }

    .search-trigger kbd { display: none; }

    .word-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }

    .word-side { position: static; order: -1; }
}

@media (max-width: 620px) {
    body { font-size: 16.5px; }

    :root { --header-height: 60px; }

    .site-header-inner { gap: 10px; padding: 0 16px; }

    .header-actions { gap: 6px; }

    .search-trigger { flex: 0 0 42px; justify-content: center; margin-left: auto; padding: 0; }

    .search-trigger span { display: none; }

    .header-chat span, .header-login { display: none; }

    .header-chat { padding: 0; width: 42px; justify-content: center; }

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

    .vocabulary-hero { padding: 44px 16px 28px; }

    .vocabulary-section, .vocabulary-page { padding-left: 16px; padding-right: 16px; }

    .word-search { padding-left: 14px; }

    .word-search .button { padding: 10px 14px; }

    .hero { padding: 40px 16px; }

    .levels-overview, .level { padding-left: 16px; padding-right: 16px; }

    .hero-stats { gap: 30px; }

    .anatomy { padding: 22px; }

    .anatomy-sentence b { font-size: 20px; }

    .level-cards { grid-template-columns: repeat(2, 1fr); }

    .level-card:last-child { grid-column: 1 / -1; }

    .word-grid-wide { grid-template-columns: minmax(0, 1fr) !important; }

    .level { padding-top: 54px; }

    .level-header { flex-wrap: wrap; }

    .level-header > div { flex: 1 1 200px; }

    .lesson-layout { padding: 0 16px; }

    .lesson { padding-top: 30px; }

    .formula { padding: 4px 16px; }

    .formula-row { grid-template-columns: minmax(0, 1fr); gap: 0; }

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

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

    .pager-next { grid-column: 1; }

    .search-trigger kbd, .search-box kbd { display: none; }
}

@media (max-width: 900px) {
    .site-footer-inner { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .footer-about { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
    .site-footer-inner { grid-template-columns: minmax(0, 1fr); }

    .footer-about { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    * { transition: none !important; }
}

@media print {
    .site-header, .site-footer, .course-nav, .toc, .pager, .toc-mobile, .reading-progress { display: none; }

    .lesson-layout { display: block; }
}

/* Scrollbars: a slim neutral pill that floats on the page background. */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-corner { background: transparent; }

::-webkit-scrollbar-thumb {
    background-color: var(--scroll-thumb);
    background-clip: padding-box;
    border: 3px solid transparent;
    border-radius: 999px;
    min-height: 40px;
}

::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-thumb-hover); }
::-webkit-scrollbar-thumb:active { background-color: var(--accent); }

.course-nav-inner::-webkit-scrollbar,
.toc-inner::-webkit-scrollbar,
.sheet-body::-webkit-scrollbar,
.search-results::-webkit-scrollbar { width: 8px; }

.course-nav-inner::-webkit-scrollbar-thumb,
.toc-inner::-webkit-scrollbar-thumb,
.sheet-body::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb { border-width: 2px; }

@supports not selector(::-webkit-scrollbar) {
    html { scrollbar-color: var(--scroll-thumb) transparent; }
    .course-nav-inner, .toc-inner, .sheet-body, .search-results { scrollbar-width: thin; }
}
