/* ── CSS Variables ────────────────────────────────────────── */
:root {
    --bg: #0d0d0d;
    --surface: #1a1a1a;
    --surface2: #222;
    --surface3: #2a2a2a;
    --border: #333;
    --border2: #444;
    --text: #e8e8e8;
    --text-muted: #888;
    --text-dim: #666;
    --accent: #4a9eff;
    --accent-hover: #3a8eef;
    --green: #22c55e;
    --yellow: #f59e0b;
    --red: #ef4444;
    --red-hover: #dc2626;
    --purple: #a855f7;
    --header-bg: #111;
    --header-border: #2a2a2a;
    --radius: 8px;
    --radius-sm: 4px;
}

/* ── Base reset ───────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

/* ── Blazor loading progress (dark) ──────────────────────── */
.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #333;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    color: var(--text-muted);
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* ── Blazor error UI ──────────────────────────────────────── */
#blazor-error-ui {
    background: #b32121;
    color: white;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,0.4);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* ── Spinner ──────────────────────────────────────────────── */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ══════════════════════════════════════════════════════════
   PRIORITY APP
   ══════════════════════════════════════════════════════════ */

/* ── Loading / error full-screen states ──────────────────── */
.fullscreen-center {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem 2.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    min-width: 280px;
    text-align: center;
}

.card h2 {
    font-size: 1.1rem;
    color: var(--text);
}

.card p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
}

.card.error {
    border-color: #ef444444;
}

.card.error h2 {
    color: var(--red);
}

.btn {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.45rem 1rem;
    font-size: 13px;
    cursor: pointer;
}

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

.btn.secondary {
    background: var(--surface2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn.secondary:hover {
    background: var(--surface3);
    color: var(--text);
}

/* ── App shell ────────────────────────────────────────────── */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── Load overlay (shown during refresh) ─────────────────── */
#loadOverlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0,0,0,0.55);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--text-muted);
    font-size: 13px;
    pointer-events: none;
}

/* ── Header ──────────────────────────────────────────────── */
#app > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: 52px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    flex-shrink: 0;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.logo {
    font-size: 1.25rem;
}

.header-title {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
}

.header-sub {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.last-loaded {
    font-size: 11px;
    color: var(--text-dim);
}

#refreshBtn {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.75rem;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}

#refreshBtn:hover:not(:disabled) {
    background: var(--surface3);
    border-color: var(--border2);
}

#refreshBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.user-pill {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ── Summary bar ─────────────────────────────────────────── */
.summary-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.stat-chip {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.15rem 0.65rem;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.stat-chip.alert {
    border-color: #f59e0b66;
    color: var(--yellow);
}

.stat-val {
    font-weight: 700;
    color: var(--text);
}

.stat-chip.alert .stat-val {
    color: var(--yellow);
}

/* ── Toolbar ─────────────────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.toolbar-label {
    font-size: 11px;
    color: var(--text-dim);
    white-space: nowrap;
}

.toolbar-select {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.5rem;
    font-size: 12px;
    cursor: pointer;
}

.toolbar-select:focus {
    outline: none;
    border-color: var(--accent);
}

.toolbar-select.active {
    border-color: var(--accent);
    color: var(--accent);
}

.toolbar-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 0.25rem;
}

.sort-dir-btn {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.6rem;
    font-size: 12px;
    cursor: pointer;
}

.sort-dir-btn:hover {
    background: var(--surface3);
    border-color: var(--border2);
}

.preset-btn {
    background: var(--surface2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.6rem;
    font-size: 12px;
    cursor: pointer;
}

.preset-btn:hover {
    background: var(--surface3);
    color: var(--text);
    border-color: var(--border2);
}

.clear-filters-btn {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.6rem;
    font-size: 12px;
    cursor: pointer;
    margin-left: auto;
}

.clear-filters-btn:hover {
    color: var(--red);
    border-color: var(--red);
}

/* ── Multi-select filter (ms-*) ──────────────────────────── */
.ms-wrapper {
    position: relative;
    display: inline-block;
}

.ms-trigger {
    background: var(--surface2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.6rem;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.ms-trigger:hover {
    background: var(--surface3);
    border-color: var(--border2);
}

.ms-trigger.active {
    color: var(--accent);
    border-color: var(--accent);
}

.ms-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 200;
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: var(--radius-sm);
    min-width: 140px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    overflow: hidden;
}

.ms-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.65rem;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-muted);
}

.ms-option:hover {
    background: var(--surface3);
    color: var(--text);
}

.ms-option.checked {
    color: var(--text);
}

.ms-option input[type="checkbox"] {
    accent-color: var(--accent);
    cursor: pointer;
}

/* ── Columns area ────────────────────────────────────────── */
.columns {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    gap: 0;
}

.column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-right: 1px solid var(--border);
    overflow: hidden;
}

.column:last-child {
    border-right: none;
}

/* ── Column header ───────────────────────────────────────── */
.col-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 0.5rem;
}

.col-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.col-counts {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-shrink: 0;
}

.count-badge {
    font-size: 11px;
    color: var(--text-dim);
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.1rem 0.5rem;
    white-space: nowrap;
}

.count-badge.danger {
    color: var(--yellow);
    border-color: #f59e0b44;
    background: #f59e0b11;
}

/* ── Column scroll ───────────────────────────────────────── */
.col-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
}

.empty-state {
    padding: 2rem;
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
}

/* ── Group headers ───────────────────────────────────────── */
.status-group {
    margin-bottom: 0.5rem;
}

.status-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.25rem;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: default;
    user-select: none;
}

.status-group-header:first-child {
    margin-top: 0;
}

.group-count {
    font-size: 11px;
    color: var(--text-dim);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    margin-left: auto;
}

.status-group-body {
    /* no extra styling needed — cards are direct children */
}

/* ── Work item card ──────────────────────────────────────── */
.item-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.4rem;
    position: relative;
}

.item-card:hover {
    border-color: var(--border2);
}

.item-card.unassigned {
    border-color: #f59e0b44;
    animation: pulse-border 2.5s ease-in-out infinite;
}

@keyframes pulse-border {
    0%, 100% { border-color: #f59e0b44; }
    50%       { border-color: #f59e0b99; }
}

/* ── Card top row (subject + badges) ─────────────────────── */
.card-top {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.card-subject {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    word-break: break-word;
}

.card-subject a {
    color: var(--text);
    text-decoration: none;
}

.card-subject a:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* ── Badges ──────────────────────────────────────────────── */
.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    flex-shrink: 0;
}

.badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge.unassigned-badge {
    background: #f59e0b22;
    color: var(--yellow);
    border-color: #f59e0b44;
}

.badge.type-change {
    background: #a855f722;
    color: var(--purple);
    border-color: #a855f744;
}

.badge.approval-approved {
    background: #22c55e22;
    color: var(--green);
    border-color: #22c55e44;
}

.badge.approval-rejected {
    background: #ef444422;
    color: var(--red);
    border-color: #ef444444;
}

.badge.approval-pending {
    background: #f59e0b22;
    color: var(--yellow);
    border-color: #f59e0b44;
}

.badge.age-green {
    background: #22c55e22;
    color: var(--green);
    border-color: #22c55e44;
}

.badge.age-yellow {
    background: #f59e0b22;
    color: var(--yellow);
    border-color: #f59e0b44;
}

.badge.age-red {
    background: #ef444422;
    color: var(--red);
    border-color: #ef444444;
}

/* ── Card meta row ───────────────────────────────────────── */
.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.5rem;
    align-items: center;
    margin-bottom: 0.35rem;
    font-size: 11px;
    color: var(--text-muted);
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.meta-item.unassigned-agent {
    color: var(--yellow);
}

/* ── Inline priority / urgency / impact selects ──────────── */
.priority-select,
.urgency-select,
.impact-select {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.15rem 0.35rem;
    font-size: 11px;
    cursor: pointer;
    max-width: 90px;
}

.priority-select:focus,
.urgency-select:focus,
.impact-select:focus {
    outline: none;
    border-color: var(--accent);
}

.priority-select:disabled,
.urgency-select:disabled,
.impact-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Priority colors */
.priority-select.p1 { border-color: #ef444466; color: var(--red); }
.priority-select.p2 { border-color: #f59e0b66; color: var(--yellow); }
.priority-select.p3 { border-color: #4a9eff66; color: var(--accent); }
.priority-select.p4 { border-color: #55555566; color: var(--text-dim); }

/* Urgency colors (u4=highest) */
.urgency-select.u4 { border-color: #ef444466; color: var(--red); }
.urgency-select.u3 { border-color: #f59e0b66; color: var(--yellow); }
.urgency-select.u2 { border-color: #4a9eff66; color: var(--accent); }
.urgency-select.u1 { border-color: #55555566; color: var(--text-dim); }

/* Impact colors (i3=highest) */
.impact-select.i3  { border-color: #ef444466; color: var(--red); }
.impact-select.i2  { border-color: #f59e0b66; color: var(--yellow); }
.impact-select.i1  { border-color: #55555566; color: var(--text-dim); }

/* Saving flash */
.priority-select.saving,
.urgency-select.saving,
.impact-select.saving {
    border-color: var(--accent);
    animation: saving-pulse 0.6s ease-in-out infinite alternate;
}

@keyframes saving-pulse {
    from { opacity: 0.6; }
    to   { opacity: 1; }
}

/* ── Save indicator ──────────────────────────────────────── */
.save-indicator {
    font-size: 10px;
    color: var(--green);
    padding: 0.1rem 0.35rem;
    background: #22c55e22;
    border-radius: 3px;
    border: 1px solid #22c55e44;
    opacity: 0;
    transition: opacity 0.2s;
}

.save-indicator.visible {
    opacity: 1;
}

/* ── Triage notes ────────────────────────────────────────── */
.triage-notes-section {
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--border);
}

.triage-notes-label {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
}

.triage-notes-textarea {
    width: 100%;
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.4rem;
    font-size: 11px;
    font-family: inherit;
    resize: vertical;
    min-height: 52px;
    line-height: 1.5;
}

.triage-notes-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.triage-notes-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.25rem;
}

.triage-notes-status {
    font-size: 10px;
    color: var(--text-dim);
}

.triage-notes-status.ok  { color: var(--green); }
.triage-notes-status.err { color: var(--red); }

.triage-notes-save-btn {
    background: var(--surface3);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.15rem 0.5rem;
    font-size: 11px;
    cursor: pointer;
}

.triage-notes-save-btn:hover:not(:disabled) {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.triage-notes-save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Meeting notes (collapsible) ─────────────────────────── */
.notes-toggle {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 11px;
    cursor: pointer;
    padding: 0.25rem 0;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.35rem;
}

.notes-toggle:hover {
    color: var(--text-muted);
}

.notes-arrow {
    display: inline-block;
    font-size: 9px;
    transition: transform 0.15s;
}

.notes-toggle.open .notes-arrow {
    transform: rotate(90deg);
}

.notes-body {
    margin-top: 0.35rem;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.2s ease;
}

.notes-body.open {
    max-height: 200px;
}

.notes-textarea {
    width: 100%;
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.4rem;
    font-size: 11px;
    font-family: inherit;
    resize: vertical;
    min-height: 52px;
    line-height: 1.5;
}

.notes-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.notes-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.25rem;
}

.notes-status {
    font-size: 10px;
    color: var(--text-dim);
}

.notes-status.ok  { color: var(--green); }
.notes-status.err { color: var(--red); }

.notes-save-btn {
    background: var(--surface3);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.15rem 0.5rem;
    font-size: 11px;
    cursor: pointer;
}

.notes-save-btn:hover:not(:disabled) {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.notes-save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ══════════════════════════════════════════════════════════
   ADMIN CHAT APP
   ══════════════════════════════════════════════════════════ */

/* ── App shell ────────────────────────────────────────────── */
#appShell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
    width: 240px;
    display: flex;
    flex-direction: column;
    background: var(--header-bg);
    border-right: 1px solid var(--header-border);
    flex-shrink: 0;
}

.sidebar-header {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}

#newChatBtn {
    width: 100%;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    justify-content: center;
}

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

.btn-icon {
    font-size: 13px;
}

#convList {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
    padding: 0.35rem;
}

.conv-loading, .conv-empty {
    padding: 1rem 0.5rem;
    font-size: 11px;
    color: var(--text-dim);
    text-align: center;
    line-height: 1.6;
}

.conv-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.1s;
}

.conv-item:hover {
    background: var(--surface2);
}

.conv-item.active {
    background: var(--surface2);
    border-color: var(--border);
}

.conv-meta {
    flex: 1;
    min-width: 0;
}

.conv-title {
    font-size: 12px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-date {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 1px;
}

.conv-del {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 0.1rem 0.3rem;
    font-size: 12px;
    border-radius: 3px;
    opacity: 0;
    flex-shrink: 0;
}

.conv-item:hover .conv-del,
.conv-item.active .conv-del {
    opacity: 1;
}

.conv-del:hover {
    color: var(--red);
    background: var(--surface3);
}

.sidebar-footer {
    padding: 0.6rem 0.75rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* Admin Chat user-pill (different from Priority App) */
#sidebar .user-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#userName {
    font-size: 12px;
    color: var(--text-muted);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#signOutBtn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: var(--radius-sm);
    padding: 0.15rem 0.45rem;
    font-size: 10px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

#signOutBtn:hover {
    border-color: var(--border2);
    color: var(--text-muted);
}

/* ── Main panel ───────────────────────────────────────────── */
#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

#main header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    height: 56px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    flex-shrink: 0;
    gap: 1rem;
}

#main .header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#main header h1 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.subtitle {
    font-size: 11px;
    color: var(--text-dim);
}

#convTitle {
    font-size: 12px;
    color: var(--text-muted);
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Chat screen ─────────────────────────────────────────── */
#chatScreen {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 1rem;
    gap: 0.75rem;
}

/* ── Quick actions ───────────────────────────────────────── */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    flex-shrink: 0;
}

.qa-btn {
    background: var(--surface2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.3rem 0.75rem;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.1s;
    white-space: nowrap;
}

.qa-btn:hover {
    background: var(--surface3);
    color: var(--text);
    border-color: var(--border2);
}

/* ── Messages ────────────────────────────────────────────── */
#messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
    padding-right: 0.25rem;
}

.message {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    max-width: 860px;
}

.message.user {
    flex-direction: row-reverse;
    margin-left: auto;
}

.msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.message.user .msg-avatar {
    background: var(--accent);
    color: white;
    font-size: 12px;
}

.message.assistant .msg-avatar {
    background: var(--surface3);
    color: var(--text-muted);
}

.message.user .msg-avatar::after {
    content: '👤';
    font-size: 14px;
}

.message.assistant .msg-avatar::after {
    content: '🤖';
    font-size: 14px;
}

.msg-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.85rem;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
    max-width: 720px;
    word-break: break-word;
}

.message.user .msg-content {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    border-bottom-right-radius: 3px;
}

.message.assistant .msg-content {
    border-bottom-left-radius: 3px;
}

/* Markdown inside assistant messages */
.msg-content p { margin: 0 0 0.5rem 0; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content ul, .msg-content ol { margin: 0.25rem 0 0.5rem 1.25rem; }
.msg-content li { margin-bottom: 0.2rem; }
.msg-content code {
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.1rem 0.3rem;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 12px;
    color: #a8e6cf;
}
.msg-content pre {
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
    overflow-x: auto;
    margin: 0.4rem 0;
}
.msg-content pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 12px;
}
.msg-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.4rem 0;
    font-size: 12px;
}
.msg-content th, .msg-content td {
    border: 1px solid var(--border2);
    padding: 0.3rem 0.6rem;
    text-align: left;
}
.msg-content th {
    background: var(--surface3);
    font-weight: 600;
}
.msg-content tr:hover td {
    background: var(--surface2);
}
.msg-content h1, .msg-content h2, .msg-content h3 {
    font-size: 1em;
    font-weight: 600;
    margin: 0.5rem 0 0.25rem 0;
    color: var(--text);
}
.msg-content a { color: var(--accent); }
.msg-content a:hover { text-decoration: none; }
.msg-content strong { color: var(--text); }

/* Thinking indicator */
.thinking {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 0.5rem 0.75rem;
}

.thinking span {
    width: 7px;
    height: 7px;
    background: var(--text-dim);
    border-radius: 50%;
    animation: bounce 1.2s infinite;
}

.thinking span:nth-child(2) { animation-delay: 0.2s; }
.thinking span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}

/* ── Input area ──────────────────────────────────────────── */
.input-area {
    flex-shrink: 0;
}

.input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

#userInput {
    flex: 1;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.75rem;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    overflow-y: hidden;
    line-height: 1.5;
    min-height: 44px;
    max-height: 200px;
    field-sizing: content;
}

#userInput:focus {
    outline: none;
    border-color: var(--accent);
}

#userInput:disabled {
    opacity: 0.6;
}

#sendBtn {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    width: 44px;
    height: 44px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.1s;
}

#sendBtn:hover:not(:disabled) {
    background: var(--accent-hover);
}

#sendBtn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.status-bar {
    font-size: 11px;
    color: var(--text-dim);
    text-align: right;
    padding: 0.2rem 0;
}
