/* Cementara Maintenance Assistant — Industrial Steel Theme */

/* Dark theme (default) */
:root {
    --bg: #12161a;
    --panel: #1a2028;
    --panel-hover: #242d38;
    --border: #2e3a46;
    --text: #d8e0e8;
    --text-muted: #7a8a9a;
    --accent: #5a7fa0;
    --accent-hover: #4a6f90;
    --user-bg: #1c3048;
    --bot-bg: #1a2028;
    --topbar-bg: #0e1216;
    --input-bg: #1a2028;
    --shadow: rgba(0,0,0,0.35);
}

/* Light theme */
[data-theme="light"] {
    --bg: #eef2f5;
    --panel: #ffffff;
    --panel-hover: #f0f4f7;
    --border: #c8d0d8;
    --text: #1a2530;
    --text-muted: #5a6a7a;
    --accent: #3a6080;
    --accent-hover: #2a5070;
    --user-bg: #d0dfe8;
    --bot-bg: #ffffff;
    --topbar-bg: #e4eaef;
    --input-bg: #ffffff;
    --shadow: rgba(0,0,0,0.08);
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
}

/* TOPBAR */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    color: var(--text);
}

.brand-logo {
    border-radius: 4px;
}

.brand-sub {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.9rem;
}

.controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#lang-select {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: var(--text);
}

/* MESSAGES */
.msgs {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    -webkit-overflow-scrolling: touch;
}

.welcome {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.welcome h2 {
    color: var(--text);
    margin-bottom: 0.5rem;
    font-size: 1.4rem;
}

.welcome p {
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.quick-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.quick-btn {
    background: var(--panel);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-btn:hover {
    background: var(--panel-hover);
    border-color: var(--accent);
}

/* Message bubbles */
.msg {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    line-height: 1.5;
    word-wrap: break-word;
    font-size: 0.95rem;
}

.msg-user {
    align-self: flex-end;
    background: var(--user-bg);
    border-bottom-right-radius: 4px;
}

.msg-bot {
    align-self: flex-start;
    background: var(--bot-bg);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.msg-bot strong { color: var(--accent); }

.msg-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-align: right;
}

.sci-badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-weight: 600;
    font-size: 0.65rem;
    letter-spacing: 0.02em;
    cursor: help;
}
.sci-high     { background: #d4edda; color: #155724; }
.sci-medium   { background: #fff3cd; color: #856404; }
.sci-low      { background: #ffe0b2; color: #e65100; }
.sci-very_low { background: #f8d7da; color: #721c24; }

/* Engineering Knowledge Layer — ASCII diagrams */
.msg-bot pre.eng-diagram {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    margin: 0.4rem 0;
    overflow-x: auto;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.78rem;
    line-height: 1.3;
    white-space: pre;
    color: var(--text);
}
.msg-bot pre.eng-diagram code {
    background: none;
    padding: 0;
    font-size: inherit;
}

/* Suggestions */
.suggest-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.suggest-btn {
    background: var(--panel);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.suggest-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Typing indicator */
.typing {
    align-self: flex-start;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
}

/* COMPOSER */
.composer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--topbar-bg);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

#user-input {
    flex: 1;
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    overflow-y: auto;
    min-height: 40px;
    max-height: 120px;
    line-height: 1.4;
}

#user-input:focus {
    border-color: var(--accent);
}

#send-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
    min-width: 44px;
    min-height: 44px;
}

#send-btn:hover {
    background: var(--accent-hover);
}

/* Microphone button */
.mic-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    min-width: 44px;
    font-size: 1.15rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.mic-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.mic-btn.mic-active {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
    animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.4); }
    50% { box-shadow: 0 0 0 10px rgba(220,38,38,0); }
}

/* Live mode button — equalizer bars */
.live-btn {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    min-width: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.live-btn:hover {
    border-color: var(--accent);
}
.live-bars {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 18px;
}
.live-bars i {
    display: block;
    width: 3px;
    background: var(--text-muted);
    border-radius: 1px;
    transition: background 0.2s;
}
.live-bars i:nth-child(1) { height: 6px; }
.live-bars i:nth-child(2) { height: 12px; }
.live-bars i:nth-child(3) { height: 18px; }
.live-bars i:nth-child(4) { height: 12px; }
.live-bars i:nth-child(5) { height: 6px; }

/* Live mode active */
.live-btn.live-active {
    background: var(--text);
    border-color: var(--text);
}
.live-btn.live-active .live-bars i {
    background: var(--bg);
    animation: eq-bounce 0.8s ease-in-out infinite alternate;
}
.live-btn.live-active .live-bars i:nth-child(1) { animation-delay: 0s; }
.live-btn.live-active .live-bars i:nth-child(2) { animation-delay: 0.15s; }
.live-btn.live-active .live-bars i:nth-child(3) { animation-delay: 0.3s; }
.live-btn.live-active .live-bars i:nth-child(4) { animation-delay: 0.45s; }
.live-btn.live-active .live-bars i:nth-child(5) { animation-delay: 0.6s; }
@keyframes eq-bounce {
    0%   { transform: scaleY(0.4); }
    100% { transform: scaleY(1); }
}

/* Speaker button in rating row */
.qa-speak {
    margin-left: 0.2rem;
}
.qa-speak:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.qa-speak.speaking {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    animation: speak-pulse 1s ease-in-out infinite;
}
@keyframes speak-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* SETTINGS PANEL */
.settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 300px;
    height: 100%;
    background: var(--panel);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 20px var(--shadow);
    z-index: 100;
    display: none;
    flex-direction: column;
}

.settings-panel.open {
    display: flex;
}

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

.settings-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-btn {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.theme-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

#fontsize {
    flex: 1;
    accent-color: var(--accent);
}

.reset-btn {
    width: 100%;
    padding: 0.6rem;
    background: #dc2626;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.reset-btn:hover {
    background: #b91c1c;
}

/* Markdown in messages — compact spacing */
.msg-bot p { margin-bottom: 0.2rem; }
.msg-bot p:last-child { margin-bottom: 0; }
.msg-bot ul, .msg-bot ol { margin: 0.1rem 0 0.2rem 1.2rem; }
.msg-bot li { margin-bottom: 0.05rem; }
.msg-bot table { border-collapse: collapse; margin: 0.25rem 0; width: 100%; font-size: 0.85rem; }
.msg-bot th, .msg-bot td { border: 1px solid var(--border); padding: 0.2rem 0.5rem; text-align: left; }
.msg-bot th { background: var(--panel-hover); font-weight: 600; }
.msg-bot blockquote { border-left: 3px solid var(--accent); padding-left: 0.75rem; color: var(--text-muted); margin: 0.25rem 0; }
.msg-bot code { background: var(--panel-hover); padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.9em; }
.msg-bot hr { border: none; border-top: 1px solid var(--border); margin: 0.3rem 0; }
.msg-bot h1, .msg-bot h2, .msg-bot h3 { margin: 0.3rem 0 0.1rem; }

/* ══════════════════════════════════════════════
   MESSAGE EXPAND/COLLAPSE (višestepeni prikaz)
   ══════════════════════════════════════════════ */
.msg-content {
    /* Wrapper for markdown content inside bot bubble */
}

.msg-expand-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: none;
    border: 1px dashed var(--border);
    border-radius: 12px;
    color: var(--accent);
    font-size: 0.78rem;
    cursor: pointer;
    padding: 0.2rem 0.6rem;
    margin: 0.4rem 0 0.2rem;
    transition: all 0.2s;
}

.msg-expand-btn:hover {
    background: var(--panel-hover);
    border-color: var(--accent);
}

/* Smooth reveal animation for expanded parts */
.msg-part:not(:first-child) {
    animation: msgFadeSlide 0.3s ease;
}

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

/* ── Batch Multi-Question ── */
.msg-batch .batch-section { margin-bottom: 0.75rem; }
.msg-batch .batch-q-header { color: var(--accent); margin-bottom: 0.3rem; font-size: 0.95em; }
.msg-batch .batch-a-body {
    margin-left: 0.5rem;
    padding-left: 0.75rem;
    border-left: 2px solid var(--accent-dim, rgba(100,200,255,0.2));
}
.msg-batch .batch-sep {
    border: none;
    border-top: 1px solid var(--border, rgba(255,255,255,0.08));
    margin: 0.75rem 0;
}
.batch-progress { font-size: 0.85em; opacity: 0.7; margin-left: 0.3em; }

/* MOBILE */
@media (max-width: 600px) {
    .app {
        max-width: 100%;
        height: 100dvh;
        height: -webkit-fill-available;
    }

    .msgs {
        padding: 0.5rem;
    }

    .msg {
        max-width: 95%;
    }

    .composer {
        position: sticky;
        bottom: 0;
        z-index: 50;
    }

    #user-input {
        font-size: 16px;
        min-height: 44px;
    }

    #send-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .settings-panel {
        width: 100%;
    }

    .welcome {
        padding: 2rem 0.5rem;
    }

    .quick-btns {
        gap: 0.4rem;
    }

    .quick-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}

/* Message fade-in animation */
.msg-fade {
    animation: fadeSlideUp 0.3s ease-out;
}
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Typing animation cursor */
.msg-animating {
    border-right: 2px solid var(--accent);
}
.msg-animating::after {
    content: '';
    display: inline;
}

/* Animated typing dots */
.typing-dots span {
    display: inline-block;
    font-weight: bold;
    font-size: 1.2em;
    animation: typingDot 1.4s 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%, 100% { opacity: 0.2; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

/* Context follow-up suggest buttons */
.suggest-btn-ctx {
    border-style: dashed;
    opacity: 0.75;
}
.suggest-btn-ctx:hover {
    opacity: 1;
    border-style: solid;
}

/* Engineering action suggest buttons (v2.8.2) */
.suggest-btn-eng {
    border-color: var(--accent, #4a9eff);
    color: var(--accent, #4a9eff);
    font-weight: 500;
}
.suggest-btn-eng:hover {
    background: var(--accent, #4a9eff);
    color: #fff;
}

/* SCI warning suggest button (v2.8.3) */
.suggest-btn-warn {
    border-color: #e65100;
    color: #e65100;
}
.suggest-btn-warn:hover {
    background: #e65100;
    color: #fff;
}

/* Session separator */
.session-sep {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.75rem 0;
    position: relative;
}
.session-sep::before,
.session-sep::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 25%;
    height: 1px;
    background: var(--border);
}
.session-sep::before { left: 8%; }
.session-sep::after { right: 8%; }

/* Export button in settings */
.export-btn {
    width: 100%;
    padding: 0.6rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}
.export-btn:hover {
    background: var(--accent-hover);
}

/* Scrollbar */
.msgs::-webkit-scrollbar { width: 6px; }
.msgs::-webkit-scrollbar-track { background: transparent; }
.msgs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.msgs::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* PWA Install Banner */
.install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    z-index: 200;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.3);
}
.install-banner span { flex: 1; }
#install-yes {
    background: #fff;
    color: var(--accent);
    border: none;
    border-radius: 6px;
    padding: 0.4rem 1rem;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
}
#install-no {
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ══════════════════════════════════════════════
   QA ACTION ICONS (ChatGPT-style)
   ══════════════════════════════════════════════ */

.qa-actions {
    display: flex;
    gap: 0.15rem;
    margin-top: 0.4rem;
    padding-top: 0.35rem;
    border-top: 1px solid var(--border);
    align-items: center;
}

.qa-act-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    border-radius: 6px;
    width: 30px;
    height: 30px;
    cursor: pointer;
    transition: all 0.18s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.qa-act-btn:hover {
    background: var(--panel-hover);
    color: var(--text);
}
.qa-act-btn svg {
    pointer-events: none;
}

/* ThumbsUp selected (green) */
.qa-up.qa-selected {
    color: #22c55e;
}
[data-theme="light"] .qa-up.qa-selected {
    color: #16a34a;
}

/* ThumbsDown selected (red) */
.qa-down.qa-selected {
    color: #ef4444;
}
[data-theme="light"] .qa-down.qa-selected {
    color: #dc2626;
}

/* Copy success (green flash) */
.qa-copied {
    color: #22c55e !important;
}

.qa-dimmed { opacity: 0.25; pointer-events: none; }

/* "..." more menu */
.qa-more-wrap {
    position: relative;
    margin-left: auto;
}
.qa-more-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 4px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px var(--shadow);
    min-width: 160px;
    z-index: 60;
    overflow: hidden;
}
.qa-more-menu.open { display: block; }
.qa-menu-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    background: none;
    border: none;
    color: var(--text);
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
    white-space: nowrap;
}
.qa-menu-item:hover {
    background: var(--panel-hover);
}
/* Highlight "..." when TTS is playing */
.qa-more.speaking {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* Severity + comment panel */
.qa-severity-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: flex-start;
    margin-top: 0.35rem;
    padding: 0.5rem 0.6rem;
    background: var(--panel-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    max-width: 90%;
}

.qa-sev-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    width: 100%;
    margin-bottom: 0.1rem;
}

.qa-sev-btn {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 4px;
    padding: 0.18rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.qa-sev-btn:hover { border-color: var(--text); color: var(--text); }
.qa-sev-v1 { border-color: #dc2626 !important; color: #fca5a5; }
.qa-sev-v2 { border-color: #d97706 !important; color: #fcd34d; }
.qa-sev-v3 { border-color: #6b7280 !important; color: #d1d5db; }
[data-theme="light"] .qa-sev-v1 { color: #dc2626; }
[data-theme="light"] .qa-sev-v2 { color: #d97706; }
[data-theme="light"] .qa-sev-v3 { color: #4b5563; }
.qa-sev-active { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }

.qa-comment {
    width: 100%;
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.3rem 0.4rem;
    font-size: 0.75rem;
    font-family: inherit;
    resize: vertical;
    min-height: 40px;
}
.qa-comment:focus { outline: none; border-color: var(--accent); }

.qa-sev-row {
    display: flex;
    gap: 0.3rem;
    align-items: center;
    width: 100%;
}

.qa-submit-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.7rem;
    font-size: 0.72rem;
    cursor: pointer;
    transition: background 0.15s;
    margin-left: auto;
}
.qa-submit-btn:hover { background: var(--accent-hover); }

/* System notification bubble */
.msg-qa-system {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--panel-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    margin: 0.3rem 0;
    max-width: 90%;
    font-style: italic;
}

/* ══════════════════════════════════════════════
   SUGGESTION PANEL
   ══════════════════════════════════════════════ */

/* Menu item SVG icons align */
.qa-menu-item svg {
    flex-shrink: 0;
}

/* Overlay */
.sug-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Modal */
.sug-modal {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 8px 32px var(--shadow);
}

.sug-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.8rem;
}

/* Category buttons */
.sug-category-row {
    display: flex;
    gap: 6px;
    margin-bottom: 0.8rem;
}
.sug-cat-btn {
    flex: 1;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}
.sug-cat-btn:hover {
    border-color: var(--text);
    color: var(--text);
}
.sug-cat-active {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #fff !important;
}

/* Textarea */
.sug-textarea {
    width: 100%;
    min-height: 80px;
    max-height: 200px;
    resize: vertical;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem;
    font-size: 0.82rem;
    font-family: inherit;
    line-height: 1.4;
}
.sug-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* Character count */
.sug-char-count {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-align: right;
    margin: 0.2rem 0 0.6rem;
}

/* Button row */
.sug-btn-row {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.sug-cancel-btn {
    padding: 0.4rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
}
.sug-cancel-btn:hover {
    border-color: var(--text);
    color: var(--text);
}
.sug-submit-btn {
    padding: 0.4rem 1.2rem;
    border: none;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s;
}
.sug-submit-btn:hover { background: var(--accent-hover); }
.sug-submit-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Light theme overrides */
[data-theme="light"] .sug-overlay {
    background: rgba(0,0,0,0.3);
}
[data-theme="light"] .sug-modal {
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

/* ══════════════════════════════════════════════
   FILE UPLOAD
   ══════════════════════════════════════════════ */

/* Upload button in composer */
.upload-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    min-width: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.upload-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.upload-btn.upload-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* Upload preview bar (above composer) */
.upload-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    background: var(--panel-hover);
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-shrink: 0;
    position: relative;
}
.upload-preview-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.upload-preview-cancel {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.3rem;
}
.upload-preview-cancel:hover { color: var(--text); }
.upload-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border);
}
.upload-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 0.3s ease;
}

/* ── MediaCard Grid ── */
.media-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    padding: 6px 0;
    max-width: 95%;
}
.media-card {
    display: flex; align-items: center; gap: 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s, background .15s;
    position: relative;
    overflow: hidden;
}
.media-card:hover {
    border-color: #4a9eff88;
    box-shadow: 0 2px 12px rgba(74,158,255,0.12);
    background: var(--panel-hover);
}
.media-card-icon {
    flex-shrink: 0;
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    background: #4a9eff18;
    border-radius: 8px;
    color: #4a9eff;
}
.media-card-info {
    display: flex; flex-direction: column; gap: 2px;
    min-width: 0;
}
.media-card-title {
    font-size: .8rem; font-weight: 600;
    color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.media-card-badge {
    font-size: .65rem; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .4px;
}
.media-card-tags {
    position: absolute; top: 5px; right: 6px;
    display: flex; gap: 3px;
}
.media-card-tag {
    font-size: .58rem; padding: 1px 5px;
    background: #4a9eff15; color: #4a9eff;
    border-radius: 4px;
}

/* ── Visual Content ── */
.msg-visual {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    max-width: 95%;
}
.visual-title {
    font-weight: 600;
    font-size: .85rem;
    margin-bottom: 8px;
    color: #4a9eff;
}
.mermaid-container { overflow-x: auto; position: relative; }
.mermaid-container svg { max-width: 100%; height: auto; }
.visual-img-wrap { position: relative; display: block; max-width: 100%; }
.visual-img { display: block; width: 100%; max-width: 100%; border-radius: 8px; margin-top: 4px; cursor: pointer; }

/* Zoom button on diagrams & images */
.visual-zoom-btn {
    position: absolute; top: 6px; right: 6px;
    width: 32px; height: 32px;
    background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px; color: #fff; font-size: 16px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity .2s;
    z-index: 2; backdrop-filter: blur(4px);
}
.mermaid-container:hover .visual-zoom-btn,
.visual-img-wrap:hover .visual-zoom-btn { opacity: 1; }
.visual-zoom-btn:hover { background: rgba(74,158,255,0.7); }

/* Popup zoom window */
.visual-lightbox {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity .2s;
}
.visual-lightbox.active { opacity: 1; }
.visual-lightbox-popup {
    position: relative;
    width: 80vw; max-width: 900px;
}
.visual-lightbox-inner {
    background: var(--panel, #1a2028);
    border: 1px solid var(--border, #2e3a46);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    width: 80vw; max-height: 85vh;
    overflow: auto; padding: 20px 24px;
    -webkit-overflow-scrolling: touch;
    cursor: default;
}
.visual-lightbox-inner svg { display: block; width: 100%; height: auto; max-height: 70vh; }
.visual-lightbox-inner img { display: block; width: 100%; max-height: 70vh; object-fit: contain; border-radius: 8px; }
.visual-lightbox-inner .mermaid-container { width: 100%; }
.visual-lightbox-inner .visual-formula,
.visual-lightbox-inner .visual-ascii { font-size: 1.1rem; }
.visual-lightbox-inner .visual-table { font-size: .95rem; }
.visual-lightbox-close {
    position: absolute; top: -12px; right: -12px; z-index: 10000;
    width: 30px; height: 30px;
    background: var(--panel, #1a2028); border: 1px solid var(--border, #2e3a46);
    border-radius: 50%; color: var(--text, #d8e0e8); font-size: 18px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.visual-lightbox-close:hover { background: #e74c3c; color: #fff; }

/* Formula display */
.visual-formula {
    font-family: 'Consolas', 'Fira Code', 'Courier New', monospace;
    font-size: .9rem; line-height: 1.7;
    background: #0d1117; border: 1px solid #30363d; border-radius: 10px;
    padding: 16px 20px; white-space: pre-wrap; color: #c9d1d9;
    overflow-x: auto; position: relative;
}
.visual-formula::before {
    content: 'f(x)'; position: absolute; top: 8px; left: 12px;
    font-size: .65rem; color: #484f58; font-style: italic;
}
[data-theme="light"] .visual-formula {
    background: #f6f8fa; border-color: #d0d7de; color: #1f2328;
}

/* Data table */
.visual-table {
    width: 100%; border-collapse: collapse; font-size: .82rem;
    border-radius: 8px; overflow: hidden;
}
.visual-table th {
    background: #21262d; color: #58a6ff; padding: 8px 10px;
    text-align: left; font-weight: 600; border-bottom: 2px solid #30363d;
    font-size: .78rem; text-transform: uppercase; letter-spacing: .3px;
}
.visual-table td {
    padding: 7px 10px; border-bottom: 1px solid #21262d; color: var(--text);
}
.visual-table tr:hover td { background: #161b22; }
[data-theme="light"] .visual-table th { background: #dfe5eb; color: #0969da; border-color: #c8d0d8; }
[data-theme="light"] .visual-table td { border-color: #e8ecf0; }
[data-theme="light"] .visual-table tr:hover td { background: #f0f4f8; }

/* ASCII diagram */
.visual-ascii {
    font-family: 'Consolas', 'Fira Code', 'Courier New', monospace;
    font-size: .82rem; line-height: 1.5;
    background: #0d1117; border: 1px solid #30363d; border-radius: 10px;
    padding: 16px 20px; color: #8b949e; overflow-x: auto;
    white-space: pre; position: relative;
}
[data-theme="light"] .visual-ascii {
    background: #f6f8fa; border-color: #d0d7de; color: #57606a;
}

/* Zoom button on formula/table/ascii */
.msg-visual { position: relative; }
.msg-visual:hover > .visual-zoom-btn { opacity: 1; }
