/* =========================================================================
   DIKA PRO STUDIO - LINEAR / RAYCAST DESIGN SYSTEM
   Bespoke, Precision-Engineered Dark Obsidian & Titanium Interface
   ========================================================================= */

:root {
    /* Core Obsidian Palette */
    --bg-base: #08090d;
    --bg-sidebar: #0d0f15;
    --bg-card: rgba(16, 18, 25, 0.78);
    --bg-card-hover: rgba(22, 25, 36, 0.9);
    --bg-surface: #11131a;
    --bg-surface-elevated: #161922;
    --bg-input: rgba(12, 14, 20, 0.85);
    
    /* Precision Hairline Borders */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-hover: rgba(255, 255, 255, 0.18);
    --border-color-active: rgba(94, 106, 210, 0.5);
    --border-subtle: rgba(255, 255, 255, 0.04);
    
    /* Studio Electric Accents (Linear Indigo & Raycast Cyan) */
    --primary: #5e6ad2;
    --primary-glow: rgba(94, 106, 210, 0.35);
    --primary-hover: #717fe0;
    --primary-muted: rgba(94, 106, 210, 0.15);
    
    --secondary: #1a1d27;
    --secondary-hover: #232735;
    
    --accent-blue: #0070f3;
    --accent-cyan: #00e5ff;
    --accent-magenta: #f43f5e;
    --accent-green: #10b981;
    --accent-amber: #f59e0b;
    
    /* High-Legibility Typography */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-code: #38bdf8;
    
    /* Metrics & Geometry */
    --border-radius-lg: 14px;
    --border-radius-md: 10px;
    --border-radius-sm: 6px;
    --glass-blur: 16px;
    
    /* Engineered Studio Shadows & Specular Highlights */
    --box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.06);
    --box-shadow-hover: 0 16px 40px -5px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.12);
    --box-shadow-focus: 0 0 0 2px var(--primary), 0 8px 24px -4px var(--primary-glow);
    --inner-specular: inset 0 1px 0 0 rgba(255, 255, 255, 0.12);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Vazirmatn', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    background-image: 
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(94, 106, 210, 0.18), transparent),
        radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 100% 100%, 24px 24px;
    background-attachment: fixed;
}

body::before {
    content: '';
    position: absolute;
    top: -20%;
    left: -10%;
    width: 55vw;
    height: 55vh;
    background: radial-gradient(circle, rgba(138, 43, 226, 0.15), transparent 70%);
    border-radius: 50%;
    filter: blur(60px);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: absolute;
    bottom: -20%;
    right: -10%;
    width: 50vw;
    height: 50vh;
    background: radial-gradient(circle, rgba(0, 240, 255, 0.12), transparent 70%);
    border-radius: 50%;
    filter: blur(60px);
    pointer-events: none;
    z-index: 0;
}

.app-container {
    display: flex;
    width: 100%;
    height: 100%;
    backdrop-filter: blur(8px);
    overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    backdrop-filter: blur(var(--glass-blur));
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 36px;
    padding: 0 8px;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
    border-radius: var(--border-radius-md);
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.logo h2 {
    font-size: 20px;
    font-weight: 800;
    background: linear-gradient(to left, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: var(--border-radius-md);
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    text-align: right;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item svg {
    transition: transform 0.3s ease;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.nav-item:hover svg {
    transform: scale(1.05);
}

.nav-item.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), rgba(138, 43, 226, 0.4));
    box-shadow: 0 4px 15px var(--primary-glow);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* Offline Badge Status */
.offline-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--border-radius-md);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-muted);
}

.offline-badge.active {
    color: var(--text-secondary);
    border-color: rgba(57, 255, 20, 0.15);
    background: rgba(57, 255, 20, 0.03);
}

.pulse {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
}

.offline-badge.active .pulse {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(57, 255, 20, 0.5); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(57, 255, 20, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(57, 255, 20, 0); }
}

/* Main Content Wrapper */
.content {
    flex-grow: 1;
    height: 100%;
    padding: 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Custom Scrollbar for Panel */
.content::-webkit-scrollbar {
    width: 8px;
}
.content::-webkit-scrollbar-track {
    background: transparent;
}
.content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}
.content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* Panels */
.panel {
    display: none;
    flex-direction: column;
    gap: 24px;
    animation: fade-in 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100%;
}

.panel.active {
    display: flex;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.panel-header h1 {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 6px;
    background: linear-gradient(to left, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.panel-header p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Glass Card */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    backdrop-filter: blur(var(--glass-blur));
    box-shadow: var(--box-shadow);
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

.glass-card:hover {
    border-color: var(--border-color-hover);
    background: var(--bg-card-hover);
}

/* Buttons */
.action-btn, .secondary-btn, .primary-btn, .remove-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--border-radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.action-btn {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: var(--border-color-hover);
}

.secondary-btn {
    background: var(--secondary);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.05);
}

.secondary-btn:hover {
    background: var(--secondary-hover);
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), #6e1dbf);
    color: #fff;
    box-shadow: 0 4px 15px var(--primary-glow);
    position: relative;
    overflow: hidden;
}

.primary-btn:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary));
    box-shadow: 0 6px 20px var(--primary-glow);
    transform: translateY(-2px);
}

.primary-btn:active {
    transform: translateY(0) scale(0.98);
}

.primary-btn:disabled, .secondary-btn:disabled, .action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Translator Panel Specifics */
.translator-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: stretch;
    height: 100%;
}

.lang-box {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    backdrop-filter: blur(var(--glass-blur));
    box-shadow: var(--box-shadow);
}

.lang-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid var(--border-color);
}

.lang-select {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 500;
    outline: none;
    cursor: pointer;
}

.lang-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.textarea-wrapper {
    flex-grow: 1;
    position: relative;
}

#source-textarea {
    width: 100%;
    height: 100%;
    min-height: 250px;
    background: transparent;
    border: none;
    resize: none;
    padding: 16px;
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.6;
    outline: none;
}

.translation-output {
    width: 100%;
    height: 100%;
    min-height: 250px;
    padding: 16px;
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.6;
    overflow-y: auto;
    white-space: pre-wrap;
    user-select: text;
}

/* Placeholder effect for translation display div */
.translation-output:empty::before {
    content: attr(placeholder);
    color: var(--text-muted);
}

.lang-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.1);
    border-top: 1px solid var(--border-color);
}

.counter {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
}

.mode-badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.mode-badge.online {
    background: rgba(0, 240, 255, 0.1);
    color: var(--accent-cyan);
    border: 1px solid rgba(0, 240, 255, 0.2);
}

.mode-badge.offline {
    background: rgba(138, 43, 226, 0.1);
    color: var(--primary-hover);
    border: 1px solid rgba(138, 43, 226, 0.2);
}

/* Swap divider */
.swap-divider {
    display: flex;
    align-items: center;
    justify-content: center;
}

.swap-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    box-shadow: var(--box-shadow);
    transition: all 0.3s ease;
}

.swap-btn:hover {
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
    transform: rotate(180deg);
}

/* Dictionary Styling */
.dictionary-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.search-bar-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    right: 18px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

#dict-search-input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 16px 52px 16px 52px;
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    box-shadow: var(--box-shadow);
    transition: border-color 0.3s ease;
}

#dict-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.dict-clear-btn {
    position: absolute;
    left: 18px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: none;
    align-items: center;
}

.dict-clear-btn:hover {
    color: var(--text-primary);
}

/* Result Card */
.dict-result-card {
    min-height: 350px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.dict-placeholder-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-muted);
    text-align: center;
}

.dict-placeholder-state h3 {
    color: var(--text-secondary);
    font-size: 18px;
}

.dict-result-content {
    animation: fade-in 0.3s ease;
}

.dict-word-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.word-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#dict-word-title {
    font-size: 32px;
    font-weight: 800;
    color: #fff;
}

.fallback-badge {
    font-size: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 12px;
    color: var(--text-secondary);
}

.speak-btn {
    background: rgba(138, 43, 226, 0.1);
    color: var(--primary-hover);
    border: 1px solid rgba(138, 43, 226, 0.15);
    padding: 8px 16px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    transition: all 0.2s ease;
}

.speak-btn:hover {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 0 10px var(--primary-glow);
}

.dict-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 20px 0;
}

.meanings-section h3 {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.meanings-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.meanings-list li {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 14px 18px;
    border-radius: var(--border-radius-md);
    font-size: 16px;
    line-height: 1.6;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.meanings-list li::before {
    content: "•";
    color: var(--primary-hover);
    font-weight: bold;
    font-size: 20px;
    line-height: 1;
}

/* OCR Layout */
.ocr-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: stretch;
}

.ocr-left-col, .ocr-right-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dropzone-card {
    border: 2px dashed var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    text-align: center;
    cursor: pointer;
    gap: 12px;
    transition: border-color 0.3s ease;
}

.dropzone-card:hover, .dropzone-card.dragover {
    border-color: var(--primary);
    background: rgba(138, 43, 226, 0.02);
}

.dropzone-card svg {
    color: var(--text-muted);
}

.dropzone-buttons {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

/* Preview Card */
.preview-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.remove-btn {
    background: rgba(255, 0, 127, 0.1);
    color: var(--accent-magenta);
    border: 1px solid rgba(255, 0, 127, 0.15);
    padding: 4px 10px;
    font-size: 12px;
    border-radius: var(--border-radius-sm);
}

.remove-btn:hover {
    background: var(--accent-magenta);
    color: #fff;
}

.img-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    max-height: 250px;
}

.img-container img {
    max-width: 100%;
    max-height: 250px;
    object-fit: contain;
}

/* OCR Result Card */
.ocr-result-card {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 380px;
}

.result-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.ocr-lang-setting {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.result-text-area {
    flex-grow: 1;
    margin-bottom: 16px;
}

#ocr-result-text, #doc-result-text {
    width: 100%;
    height: 100%;
    min-height: 200px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 16px;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.6;
    outline: none;
    resize: none;
}

.result-card-footer {
    display: flex;
    gap: 12px;
}

/* Settings and Model Download */
.settings-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-card {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.settings-info {
    max-width: 70%;
}

.settings-info h3 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 6px;
}

.settings-info p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.settings-action {
    display: flex;
    align-items: center;
    gap: 12px;
}

#model-status-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.status-label {
    font-size: 12px;
    color: var(--text-muted);
}

/* Switch Toggle Button */
.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 26px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--secondary-hover);
    transition: .3s;
    border: 1px solid var(--border-color);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .3s;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider:before {
    transform: translateX(24px);
    background-color: #fff;
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Info Card */
.info-card {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    border-color: rgba(0, 240, 255, 0.15);
    background: rgba(0, 240, 255, 0.02);
}

.info-icon {
    color: var(--accent-cyan);
}

.info-content h4 {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.info-content p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Progress Bar */
.progress-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 10px;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

.progress-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent-cyan));
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Toast System */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.toast {
    background: rgba(14, 11, 26, 0.9);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 12px 20px;
    color: #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    animation: toast-slide-in 0.3s ease forwards;
}

@keyframes toast-slide-in {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-color: rgba(57, 255, 20, 0.3); }
.toast.error { border-color: rgba(255, 0, 127, 0.3); }
.toast.info { border-color: rgba(0, 240, 255, 0.3); }

/* Hidden utility class */
.hidden {
    display: none !important;
}

/* Star/Favorite Button States */
.star-btn svg {
    transition: fill 0.2s ease, stroke 0.2s ease;
}

.star-btn.active svg {
    fill: #ffb700;
    stroke: #ffb700;
    filter: drop-shadow(0 0 4px rgba(255, 183, 0, 0.6));
}

.star-btn.active span {
    color: #ffb700;
}

/* OCR Direct Translation Display */
.ocr-translation-wrapper {
    margin-top: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    animation: fadeIn 0.3s ease;
}

.ocr-translation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
}

.ocr-translation-header .small-btn {
    padding: 4px 10px;
    font-size: 11px;
    border-radius: var(--border-radius-sm);
    gap: 4px;
}

.ocr-translation-display {
    max-height: 150px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    direction: rtl;
    text-align: right;
    white-space: pre-wrap;
    padding: 6px;
}

/* History Panel Styling */
.history-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: calc(100vh - 180px);
}

.history-tabs-header {
    display: flex;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.history-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 600;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
}

.history-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.history-tab.active {
    color: #fff;
    background: var(--secondary-hover);
    box-shadow: inset 0 0 0 1px var(--border-color);
}

.history-filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.filter-options {
    display: flex;
    gap: 8px;
}

.filter-chip {
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-chip:hover {
    border-color: var(--border-color-hover);
}

.filter-chip.active {
    background: rgba(138, 43, 226, 0.15);
    border-color: var(--primary);
    color: #fff;
}

.danger-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 0, 127, 0.1);
    border: 1px solid rgba(255, 0, 127, 0.2);
    color: var(--accent-magenta);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.danger-btn:hover {
    background: rgba(255, 0, 127, 0.2);
    border-color: rgba(255, 0, 127, 0.4);
}

.history-content-area {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 4px;
}

.history-tab-pane {
    display: none;
    height: 100%;
}

.history-tab-pane.active {
    display: block;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    padding: 48px 0;
    text-align: center;
    gap: 12px;
}

.history-empty svg {
    stroke: var(--text-muted);
}

.history-empty h3 {
    font-size: 16px;
    color: var(--text-secondary);
}

.history-empty p {
    font-size: 13px;
}

/* History List Item Cards */
.history-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: all 0.2s ease;
    animation: fadeIn 0.3s ease;
}

.history-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-color-hover);
}

.history-item-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.history-item-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.history-item-title {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.history-item-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.history-item-actions {
    display: flex;
    gap: 8px;
}

.history-action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.history-action-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.history-action-btn.fav-toggle-btn.favorited {
    color: #ffb700;
}

.history-action-btn.delete-btn:hover {
    color: var(--accent-magenta);
    background: rgba(255, 0, 127, 0.05);
}

.history-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    padding-top: 8px;
}

.history-item-badge {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    color: var(--text-secondary);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* History Tabs and Layout */
.header-with-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 16px;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
}

.history-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.history-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.history-tab:hover {
    background: rgba(255, 255, 255, 0.05);
}

.history-tab.active {
    background: rgba(138, 43, 226, 0.15);
    border-color: var(--primary);
    color: #fff;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    flex-grow: 1;
    padding-right: 4px;
}

.history-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    padding: 48px 0;
    text-align: center;
    gap: 12px;
    flex-grow: 1;
}

.history-empty-state svg {
    stroke: var(--text-muted);
}

.history-empty-state p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* History Item Styles */
.history-item {
    background: rgba(22, 18, 38, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.2s ease;
    animation: fadeIn 0.3s ease;
}

.history-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-color-hover);
}

.h-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
}

.h-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.trans-badge {
    background: rgba(138, 43, 226, 0.15);
    color: #d8b4fe;
}

.dict-badge {
    background: rgba(0, 240, 255, 0.15);
    color: var(--accent-cyan);
}

.h-date {
    font-size: 11px;
    color: var(--text-muted);
}

.h-item-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.h-source {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.h-target {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.h-item-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

.h-fav-btn.active {
    color: #ffb700;
}

.h-fav-btn.active svg {
    fill: #ffb700;
}

.h-del-btn:hover {
    color: var(--accent-magenta);
    background: rgba(255, 0, 127, 0.1);
}

/* Lang Footer alignment */
.lang-footer-left {
    display: flex;
    gap: 8px;
}

/* Instant OCR Translation styling */
.ocr-instant-translation {
    margin-top: 16px;
    animation: fadeIn 0.3s ease;
}

.ocr-divider {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin-bottom: 16px;
}

.instant-translation-area textarea {
    height: 120px;
    background: rgba(14, 11, 26, 0.5);
    border-color: rgba(138, 43, 226, 0.3);
}

.instant-translation-area textarea:focus {
    border-color: var(--primary);
}


/* Light Theme Variables */
[data-theme="light"] {
    --bg-base: #f8f9fc;
    --bg-sidebar: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-card-hover: #ffffff;
    --bg-surface: #f1f5f9;
    --bg-surface-elevated: #ffffff;
    --border-color: rgba(0, 0, 0, 0.08);
    --border-color-hover: rgba(0, 0, 0, 0.16);
    --border-subtle: rgba(0, 0, 0, 0.04);
    
    --primary: #4f46e5;
    --primary-glow: rgba(79, 70, 229, 0.2);
    --primary-hover: #4338ca;
    
    --secondary: #e2e8f0;
    --secondary-hover: #cbd5e1;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.04);
    --box-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.08);
    --inner-specular: inset 0 1px 0 0 rgba(255, 255, 255, 0.8);
}

[data-theme="light"] body {
    background-image: 
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(79, 70, 229, 0.08), transparent),
        radial-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px);
}

[data-theme="light"] .logo-icon {
    box-shadow: 0 4px 12px rgba(108, 35, 181, 0.3);
}

[data-theme="light"] #theme-toggle-btn .sun-icon {
    display: none !important;
}
[data-theme="light"] #theme-toggle-btn .moon-icon {
    display: block !important;
}

[data-theme="dark"] #theme-toggle-btn .sun-icon {
    display: block !important;
}
[data-theme="dark"] #theme-toggle-btn .moon-icon {
    display: none !important;
}

/* =========================================================================
   Light Theme Contrast Overrides
   ========================================================================= */
[data-theme="light"] .panel-header h1 {
    background: linear-gradient(to left, var(--primary), var(--text-secondary));
    -webkit-background-clip: text;
    background-clip: text;
}
[data-theme="light"] .placeholder-logo h2,
[data-theme="light"] .history-source-text,
[data-theme="light"] .dict-word-title,
[data-theme="light"] .dict-pos-tag,
[data-theme="light"] .info-content h4,
[data-theme="light"] .history-item-title,
[data-theme="light"] .h-source {
    color: var(--text-primary) !important;
}
[data-theme="light"] .swap-btn:hover {
    color: var(--primary) !important;
}
[data-theme="light"] .history-tab.active,
[data-theme="light"] .filter-chip.active,
[data-theme="light"] .dict-tab.active,
[data-theme="light"] .dict-filter-chip.active {
    color: var(--primary) !important;
    background: rgba(108, 35, 181, 0.15) !important;
    border-color: var(--primary) !important;
}
[data-theme="light"] .toast {
    background: var(--text-primary);
    color: var(--bg-base) !important;
}
[data-theme="light"] .lang-select option {
    background: #ffffff;
    color: var(--text-primary);
}
[data-theme="light"] #ocr-result-text,
[data-theme="light"] #doc-result-text {
    background: rgba(0, 0, 0, 0.05);
}

/* =========================================================================
   Camera Modal Styling
   ========================================================================= */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    width: 90%;
    max-width: 600px;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.hidden .modal-content {
    transform: scale(0.9);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.video-container {
    width: 100%;
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
}

.video-container video {
    width: 100%;
    display: block;
    object-fit: cover;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.4); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(255, 0, 0, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 0, 0, 0); }
}
.recording-pulse {
    animation: pulse 1.5s infinite;
    background: rgba(255, 0, 0, 0.1) !important;
}

/* Formula Preview Box */
.formula-preview {
    margin-top: 10px;
    padding: 15px;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px dashed var(--border);
    min-height: 40px;
    color: var(--text-primary);
    direction: ltr;
    text-align: left;
    overflow-x: auto;
    font-size: 1.1em;
}
.formula-preview.hidden {
    display: none;
}

/* =========================================================================
   Mini Mode (Widget) Styling
   ========================================================================= */
body.mini-mode {
    background: transparent !important;
}
body.mini-mode .sidebar {
    display: none !important;
}
body.mini-mode .app-container {
    padding: 0 !important;
}
body.mini-mode .panel-header, 
body.mini-mode .swap-divider,
body.mini-mode .history-filter-bar {
    display: none !important;
}
body.mini-mode .mini-mode-toolbar {
    display: flex !important;
}
body.mini-mode .translator-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
}
body.mini-mode .swap-divider {
    display: flex !important;
    transform: rotate(90deg);
    margin: 5px auto;
    align-self: center;
    width: 32px;
    height: 32px;
}
body.mini-mode .lang-box {
    min-height: auto;
}
body.mini-mode #source-textarea, 
body.mini-mode .translation-output {
    min-height: 120px;
    padding: 10px;
    border-radius: var(--border-radius-md);
}
body.mini-mode .lang-footer {
    padding: 5px 8px;
}
body.mini-mode .lang-select {
    font-size: 13px;
    padding: 4px 20px 4px 8px;
}
body.mini-mode .icon-btn {
    width: 28px;
    height: 28px;
}

/* =========================================================================
   Flashcard & Leitner System Styling
   ========================================================================= */
.learning-card-container {
    min-height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}
#flashcard-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    width: 100%;
}
.flashcard {
    background-color: transparent;
    width: 100%;
    max-width: 400px;
    height: 250px;
    perspective: 1000px;
    cursor: pointer;
}
.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
    transform-style: preserve-3d;
}
.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}
.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow);
    padding: 20px;
}
.flashcard-front {
    background: linear-gradient(135deg, rgba(138,43,226,0.1), rgba(0,240,255,0.05));
    border: 2px solid var(--primary);
}
.flashcard-back {
    background: rgba(0,0,0,0.2);
    border: 2px solid var(--border-color);
    transform: rotateY(180deg);
    overflow-y: auto;
}
.click-hint {
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-muted);
    opacity: 0.8;
}
.flashcard-controls {
    display: flex;
    gap: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.video-container {
    width: 100%;
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
}

.video-container video {
    width: 100%;
    display: block;
    object-fit: cover;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.4); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(255, 0, 0, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 0, 0, 0); }
}
.recording-pulse {
    animation: pulse 1.5s infinite;
    background: rgba(255, 0, 0, 0.1) !important;
}

/* Formula Preview Box */
.formula-preview {
    margin-top: 10px;
    padding: 15px;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px dashed var(--border);
    min-height: 40px;
    color: var(--text-primary);
    direction: ltr;
    text-align: left;
    overflow-x: auto;
    font-size: 1.1em;
}
.formula-preview.hidden {
    display: none;
}

/* =========================================================================
   Mini Mode (Widget) Styling
   ========================================================================= */
body.mini-mode {
    background: transparent !important;
}
body.mini-mode .sidebar {
    display: none !important;
}
body.mini-mode .app-container {
    padding: 0 !important;
}
body.mini-mode .panel-header, 
body.mini-mode .swap-divider,
body.mini-mode .history-filter-bar {
    display: none !important;
}
body.mini-mode .mini-mode-toolbar {
    display: flex !important;
}
body.mini-mode .translator-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
}
body.mini-mode .swap-divider {
    display: flex !important;
    transform: rotate(90deg);
    margin: 5px auto;
    align-self: center;
    width: 32px;
    height: 32px;
}
body.mini-mode .lang-box {
    min-height: auto;
}
body.mini-mode #source-textarea, 
body.mini-mode .translation-output {
    min-height: 120px;
    padding: 10px;
    border-radius: var(--border-radius-md);
}
body.mini-mode .lang-footer {
    padding: 5px 8px;
}
body.mini-mode .lang-select {
    font-size: 13px;
    padding: 4px 20px 4px 8px;
}
body.mini-mode .icon-btn {
    width: 28px;
    height: 28px;
}

/* =========================================================================
   Flashcard & Leitner System Styling
   ========================================================================= */
.learning-card-container {
    min-height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}
#flashcard-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    width: 100%;
}
.flashcard {
    background-color: transparent;
    width: 100%;
    max-width: 400px;
    height: 250px;
    perspective: 1000px;
    cursor: pointer;
}
.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
    transform-style: preserve-3d;
}
.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}
.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow);
    padding: 20px;
}
.flashcard-front {
    background: linear-gradient(135deg, rgba(138,43,226,0.1), rgba(0,240,255,0.05));
    border: 2px solid var(--primary);
}
.flashcard-back {
    background: rgba(0,0,0,0.2);
    border: 2px solid var(--border-color);
    transform: rotateY(180deg);
    overflow-y: auto;
}
.click-hint {
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-muted);
    opacity: 0.8;
}
.flashcard-controls {
    display: flex;
    gap: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.flashcard.flipped ~ .flashcard-controls {
    opacity: 1;
    pointer-events: auto;
}

[data-theme="light"] .history-item { 
    background: #ffffff; 
    border-color: #e5e7eb; 
} 
[data-theme="light"] .history-item:hover { 
    background: #f9fafb; 
} 
[data-theme="light"] .history-item-text { 
    color: #4b5563; 
}  
/* Responsive Mobile & Tablet Styles */
@media (max-width: 768px) {
    body {
        overflow: hidden;
    }
    .app-container {
        flex-direction: column-reverse; /* Put bottom navigation bar at the very bottom */
        height: 100vh;
        width: 100vw;
        overflow: hidden;
    }
    .sidebar {
        width: 100%;
        height: 65px;
        min-height: 65px;
        flex-direction: row;
        padding: 0;
        border-left: none;
        border-top: 1px solid var(--border-color);
        z-index: 1000;
        background: var(--bg-sidebar);
        justify-content: center;
        align-items: center;
    }
    .sidebar .logo, 
    .sidebar-footer {
        display: none !important;
    }
    .nav-menu {
        flex-direction: row;
        width: 100%;
        height: 100%;
        overflow-x: auto;
        justify-content: flex-start;
        align-items: center;
        gap: 4px;
        padding: 0 8px;
        scrollbar-width: none; /* Firefox */
    }
    .nav-menu::-webkit-scrollbar {
        display: none; /* Safari and Chrome */
    }
    .nav-item {
        flex-shrink: 0;
        min-width: 85px;
        height: 100%;
        padding: 8px 4px;
        margin: 0;
        flex-direction: column;
        font-size: 10px;
        justify-content: center;
        align-items: center;
        gap: 4px;
        border-radius: 0;
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
        color: var(--text-secondary);
    }
    .nav-item.active {
        color: var(--primary-hover);
        border-bottom: 2px solid var(--primary) !important;
    }
    [data-theme="light"] .nav-item.active {
        color: var(--primary) !important;
    }
    .nav-item svg {
        width: 18px;
        height: 18px;
    }
    .nav-item span {
        font-size: 9px;
        white-space: nowrap;
    }
    .content {
        flex-grow: 1;
        padding: 16px;
        height: calc(100vh - 65px);
        overflow-y: auto;
        width: 100%;
    }
    .panel-header h1 {
        font-size: 20px;
    }
    .panel-header p {
        font-size: 12px;
    }
    .translator-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 8px;
        height: auto;
    }
    .swap-divider {
        margin: 4px 0;
    }
    .swap-btn {
        transform: rotate(90deg);
        width: 38px;
        height: 38px;
    }
    .swap-btn:hover {
        transform: rotate(270deg);
    }
    .lang-box {
        min-height: auto;
    }
    #source-textarea, .translation-output {
        min-height: 160px;
        font-size: 14px;
    }
    .ocr-container {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .dropzone-card {
        min-height: 180px;
    }
    #ocr-result-text, #doc-result-text {
        min-height: 150px;
    }
    .result-card-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .ocr-lang-setting {
        justify-content: space-between;
    }
    .result-card-footer {
        flex-wrap: wrap;
        gap: 8px;
    }
    .result-card-footer button {
        flex: 1 1 auto;
    }
    .history-container {
        height: auto;
        min-height: auto;
        border: none;
        padding: 0;
    }
    .history-filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .filter-options {
        justify-content: space-between;
    }
    .settings-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .settings-info {
        max-width: 100%;
    }
    .settings-action {
        justify-content: flex-start;
    }
    #model-status-wrapper {
        align-items: flex-start;
        width: 100%;
    }
    #download-model-btn {
        width: 100%;
    }
}

/* =========================================================================
   Webpage Translator & Auto-Detect Styling
   ========================================================================= */
.web-translator-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.web-url-card {
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
}

.web-input-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.url-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.url-input-wrapper .url-icon {
    position: absolute;
    right: 14px;
    color: var(--accent-blue);
    pointer-events: none;
}

.url-input-wrapper input {
    width: 100%;
    padding: 14px 44px 14px 40px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    font-size: 15px;
    direction: ltr;
    text-align: left;
    transition: all 0.2s ease;
}

.url-input-wrapper input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.15);
    outline: none;
}

.icon-btn-inline {
    position: absolute;
    left: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.web-lang-settings {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

.web-lang-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.web-lang-item label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.web-result-card {
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.web-result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.web-view-modes {
    display: flex;
    background: var(--bg-surface);
    padding: 3px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
}

.web-mode-btn {
    background: none;
    border: none;
    padding: 6px 14px;
    font-size: 13px;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.web-mode-btn.active {
    background: var(--accent-blue);
    color: #fff;
    font-weight: 600;
}

.web-content-view {
    max-height: 550px;
    overflow-y: auto;
    padding: 10px 5px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    line-height: 1.8;
}

.web-block {
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    transition: background 0.2s;
}

.web-block:hover {
    border-color: var(--accent-blue);
}

.web-block.tag-h1 {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--accent-blue);
    background: rgba(0, 102, 255, 0.05);
}

.web-block.tag-h2, .web-block.tag-h3 {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-primary);
}

.side-by-side-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
}

.side-by-side-row:hover {
    border-color: var(--accent-blue);
}

.side-source {
    direction: ltr;
    text-align: left;
    color: var(--text-secondary);
    border-left: 2px solid var(--border-color);
    padding-left: 12px;
    font-size: 14px;
}

.side-target {
    direction: rtl;
    text-align: right;
    color: var(--text-primary);
    font-size: 15px;
}

.detected-lang-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(0, 102, 255, 0.12);
    color: var(--accent-blue);
    margin-right: 6px;
    font-weight: 500;
}

/* ==========================================================================
   Developers & API Hub Styles (Linear / Raycast Pro Aesthetic)
   ========================================================================== */
.dev-tab-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 7px 14px;
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.dev-tab-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.dev-tab-btn.active {
    background: rgba(99, 102, 241, 0.2);
    border-color: #6366f1;
    color: #a5b4fc;
    font-weight: 600;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.25);
}

.dev-code-block {
    animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.copy-snippet-btn:hover {
    background: rgba(255, 255, 255, 0.25) !important;
}
