/* ============================================================
   Repair AI Assistant — Dark Theme Stylesheet
   ============================================================ */

/* --- CSS Variables / Theme --- */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-chat: #0f3460;
    --bg-input: #1e293b;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent: #0ea5e9;
    --accent-dark: #0369a1;
    --accent-hover: #38bdf8;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --code-bg: #1e293b;
    --border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);

    --sidebar-width: 300px;
    --header-height: 56px;
    --input-area-min: 72px;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;

    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
        Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", "Cascadia Code", "Fira Code", "JetBrains Mono",
        Consolas, "Courier New", monospace;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    display: flex;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* --- Icon helper --- */
.icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
    z-index: 20;
}
.sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.sidebar-header h2 {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-section {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}
.sidebar-section-grow {
    flex: 1;
    overflow-y: auto;
    border-bottom: none;
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.sidebar-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: block;
}
.sidebar-section-header .sidebar-label {
    margin-bottom: 0;
}

/* Device search */
.device-search-wrap {
    position: relative;
    margin-bottom: 8px;
}
.device-search-wrap .input-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    width: 16px;
    height: 16px;
    pointer-events: none;
}

.input-field {
    width: 100%;
    padding: 8px 10px 8px 34px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-ui);
    outline: none;
    transition: border-color var(--transition);
}
.input-field:focus {
    border-color: var(--accent);
}
.input-field::placeholder {
    color: var(--text-secondary);
}

/* Device list */
.device-list {
    max-height: 180px;
    overflow-y: auto;
}
.device-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    transition: background var(--transition);
}
.device-item:hover {
    background: rgba(255, 255, 255, 0.05);
}
.device-item.active {
    background: var(--accent-dark);
    color: #fff;
}
.device-item .device-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.device-item .device-badge {
    font-size: 10px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
}
.device-item.active .device-badge {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Device info card */
.device-info {
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(14, 165, 233, 0.08);
    border: 1px solid rgba(14, 165, 233, 0.2);
    border-radius: var(--radius-sm);
    font-size: 12px;
    line-height: 1.6;
}
.device-info .device-stat {
    display: flex;
    justify-content: space-between;
}
.device-info .device-stat-val {
    font-weight: 600;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 12px;
}

/* Conversation list */
.conversation-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.conv-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    transition: background var(--transition);
    color: var(--text-primary);
}
.conv-item:hover {
    background: rgba(255, 255, 255, 0.05);
}
.conv-item.active {
    background: rgba(14, 165, 233, 0.12);
}
.conv-item .conv-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-item .conv-date {
    font-size: 10px;
    color: var(--text-secondary);
    white-space: nowrap;
}
.conv-item .btn-delete-conv {
    opacity: 0;
    transition: opacity var(--transition);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
}
.conv-item:hover .btn-delete-conv {
    opacity: 1;
}
.conv-item .btn-delete-conv:hover {
    color: var(--error);
}

/* Buttons */
.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), color var(--transition);
}
.btn-icon:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.btn-small {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background: var(--accent-dark);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 12px;
    font-family: var(--font-ui);
    cursor: pointer;
    transition: background var(--transition);
}
.btn-small:hover {
    background: var(--accent);
}
.btn-small .icon {
    width: 14px;
    height: 14px;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 0;
}

/* Header */
.header {
    height: var(--header-height);
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    z-index: 10;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}
.header-title h1 {
    font-size: 17px;
    font-weight: 700;
    white-space: nowrap;
}
.header-logo {
    color: var(--accent);
    width: 22px;
    height: 22px;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Health indicator */
.health-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}
.health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.health-dot-ok {
    background: var(--success);
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}
.health-dot-error {
    background: var(--error);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}
.health-dot-unknown {
    background: var(--warning);
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ============================================================
   CHAT AREA
   ============================================================ */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    max-width: 860px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Welcome screen */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    flex: 1;
}
.welcome-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}
.welcome-icon .icon {
    width: 32px;
    height: 32px;
    color: #fff;
}
.welcome-message h2 {
    font-size: 22px;
    margin-bottom: 8px;
}
.welcome-message p {
    color: var(--text-secondary);
    font-size: 14px;
    max-width: 400px;
}
.welcome-hint {
    margin-top: 4px;
    font-size: 13px !important;
}
.welcome-hint strong {
    color: var(--accent-hover);
}

/* Step-by-step guide */
.welcome-steps {
    display: flex;
    gap: 16px;
    margin: 24px 0 8px;
    justify-content: center;
    flex-wrap: wrap;
}
.welcome-step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}
.step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-dark);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.welcome-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 28px;
    justify-content: center;
    max-width: 700px;
}
.example-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-ui);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}
.example-btn:hover {
    background: var(--bg-chat);
    border-color: var(--accent);
}
.example-btn .icon {
    color: var(--accent);
    width: 16px;
    height: 16px;
}

/* Message rows */
.message-row {
    display: flex;
    gap: 10px;
    animation: fadeInUp 0.25s ease;
}
.message-row.user {
    justify-content: flex-end;
}
.message-row.assistant {
    justify-content: flex-start;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Avatar */
.message-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}
.message-row.assistant .message-avatar {
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
}
.message-avatar .icon {
    width: 16px;
    height: 16px;
    color: #fff;
}

/* Bubble */
.message-bubble {
    max-width: 75%;
    position: relative;
}
.message-row.user .message-bubble {
    max-width: 65%;
}
.message-row.assistant .message-bubble {
    max-width: 85%;
}

.message-content {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 15px;
    line-height: 1.65;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.message-row.user .message-content {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.message-row.assistant .message-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.message-row.error .message-content {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

/* Message metadata */
.message-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
    padding: 0 4px;
}
.message-row.user .message-meta {
    justify-content: flex-end;
}
.message-timestamp {
    font-size: 11px;
    color: var(--text-secondary);
}
.btn-copy {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-family: var(--font-ui);
    border-radius: 4px;
    transition: color var(--transition), background var(--transition);
    opacity: 0;
    transition: opacity var(--transition), color var(--transition);
}
.message-row:hover .btn-copy {
    opacity: 1;
}
.btn-copy:hover {
    color: var(--accent);
    background: rgba(255, 255, 255, 0.05);
}
.btn-copy .icon {
    width: 13px;
    height: 13px;
}

/* Streaming tail (incomplete line shown as plain text while typing) */
.streaming-tail {
    opacity: 0.7;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 16px;
}
.typing-dot {
    width: 7px;
    height: 7px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ============================================================
   MARKDOWN CONTENT STYLING
   ============================================================ */
.message-content p {
    margin-bottom: 8px;
}
.message-content p:last-child {
    margin-bottom: 0;
}
.message-content strong {
    font-weight: 700;
    color: #fff;
}
.message-row.assistant .message-content strong {
    color: var(--accent-hover);
}
.message-content em {
    font-style: italic;
    color: var(--text-secondary);
}
.message-row.assistant .message-content em {
    color: inherit;
    opacity: 0.85;
}

/* Inline code — component designators, net names */
.message-content code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--code-bg);
    color: var(--accent-hover);
    border: 1px solid rgba(51, 65, 85, 0.6);
}
.message-row.user .message-content code {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Code blocks */
.message-content pre {
    margin: 10px 0;
    padding: 14px 16px;
    background: #0d1117;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
}
.message-content pre code {
    background: none;
    border: none;
    padding: 0;
    color: var(--text-primary);
    font-size: inherit;
}

/* Lists */
.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}
.message-content li {
    margin-bottom: 4px;
}
.message-content li::marker {
    color: var(--accent);
}

/* Tables */
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 13px;
}
.message-content th,
.message-content td {
    padding: 8px 12px;
    text-align: left;
    border: 1px solid var(--border);
}
.message-content th {
    background: var(--code-bg);
    font-weight: 600;
    color: var(--accent-hover);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.message-content tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

/* Blockquote */
.message-content blockquote {
    border-left: 3px solid var(--accent);
    padding: 4px 12px;
    margin: 8px 0;
    color: var(--text-secondary);
    background: rgba(14, 165, 233, 0.05);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Horizontal rule */
.message-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 12px 0;
}

/* ============================================================
   INPUT AREA
   ============================================================ */
.input-area {
    padding: 12px 20px 10px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

/* Image preview bar */
.image-preview-bar {
    max-width: 860px;
    margin: 0 auto 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--accent-dark);
    border-radius: var(--radius-sm);
    animation: fadeInUp 0.2s ease;
}
.image-preview-thumb {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--border);
}
.image-preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.btn-remove-image {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--error);
    border: none;
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.image-preview-name {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Attach button */
.btn-attach {
    color: var(--text-secondary);
    flex-shrink: 0;
}
.btn-attach:hover {
    color: var(--accent);
}
.btn-attach.has-image {
    color: var(--accent);
}

.input-container {
    max-width: 860px;
    margin: 0 auto;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    transition: border-color var(--transition);
}
.input-container:focus-within {
    border-color: var(--accent);
}

.message-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: var(--font-ui);
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 150px;
    overflow-y: auto;
}
.message-input::placeholder {
    color: var(--text-secondary);
}
.message-input:disabled {
    opacity: 0.5;
}

.btn-send {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), transform var(--transition);
}
.btn-send:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: scale(1.05);
}
.btn-send:disabled {
    background: var(--border);
    cursor: not-allowed;
}
.btn-send .icon {
    width: 18px;
    height: 18px;
}

.input-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 6px;
    opacity: 0.6;
}
.input-hint kbd {
    background: var(--bg-input);
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid var(--border);
    font-family: var(--font-ui);
    font-size: 10px;
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.hidden {
    display: none !important;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        box-shadow: 4px 0 20px var(--shadow);
    }
    .sidebar.collapsed {
        margin-left: calc(-1 * var(--sidebar-width));
        box-shadow: none;
    }

    .message-row.user .message-bubble,
    .message-row.assistant .message-bubble {
        max-width: 90%;
    }

    .welcome-examples {
        flex-direction: column;
        align-items: center;
    }

    .header-title h1 {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .chat-messages {
        padding: 12px;
    }

    .input-area {
        padding: 8px 12px 6px;
    }

    .message-content {
        font-size: 14px;
        padding: 8px 12px;
    }
}

/* ============================================================
   FEEDBACK BUTTONS (thumbs up/down)
   ============================================================ */
.feedback-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
    padding: 0 4px;
    opacity: 0;
    transition: opacity var(--transition);
}
.message-row:hover .feedback-bar,
.feedback-bar.has-feedback {
    opacity: 1;
}

.btn-feedback {
    background: none;
    border: 1px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 3px 6px;
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-family: var(--font-ui);
    border-radius: 4px;
    transition: color var(--transition), background var(--transition),
        border-color var(--transition);
}
.btn-feedback:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}
.btn-feedback .icon {
    width: 14px;
    height: 14px;
}

/* Selected states */
.btn-feedback.selected-up {
    color: var(--success);
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
    cursor: default;
}
.btn-feedback.selected-down {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    cursor: default;
}

/* Feedback comment input (shown when thumbs down is clicked) */
.feedback-comment-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    padding: 0 4px;
    animation: fadeInUp 0.2s ease;
}
.feedback-comment-input {
    flex: 1;
    max-width: 320px;
    padding: 5px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 12px;
    font-family: var(--font-ui);
    outline: none;
    transition: border-color var(--transition);
}
.feedback-comment-input:focus {
    border-color: var(--accent);
}
.feedback-comment-input::placeholder {
    color: var(--text-secondary);
}
.btn-feedback-send {
    background: var(--accent-dark);
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-family: var(--font-ui);
    display: flex;
    align-items: center;
    gap: 3px;
    transition: background var(--transition);
}
.btn-feedback-send:hover {
    background: var(--accent);
}
.btn-feedback-send .icon {
    width: 12px;
    height: 12px;
}

/* ============================================================
   INLINE SCHEMATIC IMAGES
   ============================================================ */

/* Container for inline schematic thumbnails within a message */
.schematic-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.schematic-images-label {
    width: 100%;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.schematic-images-label .icon {
    width: 13px;
    height: 13px;
}

/* Individual thumbnail wrapper */
.schematic-thumb {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    overflow: hidden;
    cursor: pointer;
    transition: border-color var(--transition), transform var(--transition),
        box-shadow var(--transition);
    background: var(--code-bg);
    flex-shrink: 0;
}
.schematic-thumb:hover {
    border-color: var(--accent);
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--shadow);
}

.schematic-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.schematic-thumb-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 3px 6px;
    background: rgba(0, 0, 0, 0.75);
    color: var(--accent-hover);
    font-size: 10px;
    font-family: var(--font-mono);
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Lightbox overlay */
.schematic-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    animation: fadeIn 0.2s ease;
    cursor: pointer;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.schematic-lightbox-inner {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    cursor: default;
}

.schematic-lightbox-inner img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

.schematic-lightbox-caption {
    text-align: center;
    margin-top: 10px;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: var(--font-mono);
}
.schematic-lightbox-caption strong {
    color: var(--accent-hover);
}

.schematic-lightbox-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    transition: background var(--transition), color var(--transition);
    z-index: 10000;
}
.schematic-lightbox-close:hover {
    background: var(--error);
    border-color: var(--error);
    color: #fff;
}

/* Responsive adjustments for schematic images */
@media (max-width: 480px) {
    .schematic-thumb {
        width: 80px;
        height: 80px;
    }
}

/* ============================================================
   USER-UPLOADED IMAGE IN CHAT
   ============================================================ */
.user-image-wrap {
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    max-width: 240px;
    border: 1px solid rgba(255,255,255,0.15);
    cursor: pointer;
}
.user-image-wrap img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: cover;
}

/* Vision analysis result box */
.vision-analysis-box {
    margin-top: 8px;
    padding: 10px 14px;
    background: rgba(14, 165, 233, 0.06);
    border: 1px solid rgba(14, 165, 233, 0.18);
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.6;
}
.vision-analysis-box .vision-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.vision-analysis-box .vision-label .icon {
    width: 13px;
    height: 13px;
}
.vision-components-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}
.vision-chip {
    font-size: 11px;
    font-family: var(--font-mono);
    padding: 2px 8px;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--accent-hover);
}
.vision-damage-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    margin-top: 6px;
}
