/* --- Шрифт: Montserrat Alternates со своего сервера (SIL OFL 1.1, fonts/OFL.txt) --- */
@font-face { font-family: "Montserrat Alternates"; font-weight: 400; font-display: swap; src: url("fonts/montserrat-alternates-cyrillic-400-normal.woff2") format("woff2"); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "Montserrat Alternates"; font-weight: 400; font-display: swap; src: url("fonts/montserrat-alternates-latin-ext-400-normal.woff2") format("woff2"); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Montserrat Alternates"; font-weight: 400; font-display: swap; src: url("fonts/montserrat-alternates-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Montserrat Alternates"; font-weight: 500; font-display: swap; src: url("fonts/montserrat-alternates-cyrillic-500-normal.woff2") format("woff2"); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "Montserrat Alternates"; font-weight: 500; font-display: swap; src: url("fonts/montserrat-alternates-latin-ext-500-normal.woff2") format("woff2"); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Montserrat Alternates"; font-weight: 500; font-display: swap; src: url("fonts/montserrat-alternates-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Montserrat Alternates"; font-weight: 600; font-display: swap; src: url("fonts/montserrat-alternates-cyrillic-600-normal.woff2") format("woff2"); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "Montserrat Alternates"; font-weight: 600; font-display: swap; src: url("fonts/montserrat-alternates-latin-ext-600-normal.woff2") format("woff2"); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Montserrat Alternates"; font-weight: 600; font-display: swap; src: url("fonts/montserrat-alternates-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

:root {
    --text: #333;
    --muted: #8a8a8a;
    --accent: #cb4545;
    --accent-hover: #b53c3c;
    --accent-soft: rgba(203, 69, 69, 0.14);
    --surface: #f7f7f7;
    --line: #e4e4e4;
    --radius: 14px;
    --hanzi: "Kaiti SC", "STKaiti", "KaiTi", "BiauKai", serif;
    /* 米字格 как в PDF-прописях: крест и диагонали бледным акцентом, пунктиром */
    --mizige: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M50 0V100M0 50H100M0 0L100 100M100 0L0 100' stroke='%23ebb9b9' stroke-width='1' stroke-dasharray='3 3' vector-effect='non-scaling-stroke' fill='none'/%3E%3C/svg%3E");
    color-scheme: light;
}

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

body {
    background: #fff;
    color: var(--text);
    font-family: "Montserrat Alternates", sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

input, button { font: inherit; color: inherit; }

/* --- Шапка и заголовок --- */
.header { text-align: center; padding: 32px 16px 8px; }
.header__logo { width: 150px; display: inline-block; }

.main { max-width: 640px; margin: 0 auto; padding: 24px 16px 64px; }
.title { font-size: 34px; font-weight: 600; text-align: center; line-height: 1.2; }
.lead { color: var(--muted); text-align: center; margin: 12px 0 36px; }

/* --- Карточка --- */
.card {
    background: var(--surface);
    border-radius: 24px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}
.card [hidden] { display: none; }

.field { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.field__label { font-weight: 500; }
.field__hint { font-size: 13px; color: var(--muted); }
.field__hint.is-error { color: var(--accent); }

input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-family: var(--hanzi), "Montserrat Alternates", sans-serif;
    font-size: 26px;
    line-height: 1.3;
    transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #b8b8b8; }
input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

/* --- Иероглифы слова: переключение между знаками --- */
.chars { display: flex; flex-wrap: wrap; gap: 8px; }
.chars button {
    width: 52px;
    height: 52px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    font-family: var(--hanzi);
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    transition: border-color .15s, color .15s, box-shadow .15s;
}
.chars button:hover { border-color: var(--accent); }
.chars button.is-active { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chars button:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-soft); }

/* --- Переключатель «анимация / тренировка» --- */
.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #ececec;
    border-radius: var(--radius);
    padding: 4px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
    display: block;
    text-align: center;
    padding: 10px 8px;
    border-radius: 10px;
    color: var(--muted);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.segmented input:checked + span { background: #fff; color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.segmented input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }

/* --- Поле с иероглифом --- */
.board { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.writer {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1;
    background: #fff var(--mizige) center / 100% 100% no-repeat;
    border: 1.5px solid var(--accent);
    border-radius: 6px;
    touch-action: none; /* в тренировке палец рисует черту, а не прокручивает страницу */
}
.writer svg { display: block; }
.board__status { min-height: 1.5em; color: var(--muted); text-align: center; }
.board__status.is-done { color: var(--accent); font-weight: 600; }
.board__status.is-error { color: var(--accent); }

.controls { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 16px 28px; }

/* --- Тумблер --- */
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 500; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
    flex: none;
    position: relative;
    width: 44px;
    height: 26px;
    border-radius: 13px;
    background: #d6d6d6;
    transition: background .2s;
}
.switch__track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
    transition: transform .2s;
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 4px var(--accent-soft); }

/* --- Кнопка --- */
.button {
    border: 0;
    border-radius: var(--radius);
    padding: 14px 24px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: background .15s, transform .1s;
}
.button:hover { background: var(--accent-hover); }
.button:active { transform: scale(.99); }
.button:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-soft); }

/* --- Разбивка по чертам: каждая следующая черта красным --- */
.strokes { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.stroke {
    position: relative;
    aspect-ratio: 1;
    background: #fff var(--mizige) center / 100% 100% no-repeat;
    border: 1px solid var(--line);
    border-radius: 6px;
}
.stroke svg { display: block; width: 100%; height: 100%; }
.stroke span { position: absolute; top: 2px; left: 5px; font-size: 11px; color: var(--muted); }

/* --- Плашка про соседний сервис, между карточкой и SEO-текстом --- */
.promo { max-width: 640px; margin: 0 auto 40px; padding: 0 16px; }
.promo__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px 20px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 24px;
}
.promo__hanzi {
    flex: none;
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    background: #fff var(--mizige) center / 100% 100% no-repeat;
    border: 1.5px solid var(--accent);
    border-radius: 6px;
    font-family: var(--hanzi);
    font-size: 48px;
    line-height: 1;
}
.promo__text { flex: 1 1 200px; }
.promo__title { font-size: 18px; font-weight: 600; }
.promo__desc { margin-top: 4px; font-size: 14px; color: #555; }
.promo .button { flex: none; text-decoration: none; }

/* --- SEO-текст под карточкой и юридические страницы --- */
.info, .legal-page { max-width: 640px; margin: 0 auto; padding: 0 16px 72px; }
.legal-page { max-width: 760px; padding-top: 24px; }
.info h2, .legal-page h2 { font-size: 22px; font-weight: 600; line-height: 1.3; margin: 48px 0 14px; }
.info h2:first-child { margin-top: 24px; }
.info h3, .legal-page h3 { font-size: 17px; font-weight: 600; margin: 24px 0 6px; }
.info p, .info li, .legal-page p, .legal-page li { color: #555; line-height: 1.7; }
.info p + p, .legal-page p + p { margin-top: 12px; }
.info ol, .info ul, .legal-page ul { padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; }
.legal-page a { color: var(--accent); overflow-wrap: anywhere; } /* длинные URL распирали страницу на телефоне */
.info .hz { font-family: var(--hanzi); font-size: 1.25em; color: var(--text); }
.legal-page h1 { font-size: 28px; font-weight: 600; line-height: 1.25; margin-bottom: 8px; }
.legal-page strong { color: var(--text); }
.legal-page__dates { font-size: 14px; color: var(--muted) !important; margin-bottom: 8px; }
.legal-page__table-wrap { overflow-x: auto; margin: 12px 0 20px; }
.legal-page table { width: 100%; border-collapse: collapse; font-size: 14px; color: #555; }
.legal-page th { background: var(--surface); color: var(--text); font-weight: 500; text-align: left; }
.legal-page th, .legal-page td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }

/* --- Подвал --- */
.footer { border-top: 1px solid var(--line); padding: 24px 16px 40px; }
.footer__nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 24px; }
.footer__nav a { font-size: 14px; color: var(--muted); text-decoration: none; }
.footer__nav a:hover { color: var(--accent); }

/* --- Баннер о файлах cookie (static/cookie-banner.js) --- */
.cookie-banner {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1000;
    width: calc(100% - 40px);
    max-width: 380px;
    padding: 20px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 6px 24px rgba(0, 0, 0, .14);
}
.cookie-banner__text { font-size: 13px; line-height: 1.45; color: #555; margin-bottom: 16px; }
.cookie-banner__text a { color: var(--accent); }
.cookie-banner__button {
    width: 100%;
    padding: 10px 16px;
    background: var(--accent);
    border: 0;
    border-radius: 10px;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
}
.cookie-banner__button:hover { background: var(--accent-hover); }

/* --- Телефон --- */
@media (max-width: 560px) {
    .header { padding-top: 24px; }
    .header__logo { width: 130px; }
    .title { font-size: 28px; }
    .lead { margin-bottom: 28px; }
    .card { padding: 22px 18px; border-radius: 20px; gap: 24px; }
    .strokes { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); }
    .promo__inner { padding: 22px 18px; border-radius: 20px; }
    .promo .button { width: 100%; text-align: center; }
    .info h2, .legal-page h2 { font-size: 20px; margin-top: 40px; }
    .legal-page h1 { font-size: 24px; }
    .cookie-banner { right: 12px; bottom: 12px; width: calc(100% - 24px); }
}
