:root {
    --verbi-red: #8f3f5e;
    --verbi-red-deep: #672543;
    --verbi-coral: #a84d75;
    --page-bg: #f7f1f3;
    --surface: rgba(255, 255, 255, 0.86);
    --surface-strong: #ffffff;
    --surface-soft: rgba(143, 63, 94, 0.09);
    --text: #311923;
    --muted: #765d66;
    --border: rgba(143, 63, 94, 0.2);
    --shadow: 0 18px 44px rgba(63, 28, 43, 0.12);
    --content-width: min(92vw, 860px);
    --good: #2d7438;
    --bad: #8f3f5e;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--page-bg);
}

body {
    min-height: 100svh;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 8% 0%, rgba(143, 63, 94, 0.08), transparent 28%),
        linear-gradient(180deg, #fff8f7 0%, var(--page-bg) 46%, #efe2e8 100%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    transition: background 0.4s ease, color 0.4s ease;
}

body.dark-mode {
    --page-bg: #1c0c14;
    --surface: rgba(48, 20, 34, 0.88);
    --surface-strong: #351526;
    --surface-soft: rgba(255, 248, 245, 0.07);
    --text: #fff2f5;
    --muted: #d7bdc8;
    --border: rgba(255, 211, 224, 0.2);
    --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
    --good: #b6f0bf;
    --bad: #ffc0d2;
    --verbi-coral: #c86c95;
    background:
        radial-gradient(circle at 8% 0%, rgba(214, 91, 61, 0.12), transparent 28%),
        linear-gradient(180deg, #341123 0%, #1c0c14 52%, #12070d 100%);
}

.progress-track {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 20;
    width: 100%;
    height: 4px;
    background: rgba(143, 63, 94, 0.1);
}

.progress-fill {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--verbi-red), var(--verbi-coral));
    box-shadow: 0 0 14px rgba(143, 63, 94, 0.25);
    transition: width 0.22s ease;
}

.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;
}

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

.page {
    width: var(--content-width);
    margin: 0 auto;
    padding: clamp(18px, 4vh, 34px) 0 28px;
}

.topbar {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    align-items: center;
    gap: 14px;
    margin-bottom: clamp(22px, 5vh, 40px);
}

.topbar > * {
    align-self: center;
}

.topbar .icon-button {
    justify-self: start;
}

.topbar .kicker-row {
    justify-self: center;
}

.topbar .mode-button {
    justify-self: end;
}

.icon-button,
.mode-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--verbi-red);
    box-shadow: 0 10px 24px rgba(63, 28, 43, 0.08);
    text-decoration: none;
    cursor: pointer;
    transition:
        transform 0.2s ease,
        background-color 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease;
}

.icon-button:hover,
.mode-button:hover {
    transform: translateY(-1px);
    background: var(--verbi-red);
    color: #fff8f4;
    border-color: rgba(143, 63, 94, 0.28);
}

.icon-button:focus-visible,
.mode-button:focus-visible,
.submit-button:focus-visible,
.secondary-button:focus-visible,
.export-toggle:focus-visible,
.qr-toggle:focus-visible,
input[type="text"]:focus-visible {
    outline: 2px solid rgba(143, 63, 94, 0.45);
    outline-offset: 3px;
}

.home-icon {
    width: 19px;
    height: 19px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 11.5L12 4l9 7.5'/%3E%3Cpath d='M5.5 10.5V20h13v-9.5'/%3E%3Cpath d='M9.5 20v-6h5v6'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 11.5L12 4l9 7.5'/%3E%3Cpath d='M5.5 10.5V20h13v-9.5'/%3E%3Cpath d='M9.5 20v-6h5v6'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}

.mode-button {
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    text-shadow: 0.35px 0 currentColor, -0.35px 0 currentColor;
}

.hero {
    margin-bottom: 22px;
    text-align: center;
}

.kicker-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 1 auto;
    min-height: 44px;
    min-width: 0;
    margin: 0;
}

.kicker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    margin: 0;
    padding: 0 18px;
    border: 1px solid var(--border);
    border-radius: 9999px;
    background: var(--surface);
    color: var(--verbi-red);
    box-shadow: 0 10px 24px rgba(63, 28, 43, 0.08);
    font-size: 15px;
    font-weight: 750;
}

body.dark-mode .kicker {
    color: #ffe5ef;
}

.qr-toggle {
    position: static;
    flex: 0 0 auto;
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--verbi-red);
    box-shadow: 0 10px 24px rgba(63, 28, 43, 0.08);
    cursor: pointer;
    transition:
        transform 0.22s ease,
        background-color 0.2s ease,
        color 0.2s ease;
}

.qr-toggle::before {
    content: "";
    width: 9px;
    height: 9px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.22s ease;
}

.qr-toggle:hover {
    background: var(--verbi-red);
    color: #fff8f4;
    transform: scale(1.04);
}

.hero.qr-open .qr-toggle::before {
    transform: translateY(2px) rotate(225deg);
}

.qr-panel {
    max-height: 0;
    overflow: hidden;
    padding: 0 18px;
    opacity: 0;
    transform: translateY(-6px);
    transition:
        max-height 0.3s ease,
        opacity 0.22s ease,
        transform 0.26s ease,
        margin-top 0.3s ease;
}

.hero.qr-open .qr-panel {
    max-height: 560px;
    overflow: visible;
    margin-top: 18px;
    opacity: 1;
    transform: translateY(0);
}

.qr-card {
    width: min(100%, 330px);
    margin: 0 auto;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.qr-card img {
    display: block;
    width: min(100%, 270px);
    height: auto;
    margin: 0 auto 12px;
    border-radius: 18px;
    background: white;
}

.qr-url {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

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

.hero h1 {
    margin: 0;
    color: var(--verbi-red);
    font-size: clamp(38px, 8vw, 58px);
    line-height: 1;
}

body.dark-mode .hero h1 {
    color: #fff2f5;
}

.hero > p:not(.kicker) {
    max-width: 620px;
    margin: 12px auto 0;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.45;
}

.exercise-form {
    display: grid;
    gap: 18px;
}

.questions {
    display: grid;
    gap: 12px;
}

.question,
.actions-panel {
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: 0 10px 26px rgba(63, 28, 43, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.question {
    position: relative;
    padding: 16px 18px 16px 68px;
    transition:
        transform 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background-color 0.2s ease;
}

.question:focus-within {
    transform: translateY(-1px);
    border-color: rgba(143, 63, 94, 0.3);
    background: var(--surface-strong);
    box-shadow: 0 14px 30px rgba(63, 28, 43, 0.12);
}

body.dark-mode .question:focus-within {
    background: rgba(255, 248, 245, 0.1);
}

.question p {
    margin: 0;
    font-size: 18px;
    line-height: 1.75;
}

.question-number {
    position: absolute;
    top: 19px;
    left: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin: 0;
    border-radius: 50%;
    background: var(--surface-soft);
    color: var(--verbi-red);
    font-size: 14px;
    font-weight: 800;
}

body.dark-mode .question-number {
    color: #ffe5ef;
}

input[type="text"] {
    width: 112px;
    height: 30px;
    margin: 0 4px;
    padding: 2px 11px;
    border: 1px solid var(--border);
    border-radius: 9999px;
    outline: none;
    background: rgba(255, 255, 255, 0.78);
    color: var(--text);
    line-height: 1.2;
    text-align: center;
    vertical-align: middle;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background-color 0.2s ease;
}

textarea {
    width: 100%;
    min-height: 220px;
    resize: vertical;
    padding: 14px 15px;
    border: 1px solid var(--border);
    border-radius: 18px;
    outline: none;
    background: rgba(255, 255, 255, 0.78);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

textarea:focus {
    border-color: rgba(143, 63, 94, 0.55);
    box-shadow: 0 0 0 4px rgba(143, 63, 94, 0.12);
}

body.dark-mode textarea {
    background: rgba(255, 248, 245, 0.08);
}

input[type="text"]:focus {
    border-color: rgba(143, 63, 94, 0.55);
    box-shadow: 0 0 0 4px rgba(143, 63, 94, 0.12);
}

body.dark-mode input[type="text"] {
    background: rgba(255, 248, 245, 0.08);
}

input.is-correct {
    border-color: rgba(45, 116, 56, 0.5);
    box-shadow: 0 0 0 4px rgba(45, 116, 56, 0.1);
}

input.is-wrong {
    border-color: rgba(143, 63, 94, 0.54);
    box-shadow: 0 0 0 4px rgba(143, 63, 94, 0.1);
}

.feedback-div {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 9px;
}

.feedback {
    display: none;
    padding: 6px 10px;
    border-radius: 9999px;
    background: rgba(143, 63, 94, 0.1);
    color: var(--bad);
    font-size: 14px;
    font-weight: 650;
    line-height: 1.25;
}

.feedback:not(:empty) {
    display: inline-flex;
}

.feedback.correct {
    background: rgba(45, 116, 56, 0.12);
    color: var(--good);
}

.actions-panel {
    display: grid;
    gap: 12px;
    padding: clamp(18px, 4vw, 26px);
    text-align: center;
}

.button-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.submit-button,
.secondary-button {
    min-height: 48px;
    padding: 12px 24px;
    border-radius: 9999px;
    font-weight: 750;
    cursor: pointer;
    transition:
        transform 0.2s ease,
        background-color 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease;
}

.submit-button {
    border: none;
    background: var(--verbi-red);
    color: #fff8f4;
    box-shadow: 0 12px 28px rgba(143, 63, 94, 0.22);
}

.submit-button:hover {
    transform: translateY(-1px);
    background: var(--verbi-coral);
}

.secondary-button {
    border: 1px solid var(--border);
    background: var(--surface-strong);
    color: var(--verbi-red);
}

.secondary-button:hover {
    transform: translateY(-1px);
    background: var(--surface-soft);
}

body.dark-mode .secondary-button {
    background: rgba(255, 248, 245, 0.08);
    color: #ffe5ef;
}

.result-message,
.export-message {
    margin: 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.45;
}

.export-toggle {
    justify-self: center;
    min-height: 34px;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 9999px;
    background: transparent;
    color: var(--verbi-red);
    font-size: 14px;
    font-weight: 750;
    cursor: pointer;
    transition:
        transform 0.2s ease,
        background-color 0.2s ease;
}

.export-toggle:hover {
    transform: translateY(-1px);
    background: var(--surface-soft);
}

.export-toggle[hidden] {
    display: none;
}

body.dark-mode .export-toggle {
    color: #ffe5ef;
}

.export-panel {
    display: grid;
    grid-template-rows: 0fr;
    margin: 0 -4px;
    padding: 0 4px;
    opacity: 0;
    text-align: left;
    transform: translateY(-4px);
    transition:
        grid-template-rows 0.28s ease,
        opacity 0.2s ease,
        transform 0.28s ease;
}

.export-panel.is-open {
    grid-template-rows: 1fr;
    opacity: 1;
    transform: translateY(0);
}

.export-panel[hidden] {
    display: none;
}

.export-panel-inner {
    display: grid;
    gap: 9px;
    min-height: 0;
    overflow: hidden;
    padding: 4px;
    margin: -4px;
}

.export-panel.is-open .export-panel-inner {
    overflow: visible;
}

.export-panel label {
    color: var(--verbi-red);
    font-size: 15px;
    font-weight: 750;
}

body.dark-mode .export-panel label {
    color: #ffe5ef;
}

.result-message:not(:empty) {
    color: var(--verbi-red);
    font-size: 18px;
    font-weight: 750;
}

body.dark-mode .result-message:not(:empty) {
    color: #ffe5ef;
}

footer {
    margin-top: 26px;
    color: var(--muted);
    text-align: center;
    font-size: 14px;
}

@media (max-width: 640px) {
    .page {
        width: min(92vw, 460px);
        padding-top: 18px;
    }

    .question,
    .actions-panel {
        border-radius: 20px;
    }

    .question {
        padding: 14px 14px 14px 54px;
    }

    .question p {
        font-size: 17px;
        line-height: 1.7;
    }

    .question-number {
        top: 17px;
        left: 16px;
        width: 28px;
        height: 28px;
        font-size: 13px;
    }

    .qr-toggle {
        width: 36px;
        height: 36px;
    }

    input[type="text"] {
        width: min(118px, 44vw);
        height: 30px;
        margin-top: 3px;
        margin-bottom: 3px;
    }

    .submit-button,
    .secondary-button {
        width: 100%;
    }
}

@media (max-width: 410px) {
    .topbar {
        grid-template-columns: 44px minmax(0, 1fr) 44px;
        row-gap: 12px;
    }

    .topbar .icon-button {
        grid-column: 1;
        grid-row: 1;
    }

    .topbar .kicker-row {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
    }

    .topbar .mode-button {
        grid-column: 3;
        grid-row: 1;
    }
}
