:root {
    /* Background Neutral */
    --neutral-primary-soft: #FFFFFF;
    --neutral-primary: #FFFFFF;
    --neutral-primary-medium: #FFFFFF;
    --neutral-primary-strong: #FFFFFF;
    --neutral-secondary-soft: #F9FAFB;
    --neutral-secondary: #F9FAFB;
    --neutral-secondary-medium: #F9FAFB;
    --neutral-secondary-strong: #F9FAFB;
    --neutral-tertiary-soft: #F3F4F6;
    --neutral-tertiary: #F3F4F6;
    --neutral-tertiary-medium: #F3F4F6;
    --neutral-quaternary: #E5E7EB;
    --quaternary-medium: #E5E7EB;
    --gray: #D1D5DC;

    /* Background Brand */
    --brand-softer: #FDF6EC;
    --brand-soft: #FAECDA;
    --brand: #F5DFBB;
    --brand-medium: #EDD1A3;
    --brand-strong: #D4A96E;

    /* Background Status */
    --success-soft: #ECFDF5;
    --success: #007A55;
    --success-medium: #D0FAE5;
    --success-strong: #006045;
    --danger-soft: #FEF0F2;
    --danger: #C70036;
    --danger-medium: #FFE4E6;
    --danger-strong: #A50036;
    --warning-soft: #FFF7ED;
    --warning: #F97316;
    --warning-medium: #FFEDD5;
    --warning-strong: #C2410C;

    /* Background Utility */
    --dark: #1F2937;
    --dark-strong: #111827;
    --disabled: #F3F4F6;

    /* Text Base */
    --white: #FFFFFF;
    --black: #111827;
    --heading: #111827;
    --body: #4B5563;
    --body-subtle: #6B7280;

    /* Text Brand */
    --fg-brand-subtle: #EDD1A3;
    --fg-brand: #A07840;
    --fg-brand-strong: #7D5C2E;

    /* Text Status */
    --fg-success: #047857;
    --fg-success-strong: #065F46;
    --fg-danger: #BE123C;
    --fg-danger-strong: #881337;
    --fg-warning-subtle: #EA580C;
    --fg-warning: #7C2D12;
    --fg-disabled: #9CA3AF;

    /* Text Informational */
    --fg-yellow: #FACC15;
    --fg-info: #312E81;
    --fg-purple: #6C5CE7;
    --fg-purple-strong: #4D36D0;
    --fg-cyan: #0891B2;
    --fg-indigo: #818CF8;
    --fg-pink: #DB2777;
    --fg-lime: #65A30D;

    /* Borders */
    --border-dark: #1F2937;
    --border-buffer: #FFFFFF;
    --border-buffer-medium: #FFFFFF;
    --border-buffer-strong: #FFFFFF;
    --border-muted: #F9FAFB;
    --border-light-subtle: #F3F4F6;
    --border-light: #F3F4F6;
    --border-light-medium: #F3F4F6;
    --border-default-subtle: #E5E7EB;
    --border-default: #E5E7EB;
    --border-default-medium: #E5E7EB;
    --border-default-strong: #E5E7EB;
    --border-success-subtle: #A7F3D0;
    --border-success: #047857;
    --border-danger-subtle: #FECDD3;
    --border-danger: #BE123C;
    --border-warning-subtle: #FED7AA;
    --border-warning: #EA580C;
    --border-brand-subtle: #FAECDA;
    --border-brand-light: #EDD1A3;
    --border-brand: #D4A96E;
    --border-dark-subtle: #1F2937;
    --border-purple: #8474FE;
    --border-orange: #FB923C;

    /* Radius Tokens */
    --radius-base: 24px;
    --radius-default: 48px;
    --radius-sm: 8px;
    --radius-full: 9999px;

    /* Shadow Tokens */
    --shadow-2xs: 0 1px 2px rgb(0 0 0 / 0.04);
    --shadow-xs: 0 2px 4px 0 rgb(0 0 0 / 0.04);
    --shadow-sm: 0 2px 6px 0 rgb(0 0 0 / 0.06), 0 1px 2px -1px rgb(0 0 0 / 0.04);
    --shadow-md: 0 6px 16px -4px rgb(0 0 0 / 0.08), 0 2px 6px -2px rgb(0 0 0 / 0.04);
    --shadow-lg: 0 12px 28px -6px rgb(0 0 0 / 0.08), 0 4px 10px -4px rgb(0 0 0 / 0.04);
    --shadow-xl: 0 24px 48px -8px rgb(0 0 0 / 0.1), 0 8px 16px -4px rgb(0 0 0 / 0.04);
    --shadow-2xl: 0 40px 80px -16px rgb(0 0 0 / 0.18);
}

@media (prefers-color-scheme: dark) {
    :root {
        /* Background Neutral Dark */
        --neutral-primary-soft: #101828;
        --neutral-primary: #030712;
        --neutral-primary-medium: #1E2939;
        --neutral-primary-strong: #333E4F;
        --neutral-secondary-soft: #101828;
        --neutral-secondary: #030712;
        --neutral-secondary-medium: #1E2939;
        --neutral-secondary-strong: #333E4F;
        --neutral-tertiary-soft: #101828;
        --neutral-tertiary: #1E2939;
        --neutral-tertiary-medium: #333E4F;
        --neutral-quaternary: #333E4F;
        --quaternary-medium: #4A5565;
        --gray: #4A5565;

        /* Background Brand Dark */
        --brand-softer: #3D2E10;
        --brand-soft: #5C4520;
        --brand: #F5DFBB;
        --brand-medium: #5C4520;
        --brand-strong: #F5DFBB;

        /* Background Status Dark */
        --success-soft: #002C22;
        --success: #009966;
        --success-medium: #004F3B;
        --success-strong: #007A55;
        --danger-soft: #4D0218;
        --danger: #C70036;
        --danger-medium: #8B0836;
        --danger-strong: #A50036;
        --warning-soft: #7C2D12;
        --warning: #F97316;
        --warning-medium: #7C2D12;
        --warning-strong: #C2410C;

        /* Utility Dark */
        --dark: #1F2937;
        --dark-strong: #374151;
        --disabled: #1F2937;

        /* Text Base Dark */
        --heading: #FFFFFF;
        --body: #9CA3AF;
        --body-subtle: #9CA3AF;

        /* Text Brand Dark */
        --fg-brand-subtle: #5C4520;
        --fg-brand: #F5DFBB;
        --fg-brand-strong: #EDD1A3;

        /* Text Status Dark */
        --fg-success: #065F46;
        --fg-success-strong: #10B981;
        --fg-danger: #F43F5E;
        --fg-danger-strong: #F87171;
        --fg-warning-subtle: #F97316;
        --fg-warning: #FBBF24;
        --fg-disabled: #6B7280;

        /* Border Dark */
        --border-dark: #4B5563;
        --border-buffer: #030712;
        --border-buffer-medium: #1F2937;
        --border-buffer-strong: #374151;
        --border-muted: #111827;
        --border-light-subtle: #111827;
        --border-light: #1F2937;
        --border-light-medium: #374151;
        --border-default-subtle: #111827;
        --border-default: #1F2937;
        --border-default-medium: #374151;
        --border-default-strong: #4B5563;
        --border-success-subtle: #064E3B;
        --border-success: #065F46;
        --border-danger-subtle: #881337;
        --border-danger: #BE123C;
        --border-warning-subtle: #7C2D12;
        --border-warning: #F97316;
        --border-brand-subtle: #5C4520;
        --border-brand-light: #EDD1A3;
        --border-brand: #F5DFBB;
        --border-dark-subtle: #374151;
    }
}

/* ==========================================================================
   Manual theme override (data-theme attribute set by the theme toggle button)
   Takes precedence over the prefers-color-scheme media query above, since
   these rules come later in source order at equal specificity.
   ========================================================================== */
:root[data-theme="dark"] {
    --neutral-primary-soft: #101828;
    --neutral-primary: #030712;
    --neutral-primary-medium: #1E2939;
    --neutral-primary-strong: #333E4F;
    --neutral-secondary-soft: #101828;
    --neutral-secondary: #030712;
    --neutral-secondary-medium: #1E2939;
    --neutral-secondary-strong: #333E4F;
    --neutral-tertiary-soft: #101828;
    --neutral-tertiary: #1E2939;
    --neutral-tertiary-medium: #333E4F;
    --neutral-quaternary: #333E4F;
    --quaternary-medium: #4A5565;
    --gray: #4A5565;

    --brand-softer: #3D2E10;
    --brand-soft: #5C4520;
    --brand: #F5DFBB;
    --brand-medium: #5C4520;
    --brand-strong: #F5DFBB;

    --success-soft: #002C22;
    --success: #009966;
    --success-medium: #004F3B;
    --success-strong: #007A55;
    --danger-soft: #4D0218;
    --danger: #C70036;
    --danger-medium: #8B0836;
    --danger-strong: #A50036;
    --warning-soft: #7C2D12;
    --warning: #F97316;
    --warning-medium: #7C2D12;
    --warning-strong: #C2410C;

    --dark: #1F2937;
    --dark-strong: #374151;
    --disabled: #1F2937;

    --heading: #FFFFFF;
    --body: #9CA3AF;
    --body-subtle: #9CA3AF;

    --fg-brand-subtle: #5C4520;
    --fg-brand: #F5DFBB;
    --fg-brand-strong: #EDD1A3;

    --fg-success: #065F46;
    --fg-success-strong: #10B981;
    --fg-danger: #F43F5E;
    --fg-danger-strong: #F87171;
    --fg-warning-subtle: #F97316;
    --fg-warning: #FBBF24;
    --fg-disabled: #6B7280;

    --border-dark: #4B5563;
    --border-buffer: #030712;
    --border-buffer-medium: #1F2937;
    --border-buffer-strong: #374151;
    --border-muted: #111827;
    --border-light-subtle: #111827;
    --border-light: #1F2937;
    --border-light-medium: #374151;
    --border-default-subtle: #111827;
    --border-default: #1F2937;
    --border-default-medium: #374151;
    --border-default-strong: #4B5563;
    --border-success-subtle: #064E3B;
    --border-success: #065F46;
    --border-danger-subtle: #881337;
    --border-danger: #BE123C;
    --border-warning-subtle: #7C2D12;
    --border-warning: #F97316;
    --border-brand-subtle: #5C4520;
    --border-brand-light: #EDD1A3;
    --border-brand: #F5DFBB;
    --border-dark-subtle: #374151;
}

:root[data-theme="light"] {
    --neutral-primary-soft: #FFFFFF;
    --neutral-primary: #FFFFFF;
    --neutral-primary-medium: #FFFFFF;
    --neutral-primary-strong: #FFFFFF;
    --neutral-secondary-soft: #F9FAFB;
    --neutral-secondary: #F9FAFB;
    --neutral-secondary-medium: #F9FAFB;
    --neutral-secondary-strong: #F9FAFB;
    --neutral-tertiary-soft: #F3F4F6;
    --neutral-tertiary: #F3F4F6;
    --neutral-tertiary-medium: #F3F4F6;
    --neutral-quaternary: #E5E7EB;
    --quaternary-medium: #E5E7EB;
    --gray: #D1D5DC;

    --brand-softer: #FDF6EC;
    --brand-soft: #FAECDA;
    --brand: #F5DFBB;
    --brand-medium: #EDD1A3;
    --brand-strong: #D4A96E;

    --success-soft: #ECFDF5;
    --success: #007A55;
    --success-medium: #D0FAE5;
    --success-strong: #006045;
    --danger-soft: #FEF0F2;
    --danger: #C70036;
    --danger-medium: #FFE4E6;
    --danger-strong: #A50036;
    --warning-soft: #FFF7ED;
    --warning: #F97316;
    --warning-medium: #FFEDD5;
    --warning-strong: #C2410C;

    --dark: #1F2937;
    --dark-strong: #111827;
    --disabled: #F3F4F6;

    --heading: #111827;
    --body: #4B5563;
    --body-subtle: #6B7280;

    --fg-brand-subtle: #EDD1A3;
    --fg-brand: #A07840;
    --fg-brand-strong: #7D5C2E;

    --fg-success: #047857;
    --fg-success-strong: #065F46;
    --fg-danger: #BE123C;
    --fg-danger-strong: #881337;
    --fg-warning-subtle: #EA580C;
    --fg-warning: #7C2D12;
    --fg-disabled: #9CA3AF;

    --border-dark: #1F2937;
    --border-buffer: #FFFFFF;
    --border-buffer-medium: #FFFFFF;
    --border-buffer-strong: #FFFFFF;
    --border-muted: #F9FAFB;
    --border-light-subtle: #F3F4F6;
    --border-light: #F3F4F6;
    --border-light-medium: #F3F4F6;
    --border-default-subtle: #E5E7EB;
    --border-default: #E5E7EB;
    --border-default-medium: #E5E7EB;
    --border-default-strong: #E5E7EB;
    --border-success-subtle: #A7F3D0;
    --border-success: #047857;
    --border-danger-subtle: #FECDD3;
    --border-danger: #BE123C;
    --border-warning-subtle: #FED7AA;
    --border-warning: #EA580C;
    --border-brand-subtle: #FAECDA;
    --border-brand-light: #EDD1A3;
    --border-brand: #D4A96E;
    --border-dark-subtle: #1F2937;
}

/* ==========================================================================
   Typography & Base
   ========================================================================== */
body {
    font-family: 'Public Sans', sans-serif;
    background-color: var(--neutral-primary);
    color: var(--body);
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 16px;
    line-height: 1.5;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Page Level Gradient */
.page-gradient-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background: linear-gradient(135deg, rgba(242, 217, 220, 0.2) 0%, rgba(224, 217, 241, 0.2) 50%, rgba(218, 239, 248, 0.2) 100%);
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--heading);
    margin-top: 0;
}

h1 { font-size: 36px; line-height: 1.1; letter-spacing: -1px; margin-bottom: 16px; }
h2 { font-size: 28px; line-height: 1.1; letter-spacing: -0.5px; }
h3 { font-size: 24px; line-height: 1.2; }
h4 { font-size: 22px; line-height: 1.25; }
h5 { font-size: 20px; line-height: 1.4; }
h6 { font-size: 18px; line-height: 1.3; }

@media (min-width: 768px) {
    h1 { font-size: 44px; }
    h2 { font-size: 36px; }
    h3 { font-size: 30px; }
    h4 { font-size: 26px; }
    h5 { font-size: 22px; }
    h6 { font-size: 18px; }
}

@media (min-width: 1024px) {
    h1 { font-size: 52px; line-height: 1.1; }
    h2 { font-size: 40px; line-height: 1.15; }
    h3 { font-size: 32px; line-height: 1.2; }
    h4 { font-size: 26px; line-height: 1.25; }
    h5 { font-size: 22px; line-height: 1.4; }
    h6 { font-size: 18px; line-height: 1.3; }
}

p {
    margin-bottom: 16px;
    max-width: 65ch;
}
.leading-paragraph {
    font-size: 18px;
    max-width: 70ch;
}

a {
    color: var(--fg-brand);
    text-decoration: underline;
}
a:hover {
    text-decoration: none;
}

/* ==========================================================================
   Layout
   ========================================================================== */
.container {
    width: 100%;
    max-width: 1152px;
    margin: 0 auto;
    padding: 48px 24px;
    box-sizing: border-box;
    text-align: center;
}

.section-header {
    margin-bottom: 24px;
    text-align: center;
}

/* ==========================================================================
   Cards
   ========================================================================== */
.card-container {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.card {
    background-color: var(--neutral-primary-soft);
    border-radius: var(--radius-default);
    border: 1px solid var(--border-default);
    padding: 20px;
    box-sizing: border-box;
    position: relative;
    box-shadow: none;
    max-width: 600px;
    margin: 0 auto;
}

.card.interactive {
    cursor: pointer;
    transition: all 0.2s ease;
}

.card.interactive:hover {
    filter: brightness(1.03);
}

.card.pastel-rose { background-color: #F2D9DC; border: none; }
.card.pastel-mint { background-color: #D9F2D8; border: none; }
.card.pastel-lavender { background-color: #E0D9F1; border: none; }
.card.pastel-sky { background-color: #DAEFF8; border: none; }

/* ==========================================================================
   Buttons
   ========================================================================== */
button {
    font-family: 'Public Sans', sans-serif;
    font-weight: 500;
    border-radius: var(--radius-full);
    box-sizing: border-box;
    transition: all 0.15s ease-out;
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: var(--shadow-xs);
}

button:focus-visible {
    outline: none;
}

/* Primary (Brand) */
button.primary, #btnCheckGrammar, #btnShow, #btnGroupCheck button:last-child {
    background: linear-gradient(0deg, rgba(77, 54, 208, 1) 0%, rgba(132, 116, 254, 1) 100%);
    color: var(--white);
    border: none;
}
button.primary:hover, #btnCheckGrammar:hover, #btnShow:hover, #btnGroupCheck button:last-child:hover {
    background: linear-gradient(0deg, rgba(69, 49, 187, 1) 0%, rgba(119, 104, 229, 1) 100%);
    transform: scale(1.02);
}
button.primary:focus-visible {
    box-shadow: 0 0 0 4px var(--brand-medium);
}

/* Secondary */
button.secondary, button {
    background-color: var(--neutral-secondary-medium);
    border-color: var(--border-default-medium);
    color: var(--body);
}
button.secondary:hover, button:hover {
    background-color: var(--neutral-tertiary-medium);
    color: var(--heading);
}
button.secondary:focus-visible, button:focus-visible {
    box-shadow: 0 0 0 4px var(--neutral-tertiary);
}

/* Success */
button.success {
    background-color: var(--success);
    color: var(--white);
    border: none;
}
button.success:hover { background-color: var(--success-strong); }
button.success:focus-visible { box-shadow: 0 0 0 4px var(--success-medium); }

/* Danger */
button.danger {
    background-color: var(--danger);
    color: var(--white);
    border: none;
}
button.danger:hover { background-color: var(--danger-strong); }
button.danger:focus-visible { box-shadow: 0 0 0 4px var(--danger-medium); }

/* Warning */
button.warning {
    background-color: var(--warning);
    color: var(--white);
    border: none;
}
button.warning:hover { background-color: var(--warning-strong); }
button.warning:focus-visible { box-shadow: 0 0 0 4px var(--warning-medium); }

/* Ghost */
button.ghost, .logout-btn {
    background-color: transparent;
    border: transparent;
    color: var(--heading);
    box-shadow: none;
}
button.ghost:hover, .logout-btn:hover {
    background-color: var(--neutral-secondary-medium);
}
button.ghost:focus-visible, .logout-btn:focus-visible {
    box-shadow: 0 0 0 4px var(--neutral-tertiary);
}

/* Disabled */
button:disabled {
    background-color: var(--disabled);
    border-color: var(--border-default-medium);
    color: var(--fg-disabled);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Audio & Small Icons */
.audio-btn {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: var(--radius-full);
}
.audio-btn.small {
    width: 32px;
    height: 32px;
    font-size: 16px;
    padding: 0;
}

.star-btn {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 5px;
}
.star-btn:hover { background: transparent; transform: scale(1.1); }

/* ==========================================================================
   Inputs
   ========================================================================== */
input, select, textarea {
    display: block;
    box-sizing: border-box;
    padding: 10px 12px;
    margin-bottom: 16px;
    background-color: var(--neutral-secondary-medium);
    border: 1px solid var(--border-default-medium);
    border-radius: var(--radius-full);
    font-family: 'Public Sans', sans-serif;
    font-size: 14px;
    color: var(--heading);
    box-shadow: var(--shadow-xs);
    transition: all 0.2s;
    outline: none;
}

/* width:100% is split out from the shared rule above and scoped to exclude
   .candidate-fields inputs, so those never receive width:100% at all (not
   even transiently before an override) - every other <input> in the app
   (login, #newWord, #newMeaning, #searchVocab, etc.) is unaffected. */
select, textarea {
    width: 100%;
}

input:not(.candidate-fields input) {
    width: 100%;
}

textarea {
    border-radius: var(--radius-base);
}

input::placeholder, select::placeholder, textarea::placeholder {
    color: var(--body);
}

input:hover, select:hover, textarea:hover {
    border-color: var(--border-default-strong);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--border-brand);
    box-shadow: 0 0 0 1px var(--brand);
}

input:disabled, select:disabled, textarea:disabled {
    background-color: var(--disabled);
    color: var(--fg-disabled);
    cursor: not-allowed;
}

/* Checkboxes/radios opt out of the block/full-width text-input styling above -
   otherwise a checkbox renders as a full-width filled bar instead of a tickbox. */
input[type="checkbox"], input[type="radio"] {
    display: inline-block;
    width: auto;
    box-shadow: none;
    padding: 0;
    margin-bottom: 0;
    accent-color: var(--brand);
}

/* ==========================================================================
   Tabs
   ========================================================================== */
.tabs {
    display: flex;
    justify-content: center;
    border-bottom: 1px solid var(--border-default);
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.tab-btn {
    background: transparent;
    padding: 12px 12px;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 24px 24px 0 0;
    font-weight: 500;
    font-size: 14px;
    color: var(--body);
    transition: color 0.15s, border-color 0.15s;
    box-shadow: none;
}

.tab-btn:hover {
    color: var(--heading);
    border-bottom-color: var(--border-default-strong);
    background: transparent;
    transform: none;
}

.tab-btn.active {
    color: var(--fg-brand);
    border-bottom-color: var(--border-brand);
    background: transparent;
}

.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

/* Sub-tabs (Pills) */
.sub-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.sub-tab-btn {
    background: transparent;
    padding: 8px 12px;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 500;
    color: var(--body);
    border: none;
    box-shadow: none;
    transition: all 0.2s ease;
}

.sub-tab-btn:hover {
    background-color: var(--neutral-secondary-soft);
    color: var(--heading);
    transform: none;
}

.sub-tab-btn.active {
    background-color: var(--brand);
    color: var(--white);
    box-shadow: var(--shadow-sm);
}

.sub-view {
    display: none;
    animation: fadeIn 0.3s ease-out forwards;
}
.sub-view.active {
    display: block;
}

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

/* ==========================================================================
   Badges / Tags
   ========================================================================== */
.tag-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    background-color: var(--neutral-secondary-medium);
    color: var(--heading);
    border: 1px solid var(--border-default);
    margin-right: 6px;
    margin-bottom: 6px;
}

/* ==========================================================================
   Feedback Alerts
   ========================================================================== */
.feedback {
    padding: 12px 16px;
    border-radius: var(--radius-base);
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.6;
    margin-top: 16px;
    margin-bottom: 16px;
    min-height: 24px;
}
.feedback:empty {
    display: none;
}
.feedback.success {
    background-color: var(--success-soft);
    border-color: var(--border-success-subtle);
    color: var(--fg-success-strong);
}
.feedback.error {
    background-color: var(--danger-soft);
    border-color: var(--border-danger-subtle);
    color: var(--fg-danger-strong);
}
.feedback.warning {
    background-color: var(--warning-soft);
    border-color: var(--border-warning-subtle);
    color: var(--fg-warning);
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrapper {
    overflow-x: auto;
    background-color: var(--neutral-primary-soft);
    border-radius: var(--radius-base);
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-xs);
    margin-top: 16px;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
    color: var(--body);
}

.history-table th {
    font-weight: 500;
    background-color: var(--neutral-secondary-soft);
    border-bottom: 1px solid var(--border-default);
    padding: 12px 16px;
}

.history-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-default);
    background-color: var(--neutral-primary);
}

.history-table tr:last-child td {
    border-bottom: none;
}

/* ==========================================================================
   Specific App Layouts & Lists
   ========================================================================== */
.stats-dashboard {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 24px;
    margin-bottom: 30px;
}
@media (min-width: 640px) {
    .stats-dashboard { grid-template-columns: repeat(3, 1fr); }
}

.stat-box {
    text-align: center;
}
.stat-box h4 {
    font-size: 14px;
    color: var(--body);
    margin-bottom: 8px;
}
.stat-box p {
    font-size: 40px;
    font-weight: 700;
    color: var(--heading);
    margin: 0;
}

.vocab-list {
    text-align: left;
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.vocab-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
}

/* AI sentence-prediction candidate row: checkbox in a fixed-width column,
   the editable fields in a second column that always fills the rest of the
   row width. Grid's explicit "1fr" track is used instead of a nested
   flex-grow item so the fields column can't end up sized to content. */
.candidate-row {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: start;
    gap: 8px;
}

.candidate-fields {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.candidate-row input[type="checkbox"] {
    margin-top: 10px;
}

/* .candidate-fields input never gets width:100% in the first place (see the
   input:not(.candidate-fields input) rule above). .candidate-fields select
   still matches the shared `select, textarea { width: 100%; }` rule, so it's
   overridden here to width:auto for the same reason: it's a grid item that's
   also its own flex container, and percentage resolution against that
   nested combination is unreliable in some browsers - width:auto lets the
   flex container's default align-items:stretch size it directly instead. */
.candidate-fields select {
    width: auto;
}

/* Icons & Decorative */
.star-icon {
    position: absolute;
    top: 24px;
    right: 24px;
    font-size: 24px;
    cursor: pointer;
    color: var(--body-subtle);
}
.star-icon:hover { color: var(--heading); }

.text-success { color: var(--fg-success) !important; }
.text-danger { color: var(--fg-danger) !important; }
.text-warning { color: var(--fg-warning) !important; }

/* ==========================================================================
   Theme Toggle
   ========================================================================== */
.theme-toggle-btn {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: var(--radius-full);
    background-color: var(--neutral-primary-soft);
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-sm);
    font-size: 18px;
}
