/* CSS STYLES */
:root {
    --primary: #2563eb;
    --action: #047857; /* a11y-20260718: was #10b981, white text failed WCAG 1.4.3 (2.54:1) */
    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --text-main: #1f2937;
    --text-sub: #646d7b; /* a11y-20260718: was #6b7280 (4.39:1 on --bg) */
    --text-rom: #663300;
    --border-col: #eee;
    --input-bg: #fff;
    --stim-bg: #eff6ff;
    --stim-border: #dbeafe;
    --resp-bg: #ecfdf5;
    --resp-border: #a7f3d0;
    --font-scale: 1.0;
}

body.dark-mode {
    --primary: #60a5fa;
    --action: #047857; /* a11y-20260718: was #34d399, white text failed WCAG 1.4.3 */
    --bg: #111827;
    --card-bg: #1f2937;
    --text-main: #f3f4f6;
    --text-sub: #9ca3af;
    --text-rom: #fdba74;
    --border-col: #374151;
    --input-bg: #374151;
    --stim-bg: #1e3a8a;
    --stim-border: #2563eb;
    --resp-bg: #064e3b;
    --resp-border: #059669;
}

:root {
    --anki-again: #e11d48;
    --anki-hard: #b45309; /* a11y-20260718: was #d97706 (3.19:1 with white) */
    --anki-good: #047857; /* a11y-20260718: was #10b981 (2.54:1 with white) */
    --anki-easy: #2563eb;
}

* {
    box-sizing: border-box;
}

/* --- CONTENT PROTECTION: Global Select Restrictions --- */
body {
    font-family: 'Segoe UI', 'Noto Color Emoji', system-ui, sans-serif;
    letter-spacing: normal !important;
    word-spacing: normal !important;
    background: var(--bg);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 10px;
    padding-bottom: 20px;
    transition: background 0.3s, color 0.3s;

    /* Makes text selection and context menus harder on mobile */
    -webkit-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
}

/* Prevents PDF/print export of vocabulary */
@media print {
    body {
        display: none !important;
    }
}

/* --- CONTENT PROTECTION: Pseudo-Element Trick --- 
           Nutze class="protected-text" und data-text="Dein Text", 
           so text cannot be copied from the HTML node. */
.protected-text {
    color: transparent !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    pointer-events: none !important;
}

.protected-text::after {
    content: attr(data-text);
    color: var(--text-main);
    pointer-events: none;
    filter: blur(0.16em);
    letter-spacing: 0.08em;
}

body.dark-mode .protected-text::after {
    color: #f3f4f6;
}

/* ------------------------------------------------ */

/* Font Fix for Flags */
select,
option {
    font-family: 'Noto Color Emoji', 'Segoe UI', system-ui, sans-serif;
}

input,
select,
textarea {
    -webkit-user-select: text;
    user-select: text;
}

img,
a,
button,
div,
span {
    -webkit-user-drag: none;
}

body.hide-rom .js-rom {
    display: none !important;
}

.global-gear-btn {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--border-col);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
}

body.dark-mode .global-gear-btn {
    background: rgba(31, 41, 55, 0.8);
    color: #fff;
}

.global-gear-btn:hover {
    transform: rotate(45deg);
}

/* Animation for loading state */
.card.loading-audio {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.card.loading-audio::after {
    display: none !important;
    content: none !important;
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: bold;
    z-index: 100;
}

#loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Modern look: Semi-transparent white with blur */
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2500;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
}

/* Dark Mode: Dark transparent with blur */
body.dark-mode #loader-overlay {
    background: rgba(17, 24, 39, 0.7);
}

.spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--primary);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

#lblLoaderText {
    color: var(--text-sub);
    font-size: 1rem;
    max-width: 400px;
    line-height: 1.4;
    transition: opacity 0.5s;
    min-height: 3em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-track {
    width: 100%;
    max-width: 300px;
    height: 8px;
    background-color: var(--border-col);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 15px;
    margin-bottom: 5px;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary);
    width: 0%;
    transition: width 0.3s ease-out;
    border-radius: 4px;
}


#startOverlay,

#settingsOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 10px;
}
#startOverlay {
    justify-content: flex-start;
    padding-top: env(safe-area-inset-top, 20px);
}

#settingsOverlay {
    display: none;
    z-index: 2200;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
}

body.dark-mode #settingsOverlay {
    background: rgba(0, 0, 0, 0.7);
}

.start-box {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    text-align: center;
    width: 95%;
    max-width: 550px;
    border: 1px solid var(--border-col);
    margin-bottom: 20px;
    position: relative;
}

.start-box h2 {
    margin-top: 0;
    color: var(--primary);
    margin-bottom: 15px;
    font-size: 1.4rem;
}

.config-section {
    margin-bottom: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-col);
    padding-bottom: 10px;
}

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

.language-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 5px;
    width: 100%;
}

.lang-group {
    flex: 1;
}

.settings-inline-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: nowrap;
}

.mini-group {
    display: flex;
    flex-direction: column;
    width: 65px;
    flex-shrink: 0;
}

.mini-group label {
    font-size: 0.7rem;
    color: var(--text-sub);
    font-weight: 600;
    margin-bottom: 3px;
    white-space: nowrap;
}

.mini-group input {
    width: 100%;
    padding: 6px;
    border: 1px solid var(--border-col);
    background: var(--input-bg);
    color: var(--text-main);
    border-radius: 6px;
    font-size: 0.95rem;
    text-align: center !important;
}

.radio-group-container {
    flex-grow: 0;
    width: auto;
    display: flex;
    padding: 2px 10px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border-col);
    justify-content: center;
    gap: 15px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-main);
}

.radio-text-col {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.rt-main {
    font-weight: 600;
    font-size: 0.85rem;
}

.rt-sub {
    font-size: 0.7rem;
    color: var(--text-sub);
}

.input-group {
    margin-bottom: 10px;
}

.input-group label,
.lang-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-sub);
    margin-bottom: 3px;
    font-weight: 600;
}

.input-group select,
.input-group input,
.lang-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-col);
    background: var(--input-bg);
    color: var(--text-main);
    border-radius: 8px;
    font-size: 1rem;
}

.swap-btn-overlay {
    background: none;
    border: 1px solid var(--border-col);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 17px;
    cursor: pointer;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2px;
    flex-shrink: 0;
}

/* SETTINGS MODAL STYLES */
#settingsContent {
    text-align: left;
    max-height: 90vh;
    overflow-y: auto;
}

.settings-tab-header {
    display: flex;
    border-bottom: 1px solid var(--border-col);
    margin-bottom: 10px;
    margin-top: 10px;
}

.settings-tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-sub);
    border-bottom: 2px solid transparent;
    font-size: 0.85rem;
}

.settings-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.settings-tab-content {
    display: none;
}

.settings-tab-content.active {
    display: block;
}

/* SLIDER STYLING */
.slider-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.slider-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
}

.slider-value {
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--primary);
    background: var(--stim-bg);
    padding: 2px 6px;
    border-radius: 4px;
}

.slider-input {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #d1d5db;
    outline: none;
    margin-top: 5px;
}

.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.slider-input::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

body.dark-mode .slider-input {
    background: #4b5563;
}

.theme-toggle-settings {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: var(--stim-bg);
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid var(--stim-border);
}

.theme-toggle-settings label {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.9rem;
}

header {
    width: 100%;
    max-width: 600px;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    margin-bottom: 8px;
    background: var(--card-bg);
    padding: 8px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.topic-row {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-bottom: 1px solid var(--border-col);
    padding-bottom: 6px;
    margin-bottom: 2px;
}

.topic-back-btn {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: var(--action);
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    color: white;
    font-weight: 700;
    font-size: 1.4rem;
}


#lblCurrentTopic {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.95rem;
    text-align: center;
    max-width: 70%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%232f67ea' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.header-controls {
    display: flex;
    width: 100%;
    justify-content: center;
    gap: 8px;
    align-items: flex-end;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.control-group label {
    font-size: 0.65rem;
    color: var(--text-sub);
    font-weight: 600;
    margin-bottom: 2px;
}

header select {
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-col);
    background: var(--input-bg);
    color: var(--text-main);
    font-size: 15px;
    cursor: pointer;
    min-width: 90px;
    height: 32px;
}

.swap-btn-header {
    background: none;
    border: 1px solid var(--border-col);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mode-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    background: var(--border-col);
    padding: 4px;
    border-radius: 12px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.mode-controls label {
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.mode-controls input:checked+span {
    color: var(--primary);
    font-weight: 700;
}

.mode-controls input:checked+span+span {
    color: var(--primary);
    font-weight: 700;
}

.mode-icon {
    font-size: 1.1rem;
    line-height: 1;
}

#autoPlayOptions {
    width: 100%;
    text-align: center;
    padding: 5px;
    display: none;
    background: #dbeafe;
    border-radius: 8px;
    margin-top: 4px;
    border: 1px dashed #2563eb;
}

body.dark-mode #autoPlayOptions {
    background: #1e3a8a;
    border-color: #60a5fa;
}

#autoPlayOptions label {
    font-weight: bold;
    color: var(--primary);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.card {
    background: var(--card-bg);
    width: 100%;
    max-width: 550px;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 15px;
    text-align: center;
    position: relative;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-grow: 1;
}

.card-section-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px;
    border-radius: 10px;
    transition: background-color 0.2s;
    cursor: pointer;
    justify-content: center;
    align-items: center;
}

.card-section-container:active {
    background-color: transparent !important;
}


.line-row {
    padding: 10px 12px;
    border-radius: 12px;
    margin-bottom: 8px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: background-color 0.1s ease;
    border: 1px solid transparent;
}

.line-row.js-target {
    background-color: var(--stim-bg);
    border-color: var(--stim-border);
}

.line-row.js-target:active {
    filter: brightness(0.95);
}

#responseContainer .line-row.js-target {
    background-color: var(--resp-bg);
    border-color: var(--resp-border);
}

.line-text.target {
    font-size: calc(1.4rem * var(--font-scale));
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 2px;
}

.line-row.js-native {
    background-color: #f9fafb;
    border-color: #f3f4f6;
}

body.dark-mode .line-row.js-native {
    background-color: #374151;
    border-color: #4b5563;
}

.line-row.js-native:active {
    background-color: #e5e7eb;
}

.line-text.native {
    font-size: calc(1.05rem * var(--font-scale));
    color: var(--text-sub);
    font-style: italic;
}

/* Active sentence: Pop-out effect */
.active-sentence {
    background-color: #fffde7 !important;
    /* Helles Gelb */
    color: #000 !important;
    border: 2px solid #fbbf24 !important;
    /* Goldener Rand */
    transform: scale(1.05) !important;
    /* 5% larger */
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15) !important;
    /* Nice shadow */
    z-index: 50;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* Sprung-Effekt */
}

body.dark-mode .active-sentence {
    background-color: #312e81 !important;
    /* Strong dark blue */
    border-color: #fbbf24 !important;
    /* Goldener Rand bleibt */
    color: #fff !important;
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.4) !important;
    /* Goldenes Leuchten */
}

.line-row.js-extra {
    background-color: #f5f3ff;
    border-color: #ede9fe;
}

body.dark-mode .line-row.js-extra {
    background-color: #4c1d95;
    border-color: #6d28d9;
}

.line-row.js-extra:active {
    background-color: #ddd6fe;
}

.line-text.extra {
    font-size: calc(0.9rem * var(--font-scale));
    color: var(--text-sub);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.extra-rom {
    font-size: calc(0.8rem * var(--font-scale));
    color: var(--text-rom);
    display: block;
}

.line-row.js-rom {
    background-color: transparent !important;
    border: none !important;
    padding-top: 0;
    padding-bottom: 2px;
    margin-top: -8px;
    margin-bottom: 10px;
}

.line-text.rom {
    font-size: calc(0.9rem * var(--font-scale));
    color: var(--text-rom);
    font-weight: 500;
}

.line-row.js-rom .line-icon {
    display: none !important;
}

.line-text {
    flex-grow: 0;
    text-align: center;
    line-height: 1.3;
    color: var(--text-main);
}

.line-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    transition: all 0.2s;
}

body.dark-mode .line-icon {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
}

.line-icon:active {
    transform: scale(0.95);
    background: #dbeafe;
}

.line-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.mic-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    flex-shrink: 0;
}

body[data-mode="cloze"] .mic-wrapper,
body[data-mode="wordorder"] .mic-wrapper,
body[data-mode="autoplay"] .mic-wrapper {
    display: none !important;
}

.mic-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-sub);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.line-icon.mic-btn {
    margin-left: 0;
    color: var(--text-sub);
    width: 34px;
    height: 34px;
}

.line-icon.mic-btn.recording {
    color: #ef4444;
    background: #fee2e2;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.mic-label.recording {
    color: #ef4444;
}

.cloze-gap {
    color: var(--primary);
    font-weight: bold;
    background: #e0f2fe;
    padding: 2px 8px;
    border-radius: 4px;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
    min-width: 60px;
}

body.dark-mode .cloze-gap {
    background: #1e40af;
}

.cloze-solved {
    color: white;

    background-color: var(--action);
    transition: width 0.4s ease-out, background-color 0.4s ease;

    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
}

/* =========================
           WRITE MODE (Typing / "Schreiben")
           -------------------------
           This mode turns a sentence into a small spelling exercise:
           - One key word becomes a blank (most important or 2nd most important word, picked randomly)
           - The learner fills the missing word by clicking letters in a mini on-screen keyboard
           - We also add a couple of random distractor letters
           ========================= */
.write-gap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 6px;
    border: 2px dashed var(--primary);
    background: rgba(37, 99, 235, 0.12);
    min-width: 60px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

body.dark-mode .write-gap {
    background: rgba(59, 130, 246, 0.20);
}

.write-gap.correct {
    border-style: solid;
    background: rgba(16, 185, 129, 0.18);
}

.write-gap.wrong {
    border-style: solid;
    background: rgba(239, 68, 68, 0.14);
}


.write-keyboard {
            width: 100%;
            display: flex;
            flex-wrap: wrap; /* Keys wrap neatly to the next line */
            gap: 6px;
            margin-top: 10px;
            justify-content: center;
            padding: 8px 10px;
            border-radius: 12px;
            border: 1px solid var(--border-col);
            background: rgba(2, 132, 199, 0.04);
        }
		

body.dark-mode .write-keyboard {
    background: rgba(255, 255, 255, 0.03);
}

.write-key {
    width: 34px;
    /* portrait: narrower */
    height: 52px;
    /* portrait: taller */
    padding: 0;
    border-radius: 12px;
    border: 1px solid var(--border-col);
    background: var(--input-bg);
    cursor: pointer;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    font-weight: 400;
    /* NOT bold */
    font-size: 16px;
    line-height: 1;
    text-transform: none;
    user-select: none;
    touch-action: manipulation;

    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    transition: transform 0.06s ease;
    flex: 0 0 auto;
}

.write-key:active {
    transform: translateY(1px);
}

.write-key:disabled {
    opacity: 0.45;
    cursor: default;
}

.write-key.distractor {
    opacity: 0.75;
    border-style: dashed;
}

.write-key.control {
    font-weight: 500;
}

.wordorder-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 5px;
}

.wordorder-selected,
.wordorder-pool {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    min-height: 30px;
}

.wordorder-btn {
    border: 1px solid var(--border-col);
    background: var(--input-bg);
    color: var(--text-main);
    border-radius: 12px;
    padding: 6px 10px;
    font-size: 0.95rem;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    touch-action: manipulation;
}

.wordorder-btn:active {
    transform: translateY(1px);
    background-color: var(--border-col);
}

.wordorder-status {
    font-size: 0.85rem;
    color: var(--text-sub);
    margin-top: 2px;
    font-weight: 500;
}

.wordorder-wrong {
    border-color: #ef4444 !important;
    background: #fee2e2 !important;
    color: #991b1b !important;
}

.wordorder-selected .wordorder-btn {
    border-color: #93c5fd;
    background: #eff6ff;
    color: #1e3a8a;
}

body.dark-mode .wordorder-selected .wordorder-btn {
    background: #1e3a8a;
    color: #93c5fd;
    border-color: #2563eb;
}

hr {
    border: 0;
    border-top: 1px solid var(--border-col);
    margin: 10px 0;
    width: 100%;
}

.extra-lines-container {
    margin-top: 10px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px dashed var(--border-col);
    padding-top: 8px;
}

.nav-container {
    width: 100%;
    max-width: 550px;
    margin-top: 15px;
    min-height: 44px;
    display: flex;
    gap: 10px;
}

.standard-nav {
    display: flex;
    gap: 10px;
    width: 100%;
}

.nav-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-col);
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-main);
    flex: 1;
    font-size: 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.nav-btn.show-solution {
    background: var(--action);
    color: white;
    border: none;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

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

#player-controls {
    display: none;
    gap: 15px;
    width: 100%;
    justify-content: center;
    margin-top: 15px;
}

.btn-pause {
    background-color: #f59e0b;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
    flex: 1;
    max-width: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 1rem;
}

.btn-stop {
    background-color: #ef4444;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
    flex: 1;
    max-width: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 1rem;
}

.hidden-in-autoplay {
    display: none !important;
}

.anki-nav {
    display: flex;
    gap: 5px;
    width: 100%;
}

.anki-btn {
    flex: 1;
    padding: 8px 2px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    color: white;
    text-align: center;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.anki-time {
    display: block;
    font-size: 0.65rem;
    opacity: 0.85;
    font-weight: normal;
}

.btn-again {
    background-color: var(--anki-again);
}

.btn-hard {
    background-color: var(--anki-hard);
}

.btn-good {
    background-color: var(--anki-good);
}

.btn-easy {
    background-color: var(--anki-easy);
}


#counter {
    margin-top: 10px;
    color: var(--text-sub);
    font-size: 0.75rem;
    text-align: center;
    font-family: 'RobotoMono', monospace;
    letter-spacing: 0;
    word-spacing: 0;
}

.copyright-text {
    letter-spacing: 0 !important;
    word-spacing: 0 !important;
    font-size: 0.7rem;
    color: var(--text-sub);
    margin-top: 15px;
    text-align: center;
    width: 100%;
    margin-bottom: 5px;
}

.start-btn {
    background-color: #10b981;
    color: #ffffff;
    border: none;
    padding: 12px 20px;
    font-size: 1rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
}

.start-btn:active {
    transform: scale(0.97);
}

/* Visibility Control */
#flashcard:not(.solution-visible) .js-extra,
#flashcard:not(.solution-visible) .extra-lines-container {
    display: none !important;
}

/* AutoPlay: Extras sollen auch vor "Solution" sichtbar sein */
body[data-mode="autoplay"] #flashcard:not(.solution-visible) .extra-lines-container {
    display: block !important;
}

body[data-mode="autoplay"] #flashcard:not(.solution-visible) .js-extra {
    display: flex !important;
}

body[data-mode="translate"] #flashcard:not(.solution-visible) .js-target,
body[data-mode="translate"] #flashcard:not(.solution-visible) .js-rom {
    display: none !important;
}

body[data-mode="read"] #flashcard:not(.solution-visible) .js-native {
    display: none !important;
}

body[data-mode="listen"] #flashcard:not(.solution-visible) .js-native {
    display: none !important;
}

body[data-mode="listen"] #flashcard:not(.solution-visible) .line-text {
    filter: blur(8px);
    user-select: none;
}

body[data-mode="cloze"] #flashcard:not(.solution-visible) .js-native {
    display: flex !important;
}

body[data-mode="cloze"] #flashcard:not(.solution-visible) .line-text.native {
    font-size: calc(1.1rem * var(--font-scale));
    color: var(--text-sub);
    font-style: italic;
}

/* Hide Response in Cloze AND WordOrder */
body[data-mode="cloze"] #flashcard:not(.solution-visible) #responseContainer {
    display: none !important;
}

body[data-mode="wordorder"] #flashcard:not(.solution-visible) #responseContainer {
    display: none !important;
}

body[data-mode="wordorder"] #flashcard:not(.solution-visible) .js-native {
    display: flex !important;
}

body[data-mode="wordorder"] #flashcard:not(.solution-visible) .line-text.native {
    font-size: calc(1.1rem * var(--font-scale));
    color: var(--text-sub);
    font-style: italic;
}

body[data-mode="translate"] #flashcard:not(.solution-visible) .line-text.native {
    font-size: calc(1.4rem * var(--font-scale));
    font-weight: 600;
    color: var(--text-main);
    font-style: normal;
    text-align: center;
}

body[data-mode="translate"] #flashcard.solution-visible .js-native .line-icon {
    display: none !important;
}

/* MODE OVERLAY STYLES */
#modeOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 1000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    max-width: 550px;
}

.mode-big-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-col);
    padding: 20px 10px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: transform 0.1s, background 0.2s;
    color: var(--text-main);
}

.mode-big-btn:hover {
    background: var(--stim-bg);
    border-color: var(--primary);
    color: var(--primary);
}

.mode-big-btn:active {
    transform: scale(0.96);
}

.mode-big-btn span {
    font-size: 1rem;
    line-height: 1;
}

body.dark-mode #modeOverlay {
    background: var(--bg);
}

@media (max-width: 480px) {
    body {
        padding: 5px;
        padding-bottom: 15px;
    }

    header {
        padding: 6px;
        margin-bottom: 6px;
    }

    .header-controls {
        gap: 4px;
    }

    header select {
        font-size: 14px;
        min-width: 80px;
        height: 30px;
    }

    .mode-controls {
        gap: 4px;
        padding: 3px;
    }

    .mode-controls label {
        font-size: 0.75rem;
        padding: 4px 6px;
    }

    .card {
        padding: 10px 5px;
        min-height: 130px;
    }

    .line-text.target {
        font-size: calc(1.25rem * var(--font-scale));
    }

    .line-text.native {
        font-size: calc(1rem * var(--font-scale));
    }

    .nav-container {
        margin-top: 10px;
    }

    .nav-btn {
        font-size: 0.95rem;
        padding: 12px;
    }

    .wordorder-btn {
        padding: 8px 10px;
        font-size: 0.95rem;
        min-height: 36px;
    }
}

/* WRITE mode: flash wrong key in light red (non-destructive feedback). */
.write-key.write-wrong {
    border-color: #ef4444 !important;
    background: #fee2e2 !important;
    color: #991b1b !important;
}

/* --- AUTH & PREMIUM STYLES --- */
.account-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-col);
    border-radius: 50px;
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.account-btn.premium-active {
    border-color: #fbbf24;
    color: #d97706;
    background: #fffbeb;
}

.acct-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1;
}

.acct-email {
    font-size: 0.72rem;
    color: var(--text-sub);
    margin-top: 1px;
}

.account-btn.premium-active .acct-email {
    color: #b45309;
}

/* Auth Modal Specifics */
.auth-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-col);
    margin-bottom: 15px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    cursor: pointer;
    text-align: center;
    font-weight: 600;
    color: var(--text-sub);
    border-bottom: 2px solid transparent;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.auth-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.auth-form {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.auth-form.active {
    display: flex;
}

.auth-input {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-col);
    background: var(--input-bg);
    color: var(--text-main);
    font-size: 1rem;
}

.auth-submit {
    background: var(--primary);
    color: white;
    padding: 12px;
    border-radius: 8px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
    font-size: 1rem;
}

.auth-footer {
    margin-top: 15px;
    font-size: 0.8rem;
    color: var(--text-sub);
    text-align: center;
}

.error-msg {
    color: #ef4444;
    font-size: 0.85rem;
    text-align: center;
    display: none;
    margin-bottom: 5px;
}

/* Premium Upgrade UI inside Modal */
.plan-box {
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    margin-bottom: 15px;
    background: var(--stim-bg);
}

.plan-price {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
    margin: 10px 0;
}

.plan-features {
    list-style: none;
    padding: 0;
    margin: 0 0 15px 0;
    text-align: left;
    display: inline-block;
}

.plan-features li {
    margin-bottom: 5px;
}

/* --- MICROSOFT STYLE AUTH MODAL --- */
.ms-card {
    background: var(--card-bg);
    padding: 44px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    border-radius: 0;
    /* Eckig wie bei Microsoft */
    text-align: left;
    position: relative;
    animation: fadeIn 0.3s ease;
}

body.dark-mode .ms-card {
    background: #2b2b2b;
    border: 1px solid #444;
}

/* Logo Style */
.ms-logo {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.ms-logo img {
    height: 40px;
    width: auto;
    display: block;
}

/* Texte & Inputs */
.ms-header {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 5px;
}

.ms-sub {
    font-size: 0.9rem;
    color: var(--text-main);
    margin-bottom: 20px;
}

.ms-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #8f8f9e;
    border-radius: 2px;
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text-main);
    background: var(--input-bg);
    transition: border-color 0.2s;
}

.ms-input:focus {
    border-color: #0067b8;
    border-width: 2px;
    outline: none;
    padding: 9px 11px;
}

/* Links & Buttons */
.ms-link {
    color: #0067b8;
    font-size: 0.85rem;
    text-decoration: none;
    cursor: pointer;
    display: inline-block;
    margin-top: 5px;
}

.ms-link:hover {
    text-decoration: underline;
    color: #005da6;
}

/* a11y-20260718: .ms-link rendered as real <button> for keyboard access */
button.ms-linkbtn {
    background: none;
    border: 0;
    padding: 0;
    font-family: inherit;
}

/* a11y-20260718 (WCAG 2.4.7): range sliders declare outline:none above — restore a visible keyboard focus */
.slider-input:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

body.dark-mode .ms-link {
    color: #4dabf7;
}

.ms-btn {
    background: #0067b8;
    color: white;
    border: none;
    padding: 8px 30px;
    font-size: 1rem;
    min-width: 100px;
    margin-top: 20px;
    float: right;
    /* Button right-aligned */
    cursor: pointer;
    transition: background 0.2s;
}

.ms-btn:hover {
    background: #005da6;
}

.ms-btn:active {
    transform: scale(0.98);
}

.ms-btn.full {
    width: 100%;
    float: none;
}

/* Layout Helfer */
.ms-footer {
    margin-top: 40px;
    font-size: 0.85rem;
    clear: both;
    padding-top: 20px;
}

.ms-view {
    display: none;
}

.ms-view.active {
    display: block;
}

.ms-error {
    color: #e81123;
    font-size: 0.85rem;
    margin-bottom: 10px;
    display: none;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Progress bar during the lesson */
.session-progress-container {
    width: 100%;
    max-width: 550px;
    height: 6px;
    background: var(--border-col);
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
    display: none;
    /* Wird erst beim Start eingeblendet */
}

.session-progress-fill {
    height: 100%;
    background-color: var(--action);
    width: 0%;
    transition: width 0.4s ease-out, background-color 0.4s ease;
}

/* ... ganz viele andere Styles ... */

/* Additional styles */
.limit-progress-bar {
    width: 100%;
    height: 4px;
    background: var(--border-col);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
    display: block;
}

.limit-progress-fill {
    height: 100%;
    background-color: var(--action);
    /* Hier 'background-color' statt 'background' */
    width: 0%;
    transition: width 0.4s ease, background-color 0.4s ease;
}

/* Optimization for mobile devices */
@media (max-width: 480px) {
    .write-keyboard {
        gap: 4px;
        padding: 5px;
        justify-content: flex-start;
        /* Allows natural scrolling on small displays */
    }

    .write-key {
        width: 32px;
        /* Slightly narrower for more keys per row */
        height: 48px;
        font-size: 15px;
    }

    /* Prevents the card from jumping off screen on active sentences */
    .active-sentence {
        transform: scale(1.02) !important;
        /* Slightly more subtle zoom on mobile */
    }

    /* Keep navigation buttons side by side */
    .standard-nav {
        gap: 5px;
    }
}

/* Animation for new cards */
@keyframes cardEnter {
    0% {
        opacity: 0;
        transform: translateY(20px);
        /* Starting 20px from bottom (more visible) */
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.card-animate-enter {
    /* 0.5s is slower and smoother */
    animation: cardEnter 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* --- RESPONSIVE: Small phones (360px and below) --- */
@media (max-width: 360px) {
    body {
        padding: 3px;
        padding-bottom: 10px;
    }
    header {
        padding: 4px;
        margin-bottom: 4px;
    }
    header select {
        font-size: 13px;
        min-width: 70px;
        height: 28px;
    }
    .start-box {
        padding: 12px;
    }
    .start-box h2 {
        font-size: 1.15rem;
        margin-bottom: 10px;
    }
    .card {
        padding: 8px 4px;
        min-height: 100px;
    }
    .line-text.target {
        font-size: calc(1.1rem * var(--font-scale));
    }
    .line-text.native {
        font-size: calc(0.9rem * var(--font-scale));
    }
    .nav-btn {
        font-size: 0.85rem;
        padding: 10px;
    }
    .mode-controls label {
        font-size: 0.7rem;
        padding: 3px 5px;
    }
    .account-btn {
        font-size: 0.75rem;
        padding: 4px 8px;
    }
}

/* --- RESPONSIVE: Landscape phones --- */
@media (max-height: 500px) and (orientation: landscape) {
    #startOverlay {
        padding-top: 10px;
    }
    .start-box {
        padding: 10px;
        margin-bottom: 10px;
    }
    .start-box h2 {
        font-size: 1.1rem;
        margin-bottom: 8px;
    }
    .config-section {
        margin-bottom: 8px;
        padding-bottom: 6px;
    }
    header {
        padding: 4px;
        margin-bottom: 4px;
    }
    .card {
        min-height: 80px;
        padding: 6px;
    }
    .line-row {
        padding: 6px 8px;
        margin-bottom: 4px;
    }
    .nav-container {
        margin-top: 8px;
    }
    .nav-btn {
        padding: 8px;
    }
    .mode-controls {
        gap: 3px;
        padding: 2px;
    }
    .mode-controls label {
        padding: 3px 5px;
        font-size: 0.72rem;
    }
}

/* --- RESPONSIVE: Tablets (481px - 768px) --- */
@media (min-width: 481px) and (max-width: 768px) {
    .start-box {
        max-width: 500px;
    }
    .card {
        max-width: 520px;
    }
    header {
        max-width: 540px;
    }
}

/* --- Mode chip (mobile) --- */
.mode-chip {
    display: none;
    align-items: center;
    gap: 8px;
    background: var(--card-bg);
    border: 2px solid var(--primary);
    border-radius: 50px;
    padding: 8px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    margin-bottom: 8px;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.15);
    transition: transform 0.15s, box-shadow 0.15s;
}
.mode-chip:active {
    transform: scale(0.97);
}
.mode-chip-arrow {
    font-size: 0.8rem;
    opacity: 0.6;
}

@media (max-width: 600px) {
    .mode-chip {
        display: inline-flex;
    }
    .mode-controls {
        display: none !important;
    }
}

/* Samsung digit/letter word-segmentation fix */
/* Samsung Internet inserts spaces at digit-letter boundaries (e.g. "Franz8" → "Franz 8") */
#lblUserEmail {
    font-family: 'RobotoMono', monospace !important;
    font-size: 13px !important;
    word-spacing: 0 !important;
    letter-spacing: 0 !important;
    word-break: normal;
}
#lblUserStatus,
.line-text {
    word-spacing: 0 !important;
    letter-spacing: 0 !important;
    word-break: normal;
}

/* Utility: force RobotoMono on any element that displays numbers */
.sl-mono {
    font-family: inherit !important;
    letter-spacing: 0 !important;
    word-spacing: 0 !important;
}


/* Dark mode: extra languages + topic select + preview */
body.dark-mode #extraLangsContainer {
}
body.dark-mode #extraLangsContainer label {
}
body.dark-mode #extraLang1,
body.dark-mode #extraLang2,
body.dark-mode #extraLang3,
body.dark-mode #extraLang4 {
}
body.dark-mode #topicSelect {
    background: #3a3a3a !important;
    color: #e5e7eb !important;
    border-color: #555 !important;
}
body.dark-mode #topicSelect option,
body.dark-mode #extraLang1 option,
body.dark-mode #extraLang2 option,
body.dark-mode #extraLang3 option,
body.dark-mode #extraLang4 option {
    background: #2b2b2b;
    color: #e5e7eb;
}
body.dark-mode #lblPreview {
}

/* iter25-arrow */
