:root {
    color-scheme: light;
    --bg: #f6f8fc;
    --bg-elevated: #ffffff;
    --panel: rgba(255, 255, 255, .92);
    --panel-solid: #ffffff;
    --panel-soft: #f1f5fb;
    --text: #121826;
    --muted: #121c30;
    --line: #d9e1ec;
    --line-strong: #bdc9d9;
    --primary: #2457f5;
    --primary-dark: #1d44c3;
    --primary-soft: #eaf0ff;
    --accent: #0f9f7a;
    --accent-soft: #e8f8f3;
    --danger: #b42318;
    --danger-soft: #fff0ed;
    --success: #067647;
    --success-soft: #e8f8f0;
    --warning: #b54708;
    --warning-soft: #fff6df;
    --better: #175cd3;
    --better-soft: #edf4ff;
    --radius: 8px;
    --shadow: 0 18px 48px rgba(18, 24, 38, .10);
    --shadow-soft: 0 10px 28px rgba(18, 24, 38, .06);
    --header-bg: rgba(255, 255, 255, .82);
    --field-bg: #ffffff;
    --hero-glow: rgba(36, 87, 245, .16);
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d111a;
    --bg-elevated: #121826;
    --panel: rgba(20, 27, 41, .90);
    --panel-solid: #141b29;
    --panel-soft: #192233;
    --text: #eef3fb;
    --muted: #a5b2c5;
    --line: #2a3548;
    --line-strong: #3a4860;
    --primary: #7aa2ff;
    --primary-dark: #9ab8ff;
    --primary-soft: #172342;
    --accent: #49d6ad;
    --accent-soft: #102c28;
    --danger: #ff8f84;
    --danger-soft: #351715;
    --success: #65d8a2;
    --success-soft: #102b21;
    --warning: #ffc46b;
    --warning-soft: #332715;
    --better: #8bb0ff;
    --better-soft: #172342;
    --shadow: 0 20px 58px rgba(0, 0, 0, .34);
    --shadow-soft: 0 12px 32px rgba(0, 0, 0, .22);
    --header-bg: rgba(13, 17, 26, .82);
    --field-bg: #101725;
    --hero-glow: rgba(122, 162, 255, .18);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

html,
body {
    overflow-x: hidden;
}

body {
    background:
        radial-gradient(circle at 16% -8%, var(--hero-glow), transparent 24rem),
        radial-gradient(circle at 92% 8%, rgba(15, 159, 122, .12), transparent 24rem),
        linear-gradient(180deg, var(--bg-elevated) 0, var(--bg) 22rem);
    color: var(--text);
    display: flex;
    flex-direction: column;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    line-height: 1.5;
    margin: 0;
    min-height: 100vh;
}

button,
input,
textarea,
select {
    max-width: 100%;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.site-header {
    backdrop-filter: blur(18px);
    background: var(--header-bg);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav {
    align-items: center;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    margin: 0 auto;
    max-width: 1180px;
    padding: 14px 20px;
}

.brand {
    align-items: center;
    color: var(--text);
    display: inline-flex;
    font-size: 17px;
    font-weight: 800;
    gap: 10px;
    letter-spacing: -.01em;
    min-width: 0;
}

.brand:hover {
    text-decoration: none;
}

.brand-mark {
    align-items: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 8px;
    color: #fff;
    display: inline-flex;
    font-size: 12px;
    height: 32px;
    justify-content: center;
    letter-spacing: .02em;
    width: 32px;
}

.nav-links {
    align-items: center;
    display: flex;
    gap: 16px;
}

.nav-links a,
.logout-form button {
    color: var(--muted);
    font-weight: 700;
}

.nav-links a:hover,
.logout-form button:hover {
    color: var(--text);
    text-decoration: none;
}

.nav-links .button {
    color: #fff;
}

.nav-links .button:hover {
    color: #fff;
}

.nav-toggle {
    display: none;
}

.logout-form {
    margin: 0;
}

.logout-form button {
    background: transparent;
    border: 0;
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.theme-switcher {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    display: inline-flex;
    gap: 2px;
    padding: 3px;
}

.theme-option {
    background: transparent;
    border: 0;
    border-radius: 999px;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    padding: 7px 10px;
}

.theme-option.is-active {
    background: var(--panel-solid);
    box-shadow: var(--shadow-soft);
    color: var(--text);
}

.container {
    flex: 1;
    margin: 0 auto;
    max-width: 1180px;
    padding: 40px 20px 72px;
    width: 100%;
}

.hero,
.card,
.auth-card,
.feedback-summary,
.annotation-card,
.criterion-card,
.polished,
.next-steps li {
    overflow-wrap: anywhere;
}

.hero {
    align-items: center;
    background:
        linear-gradient(135deg, rgba(36, 87, 245, .12), rgba(15, 159, 122, .10)),
        var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    min-height: 360px;
    overflow: hidden;
    padding: 56px;
    position: relative;
}

.hero > div {
    position: relative;
    z-index: 1;
}

.hero::after {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .42), rgba(255, 255, 255, .08)),
        linear-gradient(135deg, var(--primary), var(--accent));
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 26px;
    content: "";
    height: 210px;
    opacity: .36;
    position: absolute;
    right: -58px;
    top: -58px;
    transform: rotate(12deg);
    width: 310px;
}

.hero h1,
.page-heading h1 {
    font-size: clamp(34px, 5vw, 58px);
    letter-spacing: -.04em;
    line-height: 1.04;
    margin: 0 0 16px;
    max-width: 820px;
}

.hero-copy,
.page-heading p,
.muted,
.site-footer p,
.footer-support span {
    color: var(--muted);
}

.hero-copy {
    font-size: 18px;
    max-width: 660px;
}

.hero-actions,
.recorder-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

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

.grid {
    display: grid;
    gap: 22px;
    margin-top: 24px;
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card,
.auth-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 24px;
}

.card h2,
.card h3,
.auth-card h1 {
    margin-top: 0;
}

.card p:last-child,
.auth-card p:last-child {
    margin-bottom: 0;
}

.auth-card {
    margin: 32px auto;
    max-width: 470px;
}

.page-heading {
    margin-bottom: 24px;
}

.page-heading.split {
    align-items: center;
    display: flex;
    gap: 24px;
    justify-content: space-between;
}

.score {
    align-items: center;
    background: var(--primary);
    border-radius: var(--radius);
    color: #fff;
    display: flex;
    flex: 0 0 auto;
    font-size: 36px;
    font-weight: 800;
    height: 96px;
    justify-content: center;
    width: 120px;
}

.band-score {
    align-items: center;
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius);
    box-shadow: 0 18px 42px rgba(36, 87, 245, .26);
    color: #fff;
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    justify-content: center;
    min-height: 118px;
    padding: 18px 24px;
    width: 150px;
}

.band-score span,
.band-score small {
    color: rgba(255, 255, 255, .78);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.band-score strong {
    font-size: 44px;
    letter-spacing: -.04em;
    line-height: 1;
    margin: 7px 0;
}

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

label {
    font-weight: 800;
}

input,
textarea {
    background: var(--field-bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--text);
    font: inherit;
    padding: 13px 14px;
    transition: border-color .18s ease, box-shadow .18s ease;
    width: 100%;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
    outline: 0;
}

.button {
    align-items: center;
    background: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 800;
    justify-content: center;
    padding: 12px 18px;
    transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.button:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    text-decoration: none;
}

.button-secondary {
    background: var(--panel-solid);
    border-color: var(--line-strong);
    color: var(--primary);
}

.button-secondary:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
}

.button-small {
    padding: 7px 12px;
}

.button.full {
    width: 100%;
}

.button-google {
    gap: 10px;
    margin-bottom: 18px;
}

.google-mark {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: #4285f4;
    display: inline-flex;
    font-weight: 800;
    height: 24px;
    justify-content: center;
    width: 24px;
}

.divider {
    align-items: center;
    color: var(--muted);
    display: flex;
    font-size: 13px;
    gap: 12px;
    margin: 0 0 18px;
}

.divider::before,
.divider::after {
    background: var(--line);
    content: "";
    flex: 1;
    height: 1px;
}

.button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.form-errors,
.field-error {
    color: var(--danger);
}

.form-errors {
    background: var(--danger-soft);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    border-radius: var(--radius);
    padding: 10px 12px;
}

.form-errors p,
.field-error {
    margin: 0;
}

.messages {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
}

.message {
    border-radius: var(--radius);
    padding: 12px 14px;
}

.message-success {
    background: var(--success-soft);
    color: var(--success);
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    border-collapse: collapse;
    min-width: 620px;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 14px 10px;
    text-align: left;
}

th {
    color: var(--muted);
    font-size: 13px;
}

tbody tr:hover {
    background: var(--panel-soft);
}

.pill {
    background: var(--primary-soft);
    border-radius: 999px;
    color: var(--primary);
    display: inline-block;
    font-size: 13px;
    font-weight: 800;
    padding: 5px 10px;
}

.feedback {
    border-color: var(--primary);
}

.prose {
    color: var(--text);
    white-space: normal;
}

.result-layout {
    align-items: start;
    display: grid;
    gap: 22px;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
}

.writing-panel,
.speaking-panel {
    position: sticky;
    top: 86px;
}

.feedback-panel {
    border-color: color-mix(in srgb, var(--primary) 45%, var(--line));
    box-shadow: 0 18px 42px rgba(36, 87, 245, .10);
}

.feedback-panel h2,
.section-heading h2 {
    letter-spacing: -.02em;
    margin: 0 0 12px;
}

.feedback-summary {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--text);
    margin: 0 0 18px;
    padding: 14px 16px;
}

.criteria-grid {
    display: grid;
    gap: 12px;
}

.criterion-card {
    align-items: start;
    background: var(--panel-solid);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 16px;
}

.criterion-card h3 {
    font-size: 16px;
    margin: 0 0 6px;
}

.criterion-card p {
    color: var(--muted);
    margin: 0;
}

.mini-band {
    align-items: center;
    background: var(--primary-soft);
    border-radius: 999px;
    color: var(--primary);
    display: inline-flex;
    font-weight: 800;
    height: 42px;
    justify-content: center;
    min-width: 42px;
    padding: 0 10px;
}

.feedback-section {
    margin-top: 28px;
}

.section-heading {
    margin-bottom: 14px;
}

.annotation-list {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.annotation-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 5px solid var(--primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 18px;
}

.annotation-card.mistake {
    border-left-color: var(--danger);
}

.annotation-card.warning {
    border-left-color: var(--warning);
}

.annotation-card.better {
    border-left-color: var(--better);
}

.annotation-type {
    background: var(--better-soft);
    border-radius: 999px;
    color: var(--better);
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    padding: 5px 9px;
    text-transform: uppercase;
}

.annotation-card.mistake .annotation-type {
    background: var(--danger-soft);
    color: var(--danger);
}

.annotation-card.warning .annotation-type {
    background: var(--warning-soft);
    color: var(--warning);
}

.annotation-card blockquote {
    background: var(--panel-soft);
    border-radius: var(--radius);
    color: var(--text);
    font-weight: 800;
    margin: 14px 0 12px;
    padding: 12px;
}

.annotation-card p {
    color: var(--muted);
    margin: 0 0 14px;
}

.suggestion {
    background: var(--accent-soft);
    border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
    border-radius: var(--radius);
    display: grid;
    gap: 4px;
    padding: 12px;
}

.suggestion strong {
    color: var(--success);
}

.polished {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
}

.next-steps {
    counter-reset: step;
    display: grid;
    gap: 12px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.next-steps li {
    align-items: start;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: grid;
    gap: 10px;
    grid-template-columns: auto 1fr;
    padding: 12px;
}

.next-steps li::before {
    align-items: center;
    background: var(--primary);
    border-radius: 50%;
    color: #fff;
    content: counter(step);
    counter-increment: step;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    height: 24px;
    justify-content: center;
    width: 24px;
}

audio {
    width: 100%;
}

.recorder input[type="file"] {
    background: var(--field-bg);
}

.site-footer {
    border-top: 1px solid var(--line);
    background: var(--panel);
}

.footer-inner {
    align-items: center;
    display: flex;
    gap: 24px;
    justify-content: space-between;
    margin: 0 auto;
    max-width: 1180px;
    padding: 28px 20px;
}

.footer-brand {
    margin-bottom: 8px;
}

.footer-support {
    align-items: flex-end;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: right;
}

@media (max-width: 860px) {
    body {
        background:
            radial-gradient(circle at 8% -4%, var(--hero-glow), transparent 18rem),
            linear-gradient(180deg, var(--bg-elevated) 0, var(--bg) 18rem);
    }

    .nav {
        align-items: flex-start;
        flex-direction: column;
        gap: 14px;
        padding: 12px 16px;
        position: relative;
    }

    .brand {
        max-width: calc(100% - 86px);
    }

    .brand span:last-child {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .nav-toggle {
        background: var(--panel-solid);
        border: 1px solid var(--line);
        border-radius: var(--radius);
        color: var(--text);
        display: block;
        font: inherit;
        font-weight: 800;
        padding: 8px 12px;
        position: absolute;
        right: 16px;
        top: 11px;
    }

    .nav-links {
        align-items: stretch;
        display: none;
        flex-direction: column;
        gap: 10px;
        padding-top: 4px;
        width: 100%;
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links a,
    .logout-form button {
        background: var(--panel-soft);
        border: 1px solid var(--line);
        border-radius: var(--radius);
        display: flex;
        justify-content: center;
        padding: 10px 12px;
        text-align: center;
        width: 100%;
    }

    .nav-links .button {
        background: var(--primary);
        border-color: var(--primary);
        color: #fff;
    }

    .nav-links .button:hover {
        background: var(--primary-dark);
        border-color: var(--primary-dark);
        color: #fff;
    }

    .logout-form {
        width: 100%;
    }

    .theme-switcher {
        justify-content: center;
        width: 100%;
    }

    .hero {
        padding: 30px;
        min-height: auto;
    }

    .hero::after {
        height: 150px;
        opacity: .22;
        right: -86px;
        top: -72px;
        width: 220px;
    }

    .grid.two,
    .grid.three,
    .result-layout,
    .annotation-list {
        grid-template-columns: 1fr;
    }

    .writing-panel,
    .speaking-panel {
        position: static;
    }

    .page-heading.split {
        align-items: flex-start;
        flex-direction: column;
    }

    .band-score,
    .score {
        width: 100%;
    }

    .criterion-card {
        grid-template-columns: 1fr;
    }

    .mini-band {
        justify-self: start;
    }

    .footer-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .footer-support {
        align-items: flex-start;
        text-align: left;
        width: 100%;
    }
}

@media (max-width: 520px) {
    .container {
        padding: 24px 12px 52px;
    }

    .hero,
    .card,
    .auth-card {
        padding: 20px;
    }

    .hero h1,
    .page-heading h1 {
        font-size: 31px;
        line-height: 1.08;
    }

    .hero-copy {
        font-size: 16px;
    }

    .page-heading {
        margin-bottom: 18px;
    }

    .page-heading p {
        margin-bottom: 0;
    }

    .band-score {
        min-height: 96px;
    }

    .band-score strong {
        font-size: 38px;
    }

    .button,
    .hero-actions .button,
    .recorder-controls .button {
        width: 100%;
    }

    .hero-actions,
    .recorder-controls {
        gap: 10px;
    }

    input,
    textarea {
        font-size: 16px;
        padding: 12px;
    }

    th,
    td {
        padding: 12px 8px;
    }

    .footer-inner {
        padding: 24px 12px;
    }
}

@media (max-width: 380px) {
    .brand {
        font-size: 15px;
    }

    .brand-mark {
        height: 28px;
        width: 28px;
    }

    .theme-option {
        flex: 1;
        padding-left: 6px;
        padding-right: 6px;
    }

    .hero h1,
    .page-heading h1 {
        font-size: 28px;
    }
}
