:root {
    --orange: #ff5a18;
    --orange-light: #ff8126;
    --mint: #39d4ae;
    --mint-soft: #e8fbf6;
    --dark: #262626;
    --text: #181818;
    --muted: #747474;
    --line: #dedede;
    --surface: #ffffff;
    --page: #f3f3f3;
    --success: #159b65;
    --success-soft: #e9f8f1;
    --danger: #d94a35;
    --danger-soft: #fff0ed;
    --shadow: 0 18px 50px rgba(20, 20, 20, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--page);
}

body {
    margin: 0;
    color: var(--text);
    font-family: "Montserrat", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
}

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

/* Авторизация */
.auth-page {
    min-height: 100vh;
    padding: 40px 20px;
    display: grid;
    place-items: center;
    background: #f3f3f3;
}

.auth-card {
    width: min(100%, 430px);
    padding: 36px 38px 34px;
    border-radius: 30px;
    background: var(--surface);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.025);
}

.auth-card-register {
    padding-top: 30px;
}

.auth-logo {
    display: block;
    width: 78px;
    height: 78px;
    margin: 0 auto 20px;
    object-fit: contain;
}

.auth-title {
    margin: 0 0 22px;
    text-align: center;
    font-size: clamp(24px, 4vw, 30px);
    line-height: 1.15;
    font-weight: 700;
}

.auth-form {
    display: grid;
    gap: 12px;
}

.auth-input,
.answer-input,
.answer-textarea {
    width: 100%;
    border: 1.5px solid #cfcfcf;
    border-radius: 14px;
    background: white;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-input {
    height: 52px;
    padding: 0 16px;
    font-size: 14px;
}

.auth-input::placeholder,
.answer-input::placeholder,
.answer-textarea::placeholder {
    color: #9c9c9c;
}

.auth-input:focus,
.answer-input:focus,
.answer-textarea:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 4px rgba(255, 90, 24, 0.1);
}

.password-field {
    position: relative;
}

.password-field .auth-input {
    padding-right: 50px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 14px;
    width: 30px;
    height: 30px;
    padding: 5px;
    display: grid;
    place-items: center;
    transform: translateY(-50%);
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #b8b8b8;
    cursor: pointer;
}

.password-toggle:hover,
.password-toggle.is-active {
    color: var(--orange);
}

.password-toggle svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
}

.forgot-link {
    width: fit-content;
    margin: 3px 0 24px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: underline;
}

.button {
    min-height: 48px;
    padding: 12px 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid transparent;
    border-radius: 13px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

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

.button-primary {
    color: white;
    border-color: var(--orange);
    background: linear-gradient(180deg, var(--orange-light), var(--orange));
    box-shadow: 0 9px 20px rgba(255, 90, 24, 0.18);
}

.button-primary:hover {
    box-shadow: 0 12px 24px rgba(255, 90, 24, 0.25);
}

.button-secondary {
    color: var(--text);
    border-color: #d0d0d0;
    background: white;
}

.button-secondary:hover {
    background: #f8f8f8;
}

.button-wide {
    width: 100%;
}

.auth-info {
    margin-top: 14px;
    padding: 15px 17px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-radius: 13px;
    color: white;
    background: var(--dark);
}

.auth-info-icon {
    width: 33px;
    height: 33px;
    flex: 0 0 33px;
    display: grid;
    place-items: center;
    border: 2px solid white;
    border-radius: 50%;
    font-size: 19px;
    font-family: Georgia, serif;
}

.auth-info p {
    margin: 0;
    font-size: 11px;
    line-height: 1.35;
    font-weight: 600;
}

.form-error {
    margin-bottom: 14px;
    padding: 11px 13px;
    border-radius: 10px;
    color: var(--danger);
    background: var(--danger-soft);
    font-size: 13px;
    font-weight: 600;
}

.test-account {
    margin: 18px 0 0;
    color: #9a9a9a;
    text-align: center;
    font-size: 11px;
}

/* Общая оболочка приложения */
.app-page {
    min-height: 100vh;
    background: var(--page);
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 76px;
    padding: 14px clamp(20px, 4vw, 60px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.03em;
}

.brand img {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 13px;
    font-weight: 600;
}

.header-link {
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.page-shell {
    width: min(1240px, calc(100% - 40px));
    margin: 0 auto;
    padding: 52px 0 80px;
}

.page-shell-narrow {
    width: min(1040px, calc(100% - 40px));
}

.page-heading {
    max-width: 760px;
    margin-bottom: 36px;
}

.page-heading h1 {
    margin: 0;
    font-size: clamp(38px, 6vw, 72px);
    line-height: 0.98;
    letter-spacing: -0.055em;
}

.page-heading p:not(.eyebrow) {
    max-width: 620px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.55;
}

.compact-heading h1 {
    font-size: clamp(34px, 5vw, 58px);
    line-height: 1.04;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--orange);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.breadcrumbs {
    margin-bottom: 34px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: #878787;
    font-size: 12px;
    line-height: 1.5;
}

.breadcrumbs a {
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}

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

/* Карточки блоков */
.block-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.block-card {
    min-height: 280px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 24px;
    color: var(--text);
    background: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.035);
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.block-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 90, 24, 0.28);
    box-shadow: var(--shadow);
}

.block-card-top,
.block-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.block-number {
    min-height: 30px;
    padding: 7px 11px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    color: #146b55;
    background: var(--mint-soft);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.progress-percent {
    color: var(--orange);
    font-size: 13px;
    font-weight: 800;
}

.block-card h2 {
    margin: 32px 0 24px;
    font-size: clamp(20px, 2.4vw, 29px);
    line-height: 1.08;
    letter-spacing: -0.035em;
}

.progress-track {
    width: 100%;
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #ededed;
}

.progress-track > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--mint), #63e3c4);
}

.progress-copy {
    margin-top: 14px;
    display: flex;
    align-items: baseline;
    gap: 7px;
}

.progress-copy strong {
    font-size: 17px;
}

.progress-copy span {
    color: var(--muted);
    font-size: 12px;
}

.block-card-footer {
    margin-top: auto;
    padding-top: 24px;
    color: var(--muted);
    font-size: 12px;
}

.card-arrow {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: white;
    background: var(--dark);
    font-size: 18px;
}

/* Темы */
.theme-list {
    display: grid;
    gap: 12px;
}

.theme-card {
    padding: 22px 22px 22px 26px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px 38px;
    align-items: center;
    gap: 24px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 20px;
    color: var(--text);
    background: white;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.theme-card:hover {
    transform: translateX(4px);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.06);
}

.theme-card-content h2 {
    margin: 0 0 9px;
    font-size: 17px;
    line-height: 1.35;
}

.theme-card-content p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.theme-progress {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px 12px;
}

.theme-progress .progress-track {
    grid-column: 1 / -1;
    height: 6px;
}

.theme-progress small {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 10px;
}

/* Список задач */
.task-list {
    display: grid;
    gap: 10px;
}

.task-row {
    min-height: 84px;
    padding: 15px 18px;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto 34px;
    align-items: center;
    gap: 16px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 18px;
    color: var(--text);
    background: white;
    text-decoration: none;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.task-row:hover {
    transform: translateX(3px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.05);
}

.task-row-number {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    color: #7a7a7a;
    background: #f2f2f2;
    font-size: 13px;
    font-weight: 800;
}

.task-row-correct .task-row-number {
    color: var(--success);
    background: var(--success-soft);
}

.task-row-attempted .task-row-number {
    color: var(--orange);
    background: #fff3ec;
}

.task-row-copy {
    overflow: hidden;
    font-size: 13px;
    line-height: 1.45;
}

.task-row-status {
    padding: 7px 10px;
    border-radius: 999px;
    color: #777;
    background: #f3f3f3;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.task-row-correct .task-row-status {
    color: var(--success);
    background: var(--success-soft);
}

.task-row-attempted .task-row-status {
    color: var(--orange);
    background: #fff3ec;
}

/* Страница задания */
.task-shell {
    width: min(1180px, calc(100% - 40px));
}

.task-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(310px, 0.7fr);
    align-items: start;
    gap: 22px;
}

.task-panel,
.answer-panel {
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 24px;
    background: white;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.04);
}

.task-panel {
    padding: clamp(24px, 4vw, 42px);
}

.answer-panel {
    position: sticky;
    top: 98px;
    padding: 26px;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.task-meta span {
    padding: 7px 10px;
    border-radius: 999px;
    color: #555;
    background: #f2f2f2;
    font-size: 10px;
    font-weight: 700;
}

.task-meta span:first-child {
    color: #146b55;
    background: var(--mint-soft);
}

.task-panel h1,
.answer-panel h2 {
    margin: 26px 0 18px;
}

.task-panel h1 {
    font-size: clamp(27px, 4vw, 42px);
    letter-spacing: -0.04em;
}

.answer-panel h2 {
    margin-top: 0;
    font-size: 22px;
}

.task-condition {
    color: #2c2c2c;
    font-size: clamp(15px, 1.7vw, 18px);
    line-height: 1.75;
    white-space: pre-line;
}

.task-image-wrap {
    margin: 28px 0 0;
    padding: 16px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: #f8f8f8;
}

.task-image {
    max-width: 100%;
    max-height: 540px;
    display: block;
    object-fit: contain;
}

.answer-form {
    display: grid;
    gap: 16px;
}

.answer-input {
    min-height: 52px;
    padding: 0 15px;
}

.answer-textarea {
    min-height: 150px;
    padding: 14px 15px;
    resize: vertical;
    line-height: 1.5;
}

.answer-options {
    display: grid;
    gap: 9px;
}

.answer-option {
    padding: 12px;
    display: grid;
    grid-template-columns: 18px 32px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    border: 1.5px solid #dedede;
    border-radius: 13px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1.35;
    transition: border-color 0.18s ease, background 0.18s ease;
}

.answer-option:hover {
    border-color: var(--orange);
    background: #fff8f4;
}

.answer-option:has(input:checked) {
    border-color: var(--orange);
    background: #fff5ef;
}

.answer-option input {
    width: 17px;
    height: 17px;
    accent-color: var(--orange);
}

.option-number {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: #f0f0f0;
    font-size: 11px;
    font-weight: 800;
}

.matching-options {
    margin: 0;
    padding-left: 25px;
    color: #3e3e3e;
    font-size: 12px;
    line-height: 1.55;
}

.matching-options li + li {
    margin-top: 6px;
}

.field-hint,
.attempt-count {
    margin: -8px 0 0;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.4;
}

.answer-result {
    margin-top: 18px;
    padding: 16px;
    border-radius: 15px;
}

.answer-result strong {
    font-size: 15px;
}

.answer-result > p {
    margin: 6px 0 0;
    font-size: 11px;
    line-height: 1.45;
}

.answer-result-success {
    color: #116d49;
    background: var(--success-soft);
}

.answer-result-fail {
    color: #9a3325;
    background: var(--danger-soft);
}

.answer-result-no_answer {
    color: #6d5511;
    background: #fff8df;
}

.correct-answer {
    margin-top: 14px;
    padding-top: 13px;
    display: grid;
    gap: 5px;
    border-top: 1px solid currentColor;
}

.correct-answer span {
    font-size: 10px;
    font-weight: 600;
    opacity: 0.75;
}

.correct-answer strong {
    overflow-wrap: anywhere;
    font-size: 13px;
}

.attempt-count {
    margin-top: 14px;
}

@media (max-width: 980px) {
    .block-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .task-layout {
        grid-template-columns: 1fr;
    }

    .answer-panel {
        position: static;
    }
}

@media (max-width: 720px) {
    .site-header {
        min-height: 64px;
        padding: 10px 16px;
    }

    .brand span,
    .header-user > span {
        display: none;
    }

    .brand img {
        width: 40px;
        height: 40px;
    }

    .page-shell,
    .page-shell-narrow,
    .task-shell {
        width: min(100% - 24px, 1240px);
        padding-top: 34px;
    }

    .page-heading h1,
    .compact-heading h1 {
        font-size: 40px;
    }

    .block-grid {
        grid-template-columns: 1fr;
    }

    .block-card {
        min-height: 250px;
    }

    .theme-card {
        grid-template-columns: 1fr 34px;
        gap: 16px;
    }

    .theme-progress {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .theme-card > .card-arrow {
        grid-column: 2;
        grid-row: 1;
    }

    .task-row {
        grid-template-columns: 38px minmax(0, 1fr) 32px;
    }

    .task-row-number {
        width: 38px;
        height: 38px;
    }

    .task-row-status {
        grid-column: 2;
        width: fit-content;
    }

    .task-row .card-arrow {
        grid-column: 3;
        grid-row: 1 / 3;
    }
}

@media (max-width: 480px) {
    .auth-page {
        padding: 18px 12px;
    }

    .auth-card {
        padding: 28px 20px 24px;
        border-radius: 24px;
    }

    .auth-logo {
        width: 68px;
        height: 68px;
    }

    .task-panel,
    .answer-panel {
        border-radius: 19px;
    }

    .task-panel,
    .answer-panel {
        padding: 20px;
    }

    .page-heading h1,
    .compact-heading h1 {
        font-size: 34px;
    }
}
