/* ═══════════════════════════════════════════════════════════════════════════════
   OPLOGICA AI v12.0 - STYLES
   Created by Mohamed Ibrahim & OpLogica Team
   Copyright © 2024-2026 Oplogica Inc.
═══════════════════════════════════════════════════════════════════════════════ */

:root {
    --panelWidth: 360px;
    --gutter: 16px;
    /* Primary - Elegant Teal from oplogica.com */
    --primary: #00D9A5;
    --primary-hover: #00C496;
    --primary-dim: #00B88A;
    --primary-glow: rgba(0, 217, 165, 0.3);
    --primary-bg: rgba(0, 217, 165, 0.1);
    --secondary: #00B4D8;
    /* Backgrounds - Deep dark like oplogica.com */
    --bg-primary: #0a0a0f;
    --bg-secondary: #0f0f15;
    --bg-tertiary: #15151d;
    --bg-card: #1a1a24;
    --bg-card-hover: #22222e;
    --bg-input: #12121a;
    --bg-hover: #22222e;
    --bg-active: #2a2a36;
    /* Text */
    --text-primary: #ffffff;
    --text-secondary: #b0b0c0;
    --text-muted: #707080;
    --text-dim: #505060;
    /* Borders */
    --border: #2a2a3a;
    --border-light: #3a3a4a;
    --border-primary: rgba(0, 217, 165, 0.3);
    /* Status */
    --success: #00D9A5;
    --warning: #F5A623;
    --error: #FF6B6B;
    --info: #00B4D8;
    --red: #FF6B6B;
    --red-bg: rgba(255, 107, 107, 0.1);
    --orange: #F5A623;
    --orange-bg: rgba(245, 166, 35, 0.1);
    --yellow: #eab308;
    --yellow-bg: rgba(234, 179, 8, 0.1);
    --purple: #a855f7;
    --purple-bg: rgba(168, 85, 247, 0.1);
    /* Aliases for compatibility */
    --green: var(--primary);
    --green-dim: var(--primary-dim);
    --green-bg: var(--primary-bg);
    --green-glow: var(--primary-glow);
    --cyan: var(--secondary);
    --cyan-bg: rgba(0, 180, 216, 0.1);
    /* Gradients */
    --grad-main: linear-gradient(135deg, #00D9A5 0%, #00B4D8 100%);
    --grad-primary: linear-gradient(135deg, #00D9A5 0%, #00B4D8 100%);
    --grad-pro: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
    --grad-dark: linear-gradient(180deg, #15151d 0%, #0a0a0f 100%);
    --grad-card: linear-gradient(145deg, #1a1a24 0%, #12121a 100%);
    --grad-glow: radial-gradient(ellipse at center, rgba(0,217,165,0.15) 0%, transparent 70%);
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(0, 217, 165, 0.2);
    /* Dashboard */
    --casio-bg: #0a120e;
    --casio-text: var(--primary);
    --casio-glow: 0 0 6px var(--primary-glow);
    /* Typography */
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Orbitron', monospace;
    --font-mono: 'JetBrains Mono', monospace;
    --radius: 12px;
    --radius-lg: 16px;
}

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

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

body.rtl { direction: rtl; }

body.no-colors {
    --green: var(--text-secondary);
    --red: var(--text-secondary);
    --orange: var(--text-secondary);
    --yellow: var(--text-secondary);
    --purple: var(--text-secondary);
    --casio-text: var(--text-secondary);
}

body.no-bold .msg-content strong { font-weight: 500; }

::-webkit-scrollbar { width: 7px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--cyan); }

/* ═══════════════════════════════════════════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════════════════════════════════════════ */
.app { display: flex; height: 100vh; }

.sidebar {
    width: 310px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.sidebar-head {
    padding: 18px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: var(--grad-main);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', monospace;
    font-weight: 800;
    font-size: 18px;
    color: var(--bg-primary);
    box-shadow: 0 4px 15px rgba(0, 180, 216, 0.25);
}

.logo-text {
    font-family: 'Orbitron', monospace;
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--grad-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-ver {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.new-btn {
    width: 100%;
    padding: 13px 18px;
    background: var(--grad-main);
    border: none;
    border-radius: var(--radius);
    color: var(--bg-primary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.25s ease;
}

.new-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 180, 216, 0.3);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   DASHBOARD
═══════════════════════════════════════════════════════════════════════════════ */
.dash {
    position: relative;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    transition: background 0.3s ease;
}

.dash:hover { background: linear-gradient(180deg, rgba(16,185,129,0.04) 0%, var(--bg-secondary) 100%); }

.dash-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.dash-title {
    font-family: 'Orbitron', monospace;
    font-size: 0.65rem;
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pulse-dot {
    width: 7px;
    height: 7px;
    background: var(--green);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--green-glow);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.85); }
}

.dash-badge {
    font-size: 0.6rem;
    padding: 3px 8px;
    background: var(--green-bg);
    color: var(--green);
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.gauges {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 14px;
}

.gauge-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.gauge {
    width: 75px;
    height: 75px;
    position: relative;
    background: radial-gradient(circle at 30% 30%, var(--bg-tertiary), var(--bg-primary));
    border-radius: 50%;
    border: 2px solid var(--border);
    box-shadow: inset 0 0 15px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
}

.gauge-arc {
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background: conic-gradient(
        from 135deg,
        #10b981 0deg,
        #34d399 calc(var(--v, 0) * 2.7deg),
        var(--border) calc(var(--v, 0) * 2.7deg),
        var(--border) 270deg
    );
    mask: radial-gradient(transparent 56%, black 58%);
    -webkit-mask: radial-gradient(transparent 56%, black 58%);
    transition: background 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.gauge-wrap:hover .gauge-arc { filter: drop-shadow(0 0 6px var(--green-glow)); }

.gauge-inner {
    position: absolute;
    inset: 14px;
    background: var(--bg-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
}

.gauge-val {
    font-family: 'Orbitron', monospace;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--casio-text);
    text-shadow: var(--casio-glow);
}

.gauge-lbl {
    font-size: 0.55rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 6px;
    text-align: center;
    line-height: 1.3;
    letter-spacing: 0.3px;
}

/* HUD v2.0: instrument-grade gauges, neon glow, tabular numbers */
.gauge-val {
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}
.gauge-wrap {
    position: relative;
    cursor: default;
}
.gauge-wrap:hover .gauge-arc {
    filter: drop-shadow(0 0 8px var(--primary-glow));
}
.gauge-arc {
    transition: filter 0.2s ease, opacity 0.3s ease;
}
.leds {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.led-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}
.led.on {
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}
.led-lbl {
    font-size: 0.55rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
@media (prefers-reduced-motion: reduce) {
    .gauge-arc, .pulse-dot, .led { transition: none; }
    .pulse-dot { animation: none; }
}

.casio {
    background: var(--casio-bg);
    border: 2px solid #152418;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    box-shadow: inset 0 0 18px rgba(0,0,0,0.5);
}

.casio-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid rgba(0, 168, 107, 0.08);
}

.casio-row:last-child { border: none; }

.casio-lbl {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6rem;
    color: var(--casio-text);
    opacity: 0.55;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.casio-val {
    font-family: 'Orbitron', monospace;
    font-size: 1rem;
    font-weight: 600;
    color: var(--casio-text);
    text-shadow: var(--casio-glow);
}

/* Light theme - warm gray, black accent */
body.light-theme {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ebebeb;
    --bg-tertiary: #e0e0e0;
    --bg-card: #f8f8f8;
    --bg-hover: #e8e8e8;
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-muted: #6a6a6a;
    --green: #1a1a1a;
    --cyan: #2a2a2a;
    --casio-text: #1a1a1a;
    --border: #d0d0d0;
    --border-light: #c0c0c0;
    --gauge-color: #1a1a1a;
    --card-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body.light-theme .dash { background: #f0f0f0; border-color: #d0d0d0; }
body.light-theme .gauge-arc { background: conic-gradient(from 135deg, #1a1a1a 0deg, #1a1a1a calc(var(--v, 0) * 2.7deg), #d0d0d0 calc(var(--v, 0) * 2.7deg), #d0d0d0 270deg); }
body.light-theme .casio { background: #e8e8e8; border-color: #d0d0d0; }
body.light-theme .casio-val { color: #1a1a1a; text-shadow: none; }
body.light-theme .send-btn { background: #1a1a1a; }
body.light-theme .new-btn { background: #1a1a1a; }
body.light-theme .feature { background: #ffffff; border: 1px solid #e0e0e0; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
body.light-theme .feature:hover { border-color: #1a1a1a; }
body.light-theme .mode-tab.on { background: #1a1a1a; color: #ffffff; }
body.light-theme .msg.assistant .msg-avatar { background: #1a1a1a; }
body.light-theme .alert { border-color: #1a1a1a; }
body.light-theme .toggle.on { background: #1a1a1a; border-color: #1a1a1a; }
body.light-theme .sidebar { background: var(--bg-secondary); border-right-color: var(--border); box-shadow: var(--card-shadow); }
body.light-theme .main { background: var(--bg-primary); }
body.light-theme .input-box { background: var(--bg-tertiary); border-color: var(--border); box-shadow: var(--card-shadow); }
body.light-theme .header { background: var(--bg-card); border-bottom-color: var(--border); box-shadow: var(--card-shadow); }
body.light-theme .gauge-inner,
body.light-theme .gauge { background: var(--bg-card); }
body.light-theme .toast,
body.light-theme .modal-limit-box { box-shadow: var(--card-shadow); }
body.light-theme .new-btn:hover,
body.light-theme .send-btn:hover:not(:disabled) { filter: brightness(1.1); }

.casio-val.lg { font-size: 1.2rem; }

.prog-item { margin-bottom: 10px; }

.prog-head {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.prog-lbl {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.prog-val {
    font-family: 'Orbitron', monospace;
    font-size: 0.65rem;
    color: var(--cyan);
}

.prog-bar {
    height: 5px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}

.prog-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green) 0%, var(--cyan) 100%);
    border-radius: 3px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}
.prog-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    animation: progShimmer 2s ease-in-out infinite;
}
@keyframes progShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.leds {
    display: flex;
    justify-content: center;
    gap: 14px;
    padding: 8px;
    background: var(--bg-primary);
    border-radius: 6px;
}

.led-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.led {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.3s;
}

.led.on {
    background: var(--green);
    box-shadow: 0 0 8px var(--green-glow);
    animation: ledPulse 2s ease-in-out infinite;
}
@keyframes ledPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--green-glow); }
    50% { opacity: 0.85; box-shadow: 0 0 12px var(--green-glow); }
}
.led-item:hover .led.on { transform: scale(1.15); }

.led-lbl {
    font-size: 0.5rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* HUD v2.0: freeze, motion-off, explanation panel, incomplete badge */
.gauge-wrap.hud-frozen { opacity: 0.85; }
.gauge-wrap.hud-frozen .gauge-arc { transition: none; }
.dash.hud-motion-off .led.on { animation: none; }
.dash.hud-motion-off .gauge-arc { transition: none; }

.hud-explanation-panel {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.hud-explanation-panel.show {
    display: flex;
}
.hud-explanation-inner {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 360px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}
.hud-explanation-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.hud-explanation-head span { font-weight: 600; color: var(--text-primary); }
.hud-explanation-body {
    padding: 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    overflow-y: auto;
}
.hud-incomplete-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
    box-shadow: 0 0 6px var(--orange);
}
.numeric-policy-badge {
    margin-top: 8px;
    padding: 4px 8px;
    font-size: 0.65rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    pointer-events: auto;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SETTINGS
═══════════════════════════════════════════════════════════════════════════════ */
.settings {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.settings-title {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.setting:last-child { border: none; }

.setting-name {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.toggle {
    width: 42px;
    height: 22px;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: 11px;
    cursor: pointer;
    position: relative;
    transition: all 0.3s;
}

.toggle::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--text-secondary);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle.on {
    background: var(--cyan);
    border-color: var(--cyan);
}

.toggle.on::after {
    left: 22px;
    background: var(--bg-primary);
}

.btn-danger-sm {
    padding: 6px 10px;
    background: rgba(255, 107, 107, 0.15);
    border: 1px solid var(--error);
    border-radius: 8px;
    color: var(--error);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-danger-sm:hover {
    background: rgba(255, 107, 107, 0.25);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   HISTORY
═══════════════════════════════════════════════════════════════════════════════ */
.history {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
}

.history-title {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 3px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.history-item:hover {
    background: var(--bg-hover);
    border-color: var(--border);
}

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

.history-info { flex: 1; min-width: 0; }

.history-name {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

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

.history-del {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.history-item:hover .history-del { opacity: 1; }
.history-del:hover { color: var(--red); background: var(--red-bg); }

/* ═══════════════════════════════════════════════════════════════════════════════
   MAIN AREA – Reserved space for Epistemic Control Stack (RTL/LTR safe)
═══════════════════════════════════════════════════════════════════════════════ */
.main-content-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    transition: margin-inline-end 0.3s ease;
}
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

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

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-btn {
    width: 38px;
    height: 38px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

.mode-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.85rem;
}

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

.langs {
    display: flex;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.lang-btn {
    padding: 8px 14px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.lang-btn.on { background: var(--cyan); color: var(--bg-primary); }

.innovation-toggle {
    width: 38px;
    height: 38px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.innovation-toggle:hover { color: var(--primary); border-color: var(--border-primary); background: var(--primary-bg); }
.innovation-toggle.active { color: var(--primary); border-color: var(--primary); background: var(--primary-bg); box-shadow: var(--shadow-glow); }

/* ═══════════════════════════════════════════════════════════════════════════════
   EPISTEMIC CONTROL STACK (right column)
   Dark, minimal, high-contrast. Smooth slide. Default hidden.
   Panel content: overflow-y auto, no truncation – full readability.
═══════════════════════════════════════════════════════════════════════════════ */
/* LTR: stack on the right. RTL (Arabic): stack on the left so it does not cover the sidebar/HUD panel. */
.innovation-column {
    position: fixed;
    top: 0;
    width: 380px;
    max-width: 95vw;
    height: 100vh;
    background: var(--bg-secondary);
    z-index: 800;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow: hidden;
}
.innovation-column {
    right: 0;
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
    transform: translateX(100%);
}
.innovation-column.open { transform: translateX(0); }
[dir="rtl"] .innovation-column {
    right: auto;
    left: 0;
    border-left: none;
    border-right: 1px solid var(--border);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4);
    transform: translateX(-100%);
}
[dir="rtl"] .innovation-column.open { transform: translateX(0); }

.innovation-column-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
    flex-shrink: 0;
}
.innovation-column-title {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}
.innovation-close {
    width: 28px;
    height: 28px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
}
.innovation-close:hover { color: var(--text-primary); border-color: var(--text-muted); }

.innovation-panels {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.innovation-panel {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 8px;
    background: var(--bg-card);
    overflow: hidden;
}
.innovation-panel-head {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.75rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
}
.innovation-panel-head:hover { background: var(--bg-hover); }
.innovation-panel-title { flex: 1; font-weight: 500; }
.innovation-panel-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}
.innovation-panel-status.live { background: var(--primary); color: var(--primary); }
.innovation-panel-status.incomplete { background: var(--warning); color: var(--warning); }
.innovation-panel-chevron {
    font-size: 0.6rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}
.innovation-panel.expanded .innovation-panel-chevron { transform: rotate(-180deg); }
.innovation-panel-body {
    position: relative;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}
.innovation-panel-body::before,
.innovation-panel-body::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
.innovation-panel-body::before {
    top: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.15), transparent);
}
.innovation-panel-body::after {
    bottom: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.15), transparent);
}
.innovation-panel-body.scroll-shadow-top::before { opacity: 1; }
.innovation-panel-body.scroll-shadow-bottom::after { opacity: 1; }
.innovation-panel.expanded .innovation-panel-body {
    max-height: calc(100vh - 180px);
    max-height: min(50vh, 520px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}
.innovation-panel-content {
    padding: 12px;
    padding-inline-end: 12px;
    font-size: 0.72rem;
    line-height: 1.5;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}
.innovation-panel-content.preview {
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.innovation-panel.expanded .innovation-panel-content.preview {
    display: block;
    -webkit-line-clamp: unset;
    -webkit-box-orient: unset;
    overflow-y: auto;
}
.innovation-panel-copy {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, border-color 0.2s;
}
.innovation-panel-copy:hover { color: var(--primary); border-color: var(--border-primary); }
.innovation-panel-expand-btn {
    margin-top: 6px;
    font-size: 0.7rem;
    color: var(--primary);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}
.innovation-panel-expand-btn:hover { text-decoration: underline; }

@media (max-width: 768px) {
    .innovation-column {
        width: 100%;
        max-width: 100%;
        inset-inline-end: 0;
        transform: translateX(100%);
        box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
    }
    [dir="rtl"] .innovation-column { transform: translateX(-100%); }
    .innovation-column.open {
        transform: translateX(0);
        z-index: 900;
    }
    [dir="rtl"] .innovation-column.open { transform: translateX(0); }
    .innovation-stack-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 899;
    }
    .innovation-stack-backdrop.show { display: block; }
    .main-content-wrap { margin-inline-end: 0 !important; }
    .innovation-toggle { display: flex; }
}
@media (min-width: 769px) {
    .innovation-toggle { display: flex; }
}
@media (min-width: 1025px) {
    .innovation-column { width: 380px; }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   INNOVATION 1: Cognitive Trail (المسار المعرفي)
═══════════════════════════════════════════════════════════════════════════════ */
.cognitive-trail-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.cognitive-trail-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}
.cognitive-trail-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.cognitive-trail-step {
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    transition: all 0.2s;
}
.cognitive-trail-step.done {
    background: rgba(0, 168, 107, 0.12);
    border-color: rgba(0, 168, 107, 0.35);
    color: var(--primary);
}
.cognitive-trail-step.active {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   INNOVATION 2: Claim Radar (رادار الادعاءات)
═══════════════════════════════════════════════════════════════════════════════ */
.claim-radar-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 8px 20px 4px;
    gap: 6px;
}
.claim-radar-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: linear-gradient(135deg, rgba(0, 180, 216, 0.15), rgba(0, 168, 107, 0.12));
    border: 1px solid rgba(0, 180, 216, 0.35);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}
.claim-radar-pill:hover {
    border-color: var(--cyan);
    color: var(--cyan);
    box-shadow: 0 0 14px rgba(0, 180, 216, 0.2);
}
.claim-radar-icon { font-size: 1rem; }
.claim-radar-count {
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}
.claim-radar-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0;
    max-width: 100%;
}
.claim-radar-list.open {
    max-height: 280px;
    overflow-y: auto;
    padding: 8px;
    margin-top: 4px;
}
.claim-radar-item {
    font-size: 0.72rem;
    color: var(--text-secondary);
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    line-height: 1.35;
}
.claim-radar-item:last-child { border-bottom: none; }

/* ═══════════════════════════════════════════════════════════════════════════════
   STICKY QUERY HEADER – question always visible
═══════════════════════════════════════════════════════════════════════════════ */
.query-header-wrap {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    margin: -24px -24px 16px -24px;
    padding: 0 24px 0 0;
}
.query-header {
    display: flex;
    align-items: flex-start;
    gap: var(--gutter);
    padding: 12px 0;
    min-height: 44px;
}
.query-header-chevron {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transform: rotate(0deg);
    transition: transform 0.2s;
}
.query-header-wrap.collapsed .query-header-chevron { transform: rotate(-90deg); }
.query-header-wrap.collapsed .query-header-content { display: none; }
.query-header-content { flex: 1; min-width: 0; }
.query-header-prompt {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 6px;
    white-space: pre-wrap;
    word-break: break-word;
}
.query-header-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.query-header-time { margin-inline-end: 8px; }
.query-header-mode, .query-header-lang {
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border-radius: 6px;
}
.query-header-copy {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 0;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-inline-start: auto;
    transition: color 0.2s, border-color 0.2s;
}
.query-header-copy:hover { color: var(--primary); border-color: var(--border-primary); }

/* Panel expand modal – full-height deep reading */
.panel-expand-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.6);
    align-items: center;
    justify-content: center;
    padding: var(--gutter);
}
.panel-expand-modal.show { display: flex; }
.panel-expand-modal-inner {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    max-width: 90vw;
    max-height: 90vh;
    width: 560px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}
.panel-expand-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.panel-expand-modal-body {
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.8rem;
    line-height: 1.5;
    max-height: calc(90vh - 120px);
}
.panel-expand-modal-body.scroll-shadow-top { box-shadow: inset 0 8px 12px -8px rgba(0,0,0,0.3); }
.panel-expand-modal-body.scroll-shadow-bottom { box-shadow: inset 0 -8px 12px -8px rgba(0,0,0,0.3); }

.innovation-column-title-block { display: flex; flex-direction: column; gap: 2px; }
.innovation-column-subtitle {
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   CHAT AREA
═══════════════════════════════════════════════════════════════════════════════ */
.chat {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    -webkit-overflow-scrolling: touch;
}

.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    max-width: 580px;
    margin: 0 auto;
}

.welcome-logo {
    width: 85px;
    height: 85px;
    margin-bottom: 22px;
    animation: float 4s ease-in-out infinite;
    filter: drop-shadow(0 0 15px rgba(0, 180, 216, 0.3));
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.welcome-title {
    font-family: 'Orbitron', monospace;
    font-size: 2rem;
    font-weight: 700;
    background: var(--grad-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

.welcome-sub {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.welcome-tag {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 32px;
}

.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
}

.feature {
    padding: 18px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.feature:hover {
    border-color: var(--cyan);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 180, 216, 0.15);
}

.feature-icon {
    width: 42px;
    height: 42px;
    margin: 0 auto 10px;
    background: var(--bg-hover);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.feature:nth-child(1) .feature-icon { background: var(--orange-bg); }
.feature:nth-child(2) .feature-icon { background: var(--cyan-bg); }
.feature:nth-child(3) .feature-icon { background: var(--green-bg); }

.feature-name { font-weight: 600; font-size: 0.9rem; margin-bottom: 3px; }
.feature-desc { font-size: 0.75rem; color: var(--text-muted); }

.messages {
    display: none;
    flex-direction: column;
    gap: 20px;
    max-width: 880px;
    margin: 0 auto;
    width: 100%;
}

.messages.show { display: flex; }

.msg {
    display: flex;
    gap: 14px;
    animation: msgIn 0.35s ease;
}

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

.msg-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 700;
    font-size: 0.95rem;
}

.msg.user .msg-avatar { background: var(--grad-pro); color: #fff; }
.msg.assistant .msg-avatar { 
    background: var(--grad-main); 
    color: var(--bg-primary); 
    font-family: 'Orbitron', monospace;
}

.msg-body { flex: 1; min-width: 0; }

.msg-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.msg-name { font-weight: 600; font-size: 0.9rem; }
.msg-time { font-size: 0.75rem; color: var(--text-muted); }
.msg-mode {
    font-size: 0.65rem;
    padding: 2px 8px;
    background: var(--bg-hover);
    border-radius: 8px;
    color: var(--text-secondary);
}

.msg-content {
    font-size: 1.1rem;
    line-height: 1.75;
    contain: layout style;
    -webkit-contain: layout style;
}

.msg-content p { margin-bottom: 12px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content strong { color: var(--text-primary); font-weight: 700; }
.msg-content em { color: var(--cyan); font-style: normal; }

.msg-content code {
    background: var(--bg-card);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
    color: var(--cyan);
}

.msg-content pre {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    overflow-x: auto;
    margin: 12px 0;
}

.msg-content pre code { 
    background: none; 
    padding: 0; 
    color: var(--text-primary);
}

.msg-content ul, .msg-content ol { margin: 12px 0; padding-left: 22px; }
.msg-content li { margin-bottom: 6px; }

.msg-content h1, .msg-content h2, .msg-content h3 {
    margin: 18px 0 10px;
    font-weight: 700;
    color: var(--text-primary);
}

.msg-content h1 { font-size: 1.4rem; }
.msg-content h2 { font-size: 1.25rem; }
.msg-content h3 { font-size: 1.1rem; }

/* Semantic Alerts */
.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin: 12px 0;
    border-left: 4px solid;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 2px; }
.alert-text { flex: 1; }
.alert-text strong { display: block; margin-bottom: 2px; }

.alert.critical { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.alert.warning { background: var(--orange-bg); border-color: var(--orange); color: var(--orange); }
.alert.info { background: var(--yellow-bg); border-color: var(--yellow); color: var(--yellow); }
.alert.success { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.alert.pro { background: var(--purple-bg); border-color: var(--purple); color: var(--purple); }
.alert.primary { background: var(--cyan-bg); border-color: var(--cyan); color: var(--cyan); }

.typing-text { color: var(--text-secondary); }
.typing-dots span { animation: typingDot 0.6s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
    0%, 60% { opacity: 0.3; }
    100% { opacity: 1; }
}

.msg-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    position: relative;
    z-index: 20;
    visibility: visible;
    opacity: 1;
}

.msg-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.msg-action-btn:hover {
    background: var(--cyan-bg);
    color: var(--cyan);
    border-color: rgba(0, 180, 216, 0.3);
}

.msg-action-challenge {
    background: linear-gradient(135deg, rgba(180, 0, 100, 0.12), rgba(0, 168, 107, 0.08)) !important;
    border-color: rgba(180, 0, 100, 0.35) !important;
}
.msg-action-challenge:hover {
    background: rgba(180, 0, 100, 0.18) !important;
    color: var(--primary) !important;
    border-color: var(--primary) !important;
}

.oplogica-seal-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.7rem;
    color: var(--text-muted);
}
.oplogica-seal-label { font-weight: 600; color: var(--text-secondary); }
.oplogica-seal-hash { font-family: var(--font-mono); letter-spacing: 0.5px; }
.oplogica-seal-ts { opacity: 0.85; }

.source-ref { cursor: help; border-bottom: 1px dotted var(--text-muted); }
.numeric-warning-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 10px;
    font-size: 0.7rem;
    background: rgba(230, 160, 0, 0.15);
    border: 1px solid rgba(230, 160, 0, 0.5);
    border-radius: 6px;
    color: var(--text-secondary);
}

.ccs-missing-badge {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 8px 12px;
    font-size: 0.75rem;
    background: rgba(230, 140, 0, 0.2);
    border: 1px solid rgba(230, 140, 0, 0.6);
    border-radius: 8px;
    color: var(--text-primary);
}
.ccs-missing-label { flex: 1 1 auto; font-weight: 600; }
.ccs-missing-fix-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    background: rgba(230, 140, 0, 0.35);
    border: 1px solid rgba(230, 140, 0, 0.7);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    white-space: nowrap;
}
.ccs-missing-fix-btn:hover {
    background: rgba(230, 140, 0, 0.5);
    border-color: rgba(230, 140, 0, 0.9);
}

.msg-retry-wrap { margin-top: 10px; }
.msg-retry { color: var(--orange); }
.msg-retry:hover { background: var(--orange-bg); color: var(--orange); }

.msg-export-wrap { position: relative; }
.msg-export-btn { display: inline-flex; align-items: center; gap: 4px; }
.msg-export-drop {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 4px;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.25);
    display: none;
    flex-direction: column;
    z-index: 100;
}
.msg-export-drop.show { display: flex; }
.msg-export-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
}
.msg-export-opt:hover { background: var(--bg-hover); }

.upload-progress {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    margin-bottom: 8px;
}

.upload-progress.show { display: flex; }

.upload-progress-bar-wrap {
    flex: 1;
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}

.upload-progress-bar {
    height: 100%;
    background: var(--grad-main);
    border-radius: 3px;
    transition: width 0.2s;
}

.upload-progress-pct {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 36px;
}

.voice-recording {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--red);
}

.voice-dot {
    width: 8px;
    height: 8px;
    background: var(--red);
    border-radius: 50%;
    animation: voicePulse 1s infinite;
}

@keyframes voicePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

.act-btn.recording { color: var(--red); background: var(--red-bg); }

.cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: var(--cyan);
    margin-left: 3px;
    animation: blink 0.8s infinite;
    vertical-align: text-bottom;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.gen-img {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 12px 0;
    cursor: pointer;
    transition: transform 0.2s;
    border: 1px solid var(--border);
}

.gen-img:hover { transform: scale(1.01); }

/* ═══════════════════════════════════════════════════════════════════════════════
   INPUT AREA (compact)
═══════════════════════════════════════════════════════════════════════════════ */
.input-area {
    padding: 12px 20px 16px;
    background: linear-gradient(180deg, transparent 0%, var(--bg-secondary) 35%);
}

.input-wrap {
    max-width: 900px;
    margin: 0 auto;
}

.input-box {
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 12px 16px;
    max-width: 900px;
    margin: 0 auto;
    transition: all 0.3s ease;
}

.input-box:focus-within {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.12);
}

.modes {
    display: flex;
    gap: 4px;
    padding: 6px;
    background: var(--bg-secondary);
    border-radius: 13px;
    margin-bottom: 8px;
}

.mode-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.mode-tab:hover { color: var(--text-primary); background: var(--bg-hover); }

.mode-tab.on {
    color: var(--text-primary);
    background: var(--bg-card);
}

.mode-tab.on::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 18px;
    height: 2px;
    background: var(--grad-main);
    border-radius: 1px;
}

.mode-tab svg { width: 14px; height: 14px; }

.pro-badge {
    font-size: 0.55rem;
    padding: 2px 5px;
    background: var(--grad-pro);
    color: #fff;
    border-radius: 4px;
    font-weight: 700;
}

.uploads {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.uploads.show { display: flex; }

.upload-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.8rem;
}

.upload-item img {
    width: 28px;
    height: 28px;
    object-fit: cover;
    border-radius: 4px;
}

.upload-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
}

.upload-remove:hover { color: var(--red); }

.ta-wrap { margin-bottom: 10px; }

.ta {
    width: 100%;
    min-height: 24px;
    max-height: 120px;
    padding: 10px 14px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.4;
    resize: none;
    outline: none;
}
@media (min-width: 768px) {
    .ta { font-size: 0.95rem; }
}

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

.actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 6px;
}

.act-group {
    display: flex;
    align-items: center;
    gap: 3px;
}

.act-btn {
    width: 34px;
    height: 34px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.act-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.act-btn.on {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
}

.act-btn svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.act-btn:hover svg {
    transform: scale(1.1);
}

.act-btn .tip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.7rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    margin-bottom: 8px;
    box-shadow: var(--shadow-md);
    z-index: 100;
}

.act-btn:hover .tip {
    opacity: 1;
    visibility: visible;
}

.act-btn .tip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--border);
}

.divider {
    width: 1px;
    height: 26px;
    background: var(--border);
    margin: 0 5px;
}

.model-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.model-btn:hover { border-color: var(--border-light); }

.model-icon {
    width: 22px;
    height: 22px;
    background: var(--grad-main);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.model-icon svg { width: 12px; height: 12px; color: var(--bg-primary); }

.model-drop {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: all 0.2s ease;
    z-index: 200;
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
}

.model-drop.show { opacity: 1; visibility: visible; transform: translateY(0); }

.model-opt {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.model-opt:hover { background: var(--bg-hover); }
.model-opt.on { background: var(--bg-active); }

.model-opt-info { flex: 1; }
.model-opt-name { font-size: 0.85rem; font-weight: 500; }
.model-opt-desc { font-size: 0.7rem; color: var(--text-muted); }

.proof-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--green-bg);
    border: 1px solid rgba(0, 168, 107, 0.25);
    border-radius: 8px;
    color: var(--green);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.proof-btn:hover { background: rgba(0, 168, 107, 0.18); }
.proof-btn svg { width: 15px; height: 15px; }

.send-btn {
    width: 40px;
    height: 40px;
    background: var(--grad-main);
    border: none;
    border-radius: 10px;
    color: var(--bg-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 180, 216, 0.3);
    transition: all 0.25s ease;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.06);
    box-shadow: 0 6px 20px rgba(0, 180, 216, 0.4);
}

.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.send-btn svg { width: 18px; height: 18px; }

.shortcuts {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 12px;
}

.shortcut {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.shortcut kbd {
    padding: 3px 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TOAST & MODAL
═══════════════════════════════════════════════════════════════════════════════ */
.toasts {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

body.rtl .toasts { right: auto; left: 16px; }

.toast {
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 6px 25px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s ease;
    max-width: 320px;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }
.toast.warning { border-color: var(--orange); }

.toast-icon { font-size: 1.1rem; }
.toast-text { font-size: 0.85rem; }

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show { display: flex; }

.modal-limit {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-limit.show { display: flex; }
.modal-limit-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0,0,0,0.4);
}
.modal-limit-title { font-size: 1.2rem; margin-bottom: 10px; color: var(--text-primary); }
.modal-limit-sub { color: var(--text-secondary); margin-bottom: 20px; font-size: 0.95rem; }
.modal-limit-actions, .modal-gate-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.modal-limit-actions .btn-primary, .modal-gate-actions .btn-primary { background: var(--grad-main); color: #0a0b0f; border: none; padding: 12px 20px; border-radius: var(--radius); font-weight: 600; cursor: pointer; }
.modal-limit-actions .btn-secondary, .modal-gate-actions .btn-secondary { background: var(--bg-hover); color: var(--text-secondary); border: 1px solid var(--border); padding: 12px 20px; border-radius: var(--radius); cursor: pointer; }
.modal-gate-actions .btn-ghost { background: transparent; color: var(--text-muted); border: none; padding: 12px 16px; cursor: pointer; font-size: 0.9rem; }
.quota-counter { font-size: 0.85rem; color: var(--text-muted); margin-top: 6px; margin-bottom: 4px; }
.gate-forms { margin-top: 24px; display: flex; flex-direction: column; gap: 20px; }
.gate-form { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--bg-hover); border-radius: var(--radius); }
.gate-form h4 { margin: 0 0 4px 0; font-size: 1rem; color: var(--text-primary); }
.gate-form input { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); color: var(--text-primary); }
.gate-form-error { color: var(--danger, #ef4444); font-size: 0.85rem; margin: 0; min-height: 1.2em; }

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.suggestion-chip {
    padding: 5px 12px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}
.suggestion-chip:hover {
    background: var(--cyan-bg);
    color: var(--cyan);
    border-color: rgba(6, 182, 212, 0.3);
}

.modal img {
    max-width: 92%;
    max-height: 92%;
    border-radius: var(--radius);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 38px;
    height: 38px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE / MOBILE
═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .sidebar { width: 280px; }
    .features { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 85%;
        max-width: 320px;
        z-index: 1000;
        transition: left 0.3s ease;
    }
    .sidebar.open { left: 0; }
    body.rtl .sidebar { left: auto; right: -100%; }
    body.rtl .sidebar.open { right: 0; }
    .main { width: 100%; }
    .overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.6);
        z-index: 999;
    }
    .overlay.show { display: block; }
    .menu-btn { display: flex; }
    .welcome { padding: 20px 15px; }
    .welcome-logo { width: 60px; height: 60px; }
    .welcome-title { font-size: 1.5rem; }
    .features {
        display: flex;
        overflow-x: auto;
        gap: 10px;
        padding: 10px 0;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        grid-template-columns: unset;
        max-width: none;
    }
    .feature {
        min-width: 120px;
        flex-shrink: 0;
        padding: 15px 10px;
        scroll-snap-align: start;
    }
    .modes {
        display: flex;
        overflow-x: auto;
        gap: 5px;
        padding: 5px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }
    .modes::-webkit-scrollbar { display: none; }
    .mode-tab {
        flex-shrink: 0;
        padding: 8px 12px;
        font-size: 0.75rem;
        white-space: nowrap;
        min-width: 0;
    }
    .mode-tab svg { width: 14px; height: 14px; }
    .suggestion-chips {
        display: flex;
        overflow-x: auto;
        gap: 8px;
        padding: 8px 0;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .suggestion-chips::-webkit-scrollbar { display: none; }
    .suggestion-chip { flex-shrink: 0; padding: 6px 12px; font-size: 0.75rem; }
    .input-area { padding: 10px 12px 15px; }
    .input-box { padding: 10px; }
    .ta { font-size: 16px; min-height: 44px; max-height: 120px; }
    .actions { flex-wrap: wrap; gap: 5px; }
    .act-btn { width: 36px; height: 36px; }
    .act-btn svg { width: 16px; height: 16px; }
    .divider { display: none; }
    .model-btn span:not(.model-icon) { display: none; }
    .proof-btn span { display: none; }
    .shortcuts { display: none; }
    .msg-avatar { width: 32px; height: 32px; font-size: 0.85rem; }
    .msg-content { font-size: 0.95rem; }
    .dash { display: none !important; }
}

@media (max-width: 380px) {
    .mode-tab { padding: 6px 8px; font-size: 0.7rem; }
    .welcome-title { font-size: 1.3rem; }
}

/* System Test Drawer (dev-only) */
.dev-test-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-left: 6px;
    padding: 0;
    font-size: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
}
.dev-test-toggle:hover { color: var(--primary); border-color: var(--primary); }

.system-test-drawer {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    padding: var(--gutter);
}
.system-test-drawer.show { display: flex; }
.system-test-drawer-inner {
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}
.system-test-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.system-test-drawer-title { font-size: 1rem; font-weight: 600; margin: 0; }
.system-test-drawer-body {
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
}
.system-test-drawer-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.system-test-actions { margin-bottom: 16px; }
.system-test-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.system-test-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}
.system-test-item.pass { border-color: var(--success); background: rgba(0, 217, 165, 0.08); }
.system-test-item.fail { border-color: var(--error); background: var(--red-bg); }
.system-test-item-name { flex: 1; min-width: 0; }
.system-test-item-result { flex-shrink: 0; font-weight: 600; }
.system-test-item-result.pass { color: var(--success); }
.system-test-item-result.fail { color: var(--error); }
.system-test-item-msg { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.system-test-item-actions { display: flex; gap: 8px; align-items: center; }
.system-test-item-actions button { padding: 4px 10px; font-size: 0.8rem; }
