/* ========================================
   Ad Astra Vocab - Design System
   ======================================== */

:root {
    /* Color Palette - inspired by The Economist's red */
    --red-primary: #E3120B;
    --red-dark: #B90D08;
    --red-light: #FF4D47;

    /* Dark Theme */
    --bg-primary: #0D0F14;
    --bg-secondary: #151820;
    --bg-tertiary: #1C2030;
    --bg-card: #1A1E2E;
    --bg-card-hover: #222840;
    --bg-glass: rgba(26, 30, 46, 0.85);

    /* Text */
    --text-primary: #F0F2F8;
    --text-secondary: #9BA3BF;
    --text-muted: #5E6680;
    --text-accent: #E3120B;

    /* Accent colors */
    --accent-green: #22C55E;
    --accent-yellow: #EAB308;
    --accent-orange: #F97316;
    --accent-blue: #3B82F6;
    --accent-purple: #8B5CF6;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px rgba(227, 18, 11, 0.15);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ========================================
   Reset & Base
   ======================================== */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Subtle grid background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(227, 18, 11, 0.04) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(59, 130, 246, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

#app {
    position: relative;
    z-index: 1;
    max-width: 960px;
    margin: 0 auto;
    padding: var(--space-md) var(--space-lg);
    padding-bottom: 80px;
}

/* ========================================
   Header
   ======================================== */

#app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg) 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: var(--space-lg);
}

#app-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.title-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

#app-title .accent {
    color: var(--red-primary);
}

#app-title .light {
    font-weight: 500;
    color: var(--text-secondary);
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: var(--space-xs);
}

.info-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1;
    box-shadow:
        0 10px 24px rgba(0, 0, 0, 0.26),
        0 1px 0 rgba(255, 255, 255, 0.06) inset,
        0 0 0 1px rgba(227, 18, 11, 0.06);
    transition: var(--transition-fast);
}

.info-link:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.22);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.05));
    box-shadow:
        0 14px 28px rgba(0, 0, 0, 0.32),
        0 1px 0 rgba(255, 255, 255, 0.08) inset,
        0 0 0 1px rgba(227, 18, 11, 0.12);
    transform: translateY(-1px) scale(1.02);
}

.header-right {
    display: flex;
    gap: var(--space-sm);
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-full);
    padding: var(--space-xs) var(--space-md);
    font-size: 0.8rem;
    transition: var(--transition-normal);
}

.stat-pill:hover {
    background: var(--bg-tertiary);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

/* Warning-coloured stat pill for suspect count */
.stat-pill-warn {
    border-color: rgba(234, 179, 8, 0.3);
    cursor: pointer;
}

.stat-pill-warn:hover {
    background: rgba(234, 179, 8, 0.1);
    border-color: var(--accent-yellow);
}

.stat-pill-warn .stat-value {
    color: var(--accent-yellow);
}

/* Suspect mode button */
.mode-btn-warn {
    border-color: rgba(234, 179, 8, 0.25);
    color: var(--accent-yellow);
}

.mode-btn-warn:hover {
    background: rgba(234, 179, 8, 0.1);
    border-color: var(--accent-yellow);
}

.mode-btn-warn.active {
    background: rgba(234, 179, 8, 0.15);
    color: var(--accent-yellow);
    border-color: rgba(234, 179, 8, 0.4);
}

/* Suspect warning banner on flashcard */
.card-suspect-warning {
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.3);
    border-radius: var(--radius-sm);
    color: var(--accent-yellow);
    font-size: 0.75rem;
    font-weight: 500;
    padding: var(--space-xs) var(--space-md);
    margin-bottom: var(--space-md);
    text-align: center;
}

.stat-icon {
    font-size: 0.9rem;
}

.stat-value {
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* ========================================
   Navigation Tabs
   ======================================== */

#tab-nav {
    display: flex;
    gap: var(--space-xs);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-xs);
    margin-bottom: var(--space-xl);
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: var(--red-primary);
    color: white;
    box-shadow: 0 2px 12px rgba(227, 18, 11, 0.3);
}

.tab-icon {
    font-size: 1rem;
}

/* ========================================
   Panels
   ======================================== */

.panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.panel.active {
    display: block;
}

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

/* ========================================
   Review Panel - Controls
   ======================================== */

.daily-focus-list {
    margin-bottom: var(--space-lg);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
}

.daily-focus-list-page {
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
}

.daily-focus-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.daily-focus-header h2 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
}

.daily-focus-header p {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.daily-focus-items {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-md);
    align-items: stretch;
}

.daily-focus-item {
    min-width: 0;
    min-height: 320px;
    display: flex;
    flex-direction: column;
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-align: left;
    transition: var(--transition-fast);
}

.daily-focus-card-header,
.daily-focus-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
}

.daily-focus-card-header {
    min-height: 26px;
    margin-bottom: var(--space-md);
}

.daily-focus-replace {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent-blue);
    font: inherit;
    font-size: 0.7rem;
    cursor: pointer;
    white-space: nowrap;
}

.daily-focus-replace:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.daily-focus-item:hover {
    background: var(--bg-card-hover);
    border-color: rgba(227, 18, 11, 0.35);
}

.daily-focus-word {
    overflow-wrap: anywhere;
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1.15;
}

.daily-focus-lexical-meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    min-height: 30px;
    margin-top: 7px;
}

.daily-focus-frequency {
    padding: 3px 7px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.7rem;
    line-height: 1;
    white-space: nowrap;
}

.daily-focus-ipa {
    color: var(--accent-blue);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.82rem;
}

.daily-focus-pronounce {
    width: 30px;
    height: 30px;
    margin-left: auto;
}

.daily-focus-context {
    margin-top: var(--space-md);
    padding-left: var(--space-md);
    border-left: 2px solid var(--accent-red);
    color: var(--text-secondary);
    font-size: 0.86rem;
    line-height: 1.55;
}

.daily-focus-definition {
    flex: 1;
    margin-top: var(--space-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.55;
}

.daily-focus-definition > :first-child {
    margin-top: 0;
}

.daily-focus-definition > :last-child {
    margin-bottom: 0;
}

.daily-focus-card-footer {
    margin-top: var(--space-lg);
    padding-top: var(--space-sm);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.daily-focus-article {
    min-width: 0;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.daily-focus-actions {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: var(--space-sm);
}

.daily-focus-source,
.daily-focus-action {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent-blue);
    font: inherit;
    font-size: 0.74rem;
    text-decoration: none;
    cursor: pointer;
}

.daily-focus-source:hover,
.daily-focus-action:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.review-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.mode-selector {
    display: flex;
    gap: var(--space-xs);
}

.mode-btn {
    padding: var(--space-xs) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.mode-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.1);
}

.mode-btn.active {
    background: rgba(227, 18, 11, 0.15);
    color: var(--red-light);
    border-color: rgba(227, 18, 11, 0.3);
}

.year-filter select,
.filter-select {
    padding: var(--space-xs) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
}

select {
    color-scheme: light;
}

select option {
    background: #fffdf8;
    color: #26231f;
}

.hidden {
    display: none !important;
}

/* ========================================
   Publish Panel
   ======================================== */

.publish-panel {
    margin-bottom: var(--space-xl);
    padding: var(--space-lg);
    background:
        radial-gradient(circle at top right, rgba(227, 18, 11, 0.08), transparent 42%),
        var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.publish-panel-header {
    display: flex;
    justify-content: space-between;
    gap: var(--space-md);
    align-items: flex-start;
    margin-bottom: var(--space-md);
}

.publish-panel-header h2 {
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.publish-panel-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.publish-panel-badge {
    padding: 6px 10px;
    border-radius: var(--radius-full);
    background: rgba(227, 18, 11, 0.12);
    border: 1px solid rgba(227, 18, 11, 0.24);
    color: var(--red-light);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.publish-search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px 110px;
    gap: var(--space-sm);
    align-items: center;
}

.publish-search-input {
    margin: 0;
}

.publish-search-btn {
    min-height: 42px;
}

.publish-search-status {
    min-height: 20px;
    margin-top: 10px;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.publish-search-status.status-error {
    color: var(--red-light);
}

.publish-search-status.status-success {
    color: var(--accent-green);
}

.publish-results {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: var(--space-md);
}

.publish-result-item {
    display: flex;
    justify-content: space-between;
    gap: var(--space-md);
    align-items: center;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
}

.publish-result-meta {
    min-width: 0;
}

.publish-result-title {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.45;
    color: var(--text-primary);
}

.publish-result-subtitle {
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.publish-result-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
}

.publish-result-btn {
    min-width: 92px;
}

.publish-job-card {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
}

.publish-job-top {
    display: flex;
    justify-content: space-between;
    gap: var(--space-md);
    align-items: flex-start;
}

.publish-job-kicker {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
    margin-bottom: 4px;
}

.publish-job-title {
    font-size: 1rem;
    margin-bottom: 6px;
}

.publish-job-message {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.55;
}

.publish-job-status {
    padding: 6px 10px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.publish-job-status.status-running {
    color: var(--accent-blue);
    border-color: rgba(59, 130, 246, 0.25);
    background: rgba(59, 130, 246, 0.12);
}

.publish-job-status.status-succeeded {
    color: var(--accent-green);
    border-color: rgba(34, 197, 94, 0.25);
    background: rgba(34, 197, 94, 0.12);
}

.publish-job-status.status-failed {
    color: var(--red-light);
    border-color: rgba(227, 18, 11, 0.25);
    background: rgba(227, 18, 11, 0.12);
}

.publish-job-progress-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-top: var(--space-md);
}

.publish-job-progress-bar {
    flex: 1;
    height: 8px;
    overflow: hidden;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.08);
}

.publish-job-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--red-primary), var(--accent-orange));
    transition: width 180ms ease;
}

.publish-job-progress-text {
    flex-shrink: 0;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
}

.publish-job-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: var(--space-md);
}

.publish-job-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition-fast);
}

.publish-job-link:hover {
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
}

.publish-job-log {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: var(--space-md);
}

.publish-job-log-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.5;
}

.publish-job-log-progress {
    min-width: 34px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.publish-empty {
    padding: 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.08);
    font-size: 0.88rem;
}

/* ========================================
   Progress Bar
   ======================================== */

.progress-container {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.progress-bar {
    flex: 1;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--red-primary), var(--accent-orange));
    border-radius: var(--radius-full);
    transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    width: 0%;
}

.progress-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ========================================
   Flashcard
   ======================================== */

.card-container {
    margin-bottom: var(--space-xl);
}

.flashcard {
    position: relative;
    min-height: 340px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    cursor: pointer;
    transition: var(--transition-normal);
    overflow: hidden;
}

.card-fullscreen-btn {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    z-index: 4;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.16);
    color: var(--text-secondary);
    cursor: pointer;
}

.card-fullscreen-btn:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(0, 0, 0, 0.28);
}

#panel-review:fullscreen {
    min-height: 100vh;
    overflow-y: auto;
    padding: clamp(24px, 6vw, 72px);
    background: var(--bg-primary);
}

#panel-review:fullscreen .card-container {
    max-width: 920px;
    margin: 0 auto var(--space-xl);
}

#panel-review:fullscreen .progress-container,
#panel-review:fullscreen .rating-buttons,
#panel-review:fullscreen .shortcuts-hint {
    max-width: 920px;
    margin-left: auto;
    margin-right: auto;
}

.flashcard::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--red-primary), var(--accent-orange), var(--accent-purple));
    opacity: 0.8;
}

.flashcard:hover {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    transform: translateY(-2px);
}

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

.flashcard.card-switch-in {
    animation: cardSwitchIn 220ms ease-out both;
}

@media (prefers-reduced-motion: reduce) {
    .flashcard.card-switch-in {
        animation: none;
    }
}

.card-badge {
    display: inline-block;
    padding: 2px var(--space-sm);
    background: rgba(227, 18, 11, 0.1);
    border: 1px solid rgba(227, 18, 11, 0.2);
    border-radius: var(--radius-full);
    color: var(--red-light);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-lg);
}

.card-word {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
    line-height: 1.2;
}

.card-context {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-secondary);
    padding: var(--space-md);
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--red-primary);
    margin-bottom: var(--space-lg);
}

.card-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: var(--space-md);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Card Back */
.card-definition {
    font-size: 1.1rem;
    line-height: 1.7;
    color: var(--accent-green);
    padding: var(--space-md) var(--space-lg);
    background: rgba(34, 197, 94, 0.08);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-green);
    margin-bottom: var(--space-lg);
    font-weight: 500;
    max-height: min(34vh, 260px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.card-definition::-webkit-scrollbar {
    width: 8px;
}

.card-definition::-webkit-scrollbar-track {
    background: transparent;
}

.card-definition::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 999px;
}

.card-definition::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.28);
}

.card-definition p {
    margin: 0 0 var(--space-sm);
}

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

.card-definition ul {
    margin: 0;
    padding-left: 1.25em;
}

.card-definition ol {
    margin: 0;
    padding-left: 1.35em;
}

.card-definition ul + p,
.card-definition p + ul,
.card-definition ol + p,
.card-definition p + ol,
.card-definition ul + ol,
.card-definition ol + ul {
    margin-top: var(--space-sm);
}

.card-definition li + li {
    margin-top: 0.35em;
}

.card-definition h1,
.card-definition h2,
.card-definition h3,
.card-definition h4,
.card-definition h5,
.card-definition h6 {
    margin: 0 0 var(--space-sm);
    color: var(--text-primary);
    line-height: 1.3;
}

.card-definition h1 { font-size: 1.22em; }
.card-definition h2 { font-size: 1.14em; }
.card-definition h3 { font-size: 1.08em; }
.card-definition h4,
.card-definition h5,
.card-definition h6 {
    font-size: 1em;
}

.card-definition .definition-section-line {
    color: var(--text-primary);
}

.card-definition blockquote {
    margin: 0 0 var(--space-sm);
    padding: 0.1em 0 0.1em 0.9em;
    border-left: 3px solid rgba(34, 197, 94, 0.35);
    color: var(--text-secondary);
}

.card-definition blockquote p {
    margin-bottom: 0.45em;
}

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

.card-definition pre {
    margin: 0 0 var(--space-sm);
    padding: 0.8em 0.95em;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.36);
    color: var(--text-primary);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.card-definition pre code {
    padding: 0;
    background: transparent;
}

.card-definition code {
    padding: 0.12em 0.38em;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.9em;
    color: var(--text-primary);
}

.card-definition hr {
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    margin: 0.75em 0;
}

.card-definition mark {
    background: rgba(250, 204, 21, 0.24);
    color: inherit;
    padding: 0 0.16em;
    border-radius: 0.2em;
}

.card-definition a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 0.12em;
}

.card-article {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding-top: var(--space-sm);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* ========================================
   Empty State
   ======================================== */

.empty-state {
    text-align: center;
    padding: var(--space-2xl) * 2;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: var(--space-lg);
}

.empty-state h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    margin-bottom: var(--space-sm);
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
}

.btn-primary {
    padding: var(--space-sm) var(--space-lg);
    background: var(--red-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-primary:hover {
    background: var(--red-dark);
    box-shadow: 0 4px 16px rgba(227, 18, 11, 0.3);
    transform: translateY(-1px);
}

.btn-secondary {
    padding: var(--space-sm) var(--space-lg);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    margin-top: var(--space-xs);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.35);
    color: var(--text-primary);
}

.btn-full {
    width: 100%;
}

/* ========================================
   Rating Buttons
   ======================================== */

.rating-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.rating-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-md) var(--space-sm);
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-fast);
}

.rating-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.rating-emoji {
    font-size: 1.5rem;
}

.rating-text {
    font-size: 0.8rem;
    font-weight: 600;
}

.rating-interval {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.rating-again:hover {
    border-color: #EF4444;
    background: rgba(239, 68, 68, 0.1);
}

.rating-hard:hover {
    border-color: var(--accent-orange);
    background: rgba(249, 115, 22, 0.1);
}

.rating-good:hover {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.1);
}

.rating-easy:hover {
    border-color: var(--accent-green);
    background: rgba(34, 197, 94, 0.1);
}

/* Keyboard shortcuts hint */
.shortcuts-hint {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    font-size: 0.7rem;
    color: var(--text-muted);
}

.shortcuts-hint span {
    padding: 2px var(--space-sm);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

/* ========================================
   Browse Panel
   ======================================== */

.browse-controls {
    margin-bottom: var(--space-lg);
}

.browse-today-header {
    align-items: flex-end;
}

.browse-today-count {
    color: var(--text-muted);
    font-size: 0.78rem;
    white-space: nowrap;
}

.browse-today-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

@media (max-width: 900px) {
    .daily-focus-items {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .daily-focus-items {
        grid-template-columns: 1fr;
    }
}

.search-input {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    margin-bottom: var(--space-md);
    transition: var(--transition-fast);
}

.search-input:focus {
    outline: none;
    border-color: var(--red-primary);
    box-shadow: 0 0 0 3px rgba(227, 18, 11, 0.1);
}

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

.browse-filters {
    display: flex;
    gap: var(--space-sm);
}

.vocab-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.vocab-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.vocab-item:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.08);
    transform: translateX(4px);
}

.vocab-item-expandable {
    flex-wrap: wrap;
}

.vocab-item-expandable:hover,
.vocab-item-expandable.is-expanded {
    transform: none;
}

.vocab-item-expandable:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

.vocab-item-details {
    width: 100%;
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
    cursor: default;
}

.vocab-item-details section + section {
    margin-top: var(--space-md);
}

.vocab-detail-label {
    display: block;
    margin-bottom: var(--space-xs);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.vocab-item-details p,
.vocab-detail-definition {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.65;
}

.vocab-detail-definition > :first-child {
    margin-top: 0;
}

.vocab-detail-definition > :last-child {
    margin-bottom: 0;
}

.vocab-item-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.vocab-item-word {
    font-weight: 600;
    font-size: 1rem;
    min-width: 120px;
}

.vocab-standalone-note {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    padding: 2px 6px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1.2;
    vertical-align: middle;
}

.vocab-frequency {
    display: inline-flex;
    align-items: center;
    margin-left: var(--space-sm);
    padding: 2px 6px;
    border: 1px solid rgba(34, 197, 94, 0.28);
    border-radius: var(--radius-sm);
    color: var(--accent-green);
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    vertical-align: middle;
}

.vocab-frequency.is-untracked {
    border-color: var(--border-color);
    color: var(--text-muted);
    font-weight: 500;
}

/* Keep Browse summaries on one line; expanded details remain below. */
:is(#today-vocab-list, #vocab-list) .vocab-item {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-md);
}

:is(#today-vocab-list, #vocab-list) .vocab-item-left {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    flex-wrap: nowrap;
    align-items: center;
}

:is(#today-vocab-list, #vocab-list) .vocab-item-left > div {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

:is(#today-vocab-list, #vocab-list) .vocab-item-def {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

:is(#today-vocab-list, #vocab-list) .vocab-item-right {
    flex: 0 0 auto;
    width: auto;
    flex-wrap: nowrap;
    white-space: nowrap;
}

:is(#today-vocab-list, #vocab-list) .vocab-item-details {
    flex: 0 0 100%;
}

.vocab-item-def {
    color: var(--text-secondary);
    font-size: 0.85rem;
    max-width: 500px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vocab-item-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.vocab-badge {
    padding: 2px var(--space-sm);
    border-radius: var(--radius-full);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-new {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
}

.badge-learning {
    background: rgba(249, 115, 22, 0.15);
    color: var(--accent-orange);
}

.badge-mastered {
    background: rgba(34, 197, 94, 0.15);
    color: var(--accent-green);
}

.vocab-year {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Article group header in browse */
.article-group-header {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--red-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: var(--space-md);
    border-left: 2px solid var(--red-primary);
}

/* ========================================
   Stats Panel
   ======================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.stats-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.stats-card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
    color: var(--text-secondary);
}

.stats-content {
    min-height: 120px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.stat-row-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stat-row-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Year bar chart */
.year-bar-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.year-bar-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.year-bar-label {
    font-size: 0.8rem;
    font-weight: 600;
    width: 40px;
    color: var(--text-secondary);
}

.year-bar-track {
    flex: 1;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}

.year-bar-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    padding-left: var(--space-sm);
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.year-bar-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    width: 50px;
    text-align: right;
}

/* Difficult words list */
.difficult-word-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.difficult-word-text {
    font-weight: 600;
    font-size: 0.85rem;
}

.difficult-word-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Heatmap */
.heatmap-container {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    background: var(--bg-tertiary);
    transition: var(--transition-fast);
}

.heatmap-cell:hover {
    transform: scale(1.3);
}

.heatmap-level-0 { background: var(--bg-tertiary); }
.heatmap-level-1 { background: rgba(227, 18, 11, 0.2); }
.heatmap-level-2 { background: rgba(227, 18, 11, 0.4); }
.heatmap-level-3 { background: rgba(227, 18, 11, 0.6); }
.heatmap-level-4 { background: rgba(227, 18, 11, 0.8); }

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-top: var(--space-md);
    justify-content: flex-end;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.heatmap-legend-cell {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    #app {
        padding: max(var(--space-sm), env(safe-area-inset-top)) var(--space-md);
        padding-bottom: calc(88px + env(safe-area-inset-bottom));
    }

    #app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-md);
    }

    .header-right {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--space-sm);
    }

    .title-row {
        flex-wrap: wrap;
        gap: 10px;
    }

    .stat-pill,
    .user-pill {
        width: 100%;
        min-height: 42px;
        justify-content: center;
        min-width: 0;
    }

    .stat-pill {
        padding: var(--space-sm) var(--space-md);
    }

    .stat-label,
    #user-name-display {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .user-menu {
        top: auto;
        left: var(--space-md);
        right: var(--space-md);
        width: auto;
        min-width: 0;
        bottom: calc(16px + env(safe-area-inset-bottom));
    }

    #tab-nav {
        overflow-x: auto;
        padding-bottom: calc(var(--space-xs) + 2px);
        scrollbar-width: none;
    }

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

    .tab-btn {
        flex: 0 0 auto;
        min-width: 108px;
        padding: 10px 14px;
    }

    .review-controls,
    .progress-container {
        flex-direction: column;
        align-items: stretch;
    }

    .publish-search-row {
        grid-template-columns: 1fr;
    }

    .publish-result-item,
    .publish-job-top {
        flex-direction: column;
        align-items: stretch;
    }

    .publish-result-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .mode-selector {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 2px;
        scrollbar-width: none;
    }

    .mode-selector::-webkit-scrollbar {
        display: none;
    }

    .mode-btn {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .year-filter select,
    .filter-select {
        width: 100%;
        min-height: 42px;
    }

    .progress-container {
        gap: var(--space-sm);
    }

    .card-container {
        margin-bottom: var(--space-lg);
    }

    .flashcard {
        min-height: 300px;
        padding: var(--space-xl) var(--space-lg);
        border-radius: 20px;
    }

    .card-word {
        font-size: clamp(2rem, 9vw, 2.4rem);
        margin-bottom: var(--space-md);
    }

    .card-context,
    .card-definition {
        padding: var(--space-md);
    }

    .card-definition {
        max-height: min(30vh, 220px);
    }

    .card-actions {
        flex-wrap: wrap;
    }

    .card-action-btn {
        flex: 1 1 calc(50% - var(--space-xs));
        justify-content: center;
        min-height: 40px;
    }

    .empty-state {
        padding: calc(var(--space-2xl) + var(--space-md)) var(--space-md);
    }

    .card-word {
        font-size: 1.8rem;
    }

    .btn-pronounce {
        width: 30px;
        height: 30px;
    }

    .btn-pronounce svg {
        width: 15px;
        height: 15px;
    }

    .rating-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .rating-btn {
        min-height: 84px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

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

    .vocab-item {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-md);
        padding: var(--space-md);
    }

    .vocab-item:hover {
        transform: none;
    }

    .vocab-item-left,
    .vocab-item-right {
        width: 100%;
    }

    .vocab-item-left {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    .vocab-item-right {
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .vocab-item-word {
        min-width: 0;
    }

    .vocab-item-def {
        max-width: none;
        white-space: normal;
        overflow: visible;
        text-overflow: initial;
    }

    .vocab-edit-btn {
        opacity: 1;
    }

    .lb-row {
        flex-wrap: wrap;
        gap: var(--space-md);
        align-items: flex-start;
    }

    .lb-details {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .modal-overlay {
        align-items: flex-end;
        padding: var(--space-md);
    }

    .modal-card {
        max-width: none;
        max-height: min(92vh, 760px);
        padding: var(--space-xl) var(--space-lg);
        border-radius: 24px 24px 18px 18px;
        overflow-y: auto;
    }

    .avatar-picker {
        flex-wrap: wrap;
    }

    .edit-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .edit-actions .btn-primary,
    .edit-actions .btn-secondary,
    .edit-actions .btn-danger {
        width: 100%;
    }

    .profile-status-stack {
        gap: var(--space-xs);
    }

    .shortcuts-hint {
        display: none;
    }
}

@media (max-width: 560px) {
    #app {
        padding: max(var(--space-sm), env(safe-area-inset-top)) 14px;
        padding-bottom: calc(92px + env(safe-area-inset-bottom));
    }

    .header-right,
    .browse-filters {
        grid-template-columns: 1fr;
    }

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

    .publish-panel-header {
        flex-direction: column;
    }

    .publish-job-progress-row,
    .publish-job-log-item {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .info-link {
        width: 32px;
        height: 32px;
    }

    #tab-nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        overflow: visible;
        margin-bottom: var(--space-lg);
    }

    .tab-btn {
        min-width: 0;
        width: 100%;
        font-size: 0.85rem;
    }

    .mode-selector {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        overflow: visible;
    }

    .mode-btn {
        min-width: 0;
        white-space: normal;
    }

    .mode-selector .mode-btn:last-child {
        grid-column: 1 / -1;
    }

    .flashcard {
        min-height: 280px;
        padding: var(--space-lg) var(--space-md);
    }

    .card-context,
    .card-definition {
        font-size: 0.92rem;
        line-height: 1.6;
    }

    .card-definition {
        max-height: min(28vh, 200px);
    }

    .card-action-btn {
        flex-basis: 100%;
    }

    .rating-buttons {
        gap: var(--space-xs);
    }

    .rating-btn {
        min-height: 78px;
        padding: var(--space-sm);
    }

    .lb-score {
        min-width: 0;
    }

    .lb-stat {
        flex: 1 1 100%;
    }

    .modal-card {
        padding: var(--space-lg) var(--space-md);
    }
}

/* ========================================
   Scrollbar
   ======================================== */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========================================
   Card back expand / collapse
   ======================================== */

.card-back {
    overflow: hidden;
    transition: max-height 0.35s ease, opacity 0.3s ease, margin-top 0.35s ease;
}

.card-back-collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.card-back-expanded {
    max-height: 600px;
    opacity: 1;
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

body.light .card-back-expanded {
    border-top-color: rgba(0, 0, 0, 0.08);
}

/* ========================================
   Loading state
   ======================================== */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--bg-tertiary);
    border-top-color: var(--red-primary);
    border-radius: 50%;
    margin-left: var(--space-sm);
    animation: spin 0.8s linear infinite;
}

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

/* ========================================
   IPA Display
   ======================================== */

.card-pronunciation {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    min-height: 1.6em;
}

.card-ipa {
    font-family: 'Inter', monospace;
    font-size: 1.05rem;
    color: var(--accent-blue);
    letter-spacing: 0.05em;
}

.btn-pronounce {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.25);
    color: var(--accent-blue);
    cursor: pointer;
    transition: var(--transition-fast);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.btn-pronounce:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent-blue);
    transform: scale(1.1);
}

.btn-pronounce:active {
    transform: scale(0.95);
}

.btn-pronounce.speaking {
    background: rgba(59, 130, 246, 0.25);
    border-color: var(--accent-blue);
    animation: pronounce-pulse 0.8s ease infinite;
}

@keyframes pronounce-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.3); }
    50% { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0); }
}

.card-base-form {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
    font-style: italic;
}

.vocab-ipa {
    font-size: 0.75rem;
    color: var(--accent-blue);
    margin-left: var(--space-sm);
    opacity: 0.8;
    font-family: monospace;
}

/* ========================================
   Login Modal
   ======================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.modal-card {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg), 0 0 60px rgba(227, 18, 11, 0.1);
}

.modal-logo {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: var(--space-xs);
}

.modal-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: var(--space-lg);
}

.modal-user-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    max-height: 220px;
    overflow-y: auto;
    margin-bottom: var(--space-md);
}

.modal-user-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: left;
    width: 100%;
    color: var(--text-primary);
    font-family: inherit;
}

.modal-user-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--red-primary);
    box-shadow: 0 0 0 1px var(--red-primary);
}

.modal-user-avatar { font-size: 1.5rem; }

.modal-user-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.modal-user-stats {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.modal-divider {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: var(--space-lg) 0 var(--space-md);
    position: relative;
}

.modal-divider::before, .modal-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
}

.modal-divider::before { left: 0; }
.modal-divider::after  { right: 0; }

.modal-input {
    width: 100%;
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    margin-bottom: var(--space-md);
    transition: var(--transition-fast);
}

.modal-input:focus {
    outline: none;
    border-color: var(--red-primary);
    box-shadow: 0 0 0 3px rgba(227, 18, 11, 0.1);
}

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

.avatar-picker {
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

.avatar-btn {
    width: 54px;
    height: 54px;
    padding: 0;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.avatar-btn:hover { border-color: rgba(255, 255, 255, 0.15); }

.avatar-btn.active {
    border-color: var(--red-primary);
    background: rgba(227, 18, 11, 0.1);
    box-shadow: 0 0 0 2px rgba(227, 18, 11, 0.25);
}

.avatar-btn-image {
    display: block;
    width: 112%;
    height: 112%;
    object-fit: cover;
    max-width: none;
    transform: scale(1.08);
}

.register-avatar-section {
    margin-bottom: var(--space-md);
    padding: var(--space-md);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.02);
}

.register-avatar-preview {
    width: 72px;
    height: 72px;
    margin: 0 auto var(--space-md);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: rgba(227, 18, 11, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 2rem;
    box-shadow: var(--shadow-sm);
}

.register-avatar-preview.has-image {
    background: var(--bg-tertiary);
}

.register-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.register-avatar-preview.has-image .register-avatar-image {
    display: block;
}

.register-avatar-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.register-avatar-preview.has-image .register-avatar-text {
    display: none;
}

.register-avatar-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.register-avatar-input {
    margin-bottom: var(--space-sm);
}

.register-avatar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.register-avatar-btn {
    width: 100%;
}

.register-avatar-hint {
    font-size: 0.76rem;
    line-height: 1.45;
    color: var(--text-muted);
}

.btn-full { width: 100%; }

/* ========================================
   User Pill & Menu
   ======================================== */

.user-pill {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    padding: var(--space-xs) var(--space-md);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition-fast);
    user-select: none;
    position: relative;
}

#user-avatar-display {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.user-pill-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.user-pill:hover {
    background: var(--bg-tertiary);
    border-color: rgba(255, 255, 255, 0.12);
}

.user-pill-caret {
    font-size: 0.6rem;
    color: var(--text-muted);
}

.user-menu {
    position: absolute;
    top: 80px;
    right: var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 500;
    min-width: 180px;
    overflow: hidden;
}

.user-menu-item {
    display: block;
    width: 100%;
    padding: var(--space-sm) var(--space-lg);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: var(--transition-fast);
}

.user-menu-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.user-menu-item.active { color: var(--red-light); font-weight: 600; }

.user-menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: var(--space-xs) 0;
}

.user-menu-btn {
    display: block;
    width: 100%;
    padding: var(--space-sm) var(--space-lg);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.8rem;
    text-align: left;
    cursor: pointer;
    transition: var(--transition-fast);
}

.user-menu-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }

/* ========================================
   Leaderboard
   ======================================== */

.lb-header {
    margin-bottom: var(--space-xl);
}

.lb-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--space-xs);
}

.lb-subtitle {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.lb-table {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.lb-row {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.lb-row:hover { border-color: rgba(255, 255, 255, 0.08); }

.lb-row-me {
    border-color: rgba(227, 18, 11, 0.3);
    background: rgba(227, 18, 11, 0.05);
    box-shadow: 0 0 0 1px rgba(227, 18, 11, 0.15);
}

.lb-rank {
    font-size: 1.3rem;
    min-width: 36px;
    text-align: center;
}

.lb-user {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex: 1;
}

.lb-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(227, 18, 11, 0.08);
    font-size: 1.4rem;
}

.lb-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.lb-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.lb-score {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-yellow);
    min-width: 60px;
    text-align: right;
}

.lb-details {
    display: flex;
    gap: var(--space-md);
}

.lb-stat {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.lb-empty {
    text-align: center;
    color: var(--text-muted);
    padding: var(--space-2xl);
}

/* ========================================
   Card Action Buttons (Open in TDoc / Edit)
   ======================================== */

.card-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.card-action-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-md);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    background: transparent;
    color: var(--text-secondary);
    /* Stop flashcard flip propagation */
    position: relative;
    z-index: 10;
}

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

.btn-tdoc {
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--accent-blue);
}

.btn-tdoc:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent-blue);
}

.btn-edit {
    border-color: rgba(234, 179, 8, 0.3);
    color: var(--accent-yellow);
}

.btn-edit:hover {
    background: rgba(234, 179, 8, 0.1);
    border-color: var(--accent-yellow);
}

/* ========================================
   Edit Vocab Modal
   ======================================== */

.edit-modal-card {
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}

.profile-modal-card {
    max-width: 520px;
}

.profile-user-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
}

.profile-avatar {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(227, 18, 11, 0.12);
    font-size: 1.5rem;
    flex-shrink: 0;
}

.profile-user-meta {
    min-width: 0;
}

.profile-user-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.profile-user-role {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.profile-status-stack {
    display: grid;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.profile-status-item {
    font-size: 0.82rem;
    color: var(--text-secondary);
    padding: var(--space-sm) var(--space-md);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
}

.profile-help {
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.edit-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.edit-modal-header h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    font-weight: 700;
}

.modal-close-btn {
    width: 32px;
    height: 32px;
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-full);
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.modal-close-btn:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.edit-source-info {
    font-size: 0.75rem;
    color: var(--accent-blue);
    margin-bottom: var(--space-lg);
    padding: var(--space-xs) var(--space-sm);
    background: rgba(59, 130, 246, 0.08);
    border-radius: var(--radius-sm);
    border-left: 2px solid var(--accent-blue);
}

.edit-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

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

.edit-field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.edit-field label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.edit-inline-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.edit-auto-btn {
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.edit-auto-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.edit-auto-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    transform: none;
}

.modal-textarea {
    width: 100%;
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
    transition: var(--transition-fast);
}

.modal-textarea:focus {
    outline: none;
    border-color: var(--red-primary);
    box-shadow: 0 0 0 3px rgba(227, 18, 11, 0.1);
}

.edit-sync-status {
    font-size: 0.82rem;
    line-height: 1.5;
    min-height: 1.4em;
    margin-bottom: var(--space-sm);
    transition: var(--transition-fast);
}

.edit-sync-status.status-ok     { color: var(--accent-green); }
.edit-sync-status.status-warn   { color: var(--accent-yellow); }
.edit-sync-status.status-error  { color: #EF4444; }
.edit-sync-status.status-saving { color: var(--text-muted); }

.edit-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
}

.btn-secondary {
    padding: var(--space-sm) var(--space-lg);
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.btn-danger {
    padding: var(--space-sm) var(--space-lg);
    background: rgba(220, 38, 38, 0.14);
    border: 1px solid rgba(220, 38, 38, 0.28);
    border-radius: var(--radius-sm);
    color: #fca5a5;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(220, 38, 38, 0.2);
    color: #fecaca;
}

.btn-danger:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}


/* ========================================
   Admin & Password UI
   ======================================== */

.admin-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    background: linear-gradient(135deg, #f5a623, #e07b00);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 4px;
    vertical-align: middle;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.editor-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    background: linear-gradient(135deg, #4a9eff, #1e6fcc);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 4px;
    vertical-align: middle;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.lock-icon {
    margin-left: 4px;
    font-size: 0.75rem;
    opacity: 0.7;
    vertical-align: middle;
}

.password-error {
    color: #ff6b6b;
    font-size: 0.82rem;
    margin-bottom: var(--space-sm);
    text-align: center;
}

.lb-you {
    font-style: normal;
    color: var(--text-muted, #666);
    font-size: 0.8em;
}

/* Edit button on vocab browse items */
.vocab-edit-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--text-muted, #888);
    font-size: 0.85rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    opacity: 0;
}

.vocab-item:hover .vocab-edit-btn {
    opacity: 1;
}

.vocab-mastered-btn {
    min-height: 28px;
    padding: 4px 10px;
    border: 1px solid rgba(34, 197, 94, 0.35);
    border-radius: 6px;
    background: transparent;
    color: var(--accent-green);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}

.vocab-mastered-btn:hover {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.65);
}

.vocab-mastered-btn:disabled {
    cursor: wait;
    opacity: 0.55;
}

.vocab-edit-btn:hover {
    background: rgba(74, 158, 255, 0.15);
    border-color: rgba(74, 158, 255, 0.5);
    color: #4a9eff;
}

/* Edited indicator on card words */
.edited-mark {
    display: inline-block;
    margin-left: 4px;
    font-size: 0.75rem;
    color: #4a9eff;
    opacity: 0.8;
    vertical-align: super;
}


/* ========================================
   Light Mode Theme
   ======================================== */

body.light {
    --bg-primary: #F5F6FA;
    --bg-secondary: #ECEEF5;
    --bg-tertiary: #DFE2EE;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F0F2FA;
    --bg-glass: rgba(255, 255, 255, 0.88);

    --text-primary: #1A1D2E;
    --text-secondary: #4E5572;
    --text-muted: #8A92B0;
    --text-accent: #E3120B;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.07);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.10);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 40px rgba(227, 18, 11, 0.10);
}

body.light::before {
    background:
        radial-gradient(circle at 20% 20%, rgba(227, 18, 11, 0.04) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(59, 130, 246, 0.04) 0%, transparent 50%);
}

body.light #app-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.light .stat-pill {
    border-color: rgba(0, 0, 0, 0.07);
}

body.light .stat-pill:hover {
    border-color: rgba(0, 0, 0, 0.13);
}

body.light .modal-card {
    background: #FFFFFF;
    border-color: rgba(0, 0, 0, 0.08);
}

body.light .modal-input,
body.light .modal-textarea {
    background: var(--bg-secondary);
    border-color: rgba(0, 0, 0, 0.12);
    color: var(--text-primary);
}

body.light .edit-auto-btn {
    background: rgba(15, 23, 42, 0.04);
    border-color: rgba(15, 23, 42, 0.08);
    color: var(--text-secondary);
}

body.light .edit-auto-btn:hover:not(:disabled) {
    background: rgba(15, 23, 42, 0.08);
    color: var(--text-primary);
}

body.light .modal-input:focus,
body.light .modal-textarea:focus {
    border-color: var(--red-primary);
    background: #fff;
}

body.light .user-menu {
    background: #FFFFFF;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: var(--shadow-md);
}

body.light .user-menu-btn,
body.light .user-menu-item {
    color: var(--text-primary);
}

body.light .user-menu-btn:hover,
body.light .user-menu-item:hover {
    background: var(--bg-secondary);
}

body.light .user-menu-divider {
    border-color: rgba(0, 0, 0, 0.08);
}

body.light .tab-btn {
    color: var(--text-secondary);
}

body.light .tab-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

body.light .tab-btn.active {
    background: #FFFFFF;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

body.light .flashcard {
    border-color: rgba(0, 0, 0, 0.07);
}

body.light .info-link {
    border-color: rgba(0, 0, 0, 0.1);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 241, 235, 0.96));
    box-shadow:
        0 10px 22px rgba(15, 23, 42, 0.10),
        0 1px 0 rgba(255, 255, 255, 0.9) inset,
        0 0 0 1px rgba(227, 18, 11, 0.05);
}

body.light .info-link:hover {
    border-color: rgba(0, 0, 0, 0.14);
    box-shadow:
        0 14px 26px rgba(15, 23, 42, 0.14),
        0 1px 0 rgba(255, 255, 255, 1) inset,
        0 0 0 1px rgba(227, 18, 11, 0.1);
}

body.light .card-hint {
    color: var(--text-muted);
}

body.light .card-definition {
    scrollbar-color: rgba(15, 23, 42, 0.18) transparent;
}

body.light .card-definition::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.18);
}

body.light .card-definition::-webkit-scrollbar-thumb:hover {
    background: rgba(15, 23, 42, 0.28);
}

body.light .card-definition blockquote {
    border-left-color: rgba(34, 197, 94, 0.28);
}

body.light .card-definition pre {
    background: rgba(15, 23, 42, 0.06);
}

body.light .card-definition hr {
    border-top-color: rgba(15, 23, 42, 0.12);
}

body.light .btn-danger {
    background: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.18);
    color: #b91c1c;
}

body.light .btn-danger:hover:not(:disabled) {
    background: rgba(220, 38, 38, 0.16);
    color: #991b1b;
}

body.light select {
    background: var(--bg-secondary);
    border-color: rgba(0, 0, 0, 0.12);
    color: var(--text-primary);
}

/* ── Auth Tabs ────────────────────────────────── */
.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: var(--space-md);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
}
.auth-tab {
    flex: 1;
    padding: var(--space-xs) var(--space-sm);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}
.auth-tab.active {
    background: var(--accent-blue);
    color: white;
}
.auth-tab:hover:not(.active) {
    background: var(--bg-tertiary);
}
