:root {
    /* Premium Color Palette */
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #10b981;
    --accent-red: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --danger-border: rgba(239, 68, 68, 0.2);
    
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow: hidden;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
}

.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    padding: 20px;
    gap: 20px;
}

/* Sidebar */
.sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    padding: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 40px;
    color: var(--primary);
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.nav-links li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-muted);
    font-weight: 500;
}

.nav-links li:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
}

.nav-links li.active {
    background: var(--primary);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.view-section {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    transition: opacity 0.3s ease;
}

.view-section.hidden {
    display: none;
    opacity: 0;
}

.hidden {
    display: none !important;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    margin-bottom: 20px;
}

.styled-select {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--glass-border);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    cursor: pointer;
}

.styled-select option {
    background: #1e1b4b;
    color: white;
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

.chat-container::-webkit-scrollbar {
    width: 6px;
}
.chat-container::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.message {
    display: flex;
    gap: 16px;
    max-width: 80%;
}

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

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-message .avatar {
    background: var(--primary);
}

.content {
    background: rgba(255, 255, 255, 0.05);
    padding: 16px;
    border-radius: 20px;
    border-top-left-radius: 4px;
    line-height: 1.5;
    position: relative;
}

.user-message .content {
    border-top-left-radius: 20px;
    border-top-right-radius: 4px;
    background: rgba(139, 92, 246, 0.2);
}

.content .word, .story-content .word {
    cursor: pointer;
    transition: color 0.2s;
    border-bottom: 1px dashed transparent;
}

.content .word:hover, .story-content .word:hover {
    color: var(--accent);
    border-bottom: 1px dashed var(--accent);
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 12px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(139, 92, 246, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-main);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.25);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-clear-input {
    transition: all 0.2s ease;
}

.btn-clear-input:hover {
    color: white !important;
    background: rgba(255, 255, 255, 0.1) !important;
    transform: scale(1.1);
}

.mic-controls-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
    margin: 6px 0;
}

.btn-mic-action {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 25px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-family: inherit;
    backdrop-filter: blur(8px);
}

.btn-mic-action i {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

.retry-btn:hover {
    background: rgba(245, 158, 11, 0.16);
    border-color: rgba(245, 158, 11, 0.5);
    color: #fcd34d;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.25);
}

.retry-btn:hover i {
    transform: rotate(-90deg);
}

.retry-btn.active-listening {
    background: rgba(245, 158, 11, 0.22);
    border-color: rgba(245, 158, 11, 0.6);
    color: #fbbf24;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
}

.cancel-btn:hover {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--accent-red);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.25);
}

#btn-mic {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    padding: 0;
    justify-content: center;
    background: var(--primary);
    flex-shrink: 0;
}

#btn-mic i {
    width: 28px;
    height: 28px;
}

#btn-mic.listening {
    background: var(--accent-red);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 20px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

#recording-status {
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: color 0.3s ease;
    text-align: center;
}

/* Vocab Section */
.vocab-container {
    flex: 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.tabs {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 12px;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-family: inherit;
}

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

.tab-btn.active {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.tab-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding-right: 8px; /* Space for scrollbar */
}

.tab-content::-webkit-scrollbar {
    width: 6px;
}
.tab-content::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

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

.word-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.word-list li {
    background: rgba(255, 255, 255, 0.03);
    padding: 16px;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.word-list .word-en {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary);
}

.word-list .word-tr {
    color: var(--text-muted);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
    font-style: italic;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s;
}

#word-modal {
    z-index: 2000;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    width: 100%;
    max-width: 450px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal h2 {
    font-size: 1.5rem;
    color: white;
}

.modal input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 14px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    outline: none;
    font-family: inherit;
}

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

.modal-footer {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
}
.modal-footer a {
    color: var(--primary);
    text-decoration: none;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    padding: 10px 16px;
}
.btn-text:hover {
    color: white;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--glass-border);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mt-4 {
    margin-top: 16px;
}

.story-content {
    background: rgba(0,0,0,0.2);
    padding: 20px;
    border-radius: var(--radius-md);
    line-height: 1.6;
    border: 1px solid var(--glass-border);
}

/* Flashcard SRS UI */
.flashcard-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.flashcard {
    width: 320px;
    height: 260px;
    perspective: 1000px;
    cursor: pointer;
}

.flashcard-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
    width: 100%;
    height: 100%;
    position: absolute;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
}

.flashcard-front {
    background: rgba(139, 92, 246, 0.1);
    border: 2px solid var(--primary);
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
}

.flashcard-back {
    transform: rotateY(180deg);
    background: rgba(16, 185, 129, 0.1);
    border: 2px solid var(--accent);
    flex-direction: column;
    overflow-y: auto;
    font-size: 1.2rem;
    color: white;
}

/* Custom scrollbar for flashcard back */
.flashcard-back::-webkit-scrollbar {
    width: 4px;
}
.flashcard-back::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.srs-controls {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.srs-controls.visible {
    opacity: 1;
    pointer-events: auto;
}

.btn-srs {
    padding: 10px 20px;
    border-radius: 20px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    color: white;
    font-family: inherit;
}

.btn-hard { background: #ef4444; }
.btn-good { background: #eab308; }
.btn-easy { background: #10b981; }

/* Typing animation */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    border-top-left-radius: 4px;
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.feedback-alert {
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.3);
    color: #fde047;
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-top: 8px;
    font-size: 0.9rem;
}

/* Topics Section */
.topics-container {
    flex: 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
}

.topics-container::-webkit-scrollbar {
    width: 6px;
}
.topics-container::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding-bottom: 20px;
}

.topics-grid.hidden {
    display: none;
}

.topic-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.topic-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.5);
    background: rgba(255, 255, 255, 0.06);
}

.topic-image {
    width: 100%;
    height: 160px;
    background-size: cover;
    background-position: center;
    border-bottom: 1px solid var(--glass-border);
}

.topic-info {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.topic-info h3 {
    color: white;
    font-size: 1.2rem;
    margin: 0;
}

.topic-info p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.topic-count {
    display: inline-block;
    background: rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    width: fit-content;
    margin-top: 8px;
}

.topic-detail {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.topic-detail.hidden {
    display: none;
}

.topic-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 16px;
}

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

/* Theme Toggle */
.theme-switch-wrapper {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 100;
}

.theme-switch {
    display: inline-block;
    height: 34px;
    position: relative;
    width: 60px;
}

.theme-switch input {
    display: none;
}

.slider {
    background-color: #1e1b4b;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px;
}

.slider.round {
    border-radius: 34px;
}

.slider:before {
    background-color: white;
    bottom: 3px;
    content: "";
    height: 26px;
    left: 4px;
    position: absolute;
    transition: .4s;
    width: 26px;
    border-radius: 50%;
    z-index: 2;
}

input:checked + .slider {
    background-color: #cbd5e1;
    border-color: rgba(0, 0, 0, 0.2);
}

input:checked + .slider:before {
    transform: translateX(24px);
    background-color: var(--primary);
}

.icon-sun, .icon-moon {
    width: 14px;
    height: 14px;
    color: #eab308;
    z-index: 1;
}

.icon-moon {
    color: #94a3b8;
}

input:checked + .slider .icon-moon {
    color: white;
}

/* Light Mode Overrides */
body.light-mode {
    --bg-gradient: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.1);
    --primary: #7c3aed;
    --primary-hover: #6d28d9;
    --text-main: #0f172a;
    --text-muted: #475569;
    --accent: #059669;
    --accent-red: #dc2626;
}

body.light-mode .glass-panel {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

body.light-mode .styled-select {
    background: rgba(255, 255, 255, 0.8) !important;
    color: var(--text-main) !important;
    border-color: rgba(0, 0, 0, 0.2) !important;
}

body.light-mode .styled-select option {
    background: #f1f5f9;
    color: var(--text-main);
}

body.light-mode input[type="text"],
body.light-mode input[type="password"] {
    background: rgba(255, 255, 255, 0.8) !important;
    color: var(--text-main) !important;
    border-color: rgba(0, 0, 0, 0.2) !important;
}

body.light-mode input::placeholder {
    color: var(--text-muted) !important;
}

body.light-mode .nav-links li.active {
    color: white;
}

body.light-mode .nav-links li:hover:not(.active) {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-main);
}

body.light-mode .avatar {
    background: rgba(0, 0, 0, 0.08);
}

body.light-mode .content,
body.light-mode .story-content {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

body.light-mode .user-message .content {
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.2);
}

body.light-mode .btn-secondary {
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-main);
    border-color: rgba(0, 0, 0, 0.2);
}

body.light-mode .btn-secondary:hover {
    background: rgba(255, 255, 255, 1);
}

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

body.light-mode .tab-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-main);
}

body.light-mode .tab-btn.active {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-main);
}

body.light-mode .word-list li,
body.light-mode .topic-card {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .word-list li:hover,
body.light-mode .topic-card:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: var(--primary);
}

body.light-mode .topic-count {
    background: rgba(124, 58, 237, 0.1);
    color: var(--primary);
}

body.light-mode .typing-indicator {
    background: rgba(0, 0, 0, 0.05);
}

body.light-mode .modal {
    background: #f8fafc;
    border: 1px solid rgba(0,0,0,0.1);
}

body.light-mode .btn-text {
    color: var(--text-muted);
}
body.light-mode .btn-text:hover {
    color: var(--text-main);
}

/* Override inline styles for light mode */
body.light-mode [style*="color: white"] {
    color: var(--text-main) !important;
}

body.light-mode [style*="background: rgba(0,0,0,0.2)"] {
    background: rgba(255,255,255,0.8) !important;
}

body.light-mode [style*="background:rgba(255,255,255,0.05)"],
body.light-mode [style*="background: rgba(255,255,255,0.05)"] {
    background: rgba(255,255,255,0.8) !important;
}

body.light-mode header h2,
body.light-mode header h3,
body.light-mode .modal h2,
body.light-mode h2,
body.light-mode h3 {
    color: var(--text-main) !important;
}

body.light-mode .modal p,
body.light-mode .modal {
    color: var(--text-main);
}

body.light-mode .logo {
    color: var(--primary);
}

body.light-mode .flashcard-front,
body.light-mode .flashcard-back {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.9);
}

body.light-mode .flashcard-back div {
    color: var(--text-main) !important;
}

body.light-mode #btn-listen-fc {
    color: var(--text-main) !important;
    border-color: rgba(0, 0, 0, 0.3) !important;
    background: rgba(0, 0, 0, 0.05) !important;
}


/* ===================== Mobile (phone) layout ===================== */
.label-short,
.mobile-only,
.nav-links li.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    body {
        min-height: 100dvh;
    }

    .app-container {
        height: 100dvh;
        flex-direction: column;
        padding: calc(8px + env(safe-area-inset-top)) 8px calc(72px + env(safe-area-inset-bottom)) 8px;
        gap: 8px;
    }

    /* Sidebar becomes a bottom tab bar */
    .sidebar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        z-index: 200;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        border-radius: 16px 16px 0 0;
        border-bottom: none;
        background: rgba(15, 23, 42, 0.92);
    }

    .sidebar .logo {
        display: none;
    }

    .nav-links {
        flex-direction: row;
        justify-content: space-around;
        gap: 2px;
    }

    .nav-links li {
        flex: 1 1 0;
        min-width: 0;
        flex-direction: column;
        gap: 3px;
        padding: 6px 2px;
        font-size: 0.68rem;
        border-radius: 10px;
        text-align: center;
    }

    .nav-links li svg {
        width: 22px;
        height: 22px;
    }

    .nav-links li.mobile-only {
        display: flex;
    }

    .label-long {
        display: none;
    }

    .label-short {
        display: inline;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    /* Theme switch: small, top-right */
    .theme-switch-wrapper {
        position: fixed;
        top: calc(10px + env(safe-area-inset-top));
        right: 12px;
        transform: scale(0.8);
        transform-origin: top right;
    }

    header {
        padding: 10px 12px;
        margin-bottom: 8px;
        padding-right: 64px;
    }

    header h2 {
        font-size: 1.15rem;
    }

    /* iOS zooms into inputs smaller than 16px */
    input,
    select,
    textarea,
    .styled-select {
        font-size: 16px !important;
    }

    /* Chat header: hide title, options in a 2x2 grid */
    .chat-header h2 {
        display: none;
    }

    .chat-header {
        padding-right: 64px;
    }

    .chat-header .chat-options {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 6px !important;
        width: 100%;
    }

    .chat-header .styled-select {
        padding: 6px 8px;
        width: 100%;
        min-width: 0;
    }

    .chat-container {
        padding: 12px;
        gap: 12px;
        margin-bottom: 8px;
    }

    .message {
        max-width: 100%;
        gap: 8px;
    }

    .message .avatar {
        display: none;
    }

    .content {
        padding: 10px 12px;
    }

    .controls {
        padding: 10px;
        gap: 6px;
    }

    .controls > div:first-child {
        margin-bottom: 8px !important;
    }

    #btn-send-text span {
        display: none;
    }

    .mic-controls-container {
        gap: 14px;
        margin: 0;
    }

    .btn-mic-action {
        padding: 10px 12px;
    }

    .btn-mic-action .btn-label {
        display: none;
    }

    #recording-status {
        margin-top: 4px !important;
        font-size: 0.85rem;
        text-align: center;
    }

    /* Chat view: news panel is its own tab on phones */
    #view-chat #news-sidebar {
        display: none !important;
    }

    #view-chat.news-mode .chat-main {
        display: none !important;
    }

    #view-chat.news-mode #news-sidebar {
        display: flex !important;
        width: 100% !important;
        margin-left: 0 !important;
    }

    /* Header descriptions take too much room on phones */
    #view-topics > header > div,
    #view-oxford > header > div {
        display: none;
    }

    .topics-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .topics-container,
    .vocab-container {
        padding: 12px;
    }

    .tabs {
        gap: 6px;
        overflow-x: auto;
        margin-bottom: 12px;
    }

    .tab-btn {
        white-space: nowrap;
    }

    .word-list li {
        padding: 12px;
        gap: 8px;
    }

    #view-oxford .glass-panel > div:first-child {
        flex-direction: column;
        align-items: stretch !important;
        gap: 8px;
    }

    #oxford-search {
        max-width: none !important;
    }

    #oxford-pagination {
        justify-content: center;
    }

    #view-dictionary header {
        padding: 16px 12px !important;
    }

    #view-dictionary header h2 {
        font-size: 1.4rem !important;
    }

    .modal {
        width: 92vw !important;
        max-width: 92vw !important;
        padding: 20px !important;
    }
}
