:root {
    --base-font-size: 16px;

    /* Light theme colors (default) */
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --panel-bg: white;
    --text-primary: #1a1a1a;
    --text-secondary: #666;
    --text-tertiary: #888;
    --border-color: #e9ecef;
    --input-border: #e9ecef;
    --input-focus: #667eea;
    --conversation-bg: #f8f9fa;
    --section-bg: #f8f9fa;
    --message-tutor-bg: #e3e8ff;
    --message-user-bg: #667eea;
    --message-user-text: white;
    --vocab-highlight-bg: #d4edda;
    --new-word-bg: rgba(255, 243, 205, 0.4);
    --new-word-border: #ffc107;
    --feedback-bg: #fff3cd;
    --feedback-text: #856404;
    --error-bg: #f8d7da;
    --error-text: #dc3545;
    --card-bg: white;
    --shadow: rgba(0,0,0,0.3);
    --header-overlay: rgba(255,255,255,0.2);
    --header-overlay-hover: rgba(255,255,255,0.3);
}

body.dark-theme {
    /* Dark theme colors */
    --bg-gradient-start: #1a1a2e;
    --bg-gradient-end: #16213e;
    --panel-bg: #0f3460;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --text-tertiary: #6c757d;
    --border-color: #1e3a5f;
    --input-border: #1e3a5f;
    --input-focus: #5568d3;
    --conversation-bg: #0a2342;
    --section-bg: #1a1a2e;
    --message-tutor-bg: #1e3a5f;
    --message-user-bg: #5568d3;
    --message-user-text: white;
    --vocab-highlight-bg: #1e4d2b;
    --new-word-bg: rgba(255, 193, 7, 0.2);
    --new-word-border: #ffc107;
    --feedback-bg: #3d3d00;
    --feedback-text: #ffc107;
    --error-bg: #5a1a1a;
    --error-text: #ff6b6b;
    --card-bg: #1e3a5f;
    --shadow: rgba(0,0,0,0.6);
    --header-overlay: rgba(255,255,255,0.1);
    --header-overlay-hover: rgba(255,255,255,0.2);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: var(--base-font-size);
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    padding: 0;
    color: var(--text-primary);
    overflow: hidden;
}

#root {
    display: grid;
    grid-template-columns: 250px 1fr 280px 280px;
    gap: 0;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.main-panel {
    background: var(--panel-bg);
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    grid-column: 2;
    grid-row: 1;
}

.nav-sidebar {
    background: var(--panel-bg);
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--border-color);
    grid-column: 1;
    grid-row: 1;
}

.nav-title {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.nav-title h1 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--input-focus);
}

.vocab-sidebar {
    background: var(--panel-bg);
    border-radius: 0;
    box-shadow: none;
    overflow-y: auto;
    padding: 20px;
    border-left: 1px solid var(--border-color);
    grid-column: 4;
    grid-row: 1;
}

.nav-section {
    padding: 0;
    border-bottom: 1px solid var(--border-color);
}

.nav-item {
    width: 100%;
    padding: 6px 16px;
    margin-bottom: 4px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
    text-align: left;
}

.nav-item:hover {
    background: var(--section-bg);
}

.nav-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.conversations-section {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.conversations-title {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.conversations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.conversation-session-item-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.conversation-session-item-wrapper:hover {
    background: var(--section-bg);
}

.conversation-session-item-wrapper.active {
    background: var(--message-tutor-bg);
    border-color: var(--input-focus);
}

.conversation-session-item {
    flex: 1;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.conversation-session-item:hover {
    background: var(--section-bg);
}

.conversation-session-item.active {
    background: var(--message-tutor-bg);
}

.conversation-delete-button {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    padding: 0;
}

.conversation-delete-button:hover {
    background: rgba(239, 68, 68, 0.1);
    color: rgb(239, 68, 68);
}

.conversation-preview {
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.conversation-meta {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.no-conversations {
    font-size: 13px;
    color: var(--text-tertiary);
    text-align: center;
    padding: 20px;
    font-style: italic;
}

.nav-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
}

.vocab-sidebar .section {
    background: var(--section-bg);
    padding: 16px;
    border-radius: 12px;
}

.vocab-sidebar .section h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--input-focus);
}

.sidebar {
    background: var(--panel-bg);
    border-radius: 0;
    box-shadow: none;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
    border-left: 1px solid var(--border-color);
    grid-column: 3;
    grid-row: 1;
}

.conversation-area {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--conversation-bg);
}

.message {
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
}

.message.user {
    flex-direction: row-reverse;
}

.message-content {
    display: flex;
    flex-direction: column;
    max-width: 70%;
}

.message.user .message-content {
    align-items: flex-end;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
}

.message-bubble.translating {
    opacity: 0.7;
}

.translate-toggle-btn,
.speak-toggle-btn {
    display: inline;
    padding: 0;
    margin: 0;
    font-size: inherit;
    background: none;
    color: #667eea;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 400;
    text-decoration: underline;
}

.translate-toggle-btn:hover:not(:disabled),
.speak-toggle-btn:hover:not(:disabled) {
    color: #5568d3;
    text-decoration: underline;
}

.translate-toggle-btn:disabled,
.speak-toggle-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

.translation-spinner {
    display: inline-block;
    font-style: italic;
    color: #666;
    animation: pulse 1.5s ease-in-out infinite;
}

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

.message.tutor .message-bubble {
    background: var(--message-tutor-bg);
    color: var(--text-primary);
}

.message.user .message-bubble {
    background: var(--message-user-bg);
    color: var(--message-user-text);
}

.message-line-group {
    margin-bottom: 12px;
}

.message-line-group:last-child {
    margin-bottom: 0;
}

.chinese-line {
    line-height: 1.5;
}

.pinyin-line {
    font-size: 0.75em;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.3;
    margin-top: 2px;
    opacity: 0.85;
}

.message.user .pinyin-line {
    color: rgba(255, 255, 255, 0.75);
}

.english-line {
    font-size: 0.8em;
    color: var(--text-tertiary);
    line-height: 1.3;
    margin-top: 2px;
    opacity: 0.8;
}

.message.user .english-line {
    color: rgba(255, 255, 255, 0.7);
}

.message-timestamp {
    font-size: 11px;
    margin-top: 4px;
    color: var(--text-tertiary);
    opacity: 0.8;
}

.message.user .message-timestamp {
    text-align: right;
}

.message-feedback {
    font-size: 12px;
    margin-top: 4px;
    padding: 8px;
    background: var(--feedback-bg);
    border-radius: 8px;
    color: var(--feedback-text);
}

.vocabulary-highlight {
    background: var(--vocab-highlight-bg);
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
}

.new-word-highlight {
    background: var(--new-word-bg);
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 1px dotted var(--new-word-border);
}

.input-area {
    padding: 20px 24px;
    background: var(--panel-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.input-area input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--input-border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
    background: var(--conversation-bg);
    color: var(--text-primary);
}

.input-area input:focus {
    border-color: var(--input-focus);
}

.input-area button {
    padding: 12px 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.input-area button:hover {
    background: #5568d3;
}

.input-area button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.section {
    background: var(--section-bg);
    padding: 16px;
    border-radius: 12px;
}

.section h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--input-focus);
}

.goal-item {
    padding: 12px;
    background: var(--card-bg);
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    border-left: 3px solid var(--input-focus);
}

.progress-bar {
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s;
}

.stat {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
}

.stat-value {
    font-weight: 600;
    color: var(--input-focus);
}

.vocab-item {
    padding: 8px;
    background: var(--card-bg);
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.vocab-word {
    font-weight: 600;
}

.vocab-usage-count {
    font-size: 11px;
    color: var(--text-secondary);
}

.level-badge {
    display: inline-block;
    padding: 4px 12px;
    background: #d4edda;
    color: #155724;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.loading {
    opacity: 0.6;
}

.error {
    color: var(--error-text);
    padding: 12px;
    background: var(--error-bg);
    border-radius: 8px;
    margin: 12px 0;
    font-size: 14px;
}

.settings-btn {
    background: var(--header-overlay);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.settings-btn:hover {
    background: var(--header-overlay-hover);
}

.new-session-btn {
    background: var(--header-overlay);
    border: none;
    color: white;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.3s;
}

.new-session-btn:hover {
    background: var(--header-overlay-hover);
}

.new-session-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Panel View - replaces modal overlay, takes last 3 columns */
.panel-view {
    position: absolute;
    top: 0;
    left: 250px;
    right: 0;
    bottom: 0;
    background: var(--panel-bg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--panel-bg);
}

.panel-view-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--input-focus);
    margin: 0;
}

.panel-view-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.panel-view-close:hover {
    background: var(--section-bg);
    color: var(--text-primary);
}

.panel-view-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Centered panel content for quick search */
.panel-view-content.centered {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Modal Styles - for backwards compatibility, kept but unused */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 250px;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--panel-bg);
    border-radius: 16px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px var(--shadow);
}

.modal-content h2 {
    margin-bottom: 24px;
    color: var(--input-focus);
    font-size: 24px;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.form-group input,
.form-group select {
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s;
    background: var(--conversation-bg);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--input-focus);
}

.form-group small {
    font-size: 12px;
    color: var(--text-secondary);
}

.btn-primary,
.btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--section-bg);
}

.btn-primary:disabled,
.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive modal overlay */
@media (max-width: 1200px) {
    .modal-overlay {
        left: 200px;
    }
    .panel-view {
        left: 200px;
    }
}

@media (max-width: 1024px) {
    .modal-overlay {
        left: 0;
    }
    .panel-view {
        left: 0;
    }
}

/* HSK Vocabulary Grid Styles */
.hsk-grid-modal {
    max-width: 1000px;
    width: 95%;
}

.quick-search-modal {
    max-width: 800px;
    width: 90%;
}

.band-selector {
    margin-bottom: 24px;
}

.band-selector label {
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.band-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.band-button {
    padding: 8px 16px;
    background: var(--section-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    text-align: center;
    flex: 1;
    min-width: 90px;
    color: var(--text-primary);
}

.band-button small {
    font-size: 10px;
    font-weight: 400;
    color: var(--text-secondary);
}

.band-button small.band-percentage {
    font-size: 11px;
    font-weight: 600;
    color: #667eea;
}

.band-button:hover {
    background: var(--border-color);
    border-color: var(--input-focus);
}

.band-button.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.band-button.active small {
    color: rgba(255, 255, 255, 0.9);
}

.band-button.active small.band-percentage {
    color: white;
}

.band-button.has-matches {
    background: #e3f2fd;
    border-color: #2196F3;
}

.band-button.has-matches:hover {
    background: #bbdefb;
    border-color: #1976D2;
}

.band-button.active.has-matches {
    background: #667eea;
    border-color: #667eea;
}

.band-button.active.has-matches .match-badge {
    color: white !important;
}

/* Dark theme band buttons */
body.dark-theme .band-button.has-matches {
    background: #1a3a52;
    border-color: #2196F3;
}

body.dark-theme .band-button.has-matches:hover {
    background: #244f6b;
    border-color: #1976D2;
}

body.dark-theme .band-button.active.has-matches {
    background: #667eea;
    border-color: #667eea;
}

body.dark-theme .band-button small.band-percentage {
    color: #667eea;
}

body.dark-theme .band-button.active small.band-percentage {
    color: white;
}

.vocabulary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    padding: 4px;
}

.vocab-card {
    background: var(--section-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.vocab-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
    border-color: var(--input-focus);
}

/* Manually marked as known - yellow */
.vocab-card.known {
    background: #fff3cd;
    border-color: #ffc107;
}

.vocab-card.known:hover {
    border-color: #e0a800;
}

/* Used in conversations - green */
.vocab-card.learned {
    background: #d4edda;
    border-color: #28a745;
}

.vocab-card.learned:hover {
    border-color: #1e7e34;
}

/* Both known and learned - darker green */
.vocab-card.known-learned {
    background: #c3e6cb;
    border-color: #1e7e34;
}

.vocab-card.known-learned:hover {
    border-color: #155724;
}

/* Dark theme vocab cards */
body.dark-theme .vocab-card.known {
    background: #3d3d00;
    border-color: #ffc107;
    color: #ffc107;
}

body.dark-theme .vocab-card.known:hover {
    border-color: #e0a800;
}

body.dark-theme .vocab-card.learned {
    background: #1e4d2b;
    border-color: #28a745;
}

body.dark-theme .vocab-card.learned:hover {
    border-color: #1e7e34;
}

body.dark-theme .vocab-card.known-learned {
    background: #2d5a36;
    border-color: #1e7e34;
}

body.dark-theme .vocab-card.known-learned:hover {
    border-color: #155724;
}

.vocab-card-word {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.vocab-card-pinyin {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.vocab-card-translation {
    font-size: 11px;
    color: var(--text-tertiary);
    word-wrap: break-word;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    background: var(--header-overlay);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.theme-toggle-btn:hover {
    background: var(--header-overlay-hover);
}

/* Header buttons group */
.header-buttons-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Learning Statistics Modal Styles */
.statistics-modal {
    max-width: 900px !important;
}

.statistics-section {
    margin-bottom: 32px;
}

.statistics-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--input-focus);
}

.statistics-section h4 {
    font-size: 16px;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--section-bg);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    border: 2px solid var(--border-color);
    transition: all 0.3s;
}

.stat-card:hover {
    border-color: var(--input-focus);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--input-focus);
}

.velocity-info {
    background: var(--section-bg);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.velocity-info p {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.velocity-info p:last-child {
    margin-bottom: 0;
}

.velocity-info strong {
    color: var(--input-focus);
    font-weight: 600;
}

.predictions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.prediction-item {
    background: var(--section-bg);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 2px solid var(--border-color);
    transition: all 0.3s;
}

.prediction-item:hover {
    border-color: var(--input-focus);
}

.prediction-level {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 15px;
}

.prediction-date {
    font-weight: 600;
    color: var(--input-focus);
    font-size: 15px;
}

.prediction-days {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 80px;
    text-align: right;
}

.completed-badge {
    background: #28a745;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}

/* Swipe Review Modal - uses last 3 columns */
.swipe-review-modal .panel-view-close {
    color: rgba(255, 255, 255, 0.8);
}

.swipe-review-modal .panel-view-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 1);
}

body.dark-theme .swipe-review-modal .panel-view-close {
    color: rgba(255, 255, 255, 0.8);
}

body.dark-theme .swipe-review-modal .panel-view-close:hover {
    background: rgba(0, 0, 0, 0.3);
    color: rgba(255, 255, 255, 1);
}

.swipe-review-modal {
    position: fixed;
    top: 0;
    left: 250px;
    right: 0;
    bottom: 0;
    background: var(--bg-gradient-start);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

body.dark-theme .swipe-review-modal {
    background: var(--bg-gradient-start);
}

/* Progress Bar */
.review-progress-bar {
    width: 100%;
    max-width: 400px;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.review-progress-fill {
    height: 100%;
    background: #10b981;
    transition: width 0.3s ease;
}

.review-progress-text {
    font-size: var(--base-font-size);
    color: white;
    margin-bottom: 10px;
    font-weight: 500;
}

body.dark-theme .review-progress-text {
    color: var(--text-primary);
}

.review-live-stats {
    font-size: calc(var(--base-font-size) * 0.9);
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 30px;
    text-align: center;
}

body.dark-theme .review-live-stats {
    color: var(--text-secondary);
}

/* Swipe Card */
.swipe-card {
    width: 100%;
    max-width: 400px;
    min-height: 300px;
    background: var(--card-bg);
    border-radius: 16px;
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    transition: transform 0.1s ease, opacity 0.1s ease;
    cursor: grab;
    user-select: none;
    touch-action: none;
    position: relative;
}

.swipe-card:active {
    cursor: grabbing;
}

.swipe-card-word {
    font-size: calc(var(--base-font-size) * 2.5);
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.swipe-card-pinyin {
    font-size: calc(var(--base-font-size) * 1.25);
    color: var(--input-focus);
    margin-bottom: 20px;
}

.swipe-card-translation {
    font-size: var(--base-font-size);
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 30px;
    line-height: 1.5;
}

.swipe-card-band {
    font-size: calc(var(--base-font-size) * 0.875);
    color: var(--text-tertiary);
    background: var(--section-bg);
    padding: 6px 12px;
    border-radius: 20px;
}

.swipe-audio-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.swipe-audio-btn:hover {
    color: var(--input-focus);
}

/* Action Buttons */
.swipe-actions {
    display: flex;
    gap: 20px;
    margin-top: 40px;
}

.swipe-btn {
    min-width: 120px;
    padding: 15px 25px;
    border: none;
    border-radius: 12px;
    font-size: var(--base-font-size);
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.swipe-btn-known {
    background: #10b981;
    color: white;
}

.swipe-btn-known:hover {
    background: #059669;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.swipe-btn-unknown {
    background: #ef4444;
    color: white;
}

.swipe-btn-unknown:hover {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Instructions */
.swipe-instructions {
    margin-top: 30px;
    font-size: calc(var(--base-font-size) * 0.875);
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    line-height: 1.6;
}

body.dark-theme .swipe-instructions {
    color: var(--text-secondary);
}

/* Completion Screen */
.swipe-review-complete {
    text-align: center;
    padding: 40px;
    color: white;
}

body.dark-theme .swipe-review-complete {
    color: var(--text-primary);
}

.swipe-review-complete h2 {
    font-size: calc(var(--base-font-size) * 2);
    margin-bottom: 40px;
}

.review-stats {
    display: flex;
    gap: 40px;
    justify-content: center;
    margin-bottom: 40px;
}

.stat-item {
    text-align: center;
}

.stat-item .stat-value {
    font-size: calc(var(--base-font-size) * 3);
    font-weight: bold;
    margin-bottom: 10px;
}

.stat-item:nth-child(1) .stat-value {
    color: #10b981;
}

.stat-item:nth-child(2) .stat-value {
    color: #ef4444;
}

.stat-label {
    font-size: var(--base-font-size);
    opacity: 0.9;
}

.swipe-review-complete .btn {
    background: white;
    color: var(--bg-gradient-start);
    border: none;
}

body.dark-theme .swipe-review-complete .btn {
    background: var(--card-bg);
    color: var(--text-primary);
}

/* Responsive Design */

/* Below 1024px the chat fills the screen, the navigation becomes a drawer,
   and the side panels stack under the chat instead of being pushed off-grid. */
.mobile-nav-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 900;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--panel-bg);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    cursor: pointer;
}

@media (max-width: 1200px) {
    #root {
        grid-template-columns: 200px 1fr 260px 260px;
    }

    .swipe-review-modal {
        left: 200px;
    }
}

@media (max-width: 1024px) {
    body {
        overflow: auto;
    }

    #root {
        display: flex;
        flex-direction: column;
        width: 100%;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .main-panel {
        order: 1;
        grid-column: auto;
        grid-row: auto;
        flex: 0 0 auto;
        height: 100vh;
        height: 100dvh;
    }

    .conversation-area {
        padding-top: 64px;
    }

    .sidebar,
    .vocab-sidebar {
        order: 2;
        grid-column: auto;
        grid-row: auto;
        border-left: none;
        border-top: 1px solid var(--border-color);
        max-height: none;
        overflow: visible;
    }

    .vocab-sidebar {
        order: 3;
    }

    .nav-sidebar {
        display: flex;
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(300px, 85vw);
        z-index: 1100;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        border-right: 1px solid var(--border-color);
    }

    .nav-sidebar.open {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
    }

    .mobile-nav-toggle {
        display: flex;
    }

    .mobile-nav-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1050;
        background: rgba(0, 0, 0, 0.45);
    }

    .panel-view {
        position: fixed;
    }

    .swipe-review-modal {
        left: 0;
    }
}

@media (max-width: 640px) {
    .swipe-card {
        min-height: 250px;
        padding: 30px 20px;
    }

    .swipe-card-word {
        font-size: calc(var(--base-font-size) * 2);
    }

    .review-stats {
        gap: 20px;
    }

    .stat-item .stat-value {
        font-size: calc(var(--base-font-size) * 2);
    }
}
