:root {
    --bg: #f1f3f4;
    --paper: #ffffff;
    --ink: #1f1f1f;
    --muted: #5f6368;
    --line: #dadce0;
    --accent: #1a73e8;
    --accent-soft: #e8f0fe;
    --error: #c5221f;
    --ok: #188038;
    --radius: 8px;
    --doc-width: 780px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #17181a;
        --paper: #1f2023;
        --ink: #e8eaed;
        --muted: #9aa0a6;
        --line: #3c4043;
        --accent: #8ab4f8;
        --accent-soft: #1e2b3d;
        --error: #f28b82;
        --ok: #81c995;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* --- Верхняя панель --------------------------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}

.topbar__inner {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 1180px;
    margin: 0 auto;
    padding: 12px 24px;
}

.topbar__title {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar__status {
    margin-left: auto;
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.topbar__progress {
    color: var(--muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.topbar__bar {
    height: 3px;
    background: transparent;
}

.topbar__bar i {
    display: block;
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width .25s ease;
}

/* --- Раскладка -------------------------------------------------------- */

.layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 32px;
    max-width: 1180px;
    margin: 0 auto;
    padding: 32px 24px 96px;
}

.toc {
    position: sticky;
    top: 76px;
    align-self: start;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    font-size: 14px;
}

.toc ol {
    margin: 0;
    padding-left: 20px;
    color: var(--muted);
}

.toc li { margin-bottom: 8px; }

.toc a {
    color: inherit;
    text-decoration: none;
}

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

.doc {
    margin: 0 auto;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 48px clamp(20px, 5vw, 64px) 40px;
    max-width: var(--doc-width);
    width: 100%;
}

.doc__title {
    margin: 0 0 24px;
    font-size: 28px;
    line-height: 1.3;
}

.doc__intro {
    margin: 0 0 16px;
    color: var(--muted);
}

/* --- Разделы и вопросы ------------------------------------------------- */

.section {
    margin-top: 44px;
    scroll-margin-top: 88px;
}

.section__title {
    margin: 0 0 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
    font-size: 20px;
}

.section__num { color: var(--muted); }

.section__desc,
.section__note {
    color: var(--muted);
    font-size: 14px;
}

.section__note {
    margin-top: 24px;
    padding: 12px 16px;
    background: var(--accent-soft);
    border-radius: var(--radius);
}

.q { margin-bottom: 28px; }

.q__box {
    margin: 0;
    padding: 0;
    border: 0;
}

.q__label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    padding: 0;
}

.q__num {
    color: var(--muted);
    font-weight: 400;
    margin-right: 4px;
}

.q__req { color: var(--error); }

.q__hint {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 14px;
    font-style: italic;
}

.q__error {
    margin: 6px 0 0;
    color: var(--error);
    font-size: 14px;
}

.q--error .input {
    border-color: var(--error);
}

.input {
    width: 100%;
    padding: 9px 12px;
    background: transparent;
    color: inherit;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font: inherit;
    transition: border-color .15s, box-shadow .15s;
}

.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.textarea {
    resize: vertical;
    min-height: 44px;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.option {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: baseline;
    gap: 10px;
}

.option input[type="radio"],
.option input[type="checkbox"] {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--accent);
    align-self: center;
}

.option label {
    cursor: pointer;
    padding: 2px 0;
}

.option--other .input--other {
    grid-column: 2;
    margin-top: 4px;
    max-width: 420px;
}

/* --- Подвал и состояния ------------------------------------------------ */

.doc__footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

.doc__note {
    color: var(--muted);
    font-size: 14px;
}

.btn {
    display: inline-block;
    padding: 11px 26px;
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 100px;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}

.btn:hover { filter: brightness(1.06); }

.btn[disabled] {
    opacity: .6;
    cursor: default;
}

.btn--ghost {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    text-decoration: none;
}

.btn--ghost:hover {
    background: var(--accent-soft);
    filter: none;
}

/* В тёмной теме заливка кнопки светлая — текст на ней делаем тёмным.
   Прозрачную кнопку это правило не трогает: у неё цвет текста = акцент. */
@media (prefers-color-scheme: dark) {
    .btn:not(.btn--ghost) { color: #1f2023; }
}

.form-status {
    margin: 12px 0 0;
    font-size: 14px;
    min-height: 20px;
}

.form-status--error { color: var(--error); }
.form-status--ok { color: var(--ok); }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 15px;
}

.alert--error {
    background: color-mix(in srgb, var(--error) 12%, transparent);
    color: var(--error);
}

.draft-restored {
    margin: 16px 0 0;
    padding: 10px 16px;
    background: var(--accent-soft);
    border-radius: var(--radius);
    font-size: 14px;
}

.link {
    background: none;
    border: 0;
    padding: 0;
    color: var(--accent);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.done {
    text-align: center;
    padding: 40px 0 24px;
}

.done h1 { font-size: 26px; }
.done p { color: var(--muted); }
.done .btn { margin-top: 20px; }

.hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
        padding: 20px 12px 64px;
    }
    .toc { display: none; }
    .doc { padding: 28px 20px; }
}
