:root {
    --ink: #142033;
    --ink-soft: #4a5b73;
    --paper: #eef3f8;
    --panel: rgba(255, 255, 255, 0.8);
    --line: rgba(20, 32, 51, 0.1);
    --accent: #0f8f86;
    --accent-deep: #0b6e67;
    --ok: #1f7a4c;
    --bad: #b42318;
    --shadow: 0 18px 50px rgba(20, 32, 51, 0.1);
    --radius: 22px;
    --font-display: "Syne", system-ui, sans-serif;
    --font-body: "Figtree", system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: var(--font-body);
    color: var(--ink);
    background:
        radial-gradient(circle at 12% 8%, rgba(15, 143, 134, 0.18), transparent 30%),
        radial-gradient(circle at 88% 0%, rgba(56, 119, 200, 0.16), transparent 28%),
        linear-gradient(165deg, #e7eef7 0%, #f4f7fb 45%, #e9f4f2 100%);
    line-height: 1.5;
}

.bg-mesh {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(20, 32, 51, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(20, 32, 51, 0.035) 1px, transparent 1px);
    background-size: 36px 36px;
    mask-image: radial-gradient(circle at center, black 35%, transparent 85%);
    z-index: 0;
}

.page {
    position: relative;
    z-index: 1;
    width: min(960px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.25rem 0 3rem;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 0.9rem 1rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 999px;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 16px;
    background: linear-gradient(145deg, var(--accent), #146fbf);
    color: white;
    font-family: var(--font-display);
    font-weight: 700;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-text strong {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.brand-text small {
    color: var(--ink-soft);
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav a {
    text-decoration: none;
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 0.92rem;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.nav a:hover,
.nav a.is-active {
    background: rgba(15, 143, 134, 0.14);
    color: var(--accent-deep);
}

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

.hero {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    animation: rise 0.55s ease both;
}

.hero h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 1.05;
    letter-spacing: -0.04em;
}

.hero p {
    margin: 0;
    max-width: 38rem;
    color: var(--ink-soft);
    font-size: 1.02rem;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    padding: 1.25rem;
    animation: rise 0.65s ease both;
}

.panel + .panel {
    margin-top: 1rem;
}

.stats {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.stat {
    flex: 1 1 120px;
    padding: 0.9rem 1rem;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(238, 243, 248, 0.95));
    border: 1px solid var(--line);
}

.stat strong {
    display: block;
    font-family: var(--font-display);
    font-size: 1.6rem;
    line-height: 1;
}

.stat span {
    color: var(--ink-soft);
    font-size: 0.85rem;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.toolbar h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.35rem;
}

.word-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.7rem;
}

.word-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.8rem;
    align-items: center;
    padding: 0.95rem 1rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.word-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(20, 32, 51, 0.08);
}

.word-pair {
    min-width: 0;
}

.word-pair .de {
    display: block;
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.word-pair .en {
    color: var(--ink-soft);
}

.word-actions {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn {
    appearance: none;
    border: 0;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.7rem 1.05rem;
    border-radius: 999px;
    font: inherit;
    font-weight: 700;
    font-size: 0.92rem;
    transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

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

.btn-primary {
    background: linear-gradient(145deg, var(--accent), #146fbf);
    color: white;
    box-shadow: 0 10px 24px rgba(15, 143, 134, 0.28);
}

.btn-secondary {
    background: rgba(20, 32, 51, 0.06);
    color: var(--ink);
}

.btn-ghost {
    background: transparent;
    color: var(--ink-soft);
    border: 1px solid var(--line);
}

.btn-danger {
    background: rgba(180, 35, 24, 0.1);
    color: var(--bad);
}

.form {
    display: grid;
    gap: 1rem;
}

.field {
    display: grid;
    gap: 0.4rem;
}

.field label {
    font-weight: 700;
    font-size: 0.92rem;
}

.field input,
.field select {
    width: 100%;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.9);
    font: inherit;
    color: var(--ink);
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field input:focus,
.field select:focus {
    border-color: rgba(15, 143, 134, 0.55);
    box-shadow: 0 0 0 4px rgba(15, 143, 134, 0.14);
}

.form-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.flash {
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 16px;
    font-weight: 600;
    animation: rise 0.4s ease both;
}

.flash-success {
    background: rgba(31, 122, 76, 0.12);
    color: var(--ok);
    border: 1px solid rgba(31, 122, 76, 0.2);
}

.flash-error {
    background: rgba(180, 35, 24, 0.1);
    color: var(--bad);
    border: 1px solid rgba(180, 35, 24, 0.18);
}

.empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--ink-soft);
}

.empty h3 {
    margin: 0 0 0.4rem;
    font-family: var(--font-display);
    color: var(--ink);
}

.mode-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 1rem 0 1.25rem;
}

.mode-card {
    position: relative;
    display: block;
    padding: 1rem;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.75);
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.mode-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(20, 32, 51, 0.08);
}

.mode-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mode-card strong {
    display: block;
    font-family: var(--font-display);
    margin-bottom: 0.2rem;
}

.mode-card span {
    color: var(--ink-soft);
    font-size: 0.88rem;
}

.mode-card:has(input:checked) {
    border-color: rgba(15, 143, 134, 0.55);
    background: rgba(15, 143, 134, 0.1);
    box-shadow: 0 0 0 4px rgba(15, 143, 134, 0.1);
}

.exam-question {
    text-align: center;
    padding: 1.5rem 0.5rem;
}

.exam-direction {
    display: inline-block;
    margin-bottom: 0.8rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(20, 32, 51, 0.06);
    color: var(--ink-soft);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.exam-prompt {
    margin: 0 0 1.25rem;
    font-family: var(--font-display);
    font-size: clamp(2rem, 7vw, 3.2rem);
    line-height: 1.1;
    letter-spacing: -0.04em;
}

.progress {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 0.92rem;
}

.progress-bar {
    height: 8px;
    border-radius: 999px;
    background: rgba(20, 32, 51, 0.08);
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.progress-bar > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #3b8bd4);
    border-radius: inherit;
    transition: width 0.25s ease;
}

.results-score {
    text-align: center;
    padding: 1rem 0 1.5rem;
}

.results-score .percent {
    font-family: var(--font-display);
    font-size: clamp(3rem, 10vw, 4.5rem);
    line-height: 1;
    color: var(--accent-deep);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.result-row {
    display: grid;
    gap: 0.25rem;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
}

.result-row.is-correct {
    border-color: rgba(31, 122, 76, 0.25);
    background: rgba(31, 122, 76, 0.08);
}

.result-row.is-wrong {
    border-color: rgba(180, 35, 24, 0.22);
    background: rgba(180, 35, 24, 0.07);
}

.result-list {
    display: grid;
    gap: 0.7rem;
}

.footer {
    margin-top: 2rem;
    text-align: center;
    color: var(--ink-soft);
    font-size: 0.9rem;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 720px) {
    .page {
        width: min(100% - 1.2rem, 960px);
        padding-top: 0.9rem;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
        border-radius: 24px;
        padding: 0.9rem;
    }

    .nav {
        justify-content: stretch;
    }

    .nav a {
        flex: 1;
        text-align: center;
    }

    .brand-text small {
        display: none;
    }

    .word-item {
        grid-template-columns: 1fr;
    }

    .word-actions {
        justify-content: flex-start;
    }

    .mode-grid,
    .results-grid {
        grid-template-columns: 1fr;
    }
}
