/* ===== CSS Variables ===== */
:root {
    /* Brand Colors (from Secundarium logo) */
    --brand-navy: #1e2a4a;
    --brand-navy-light: #2b3a5f;
    --brand-gold: #c9a55c;
    --brand-gold-light: #d4b978;
    --brand-gold-dark: #b8945a;
    --brand-cream: #f8f5ef;
    --brand-cream-dark: #f0ebe0;
    --brand-olive: #8a9a7c;

    /* Colors - Light Theme */
    --color-bg: #faf8f4;
    --color-bg-secondary: #f0ebe0;
    --color-bg-tertiary: #e8e2d5;
    --color-bg-hover: #e0d9ca;

    --color-text: var(--brand-navy);
    --color-text-secondary: #3d4a66;
    --color-text-tertiary: #5a6580;
    --color-text-muted: #7a8499;
    --color-text-placeholder: #9aa3b3;

    --color-border: #ddd5c5;
    --color-border-light: #e8e2d5;

    --color-accent: var(--brand-gold);
    --color-accent-hover: var(--brand-gold-dark);

    --color-success: var(--brand-olive);
    --color-success-hover: #7a8a6c;
    --color-success-bg: #eef2ea;

    --color-danger: #c45c5c;
    --color-danger-hover: #b04a4a;
    --color-danger-bg: #f8eaea;

    --color-warning: #d4956a;
    --color-warning-hover: #c4855a;

    --color-neutral: #6b7280;
    --color-neutral-hover: #4b5563;

    --color-overlay: rgba(30, 42, 74, 0.6);
    --color-shadow: rgba(30, 42, 74, 0.08);
    --color-shadow-light: rgba(30, 42, 74, 0.12);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 20px;
    --space-2xl: 30px;
    --space-3xl: 40px;

    /* Typography */
    --font-family: 'Nunito Sans', system-ui, -apple-system, sans-serif;
    --font-size-xs: 0.8rem;
    --font-size-sm: 0.85rem;
    --font-size-base: 0.9rem;
    --font-size-md: 0.95rem;
    --font-size-lg: 1rem;
    --font-size-xl: 1.1rem;
    --font-size-2xl: 1.2rem;
    --font-size-3xl: 1.5rem;
    --font-size-4xl: 1.8rem;
    --font-size-5xl: 2rem;
    --font-size-6xl: 2.5rem;

    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 15px;
    --radius-full: 50%;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;

    /* Layout */
    --max-width: 1200px;
    --sidebar-width: 320px;
    --header-height: 50px;

    /* Scrollbar */
    --scrollbar-width: 8px;
    --scrollbar-track: var(--color-bg-tertiary);
    --scrollbar-thumb: #ccc;
    --scrollbar-thumb-hover: #bbb;
}

/* Dark Theme */
[data-theme="dark"] {
    --color-bg: #141a28;
    --color-bg-secondary: #1c2436;
    --color-bg-tertiary: #242e44;
    --color-bg-hover: #2c3852;

    --color-text: #e8e4dc;
    --color-text-secondary: #b8b4ac;
    --color-text-tertiary: #8a8680;
    --color-text-muted: #6a665f;
    --color-text-placeholder: #4a4640;

    --color-border: #2c3852;
    --color-border-light: #242e44;

    --color-accent: var(--brand-gold-light);
    --color-accent-hover: var(--brand-gold);

    --color-overlay: rgba(10, 14, 24, 0.8);
    --color-shadow: rgba(0, 0, 0, 0.4);
    --color-shadow-light: rgba(0, 0, 0, 0.3);

    --scrollbar-track: #1c2436;
    --scrollbar-thumb: #3c4862;
    --scrollbar-thumb-hover: #4c5872;
}

/* System preference */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-bg: #141a28;
        --color-bg-secondary: #1c2436;
        --color-bg-tertiary: #242e44;
        --color-bg-hover: #2c3852;

        --color-text: #e8e4dc;
        --color-text-secondary: #b8b4ac;
        --color-text-tertiary: #8a8680;
        --color-text-muted: #6a665f;
        --color-text-placeholder: #4a4640;

        --color-border: #2c3852;
        --color-border-light: #242e44;

        --color-accent: var(--brand-gold-light);
        --color-accent-hover: var(--brand-gold);

        --color-overlay: rgba(10, 14, 24, 0.8);
        --color-shadow: rgba(0, 0, 0, 0.4);
        --color-shadow-light: rgba(0, 0, 0, 0.3);

        --scrollbar-track: #1c2436;
        --scrollbar-thumb: #3c4862;
        --scrollbar-thumb-hover: #4c5872;
    }
}


/* ===== Reset ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}


/* ===== Base ===== */
body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100dvh;
    line-height: 1.5;
}

.app {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-xl);
}


/* ===== Header ===== */
.top-header {
    position: sticky;
    top: 0;
    background: var(--color-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: calc(var(--space-xl) * -1) calc(var(--space-xl) * -1) var(--space-xl);
    padding: 10px var(--space-xl);
    z-index: 200;
}

nav {
    display: flex;
    gap: 24px;
}

.nav-btn {
    padding: var(--space-sm) var(--space-xs);
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: var(--font-size-md);
    font-family: var(--font-family);
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
    font-weight: var(--font-weight-semibold);
}


.nav-btn:hover {
    color: var(--color-text);
}

.nav-btn.active {
    color: var(--color-text);
}

.settings-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    line-height: 0.9;
    flex-shrink: 0;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.settings-btn:hover {
    background: var(--color-bg-hover);
}

.settings-btn.active {
    background: var(--color-accent);
    color: white;
}


/* ===== Views ===== */
.view {
    display: none;
}

.view.active {
    display: block;
}


/* ===== Two Column Layout ===== */
.two-column-layout {
    display: flex;
    gap: var(--space-2xl);
    height: calc(100dvh - 100px);
}

/* Grammar/Cheatsheets/Dialogues: scrollable content, no fixed height */
#grammar-view .two-column-layout,
#cheatsheets-view .two-column-layout,
#dialogues-view .two-column-layout {
    height: auto;
}

.words-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.word-details {
    flex: 1;
    background: var(--color-bg);
    padding: var(--space-2xl);
    overflow-y: auto;
    overflow-x: hidden;
}

.word-details-placeholder {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-2xl);
}


/* ===== Filters ===== */
.filters-row {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: 10px;
}

.filter-select,
.filter-input {
    flex: 1;
    height: 36px;
    padding: 0 var(--space-md);
    border: none;
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    background: var(--color-bg-secondary);
    color: var(--color-text);
    border-radius: var(--radius-md);
    min-width: 0;
}

.filter-select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

[data-theme="dark"] .filter-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23aaa' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .filter-select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23aaa' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    }
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
}

.filter-input::placeholder {
    color: var(--color-text-placeholder);
}

.filter-select:disabled {
    opacity: 0.5;
    cursor: default;
}

.segmented-control {
    display: flex;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    height: 36px;
    padding: 3px;
    gap: 2px;
    flex-shrink: 0;
}

.segmented-control .segment {
    flex: 1;
    padding: 0 10px;
    border: none;
    background: transparent;
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    cursor: pointer;
    color: var(--color-text-secondary);
    border-radius: var(--radius-sm);
}

.segmented-control .segment:hover {
    color: var(--color-text);
}

.segmented-control .segment.active {
    background: var(--color-bg);
    color: var(--color-accent);
    font-weight: var(--font-weight-medium);
}

.segmented-control.disabled {
    opacity: 0.5;
}

.segmented-control.disabled .segment {
    cursor: default;
}


/* ===== Words List ===== */
.words-list {
    background: var(--color-bg);
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--color-border);
}

.word-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-border-light);
    cursor: pointer;
    transition: background-color var(--transition-normal);
}

.word-item:hover {
    background: var(--color-bg-secondary);
}

.word-item.selected {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
}

.word-item:last-child {
    border-bottom: none;
}

.word-item .word-main {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
}

.word-item .spanish {
    font-weight: var(--font-weight-medium);
    color: var(--color-text);
    font-size: var(--font-size-base);
}

.word-item .russian {
    color: var(--color-text-tertiary);
    font-size: var(--font-size-sm);
}

.word-item.learned::after {
    content: '\2713';
    color: var(--color-success);
    font-weight: bold;
    font-size: var(--font-size-lg);
    flex-shrink: 0;
}


/* ===== Word Details ===== */
.word-details-top {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 1rem;
}

.word-details-top .word-image-container {
    flex-shrink: 0;
    width: 160px;
    height: 160px;
}

.word-details-top .word-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.word-details-top .word-image-container.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
}

.word-details-top .word-image-container.placeholder::before {
    content: '?';
    font-size: 3rem;
    color: var(--color-text-placeholder);
    font-weight: 300;
}

.word-details-top .word-image-container.placeholder img {
    display: none;
}

.word-info {
    flex: 1;
    min-width: 0;
}

.word-header {
    display: flex;
    align-items: baseline;
    gap: var(--space-lg);
    margin-bottom: 10px;
}

.word-header .sound-btn--lg {
    align-self: center;
    transform: translateY(4px);
}

.word-details-content h2 {
    font-size: var(--font-size-6xl);
    color: var(--color-text);
    margin: 0;
}

.detail-translation {
    font-size: var(--font-size-3xl);
    color: var(--color-accent);
    margin-bottom: 10px;
}

.detail-gender {
    font-size: var(--font-size-lg);
    color: var(--color-text-tertiary);
    margin-bottom: var(--space-xl);
    font-style: italic;
}


/* ===== Detail Sections ===== */
.detail-section {
    padding-top: var(--space-lg);
    margin-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
}

.detail-section:first-of-type {
    padding-top: 0;
    margin-top: 0;
    border-top: none;
}

.section-title {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-secondary);
    margin: 0 0 var(--space-md) 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}


/* ===== Sound Buttons ===== */
.detail-sound-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--color-bg-tertiary);
    color: var(--color-text);
    border-radius: var(--radius-full);
    font-size: var(--font-size-base);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding-left: 2px;
    flex-shrink: 0;
}

.detail-sound-btn:hover {
    background: var(--color-bg-hover);
}

.detail-sound-btn:active,
.card-sound-btn:active,
.example-sound:active {
    transform: scale(0.9);
}

.detail-sound-btn.playing,
.card-sound-btn.playing,
.example-sound.playing {
    color: var(--brand-gold);
}

.detail-sound-btn.playing::after,
.card-sound-btn.playing::after,
.example-sound.playing::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-full);
    background: conic-gradient(var(--brand-gold) var(--progress, 0%), transparent 0%);
    mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
    animation: progress-fill var(--audio-duration, 1s) linear forwards;
}

@keyframes progress-fill {
    from { --progress: 0%; }
    to { --progress: 100%; }
}

@property --progress {
    syntax: '<percentage>';
    inherits: false;
    initial-value: 0%;
}

.sound-loading.loading {
    pointer-events: none;
    border-color: transparent;
    color: transparent;
}

.sound-loading.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid var(--color-bg-hover);
    border-top-color: var(--color-text);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.sound-loading.disabled,
.example-sound.disabled {
    pointer-events: none;
    opacity: 0.4;
}

.example-sound {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    background: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
    border-radius: var(--radius-full);
    font-size: 0.65rem;
    cursor: pointer;
    margin-right: var(--space-sm);
    vertical-align: middle;
    position: relative;
    padding-left: 2px;
}

.example-sound:hover {
    background: var(--color-bg-hover);
}

.example-sound.loading {
    pointer-events: none;
    color: transparent;
}

.example-sound.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid var(--color-bg-hover);
    border-top-color: var(--color-text);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}


/* ===== Examples List ===== */
.examples-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.examples-list li {
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--color-border-light);
    color: var(--color-text-secondary);
    line-height: 1.5;
}

.examples-list li:last-child {
    border-bottom: none;
}

.examples-list strong {
    color: var(--color-accent);
    font-weight: var(--font-weight-semibold);
}


/* ===== Conjugation ===== */
.conjugation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.conjugation-header .section-title {
    margin: 0;
}

.conjugation-label {
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    font-size: var(--font-size-base);
}

.tense-toggle {
    display: flex;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    padding: 2px;
}

.tense-btn {
    padding: 5px var(--space-md);
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-size-xs);
    font-family: var(--font-family);
    color: var(--color-text-secondary);
    transition: all var(--transition-fast);
}

.tense-btn:hover {
    color: var(--color-text);
}

.tense-btn.active {
    background: var(--color-bg);
    color: var(--color-text);
    box-shadow: 0 1px 3px var(--color-shadow-light);
}

.conjugation-table {
    width: 100%;
    border-collapse: collapse;
}

.conjugation-table td {
    padding: 10px var(--space-sm);
    border-bottom: 1px solid var(--color-border-light);
}

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

.conjugation-table .pronoun {
    color: var(--color-text-tertiary);
    font-size: var(--font-size-base);
    width: 25%;
}

.conjugation-table td:nth-child(2),
.conjugation-table td:nth-child(4) {
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}


/* Speakable Spanish text */
.es {
    cursor: pointer;
    transition: color 0.15s;
}

.es:hover {
    color: var(--color-success);
}

.es.loading {
    color: var(--color-success);
    animation: pulse-text 0.6s ease-in-out infinite;
}

@keyframes pulse-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}


/* ===== Buttons ===== */
.btn {
    padding: var(--space-lg) var(--space-3xl);
    border: none;
    font-size: var(--font-size-xl);
    font-family: var(--font-family);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.btn-small {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
}

.btn-show {
    background: var(--color-text);
    color: var(--color-bg);
}

.btn-show:hover {
    opacity: 0.85;
}

.btn-start-learn,
.btn-restart,
.btn-check {
    background: var(--color-accent);
    color: white;
}

.btn-start-learn:hover,
.btn-restart:hover,
.btn-check:hover {
    background: var(--color-accent-hover);
}

.btn-dont-know {
    background: var(--color-warning);
    color: white;
}

.btn-dont-know:hover {
    background: var(--color-warning-hover);
}

.btn-know {
    background: var(--color-success);
    color: white;
}

.btn-know:hover {
    background: var(--color-success-hover);
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-danger:hover {
    background: var(--color-danger-hover);
}

.btn-finish {
    position: absolute;
    right: var(--space-xl);
    padding: 10px var(--space-xl);
    background: var(--color-neutral);
    color: white;
}

.btn-finish:hover {
    background: var(--color-neutral-hover);
}


/* ===== Learn Setup ===== */
.learn-setup {
    background: var(--color-bg);
    padding: var(--space-3xl);
    max-width: 400px;
    margin: var(--space-3xl) auto;
    text-align: center;
}

.learn-setup h2 {
    color: var(--color-text);
    margin-bottom: var(--space-2xl);
}

.setup-row {
    margin-bottom: var(--space-xl);
    text-align: left;
}

.setup-row label {
    display: block;
    margin-bottom: var(--space-sm);
    color: var(--color-text-secondary);
    font-weight: var(--font-weight-medium);
}

.setup-row select {
    width: 100%;
    height: 36px;
    padding: 0 var(--space-md);
    padding-right: 32px;
    border: none;
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    background: var(--color-bg-secondary);
    color: var(--color-text);
    border-radius: var(--radius-md);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

[data-theme="dark"] .setup-row select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23aaa' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .setup-row select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23aaa' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    }
}

.setup-row select:focus {
    outline: none;
}

.btn-start-learn {
    margin-top: var(--space-xl);
    width: 100%;
}


/* ===== Learn Header (bottom bar) ===== */
.learn-header {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--space-lg) var(--space-xl);
    z-index: 100;
    border-top: 1px solid var(--color-border);
    gap: var(--space-lg);
}

.learn-progress {
    position: absolute;
    left: var(--space-xl);
    font-size: var(--font-size-lg);
    color: var(--color-text-secondary);
    font-weight: var(--font-weight-medium);
}

.learn-exit-btn {
    position: absolute;
    right: var(--space-lg);
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 14px;
    cursor: pointer;
    padding: 8px;
    line-height: 1;
    transition: color 0.2s;
    opacity: 0.6;
}

.learn-exit-btn:hover {
    opacity: 1;
}

.learn-controls {
    display: flex;
    gap: 10px;
}

.learn-controls .btn {
    padding: var(--space-md) var(--space-2xl);
    font-size: var(--font-size-lg);
    white-space: nowrap;
}

.learn-controls .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.learn-controls .btn-next {
    background: var(--color-accent);
    color: white;
}

.learn-controls .btn-next:hover {
    background: var(--color-accent-hover);
}

.learn-controls .btn-hint {
    background: var(--color-bg-secondary);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

.learn-controls .btn-hint:hover {
    background: var(--color-border);
}

.write-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-bg);
    padding: var(--space-lg) var(--space-xl);
    border-top: 1px solid var(--color-border);
    justify-content: center;
    z-index: 100;
}

.write-controls .btn {
    flex: 0 0 auto;
}

.write-controls .learn-exit-btn {
    position: absolute;
    right: var(--space-lg);
}

#learn-view.active {
    padding-bottom: 80px;
}


/* ===== Cards ===== */
.card-container {
    margin-bottom: var(--space-2xl);
}

.card {
    width: 100%;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-xl);
    background: var(--color-bg);
    padding: var(--space-3xl) var(--space-xl);
    position: relative;
}

.card-word-row {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.card-sound-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--color-bg-tertiary);
    color: var(--color-text);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xl);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    padding-left: 2px;
}

.card-sound-btn:hover {
    background: var(--color-bg-hover);
}

.card .word {
    font-size: var(--font-size-6xl);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}

.card .translation {
    font-size: var(--font-size-4xl);
    color: var(--color-accent);
    display: none;
}

.card .translation.visible {
    display: block;
}

.card-image-container {
    width: 120px;
    height: 120px;
    margin: 1rem 0;
}

.card-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity var(--transition-slow);
}

.card-image-container.visible img {
    opacity: 1;
}

.card-image-container.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-image-container.placeholder::before {
    content: '?';
    font-size: var(--font-size-6xl);
    color: var(--color-text-placeholder);
    font-weight: 300;
    opacity: 0;
    transition: opacity var(--transition-slow);
}

.card-image-container.visible.placeholder::before {
    opacity: 1;
}

.card-image-container.placeholder img {
    display: none;
}

.card-conjugation {
    display: none;
    width: 100%;
    margin-top: var(--space-lg);
}

.card-conjugation.visible {
    display: block;
}

.card-examples {
    display: none;
    width: 100%;
    text-align: left;
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
    margin-top: 10px;
}

.card-examples.visible {
    display: block;
}

.card-examples p {
    color: var(--color-text-secondary);
    font-size: var(--font-size-lg);
    margin-bottom: var(--space-sm);
    line-height: 1.4;
}

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

.card-examples strong {
    color: var(--color-accent);
    font-weight: var(--font-weight-semibold);
}


/* ===== Answer Buttons ===== */
.answer-buttons {
    display: flex;
    gap: var(--space-xl);
    width: 100%;
    justify-content: center;
}

.btn-dont-know,
.btn-know {
    flex: 1;
    max-width: 150px;
}


/* ===== Learn Complete ===== */
.learn-complete {
    text-align: center;
    padding: var(--space-3xl);
    background: var(--color-bg);
}

.learn-complete h2 {
    color: var(--color-text);
    margin-bottom: var(--space-lg);
}

.learn-complete p {
    font-size: var(--font-size-2xl);
    color: var(--color-text-secondary);
}


/* ===== Write Mode ===== */
.write-card {
    align-items: center;
}

.write-card .card-word-row {
    gap: var(--space-md);
    justify-content: center;
}

.write-card .card-examples {
    text-align: center;
}

.write-card .card-examples p {
    justify-content: center;
}

.write-input {
    width: 100%;
    max-width: 300px;
    height: 56px;
    padding: 0 var(--space-lg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-semibold);
    text-align: center;
    background: var(--color-bg);
    color: var(--color-text);
}

.write-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.write-input.correct {
    border-color: var(--color-success);
    background: var(--color-success-bg);
}

.write-input.incorrect {
    border-color: var(--color-danger);
    background: var(--color-danger-bg);
}

.write-card .sound-btn.disabled {
    opacity: 0.3;
    pointer-events: none;
}

.write-user-answer {
    color: var(--color-danger);
    font-size: var(--font-size-md);
    background: var(--color-danger-bg);
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-sm);
    margin-top: var(--space-sm);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Match Mode ===== */
.match-container {
    padding: var(--space-3xl) var(--space-xl);
    max-width: 700px;
    margin: 0 auto;
}

.match-columns {
    display: flex;
    gap: var(--space-3xl);
    justify-content: center;
}

.match-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 200px;
}

.match-item {
    padding: var(--space-lg) var(--space-xl);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: center;
    font-size: var(--font-size-lg);
    transition: transform 0.1s;
    user-select: none;
    color: var(--color-text);
}

.match-item:hover {
    background: var(--color-bg-hover);
}

.match-item.selected {
    background: var(--color-accent);
    color: white;
}

.match-item.matched {
    background: var(--color-success);
    color: white;
    cursor: default;
    opacity: 0.7;
}

.match-item.wrong {
    animation: shake 0.3s;
    background: var(--color-danger);
    color: white;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}


/* ===== Stats ===== */
.stats-container {
    max-width: 500px;
    padding: var(--space-xl);
}

.stats-container h2 {
    margin-bottom: var(--space-2xl);
    color: var(--color-text);
}

.stats-container h3 {
    margin: var(--space-2xl) 0 var(--space-lg);
    color: var(--color-text);
    font-size: var(--font-size-lg);
}

.stats-overview {
    display: flex;
    gap: var(--space-xl);
}

.stats-card {
    flex: 1;
    background: var(--color-bg-secondary);
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
    text-align: center;
}

.stats-number {
    font-size: var(--font-size-5xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
}

.stats-label {
    color: var(--color-text-secondary);
    font-size: var(--font-size-base);
    margin-top: 5px;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--color-border);
}

.stats-row:last-child {
    border-bottom: none;
}

.stats-row-name {
    color: var(--color-text);
}

.stats-row-value {
    color: var(--color-text-secondary);
    font-weight: var(--font-weight-medium);
}


/* ===== Settings ===== */
.settings-page {
    max-width: 500px;
    padding: var(--space-xl);
}

.settings-page h2 {
    margin-bottom: var(--space-2xl);
    color: var(--color-text);
}

.settings-section {
    margin-bottom: var(--space-2xl);
    padding-bottom: var(--space-xl);
    border-bottom: 1px solid var(--color-border);
}

.settings-section:last-child {
    border-bottom: none;
}

.settings-section h3 {
    margin-bottom: var(--space-lg);
    color: var(--color-text);
    font-size: var(--font-size-lg);
}

.setting-row {
    margin-bottom: 10px;
}

.setting-row label {
    display: block;
    margin-bottom: 5px;
    color: var(--color-text-secondary);
    font-size: var(--font-size-base);
}

.setting-row input:not([type="range"]):not([type="checkbox"]),
.setting-row select {
    width: 100%;
    height: 36px;
    padding: 0 var(--space-md);
    border: none;
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    background: var(--color-bg-secondary);
    color: var(--color-text);
    border-radius: var(--radius-md);
}

.setting-row input[type="range"] {
    width: 100%;
    accent-color: var(--color-accent);
}

.setting-row select {
    cursor: pointer;
    padding-right: 32px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

[data-theme="dark"] .setting-row select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23aaa' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .setting-row select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23aaa' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    }
}

.setting-row input:focus,
.setting-row select:focus {
    outline: none;
}

.setting-hint {
    font-size: var(--font-size-sm);
    color: var(--color-text-tertiary);
    margin-bottom: var(--space-xl);
}

.checkbox-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.checkbox-row label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--color-accent);
}

.theme-selector {
    display: flex;
    gap: 8px;
}

.theme-option {
    padding: 12px 20px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    transition: all var(--transition-fast);
}

.theme-option:hover {
    border-color: var(--color-text-tertiary);
    color: var(--color-text);
}

.theme-option.active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: white;
}

.btn-clear-cache {
    background: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
}

.btn-clear-cache:hover {
    background: var(--color-bg-hover);
}


/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--color-overlay);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--color-bg);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    max-width: 500px;
    width: 100%;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-close {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-lg);
    width: 32px;
    height: 32px;
    border: none;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-full);
    font-size: var(--font-size-3xl);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    color: var(--color-text-secondary);
}

.modal-close:hover {
    background: var(--color-bg-hover);
}

.modal-content h2 {
    font-size: var(--font-size-5xl);
    color: var(--color-text);
    margin: 0;
}

.modal-content .word-header {
    margin-bottom: 10px;
}

.modal-content .detail-translation {
    font-size: var(--font-size-2xl);
    margin-bottom: 25px;
}

.modal-content h3 {
    font-size: var(--font-size-lg);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-lg);
    text-transform: uppercase;
    letter-spacing: 1px;
}


/* ===== Scrollbar ===== */
.words-list::-webkit-scrollbar,
.word-details::-webkit-scrollbar,
.modal-content::-webkit-scrollbar,
.dialogues-sidebar::-webkit-scrollbar {
    width: var(--scrollbar-width);
}

.words-list::-webkit-scrollbar-track,
.word-details::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track,
.dialogues-sidebar::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: var(--space-xs);
}

.words-list::-webkit-scrollbar-thumb,
.word-details::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb,
.dialogues-sidebar::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--space-xs);
}

.words-list::-webkit-scrollbar-thumb:hover,
.word-details::-webkit-scrollbar-thumb:hover,
.modal-content::-webkit-scrollbar-thumb:hover,
.dialogues-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}


/* ===== Responsive ===== */
@media (max-width: 768px) {
    .app {
        padding: 10px;
    }

    .top-header {
        margin: -10px -10px 10px;
        padding: 8px 10px;
        gap: 8px;
    }

    nav {
        flex: 1;
        gap: 4px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    nav::-webkit-scrollbar {
        display: none;
    }

    .nav-btn {
        padding: 6px 10px;
        font-size: var(--font-size-sm);
        white-space: nowrap;
        flex-shrink: 0;
    }

    .settings-btn {
        width: 38px;
        height: 38px;
        font-size: 1.4rem;
    }

    .two-column-layout {
        flex-direction: column;
        height: auto;
    }

    .words-sidebar {
        width: 100%;
    }

    /* Mobile: list mode (default) */
    .words-list {
        height: calc(100dvh - 180px);
        overflow-y: auto;
    }

    .word-details {
        display: none;
    }

    /* Mobile: page mode */
    .mobile-page-mode .words-sidebar {
        display: none;
    }

    .mobile-page-mode .word-details {
        display: block;
        border: none;
        padding: 0 var(--space-md);
    }

    .mobile-page-mode .word-details-placeholder {
        display: none !important;
    }

    .mobile-page-mode .word-details-content {
        display: block !important;
    }

    /* Mobile word navigation */
    .mobile-word-nav {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: var(--space-md) 0;
        margin-bottom: var(--space-md);
        border-bottom: 1px solid var(--color-border);
    }

    .mobile-word-nav .word-counter {
        color: var(--color-text-secondary);
        font-size: var(--font-size-sm);
    }

    .mobile-word-nav .nav-arrow {
        width: 40px;
        height: 40px;
        border: none;
        background: var(--color-bg-secondary);
        border-radius: var(--radius-full);
        cursor: pointer;
        font-size: var(--font-size-lg);
        color: var(--color-text-secondary);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-word-nav .nav-arrow:hover {
        background: var(--color-bg-hover);
        color: var(--color-text);
    }

    .mobile-word-nav .nav-arrow:disabled {
        opacity: 0.3;
        cursor: not-allowed;
    }
}

/* Hide mobile elements on desktop */
.mobile-word-nav,
.btn-back-to-list,
.mobile-detail-tabs {
    display: none;
}

/* Mobile detail tabs */
.mobile-detail-tabs {
    display: none;
    gap: 0;
    margin-bottom: var(--space-md);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    padding: 3px;
}

.mobile-tab {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    font-weight: var(--font-weight-medium);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.mobile-tab:hover {
    color: var(--color-text);
}

.mobile-tab.active {
    background: var(--color-bg);
    color: var(--color-accent);
}

@media (max-width: 768px) {
    /* Show tabs on mobile when viewing verbs */
    .mobile-page-mode .mobile-detail-tabs.visible {
        display: flex;
    }

    /* Hide section titles on mobile (tabs replace them) */
    .mobile-page-mode .mobile-hide {
        display: none;
    }

    /* Hide inactive tab content */
    .mobile-page-mode [data-tab-content].tab-hidden {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .mobile-page-mode .btn-back-to-list {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        padding: var(--space-lg);
        background: var(--color-bg);
        border: none;
        border-top: 1px solid var(--color-border);
        color: var(--color-text-secondary);
        font-size: var(--font-size-base);
        cursor: pointer;
        z-index: 100;
    }

    .mobile-page-mode .btn-back-to-list:hover {
        background: var(--color-bg-secondary);
        color: var(--color-text);
    }

    /* Отступ снизу для контента, чтобы кнопка не перекрывала */
    .mobile-page-mode .word-details-content {
        padding-bottom: 60px;
    }
}

@media (max-width: 480px) {
    .word-details-top {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .word-details-top .word-image-container {
        width: 140px;
        height: 140px;
    }

    .word-info {
        width: 100%;
    }

    .match-container {
        padding: var(--space-lg) var(--space-sm);
    }

    .match-columns {
        gap: var(--space-md);
    }

    .match-column {
        min-width: 0;
        flex: 1;
    }

    .match-item {
        padding: var(--space-md) var(--space-sm);
        font-size: var(--font-size-base);
    }
}

/* Book-style page turn animations for mobile word navigation */
.word-details {
    position: relative;
    overflow: hidden;
}

.word-details-content {
    position: relative;
    z-index: 2;
    background: var(--color-bg);
}

.word-details-content.page-animating {
    transition: transform 0.3s ease-out;
}

.word-details-content.page-from-right {
    transform: translateX(100%);
}

.word-details-content.page-from-left {
    transform: translateX(-100%);
}

/* Клон старой страницы */
.word-details-content.page-old {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.word-details-content.page-old.page-exit-left {
    transform: translateX(-30%);
    opacity: 0.5;
}

.word-details-content.page-old.page-exit-right {
    transform: translateX(30%);
    opacity: 0.5;
}

/* Тень на новой странице для эффекта глубины */
.word-details-content.page-animating::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 20px;
    pointer-events: none;
    z-index: 10;
}

.word-details-content.page-animating.page-from-right::before,
.word-details-content.page-animating:not(.page-from-left)::before {
    left: -20px;
    background: linear-gradient(to right, transparent, rgba(0,0,0,0.1));
}

.word-details-content.page-animating.page-from-left::before {
    right: -20px;
    left: auto;
    background: linear-gradient(to left, transparent, rgba(0,0,0,0.1));
}

/* ===== Dialogue Styles ===== */
.dialogues-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    position: sticky;
    top: 70px;
    max-height: calc(100dvh - 90px);
    overflow-y: auto;
    padding: 0;
}

.dialogues-nav {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.dialogues-nav-item {
    padding: 5px 10px;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    border-radius: var(--radius-sm);
    line-height: 1.3;
}

.dialogues-nav-item:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

.dialogues-nav-item.active {
    background: var(--color-bg-secondary);
    color: var(--color-text);
    font-weight: var(--font-weight-semibold);
}

.dialogues-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
    padding: 0 var(--space-lg) var(--space-lg) 0;
}

@media (max-width: 768px) {
    .dialogues-sidebar {
        width: 100%;
        position: static;
        margin-bottom: var(--space-lg);
        max-height: none;
    }

    .dialogues-nav {
        flex-direction: row;
        overflow-x: auto;
        gap: var(--space-sm);
        padding-bottom: var(--space-sm);
    }

    .dialogues-nav-item {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

.dialogue-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-xl);
    overflow: hidden;
}

.dialogue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
    gap: var(--space-md);
}

.dialogue-card h2 {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    margin: 0;
    flex: 1;
}

.dialogue-play-all {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    border: 2px solid var(--color-accent);
    background: var(--color-bg);
    color: var(--color-accent);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.dialogue-play-all:hover {
    background: var(--color-accent);
    color: white;
}

.dialogue-play-all:active {
    transform: scale(0.95);
}

.dialogue-play-all.playing {
    background: var(--color-error);
    border-color: var(--color-error);
    color: white;
    font-size: 0.9rem;
}

.dialogue-line-playing {
    background: var(--color-accent-bg);
    margin: 0 calc(var(--space-lg) * -1);
    padding-left: var(--space-lg) !important;
    padding-right: var(--space-lg) !important;
}

.dialogue-card .dialogue {
    margin-bottom: 0;
    border-radius: 0;
}

.dialogue {
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.dialogue-line {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    gap: var(--space-sm) var(--space-md);
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--color-border);
    align-items: start;
}

.dialogue-line:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.dialogue-line:first-child {
    padding-top: 0;
}

.dialogue-speaker {
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

.dialogue-es {
    color: var(--color-text);
    font-weight: var(--font-weight-medium);
}

.dialogue-ru {
    grid-column: 2 / 4;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-style: italic;
    margin-top: var(--space-xs);
}

.dialogue-sound {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--color-bg);
    color: var(--color-accent);
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition-fast);
    position: relative;
    flex-shrink: 0;
}

.dialogue-sound:hover {
    background: var(--color-bg-hover);
    color: var(--color-accent-hover);
}

.dialogue-sound:active {
    transform: scale(0.9);
}

.dialogue-sound.playing {
    color: var(--brand-gold);
}

.dialogue-sound.playing::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-full);
    background: conic-gradient(var(--brand-gold) var(--progress, 0%), transparent 0%);
    mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
    animation: progress-fill var(--audio-duration, 1s) linear forwards;
}

.dialogue-sound.loading {
    pointer-events: none;
    color: transparent;
}

.dialogue-sound.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid transparent;
    border-top-color: var(--color-accent);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

.dialogue-sound.disabled {
    pointer-events: none;
    opacity: 0.4;
}

/* Mobile dialogue layout */
@media (max-width: 768px) {
    .dialogue-line {
        grid-template-columns: 70px 1fr auto;
        gap: var(--space-xs) var(--space-sm);
    }

    .dialogue-speaker {
        font-size: var(--font-size-xs);
    }

    .dialogue-es {
        font-size: var(--font-size-sm);
    }

    .dialogue-ru {
        font-size: var(--font-size-xs);
    }

    .dialogue-sound {
        width: 26px;
        height: 26px;
        font-size: 11px;
    }
}

/* ==================== Unified Sound Buttons ==================== */
/*
 * Все кнопки одинаковые:
 * - Серый фон, чёрная иконка
 * - Loading: спиннер по границе
 * - Playing: зелёная иконка, зелёная полоса прогресса, фон серый
 */
.sound-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--color-bg-tertiary);
    color: var(--color-text);
    border-radius: var(--radius-full);
    cursor: pointer;
    position: relative;
    transition: background 0.15s, color 0.15s, transform 0.1s;
    padding-left: 2px;
    flex-shrink: 0;
    user-select: none;
}

.sound-btn:hover {
    background: var(--color-bg-hover);
    color: var(--color-success);
}

.sound-btn:active {
    transform: scale(0.9);
}

/* Small - inline examples */
.sound-btn--sm {
    width: 22px;
    height: 22px;
    font-size: 0.65rem;
    margin-right: var(--space-sm);
    vertical-align: middle;
}

/* Large - cards, details */
.sound-btn--lg {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
}

/* Loading state - pulsing animation with green icon */
.sound-btn.loading {
    pointer-events: none;
    color: var(--brand-gold);
    animation: pulse-btn 0.6s ease-in-out infinite;
}

@keyframes pulse-btn {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Playing state - green icon, green progress ring, gray background */
.sound-btn.playing {
    color: var(--brand-gold);
}

.sound-btn.playing::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(var(--brand-gold) var(--progress, 0%), transparent 0%);
    mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
    animation: progress-fill var(--audio-duration, 1s) linear forwards;
}

/* Thicker progress ring for large buttons */
.sound-btn--lg.playing::after {
    mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
}

.sound-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.8); opacity: 0; }
}

/* ==================== About Page ==================== */
.about-page {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--space-xl);
    text-align: center;
}

.about-logo {
    margin-bottom: var(--space-xl);
}

.about-logo img {
    max-width: 280px;
    width: 100%;
    height: auto;
    border-radius: var(--radius-lg);
}

.about-page h1 {
    font-size: var(--font-size-5xl);
    color: var(--brand-navy);
    margin: 0 0 var(--space-sm);
    font-weight: var(--font-weight-bold);
}

[data-theme="dark"] .about-page h1,
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .about-page h1 {
        color: var(--brand-gold-light);
    }
}

.about-tagline {
    font-size: var(--font-size-lg);
    color: var(--brand-gold);
    font-weight: var(--font-weight-medium);
    margin-bottom: var(--space-2xl);
    letter-spacing: 2px;
}

.about-section {
    text-align: left;
    margin-bottom: var(--space-2xl);
    padding-bottom: var(--space-xl);
    border-bottom: 1px solid var(--color-border);
}

.about-section:last-of-type {
    border-bottom: none;
}

.about-section h2 {
    font-size: var(--font-size-xl);
    color: var(--color-text);
    margin-bottom: var(--space-md);
    font-weight: var(--font-weight-semibold);
}

.about-section p {
    color: var(--color-text-secondary);
    line-height: 1.7;
}

.about-features {
    list-style: none;
    padding: 0;
    margin: 0;
}

.about-features li {
    padding: var(--space-sm) 0;
    color: var(--color-text-secondary);
    line-height: 1.5;
}

.about-features li strong {
    color: var(--brand-gold);
}

.about-footer {
    margin-top: var(--space-2xl);
    padding-top: var(--space-xl);
    border-top: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

/* ==================== Grammar/Cheatsheets Layout ==================== */
.grammar-page {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: var(--space-xl);
    max-width: 1000px;
    margin: 0 auto;
    padding: var(--space-xl);
}

.grammar-sidebar {
    position: sticky;
    top: 80px;
    height: fit-content;
}

.grammar-level-switch {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
}

.grammar-level-btn {
    flex: 1;
    padding: var(--space-sm);
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.grammar-level-btn:hover {
    background: var(--color-bg-hover);
}

.grammar-level-btn.active {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

.grammar-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.grammar-nav-item {
    display: block;
    padding: var(--space-sm) var(--space-md);
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    transition: var(--transition-fast);
}

.grammar-nav-item:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
}

.grammar-nav-item.active {
    background: var(--color-accent-bg);
    color: var(--color-accent);
    font-weight: var(--font-weight-medium);
}

.grammar-content {
    min-width: 0;
}

.grammar-section {
    margin-bottom: var(--space-2xl);
    padding-bottom: var(--space-xl);
    border-bottom: 1px solid var(--color-border);
    --color-text-secondary: var(--color-text);
}

.grammar-section:last-child {
    border-bottom: none;
}

.grammar-section h2 {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--space-lg);
    color: var(--color-text);
}

.grammar-section h3 {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    margin: var(--space-lg) 0 var(--space-md);
    color: var(--color-text);
}

.grammar-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--space-lg);
    font-size: var(--font-size-sm);
}

.grammar-table th,
.grammar-table td {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    border: 1px solid var(--color-border);
}

.grammar-table th {
    background: var(--color-bg-secondary);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}

.grammar-table td {
    background: var(--color-bg);
}

/* Mobile: Grammar/Cheatsheets */
@media (max-width: 768px) {
    .grammar-page {
        grid-template-columns: 1fr;
        padding: var(--space-md);
        gap: var(--space-md);
    }

    .grammar-sidebar {
        position: static;
        margin-bottom: var(--space-sm);
    }

    .grammar-nav {
        flex-direction: row;
        overflow-x: auto;
        gap: var(--space-sm);
        padding-bottom: var(--space-sm);
        -webkit-overflow-scrolling: touch;
    }

    .grammar-nav-item {
        white-space: nowrap;
        flex-shrink: 0;
        padding: var(--space-xs) var(--space-sm);
    }

    .grammar-level-switch {
        margin-bottom: var(--space-sm);
    }

    .grammar-section h2 {
        font-size: var(--font-size-xl);
    }

    .grammar-section h3 {
        font-size: var(--font-size-md);
    }

    .grammar-table {
        font-size: var(--font-size-xs);
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .grammar-table th,
    .grammar-table td {
        padding: var(--space-xs) var(--space-sm);
    }
}

/* Mobile: Dialogues improvements */
@media (max-width: 480px) {
    .dialogue-header {
        padding: var(--space-md);
    }

    .dialogue-card h2 {
        font-size: var(--font-size-md);
    }

    .dialogue {
        padding: var(--space-md);
    }

    .dialogue-line {
        grid-template-columns: 1fr auto;
        gap: var(--space-xs);
    }

    .dialogue-speaker {
        grid-column: 1 / -1;
        margin-bottom: var(--space-xs);
    }

    .dialogue-es {
        grid-column: 1;
    }

    .dialogue-ru {
        grid-column: 1 / -1;
    }

    .dialogue-line-playing {
        margin: 0 calc(var(--space-md) * -1);
        padding-left: var(--space-md) !important;
        padding-right: var(--space-md) !important;
    }
}
