/* === Carrot Express Lease Intelligence — B&W Flat Theme === */

/* ── 1. Reset / Base ── */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.2s, color 0.2s;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
}

img, svg {
    display: block;
}

/* ── 2. Theme Variables ── */
/* Brand mark tokens — supplemental, used only by the carrot brand-toggle
   mark and body[data-theme="brand"] (cream/taupe flavor). Everything else
   in this file reads the carrot-reporting token set below. */
:root {
    --carrot-leaf:       #6B8E23;
    --carrot-leaf-dark:  #9CC25A;
    --carrot-taupe:      #B0A696;
    --carrot-cream:      #F5EFE6;
    --carrot-cream-line: #E8DFD0;
    --carrot-warmgray:   #7A7269;
}

/* ════════════════════════════════════════════════════════════════════
   Design tokens — copied verbatim from carrot-reporting
   (PipelineMonitor/src/input.css :root + .dark, lines ~50-72).
   `:root` = light (default); `.dark` on <html> = dark. Pre-paint boot
   script (see index.html/deadlines.html/login.html <head>) toggles the
   class from localStorage('cx-theme'), falling back to
   prefers-color-scheme on first visit.
   ════════════════════════════════════════════════════════════════════ */
:root {
    --bg:#f3f3f1; --panel:#ffffff; --panel2:#ffffff; --panel3:#f7f7f5; --sub:#fafaf8;
    --line:#e2e1dd; --line2:#eceae6;
    --hi:#17181a; --tx:#34373b; --mut:#5f646b; --dim:#6d727a; --faint:#a2a7ae;
    --acc:#e05408; --acc2:#c74a06; --acc-bg:rgba(224,84,8,.10); --acc-row:rgba(224,84,8,.04);
    --ok:#136b39; --ok-bg:rgba(23,138,69,.10); --ok-bar:#7cbf99;
    --err:#c93f30; --err-bg:rgba(201,63,48,.10); --err-row:rgba(201,63,48,.04);
    --err-panel:#fdf3f1; --err-line:#f0d4cf; --err-mut:#b07067; --err-bar:#dd9188;
    --warn:#8a5e05; --info:#2a63b8; --info-bg:rgba(42,99,184,.10);
    --gray:#83888f; --gray-bg:rgba(131,136,143,.12);
    --envbg:#e9f3ec; --envln:#cde2d4;

    /* Legacy alias layer — this file's existing rules (400+ call sites)
       were written against these names; point them at the real tokens
       above so values stay single-sourced. Custom properties resolve
       live, so redefining --panel/--tx/etc. per data-theme scope below
       flows through automatically without touching every rule. */
    --surface:          var(--panel);
    --surface-elevated:  var(--panel2);
    --border:            var(--line);
    --border-muted:      var(--line2);
    --text:              var(--tx);
    --text-muted:        var(--mut);
    --text-dim:          var(--dim);
    --hover:             var(--panel3);
    --active:            var(--line2);
    --input-bg:          var(--sub);
    --scrollbar-thumb:   var(--faint);
    --error-bg:          var(--err-bg);
    --error-text:        var(--err);
    --shadow-sm:         0 1px 3px rgba(0,0,0,.07);
    --shadow-md:         0 4px 16px rgba(0,0,0,.1);
    --radius:            10px;
    --radius-sm:         6px;
}
.dark {
    --bg:#101112; --panel:#16181a; --panel2:#191b1e; --panel3:#1b1d20; --sub:#131416;
    --line:#24272b; --line2:#1e2023;
    --hi:#eceef0; --tx:#cfd2d6; --mut:#9aa0a8; --dim:#6b7078; --faint:#565b63;
    --acc:#f4650f; --acc2:#fb8b3c; --acc-bg:rgba(251,139,60,.14); --acc-row:rgba(251,139,60,.04);
    --ok:#4ade80; --ok-bg:rgba(74,222,128,.12); --ok-bar:#2f8455;
    --err:#f0655a; --err-bg:rgba(240,101,90,.14); --err-row:rgba(240,101,90,.05);
    --err-panel:#211a1b; --err-line:#47292a; --err-mut:#a3706c; --err-bar:#a8443c;
    --warn:#e8b64c; --info:#7db2f5; --info-bg:rgba(125,178,245,.12);
    --gray:#878d95; --gray-bg:rgba(154,160,168,.1);
    --envbg:#1c2b21; --envln:#27402f;
    --shadow-sm:         0 1px 3px rgba(0,0,0,.4);
    --shadow-md:         0 4px 16px rgba(0,0,0,.6);
}

html { color-scheme: light; }
html.dark { color-scheme: dark; }

/* Legacy data-theme attribute (still set by app.js/deadlines.js at
   runtime) mirrors the same real tokens, so both the class-based
   pre-paint boot and the attribute-based runtime toggle resolve to
   identical colors. */
body[data-theme="dark"],
html[data-theme="dark"] body {
    --bg:#101112; --panel:#16181a; --panel2:#191b1e; --panel3:#1b1d20; --sub:#131416;
    --line:#24272b; --line2:#1e2023;
    --hi:#eceef0; --tx:#cfd2d6; --mut:#9aa0a8; --dim:#6b7078; --faint:#565b63;
    --acc:#f4650f; --acc2:#fb8b3c; --acc-bg:rgba(251,139,60,.14); --acc-row:rgba(251,139,60,.04);
    --ok:#4ade80; --ok-bg:rgba(74,222,128,.12); --ok-bar:#2f8455;
    --err:#f0655a; --err-bg:rgba(240,101,90,.14); --err-row:rgba(240,101,90,.05);
    --warn:#e8b64c; --info:#7db2f5; --info-bg:rgba(125,178,245,.12);
    --gray:#878d95; --gray-bg:rgba(154,160,168,.1);
    --shadow-sm:         0 1px 3px rgba(0,0,0,.4);
    --shadow-md:         0 4px 16px rgba(0,0,0,.6);
}

body[data-theme="light"],
html[data-theme="light"] body {
    --bg:#f3f3f1; --panel:#ffffff; --panel2:#ffffff; --panel3:#f7f7f5; --sub:#fafaf8;
    --line:#e2e1dd; --line2:#eceae6;
    --hi:#17181a; --tx:#34373b; --mut:#5f646b; --dim:#6d727a; --faint:#a2a7ae;
    --acc:#e05408; --acc2:#c74a06; --acc-bg:rgba(224,84,8,.10); --acc-row:rgba(224,84,8,.04);
    --ok:#136b39; --ok-bg:rgba(23,138,69,.10); --ok-bar:#7cbf99;
    --err:#c93f30; --err-bg:rgba(201,63,48,.10); --err-row:rgba(201,63,48,.04);
    --warn:#8a5e05; --info:#2a63b8; --info-bg:rgba(42,99,184,.10);
    --gray:#83888f; --gray-bg:rgba(131,136,143,.12);
    --shadow-sm:         0 1px 3px rgba(0,0,0,.07);
    --shadow-md:         0 4px 16px rgba(0,0,0,.1);
}

/* Brand mode — cream/taupe flavor layered on the light palette; --acc
   stays the carrot-reporting orange (it's the accent everywhere now,
   not a brand-only exception). */
body[data-theme="brand"],
html[data-theme="brand"] body {
    --bg:               var(--carrot-cream);
    --panel:            #ffffff;
    --panel2:           #ffffff;
    --panel3:           #EFE8DD;
    --sub:              #ffffff;
    --line:             #D7D0C5;
    --line2:            var(--carrot-cream-line);
    --hi:               #3A3A3A;
    --tx:               #3A3A3A;
    --mut:              var(--carrot-warmgray);
    --dim:              var(--carrot-taupe);
    --faint:            var(--carrot-taupe);
    --acc:              #e05408;
    --acc2:             #c74a06;
    --err:              #B53A0E;
    --err-bg:           #fff5f5;
    --shadow-sm:        0 1px 3px rgba(122,114,105,.10);
    --shadow-md:        0 4px 16px rgba(122,114,105,.18);
}

body {
    background: var(--bg);
    color: var(--text);
}

/* ── 3. Layout ── */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-inline: 16px;
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
    z-index: 50;
}

/* Views fill .app-main — position: absolute relative to .app-main container */
.view {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    transition: opacity 0.2s, transform 0.2s;
}

/* ── 4. Header ── */

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-title {
    display: flex;
    flex-direction: column;
}

#header-context {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
}

#header-subtitle {
    font-size: 11px;
    color: var(--text-muted);
}

/* Back button — only visible in agent view */
.back-button {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.back-button:hover {
    background: var(--hover);
    color: var(--text);
}

body[data-view="agent"] .back-button {
    display: flex;
}

/* Theme toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
}

.theme-toggle:hover {
    background: var(--hover);
    color: var(--text);
}

body[data-theme="dark"]  .icon-sun,
html[data-theme="dark"]  .icon-sun  { display: none; }
body[data-theme="dark"]  .icon-moon,
html[data-theme="dark"]  .icon-moon { display: block; }
body[data-theme="light"] .icon-moon,
html[data-theme="light"] .icon-moon { display: none; }
body[data-theme="light"] .icon-sun,
html[data-theme="light"] .icon-sun  { display: block; }

/* Brand mode icon visibility — light-leaning, show sun */
body[data-theme="brand"] .icon-moon,
html[data-theme="brand"] .icon-moon { display: none; }
body[data-theme="brand"] .icon-sun,
html[data-theme="brand"] .icon-sun  { display: block; }

/* Brand carrot toggle button */
.brand-carrot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, outline 0.15s;
}
.brand-carrot svg { display: block; width: 20px; height: 20px; }
.brand-carrot:hover { background: var(--hover); }

/* Active brand-mode state — subtle ring around the carrot */
body[data-theme="brand"] .brand-carrot,
html[data-theme="brand"] body .brand-carrot {
    background: var(--hover);
    outline: 2px solid var(--acc);
    outline-offset: -2px;
}

.brand-carrot .carrot-body { fill: var(--acc); }
.brand-carrot .carrot-leaf { fill: var(--carrot-leaf); }

/* Dark-mode carrot override — body fills white, leaf brightens */
body[data-theme="dark"] .brand-carrot .carrot-body { fill: var(--hi); }
body[data-theme="dark"] .brand-carrot .carrot-leaf { fill: var(--carrot-leaf-dark); }

/* Brand-mode carrot stays orange (it's the brand mark) */
body[data-theme="brand"] .brand-carrot .carrot-body { fill: var(--acc); }
body[data-theme="brand"] .brand-carrot .carrot-leaf { fill: var(--carrot-leaf); }

/* ── Side Navigation ── */

.side-nav {
    display: flex;
    flex-direction: column;
    width: 200px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    transition: width 0.2s ease;
    overflow: hidden;
}

.side-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    color: var(--text-muted);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.side-nav-item:hover { background: var(--hover); color: var(--text); }

.side-nav-item.active {
    color: var(--text);
    border-left-color: var(--acc);
    background: var(--hover);
}

.side-nav-item svg { flex-shrink: 0; }

.side-nav-label { font-size: 14px; font-weight: 500; }

/* Collapsed: agent-view collapses sidebar to icon-only rail */
body[data-view="agent"] .side-nav { width: 56px; }
body[data-view="agent"] .side-nav-label { display: none; }
body[data-view="agent"] .side-nav-item { justify-content: center; padding: 14px 0; }

/* Mobile: collapse below 768px */
@media (max-width: 768px) {
    .side-nav { width: 56px; }
    .side-nav-label { display: none; }
    .side-nav-item { justify-content: center; padding: 14px 0; }
}

/* ── App Layout Shell ── */

.app-shell {
    display: flex;
    height: calc(100vh - 52px);
}

.app-main {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* User menu */
.user-menu {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 8px 4px 4px;
    color: var(--text-muted);
    transition: border-color 0.15s, background 0.15s;
}

.user-menu-btn:hover {
    background: var(--hover);
    border-color: var(--text-dim);
    color: var(--text);
}

.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    min-width: 200px;
    z-index: 300;
    overflow: hidden;
}

.user-dropdown[hidden] { display: none; }
.user-dropdown.show    { display: block; }

.dropdown-header {
    padding: 12px 14px;
}

.dropdown-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.dropdown-email {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
}

.dropdown-item {
    display: block;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-muted);
    transition: background 0.12s;
}

.dropdown-item:hover {
    background: var(--hover);
    color: var(--text);
}

.dropdown-logout {
    color: var(--error-text);
}

.dropdown-logout:hover {
    color: var(--error-text);
}

/* -- 5. View Transitions -- */

#home-view {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

body[data-view="thread"] #home-view {
    display: none;
}

#thread-view {
    display: flex;
    overflow: hidden;
}

#thread-view[hidden],
body[data-view="home"] #thread-view {
    display: none;
}

/* -- 6. Home View (conversation list) -- */

.home-view {
    padding: 24px 24px 40px;
    align-items: center;
}

.home-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    max-width: 640px;
    margin-bottom: 16px;
}

.home-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.home-new-btn {
    padding: 8px 14px;
    font-size: 13px;
    white-space: nowrap;
}

.home-search-wrap {
    width: 100%;
    max-width: 640px;
    margin-bottom: 20px;
}

.home-search {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

.home-search::placeholder { color: var(--text-dim); }
.home-search:focus { border-color: var(--text-dim); }

.home-sessions-list {
    width: 100%;
    max-width: 640px;
}

.home-empty {
    padding: 24px 8px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
}

.session-group-label {
    padding: 14px 4px 6px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.home-session-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    transition: background 0.12s, color 0.12s;
    position: relative;
}

.home-session-row:hover,
.home-session-row:focus-visible {
    background: var(--hover);
    color: var(--text);
    outline: none;
}

.home-session-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.home-session-time {
    font-size: 11px;
    color: var(--text-dim);
    flex-shrink: 0;
}

.home-session-row .session-delete {
    display: none;
    background: none;
    border: none;
    color: var(--text-dim);
    padding: 2px;
    border-radius: 3px;
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}

.home-session-row:hover .session-delete { display: block; }
.home-session-row .session-delete:hover { color: var(--error-text); }

/* -- 7. Thread Toolbar -- */

.thread-toolbar {
    display: flex;
    gap: 6px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.icon-text-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
    overflow: hidden;
}

.icon-text-btn:hover {
    background: var(--hover);
    color: var(--text);
    border-color: var(--text-dim);
}

/* -- 8. Thread View Layout -- */

.thread-view {
    display: flex;
    overflow: hidden;
}

/* -- 9. Routed Chip -- */

.routed-chip {
    display: inline-block;
    margin-right: 8px;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--acc-bg);
    color: var(--acc);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    vertical-align: middle;
}


/* ── 10. Chat Main ── */

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    position: relative;
}

.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── 11. Welcome State ── */

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 24px;
    flex: 1;
    gap: 10px;
}

.welcome-message h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.welcome-message p {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 480px;
    line-height: 1.6;
}

.example-queries {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 560px;
    margin-top: 8px;
}

.example-btn {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.example-btn:hover {
    background: var(--hover);
    border-color: var(--text-dim);
    color: var(--text);
}

/* ── 12. Messages ── */

.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: msgFadeIn 0.2s ease;
}

@keyframes msgFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.message.user      { align-self: flex-end; }
.message.assistant { align-self: flex-start; }

/* Agent attribution pill — shown above assistant bubbles in multi-agent mode */
.agent-attribution {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    padding: 2px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 4px;
    align-self: flex-start;
    letter-spacing: 0.01em;
}

.agent-attribution-avatar {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--active);
    font-size: 8px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    flex-shrink: 0;
}

.message-bubble {
    padding: 11px 15px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.65;
    word-wrap: break-word;
}

/* Hidden until the first streamed text chunk lands (T85 pattern): keeps the
   element's identity (no layout jump, no lost node) while a bare bubble
   would otherwise be a visible empty box under the activity line. */
.message-bubble.is-unfilled {
    display: none;
}

.message.user .message-bubble {
    background: var(--surface-elevated);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-right-radius: 3px;
}

[data-theme="dark"] .message.user .message-bubble {
    background: var(--panel3);
    border-color: var(--line2);
}

.message.assistant .message-bubble {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 3px;
    box-shadow: var(--shadow-sm);
}

.message-time {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 3px;
    padding-inline: 3px;
}

.message.user .message-time { text-align: right; }

/* @mention chips inside user messages */
.mention-chip {
    display: inline-block;
    padding: 1px 6px;
    background: var(--active);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-inline: 2px;
    vertical-align: middle;
}

/* Error bubble */
.error-bubble {
    background: var(--error-bg) !important;
    border-color: var(--error-text) !important;
    color: var(--error-text) !important;
}


/* ── 13. Markdown in messages ── */

.message.assistant .message-bubble h1,
.message.assistant .message-bubble h2,
.message.assistant .message-bubble h3,
.message.assistant .message-bubble h4,
.message.assistant .message-bubble h5,
.message.assistant .message-bubble h6 {
    margin-top: 12px;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text);
}

.message.assistant .message-bubble h1 { font-size: 16px; }
.message.assistant .message-bubble h2 { font-size: 15px; }
.message.assistant .message-bubble h3 { font-size: 14px; }
.message.assistant .message-bubble h4 { font-size: 13px; }
.message.assistant .message-bubble h5 { font-size: 12px; color: var(--text-muted); }
.message.assistant .message-bubble h6 { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.message.assistant .message-bubble p  { margin-bottom: 8px; }

.message.assistant .message-bubble ul,
.message.assistant .message-bubble ol {
    margin: 6px 0 8px 20px;
}

.message.assistant .message-bubble li { margin-bottom: 3px; }

.message.assistant .message-bubble strong { font-weight: 600; }

.message.assistant .message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
}

.message.assistant .message-bubble th,
.message.assistant .message-bubble td {
    padding: 6px 10px;
    border: 1px solid var(--border);
    text-align: left;
}

.message.assistant .message-bubble th {
    background: var(--surface-elevated);
    font-weight: 600;
    font-size: 12px;
    color: var(--text-muted);
}

.message.assistant .message-bubble code {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12.5px;
    font-family: ui-monospace, Menlo, Monaco, Consolas, monospace;
}

.message.assistant .message-bubble pre {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    overflow-x: auto;
    margin: 8px 0;
}

.message.assistant .message-bubble pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 12.5px;
    line-height: 1.55;
}

.message.assistant .message-bubble blockquote {
    border-left: 3px solid var(--text-dim);
    padding-left: 12px;
    color: var(--text-muted);
    margin: 8px 0;
}

/* ── 14. Loading / Streaming ── */

/* Loading bubble dots (used inside addLoadingBubble message wrapper) */
.loading-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.loading-dots span {
    width: 7px;
    height: 7px;
    background: var(--text-dim);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-6px); }
}

/* -- 15. (removed: @-mention picker no longer in UI) -- */

/* ── 16. Input Area ── */

.input-area {
    padding: 12px 24px 16px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
}

.input-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    gap: 4px;
    transition: border-color 0.15s;
}

.input-wrapper:focus-within {
    border-color: var(--text-dim);
}

.property-select {
    padding: 6px 8px;
    border: none;
    border-right: 1px solid var(--border);
    border-radius: 0;
    font-size: 12px;
    color: var(--text-muted);
    background: transparent;
    cursor: pointer;
    outline: none;
    flex-shrink: 0;
    max-width: 130px;
    font-family: inherit;
}

.property-select option {
    background: var(--surface-elevated);
    color: var(--text);
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    padding: 8px;
    max-height: 120px;
    line-height: 1.5;
    color: var(--text);
}

.chat-input::placeholder {
    color: var(--text-dim);
}

.send-btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--text);
    color: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s;
}

.send-btn:hover   { opacity: 0.85; }
.send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.input-hint {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-dim);
    padding-inline: 2px;
}

.active-agent-hint strong { color: var(--text-muted); }

/* ── 17. Message Actions ── */

.msg-actions {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: 4px;
    padding-inline: 3px;
    opacity: 0;
    transition: opacity 0.15s;
}

.message.assistant:hover .msg-actions { opacity: 1; }

.msg-action-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text-dim);
    padding: 3px 5px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 3px;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    line-height: 1;
}

.msg-action-btn:hover {
    color: var(--text);
    border-color: var(--border);
    background: var(--hover);
}

.msg-action-btn.active {
    color: var(--text);
    border-color: var(--text-dim);
    background: var(--active);
}

.msg-action-btn svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

/* Feedback comment box */
.feedback-comment-wrap {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: flex-start;
}

.feedback-comment-input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
    padding: 5px 8px;
    resize: none;
    outline: none;
    transition: border-color 0.15s;
    min-width: 180px;
}

.feedback-comment-input:focus { border-color: var(--text-dim); }

.feedback-send-btn {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--text);
    color: var(--bg);
    font-size: 12px;
    font-family: inherit;
    transition: opacity 0.15s;
    white-space: nowrap;
}

.feedback-send-btn:hover { opacity: 0.85; }

.feedback-char-counter {
    font-size: 11px;
    color: var(--text-dim);
    text-align: right;
    flex-basis: 100%;
    order: 1;
}

.feedback-char-counter-limit {
    color: var(--error-text);
    font-weight: 600;
}

/* ── 18. Followups ── */

.followups-container {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.followups-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 2px;
}

.followup-btn {
    display: inline-block;
    width: fit-content;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    line-height: 1.4;
}

.followup-btn:hover {
    background: var(--hover);
    border-color: var(--text-dim);
    color: var(--text);
}

/* ── 19. Sources Card ── */

.sources-card {
    margin-top: 8px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
}

.sources-header {
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sources-header-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    background: transparent;
    border: none;
    padding: 8px 0;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: var(--text-muted);
}
.sources-header-toggle:hover { color: var(--text); }
.sources-caret {
    display: inline-block;
    font-size: 0.7rem;
    color: var(--text-dim);
    transition: transform 0.15s ease;
    width: 10px;
}

.source-item-wrapper {
    border-bottom: 1px solid var(--border-muted);
    padding: 2px 0;
}

.source-item-wrapper:last-child { border-bottom: none; }

.source-summary {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 2px;
    color: var(--text-muted);
    font-size: 12px;
    font-family: inherit;
    text-align: left;
    border-radius: 3px;
    transition: background 0.12s;
}

.source-summary:hover { background: var(--hover); }

.source-caret {
    color: var(--text-dim);
    font-size: 10px;
    flex-shrink: 0;
    width: 10px;
}

.source-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
}

.source-property {
    font-weight: 500;
    color: var(--text);
}

.source-expanded {
    margin-left: 16px;
    margin-bottom: 6px;
}

.chunk-loading,
.chunk-error {
    padding: 8px;
    font-size: 11px;
    color: var(--text-dim);
    font-style: italic;
}

.chunk-error { color: var(--error-text); }

.chunk-excerpt {
    border-left: 2px solid var(--border);
    padding: 6px 10px;
    margin-bottom: 6px;
    background: var(--surface-elevated);
    border-radius: 0 3px 3px 0;
}

.chunk-meta {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.chunk-content {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
}

/* ── 20. Search Results in Sidebar ── */

.search-result-item {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    color: var(--text-muted);
    transition: background 0.12s;
    border-bottom: 1px solid var(--border-muted);
}

.search-result-item:last-child { border-bottom: none; }

.search-result-item:hover {
    background: var(--hover);
    color: var(--text);
}

.search-result-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result-snippet {
    font-size: 11px;
    color: var(--text-dim);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-no-results {
    padding: 16px;
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
}

/* ── 21. Modals ── */

.modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal[hidden] { display: none; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    cursor: pointer;
}

.modal-content {
    position: relative;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 380px;
    max-width: 92vw;
    box-shadow: var(--shadow-md);
    animation: modalIn 0.18s ease;
}

.modal-content-wide {
    width: 520px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.modal-body {
    padding: 14px 16px;
}

.modal-body-scroll {
    overflow-y: auto;
    max-height: 60vh;
}

.modal-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.modal-row:last-child { margin-bottom: 0; }

.modal-row label {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.modal-select {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

.modal-select:focus { border-color: var(--text-dim); }

/* Buttons in modals / global */
.primary-btn {
    padding: 8px 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--text);
    color: var(--bg);
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s;
}

.primary-btn:hover { opacity: 0.85; }

.secondary-btn {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.secondary-btn:hover {
    background: var(--hover);
    color: var(--text);
    border-color: var(--text-dim);
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 18px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}

.icon-btn:hover {
    color: var(--text);
    background: var(--hover);
}

/* ── 22. Share Modal ── */

.share-link-wrap {
    display: flex;
    gap: 8px;
    width: 100%;
}

.share-link-input {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
    outline: none;
    min-width: 0;
}

.share-existing-heading {
    margin-top: 12px;
    margin-bottom: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.share-existing-loading {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-dim);
}

.share-existing-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-top: 1px solid var(--border-muted);
}

.share-existing-info {
    flex: 1;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.share-revoke-btn {
    flex-shrink: 0;
    padding: 3px 10px;
    border: 1px solid var(--error-text);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--error-text);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.share-revoke-btn:hover {
    background: var(--error-text);
    color: var(--bg);
}

/* ── 23. Pinned Messages ── */

.pinned-item {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    background: var(--surface);
}

.pinned-item:last-child { margin-bottom: 0; }

.pinned-item-meta {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.pinned-session {
    font-weight: 600;
    color: var(--text-muted);
}

.pinned-item-content {
    font-size: 13px;
    color: var(--text);
    line-height: 1.55;
    max-height: 120px;
    overflow: hidden;
    position: relative;
}

.pinned-item-note {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

.pinned-item-go {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    text-decoration: underline;
    transition: color 0.15s;
    font-family: inherit;
}

.pinned-item-go:hover { color: var(--text); }

.pinned-loading,
.pinned-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
}

/* ── 24. Artifact Panel ── */

/* When panel is open, agent-view becomes a flex row */
.agent-view.artifact-panel-open .chat-main { flex: 0 1 55%; min-width: 0; }
.agent-view.artifact-panel-open #artifact-panel {
    display: flex;
    flex: 0 1 45%;
    min-width: 320px;
}
.agent-view.artifact-panel-open.artifact-panel-maximized .chat-main { display: none; }
.agent-view.artifact-panel-open.artifact-panel-maximized #artifact-panel { flex: 1 1 100%; }

#artifact-panel {
    position: static;
    display: none;
    flex-direction: column;
    background: var(--bg);
    border-left: 1px solid var(--border);
    overflow: hidden;
}

#artifact-panel[hidden] { display: none; }

.artifact-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.artifact-panel-title-wrap {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 1;
    min-width: 0;
}

.artifact-panel-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.artifact-panel-icon { font-size: 14px; flex-shrink: 0; }

.artifact-panel-type-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--active);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
    letter-spacing: 0.04em;
}

.artifact-panel-tabs {
    display: flex;
    gap: 2px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    padding: 2px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.artifact-panel-tab {
    padding: 4px 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.12s, color 0.12s;
}

.artifact-panel-tab:hover { color: var(--text); }

.artifact-panel-tab.active {
    background: var(--text);
    color: var(--bg);
}

.artifact-panel-tab:focus-visible {
    outline: 2px solid var(--text-dim);
    outline-offset: 1px;
}

.artifact-panel-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.artifact-panel-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.artifact-panel-btn:hover {
    background: var(--hover);
    color: var(--text);
    border-color: var(--text-dim);
}

.artifact-panel-btn:focus-visible {
    outline: 2px solid var(--text-dim);
    outline-offset: 1px;
}

.artifact-panel-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.artifact-panel-preview,
.artifact-panel-code-view {
    height: 100%;
    width: 100%;
    overflow: auto;
}

.artifact-panel-preview iframe,
.artifact-iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: white;
}

.artifact-panel-code-view pre {
    margin: 0;
    padding: 16px 18px;
    background: var(--surface-elevated);
    color: var(--text);
    font-family: ui-monospace, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    line-height: 1.55;
    white-space: pre;
    overflow: auto;
    height: 100%;
    box-sizing: border-box;
}

.artifact-panel-footer {
    padding: 6px 14px;
    border-top: 1px solid var(--border-muted);
    font-size: 11px;
    color: var(--text-dim);
    flex-shrink: 0;
}

/* Artifact chips in chat */
.artifact-chips-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 8px;
}

.artifact-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    max-width: 100%;
    text-align: left;
}

.artifact-chip:hover {
    background: var(--hover);
    border-color: var(--text-dim);
}

.artifact-chip:focus-visible {
    outline: 2px solid var(--text-dim);
    outline-offset: 2px;
}

.artifact-chip-icon { font-size: 14px; flex-shrink: 0; }

.artifact-chip-title {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.artifact-chip-type {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--active);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.artifact-chip-expired {
    opacity: 0.45;
    cursor: not-allowed;
}

.artifact-chip.active-in-panel {
    background: var(--active);
    border-color: var(--text-dim);
}

/* Artifact renderers */
.artifact-code-loading,
.artifact-error {
    padding: 24px 16px;
    text-align: center;
    font-size: 13px;
    color: var(--text-dim);
    font-style: italic;
}

.artifact-error { color: var(--error-text); }

.artifact-mermaid-source {
    font-size: 12px;
    color: var(--text-muted);
    padding: 12px 16px;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, Menlo, Monaco, Consolas, monospace;
    background: var(--surface-elevated);
    margin: 0;
}

.artifact-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.artifact-table th,
.artifact-table td {
    padding: 7px 12px;
    border: 1px solid var(--border);
    text-align: left;
    color: var(--text);
}

.artifact-table th {
    background: var(--surface-elevated);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    z-index: 1;
}

.artifact-table tbody tr:nth-child(even) { background: var(--surface); }
.artifact-table tbody tr:hover            { background: var(--hover); }

/* Mobile — artifact panel fullscreen overlay */
@media (max-width: 900px) {
    .agent-view.artifact-panel-open #artifact-panel {
        position: absolute;
        inset: 0;
        z-index: 200;
        flex: 1 1 100%;
        border-left: none;
        min-width: 0;
    }
    .agent-view.artifact-panel-open .chat-main { flex: 1 1 100%; }
}

/* ── 25. Toast Notifications ── */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    pointer-events: auto;
    animation: toastIn 0.22s ease;
    max-width: 320px;
    border: 1px solid var(--border);
}

.toast-info {
    background: var(--surface-elevated);
    color: var(--text);
}

.toast-success {
    background: var(--surface-elevated);
    color: var(--text);
    border-color: var(--text-dim);
}

.toast-error {
    background: var(--error-bg);
    color: var(--error-text);
    border-color: var(--error-text);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

/* ── 26. Scrollbars ── */

.chat-area::-webkit-scrollbar,
.sessions-list::-webkit-scrollbar,
.modal-body-scroll::-webkit-scrollbar,
.artifact-panel-preview::-webkit-scrollbar,
.artifact-panel-code-view::-webkit-scrollbar,
.chunk-content::-webkit-scrollbar {
    width: 5px;
}

.chat-area::-webkit-scrollbar-track,
.sessions-list::-webkit-scrollbar-track,
.modal-body-scroll::-webkit-scrollbar-track,
.artifact-panel-preview::-webkit-scrollbar-track,
.artifact-panel-code-view::-webkit-scrollbar-track,
.chunk-content::-webkit-scrollbar-track {
    background: transparent;
}

.chat-area::-webkit-scrollbar-thumb,
.sessions-list::-webkit-scrollbar-thumb,
.modal-body-scroll::-webkit-scrollbar-thumb,
.artifact-panel-preview::-webkit-scrollbar-thumb,
.artifact-panel-code-view::-webkit-scrollbar-thumb,
.chunk-content::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

/* ── 27. Login Page ──
   Carrotized 1c sign-in card (2026-07-10). Reads the real design tokens
   directly (:root light / .dark on <html>) — login.html carries the
   same pre-paint boot script as index.html/deadlines.html, so .dark is
   already resolved before first paint. */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    overflow: auto;
}

.login-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 48px 40px;
    text-align: center;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.35);
}

.login-logo {
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--acc);
}

.login-card h1 {
    font-size: 30px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--hi);
    margin-bottom: 6px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--mut);
    margin-bottom: 32px;
    display: block;
}

.ms-login-btn {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 44px;
    padding: 0 20px;
    background: var(--acc);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: filter 0.15s;
}

.ms-login-btn:hover {
    filter: brightness(1.08);
}

.ms-login-btn:focus-visible {
    outline: 2px solid var(--acc);
    outline-offset: 2px;
}

.login-footer {
    margin-top: 28px;
    font-size: 11px;
    color: var(--faint);
}

/* ── 28. Deadlines Dashboard ── */

.dl-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Inside deadlines page, app-shell fills remaining height; app-main is a flex column */
.dl-container .app-shell {
    flex: 1;
    min-height: 0;
}

.dl-container .app-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dl-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Filters bar */
.dl-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.dl-filters label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.dl-select {
    padding: 6px 10px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
}

.dl-select:hover,
.dl-select:focus {
    border-color: var(--text-dim);
}

.dl-filter-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
    flex-shrink: 0;
}

.dl-type-filters {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.dl-type-chip {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    transition: all 0.15s;
    white-space: nowrap;
}

.dl-type-chip.active {
    border-color: var(--text-dim);
    background: var(--active);
    color: var(--text);
}

.dl-type-chip:hover:not(.active) {
    background: var(--hover);
    color: var(--text);
}

.dl-status-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.dl-status-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--text);
}

/* Summary cards */
.dl-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.dl-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.dl-stat-card:hover {
    border-color: var(--text-dim);
    box-shadow: var(--shadow-sm);
}

.dl-stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
}

.dl-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dl-stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--error-text);
    animation: dlPulse 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes dlPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.5; transform: scale(0.8); }
}

/* By-property breakdown */
.dl-property-breakdown {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}

.dl-property-breakdown h3 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.dl-prop-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 13px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-muted);
}

.dl-prop-row:first-of-type { border-top: none; }

.dl-prop-count {
    font-weight: 600;
    color: var(--text);
    min-width: 28px;
    text-align: right;
}

/* Timeline */
.dl-timeline {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.dl-month-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dl-month-header {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.dl-month-count {
    background: var(--active);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

/* Deadline card */
.dl-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.15s, box-shadow 0.15s;
    position: relative;
}

.dl-card:hover {
    border-color: var(--text-dim);
    box-shadow: var(--shadow-sm);
}

.dl-card.dl-urgent {
    border-left: 3px solid var(--error-text);
    animation: dlCardPulse 2s ease-in-out infinite;
}

@keyframes dlCardPulse {
    0%, 100% { box-shadow: none; }
    50%       { box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.12); }
}

.dl-card-top {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.dl-property-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    min-width: 0;
}

/* Date type pills — retain semantic colors for usability */
.dl-type-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

/* Date-type pills — semantic color per lifecycle phase, brand-aligned */
.dl-pill-lease_start          { background: var(--ok-bg);   color: var(--ok);   }   /* start */
.dl-pill-renewal_notification { background: var(--acc-bg);  color: var(--acc);  }   /* action */
.dl-pill-lease_end             { background: var(--err-bg);  color: var(--err);  }   /* terminal */
.dl-pill-rent_escalation      { background: transparent; border: 1px solid var(--warn); color: var(--warn); }   /* recurring */
.dl-pill-insurance_renewal    { background: var(--info-bg); color: var(--info); }
.dl-pill-cam_reconciliation   { background: var(--gray-bg); color: var(--gray); }

.dl-days-badge {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    white-space: nowrap;
    flex-shrink: 0;
}

.dl-days-badge.dl-days-urgent { color: var(--error-text); }

.dl-card-date {
    font-size: 13px;
    color: var(--text-muted);
}

.dl-card-desc {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.5;
}

.dl-card-address {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    font-style: italic;
}

.dl-card-action {
    font-size: 13px;
    color: var(--text);
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--hover);
    border-left: 2px solid var(--acc);
    border-radius: 4px;
}

.dl-card-action-label {
    font-weight: 600;
    color: var(--acc);
}

.dl-card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 2px;
}

.dl-ask-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.dl-ask-btn:hover {
    background: var(--hover);
    border-color: var(--text-dim);
    color: var(--text);
}

/* Skeleton loader */
.dl-skeleton {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dl-skeleton-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dl-skel-line {
    height: 13px;
    border-radius: 4px;
    background: linear-gradient(
        90deg,
        var(--border) 25%,
        var(--surface-elevated) 50%,
        var(--border) 75%
    );
    background-size: 200% 100%;
    animation: dlShimmer 1.4s ease-in-out infinite;
}

@keyframes dlShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.dl-skel-line.w-40  { width: 40%; }
.dl-skel-line.w-60  { width: 60%; }
.dl-skel-line.w-80  { width: 80%; }
.dl-skel-line.w-100 { width: 100%; }

/* Empty state */
.dl-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 24px;
    gap: 12px;
    color: var(--text-muted);
}

.dl-empty-icon { opacity: 0.3; }

.dl-empty h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.dl-empty p {
    font-size: 13px;
    max-width: 420px;
    line-height: 1.6;
    color: var(--text-dim);
}

/* Deadlines header typography — match chat header context/subtitle spans */
.dl-container .header-title h1 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
    margin: 0;
}

.dl-container .header-title .header-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.2;
}

/* Deadlines empty state icon — explicit muted color */
.dl-empty-icon {
    color: var(--text-muted);
    opacity: 0.3;
}

/* ── 29. Responsive ── */

@media (max-width: 768px) {
    .agent-sidebar {
        width: 200px;
        min-width: 200px;
    }

    .message {
        max-width: 92%;
    }

    .example-queries {
        flex-direction: column;
    }

    .agent-list {
        grid-template-columns: 1fr;
    }

    .dl-body {
        padding: 12px 14px 32px;
    }

    .dl-filters {
        flex-direction: column;
        align-items: flex-start;
    }

    .dl-filter-sep { display: none; }

    .dl-summary {
        grid-template-columns: 1fr 1fr;
    }

    .dl-card-top { flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .agent-sidebar {
        display: none;
    }

    .roster-view {
        padding: 20px 16px 32px;
    }
}

/* ════════════════════════════════════════════════════════════════════
   ── 28. cx-* utility classes ──
   Generic building blocks matching the carrot-reporting "feel"
   (PipelineMonitor 1c redesign) in plain CSS — no Tailwind here.
   Available for any markup that wants the shared look.
   ════════════════════════════════════════════════════════════════════ */

.cx-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.cx-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel2);
    color: var(--tx);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.cx-btn:hover {
    background: var(--panel3);
    border-color: var(--faint);
}
.cx-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cx-btn-primary {
    background: var(--acc);
    border-color: var(--acc);
    color: #ffffff;
}
.cx-btn-primary:hover {
    background: var(--acc2);
    border-color: var(--acc2);
    color: #ffffff;
}

.cx-input {
    display: block;
    width: 100%;
    background: var(--sub);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--tx);
    font-family: inherit;
    font-size: 13px;
}
.cx-input::placeholder { color: var(--faint); }
.cx-input:focus {
    outline: 2px solid var(--acc);
    outline-offset: 1px;
    border-color: var(--acc);
}

.cx-rail {
    background: var(--panel);
    border-right: 1px solid var(--line);
}

.mono {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--gray-bg);
    color: var(--gray);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

/* ════════════════════════════════════════════════════════════════════
   ── 29. Activity line + steps log ──
   Multi-pass agent loop UI (SPEC §10). One line above the reply bubble,
   carrying the live cursor + elapsed time while a turn streams and a
   closed step-log disclosure once it has run tools — mirrors plexar-chat's
   shell.js (renderActivity/streamDoing) and app.css (.px-activity, .px-steps).
   app.js builds/updates these nodes; this file only styles them.
   ════════════════════════════════════════════════════════════════════ */

.activity {
    display: flex;
    flex-direction: column;
    align-items: flex-start;   /* chips and status keep their own width */
    gap: 4px;
    margin-bottom: 8px;
    font-size: 11px;
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--dim);
}

.stream-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.stream-caret {
    display: inline-block;
    width: 2px;
    height: 12px;
    background: var(--acc);
    animation: stream-caret-blink 1s step-end infinite;
}

@media (prefers-reduced-motion: reduce) {
    .stream-caret {
        animation: none;
        opacity: 1;
    }
}

@keyframes stream-caret-blink {
    0%, 49%   { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.stream-elapsed {
    min-width: 0;
}

.stream-doing {
    color: var(--dim);
}

/* Steps disclosure: closed by default, a real triangle drawn with borders
   in currentColor (no native marker), open + --warn when a tool call failed. */
.steps {
    margin-top: 2px;
}

.steps summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--dim);
    user-select: none;
}
.steps summary::-webkit-details-marker { display: none; }
.steps summary::before {
    content: "";
    flex: none;
    width: 5px;
    height: 5px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.15s;
}
.steps[open] summary::before {
    transform: rotate(45deg);
}
.steps.is-trouble summary {
    color: var(--warn);
}

.steps-body {
    margin-top: 4px;
    padding: 2px 0 2px 11px;
    border-left: 1px solid var(--line);
    max-height: 220px;
    overflow-y: auto;
}

.step {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 4px 0;
    cursor: pointer;
}
.step[data-ok="false"] {
    color: var(--err);
}

.step .args {
    color: var(--mut);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.step-preview {
    margin: 4px 0 6px;
    padding: 8px 10px;
    background: var(--sub);
    border: 1px solid var(--line2);
    border-radius: var(--radius-sm);
    font-size: 11.5px;
    color: var(--tx);
    white-space: pre-wrap;
    word-break: break-word;
}

.grep-hit {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 4px 8px;
    margin: 2px 0;
    background: var(--sub);
    border-radius: var(--radius-sm);
    font-size: 11.5px;
}

.grep-hit .grep-loc {
    color: var(--acc);
    font-weight: 600;
    flex-shrink: 0;
}

.grep-hit .grep-line {
    color: var(--mut);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
