/* CoPilot widget. The trigger is the header notification bell (.header-bell,
   which replaced the standalone logout icon); the old floating action button
   (.sw-fab) survives only as a fallback for pages with no bell. The panel/toasts
   are nudged below the header bar so they don't cover the bell — tune via
   --sw-top-offset. */
:root { --sw-top-offset: calc(var(--topbar-h) + 4px); }

/* ---- Header notification bell (the trigger) ---- */
.header-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 4px;
    margin: 0;
    cursor: pointer;
    color: inherit;            /* adopt the header bar's text colour */
    line-height: 0;
    border-radius: var(--r-8, 8px);
}
.header-bell:hover { background-color: var(--topbar-hover, rgba(255, 255, 255, 0.14)); }
.header-bell .lucide,
.header-bell svg,.header-bell i[data-lucide] { width: 22px; height: 22px; }
/* Issue-count pill, top-right of the bell. Colour reflects the most severe item. */
.header-bell-count {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    box-sizing: border-box;
    border-radius: var(--r-full, 999px);
    background: var(--danger);
    color: var(--on-brand);
    font-size: var(--fs-11, 10px);
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--header-bg, var(--accent));
}
.header-bell-count.warning { background: var(--warning); }
.header-bell-count.neutral { background: var(--text-subtle); }
.header-bell-count.hidden  { display: none; }
.header-bell.pulsing { animation: sw-bell-pulse 1.4s ease-in-out infinite; }
@keyframes sw-bell-pulse {
    0%, 100% { box-shadow: none; }
    50%      { box-shadow: 0 0 0 4px rgba(197, 48, 48, 0.22); }
}

/* ---- Fallback floating button (only when a page has no header bell) ---- */
.sw-fab {
    position: fixed;
    bottom: 22px;
    right: calc(22px + var(--scroll-lock-gap, 0px)); /* holds still while a modal locks the page (app.css .topbar) */
    width: 72px;
    height: 72px;
    border-radius: var(--r-full, 999px);
    background: var(--surface-2);
    border: 1.25px solid var(--border);
    cursor: pointer;
    box-shadow: var(--elev-3, 0 8px 24px rgba(16, 42, 94, 0.32), 0 1px 3px rgba(0,0,0,0.12));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 99990;
    transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.sw-fab:hover { transform: translateY(-1px); box-shadow: var(--elev-3, 0 12px 28px rgba(16, 42, 94, 0.24)); }
.sw-fab .sally-tile { --sally-h: 44px; pointer-events: none; }
.sw-fab .header-bell-count { top: -4px; right: -4px; box-shadow: 0 0 0 2px #fff; }
.sw-fab.pulsing { animation: sw-pulse 1.4s ease-in-out infinite; }
@keyframes sw-pulse {
    0%, 100% { box-shadow: 0 8px 24px rgba(197, 48, 48, 0.45); }
    50%      { box-shadow: 0 8px 32px rgba(197, 48, 48, 0.75), 0 0 0 8px rgba(197,48,48,0.10); }
}

.sw-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(16, 42, 94, 0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease);
    z-index: 99989;
}
.sw-backdrop.open { opacity: 1; pointer-events: auto; }

/* While the CoPilot panel is open, lift the global topbar above the panel
   (99991) + backdrop (99989) so the user avatar and its theme-toggle dropdown
   stay clickable and render over the panel — instead of the backdrop swallowing
   the click and closing the panel. 99992 keeps it BELOW the CoPilot modal/
   lightbox (99993/99995), which should still cover the header. Scoped to
   panel-open so ordinary app modals (z-index ≤ 11000, which must cover the
   header) are untouched. Set on <body> by openPanel()/closePanel().
   Only where the panel is an OVERLAY (under 1100px): docked, the bar ends where
   the panel begins (app.css "SALLY DOCKED"), so nothing needs lifting — and a
   lifted bar covered the floating rail's head, its logo and pin (owner,
   2026-10-22: "when the sally chat is open then it hides the top part of the
   sidebar"). The rail goes up with the bar for the same reason. */
@media (max-width: 1099px) {
    body.copilot-panel-open .topbar { z-index: 99992; }
}
@media (min-width: 769px) and (max-width: 1099px) {
    body.copilot-panel-open .sidebar { z-index: 99992; }
}

.sw-panel {
    position: fixed;
    top: var(--sw-top-offset);
    right: 0;
    width: 596px;
    max-width: 100vw;
    height: calc(var(--vh) - var(--sw-top-offset));
    background: var(--surface);
    /* A fine frame on the two sides that face the page (left + top) and a
       rounded corner where they meet — the right and bottom sit on the screen
       edge. Without it the panel was a hard rectangle held apart from the page
       only by a light-mode shadow, which vanishes on dark. */
    border: 1px solid var(--border-strong);
    border-right: 0;
    border-bottom: 0;
    border-top-left-radius: var(--radius-lg);
    transform: translateX(100%);
    transition: transform var(--dur-panel) var(--ease-glide), box-shadow var(--dur-panel) var(--ease-glide);
    display: flex;
    flex-direction: column;
    z-index: 99991;
}
/* The shadow only while open: parked off-screen, its blur would still reach
   into the right edge of the page. */
.sw-panel.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
/* DOCKED (the new layout, step 3 — owner, 2026-10-21): on a wide window Sally is
   an inspector BESIDE the page — no scrim, the page moves over to make room and
   stays usable (app.css "SALLY DOCKED" keeps the room); × and Esc close it.
   Narrower windows keep the overlay with its scrim, a phone the full screen. */
@media (min-width: 1100px) {
    .sw-panel { width: var(--sw-dock-w); }
    .sw-backdrop { display: none; }
}
.sw-panel-head .sw-close svg { pointer-events: none; }
.sw-panel-head {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sw-panel-head h3 { margin: 0; font-size: var(--fs-16, 1rem); color: var(--text-strong); flex: 1; display: flex; align-items: center; gap: 8px; }
/* Sally's tile beside the panel's name (app.css SALLY MARK) */
.sw-panel-head h3 .sally-tile { --sally-h: 24px; }
/* The close is a round button in the same family as the Chat / Today switch and
   the History · New chat capsule beside it: same height, fill and hairline. */
.sw-panel-head .sw-close {
    flex: none; box-sizing: border-box; cursor: pointer; color: var(--text-subtle);
    width: 30px; height: 30px; border-radius: var(--r-full, 999px); padding: 0;
    background: var(--surface-2); border: 1px solid var(--border-light);
    display: inline-flex; align-items: center; justify-content: center;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.sw-panel-head .sw-close:hover { background: var(--surface-3); color: var(--text-strong); }
.sw-panel-head .sw-close svg { stroke: currentColor; width: 15px; height: 15px; }

.sw-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
}
.sw-section { margin-bottom: 1rem; }
.sw-section-title {
    font: 600 var(--fs-12, 12px) var(--font-display);
    color: var(--text-muted);
    margin: 0.35rem 2px 0.45rem;
}

/* A section title with an action on the right (Notifications · N … Mark all read). */
.sw-section-title.sw-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sw-section-act {
    border: 0; background: transparent; padding: 0; cursor: pointer;
    font: inherit; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--link);
}
.sw-section-act:hover { text-decoration: underline; }

.sw-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-12, 12px);
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.55rem;
    transition: border-color var(--dur-fast) var(--ease);
}
/* Severity (critical / warning) is a .pill in the title (sevPill() in
   copilot-widget.js) and unread is the "N new" pill — never a coloured edge or tint. */
.sw-card .sw-card-title .pill { margin-right: 6px; }
.sw-card .sw-card-sku-row {
    margin-bottom: 3px;
}
.sw-card .sw-card-sku {
    font-family: var(--font-mono, "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace);
    font-size: var(--fs-12, 0.74rem);
    font-weight: 600;
    color: var(--link);
    text-decoration: none;
}
.sw-card a.sw-card-sku:hover { text-decoration: underline; }
.sw-card span.sw-card-sku { color: var(--text-muted); }
.sw-card .sw-card-sku code { font-family: inherit; }
.sw-card .sw-card-title {
    font-weight: 600;
    font-size: var(--fs-14, 0.9rem);
    color: var(--text-strong);
    margin-bottom: 4px;
}
.sw-card .sw-card-unread {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: var(--r-full, 999px);
    background: var(--danger);
    color: var(--on-brand);
    font-size: var(--fs-11, 0.62rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: middle;
}
.sw-card .sw-card-body {
    font-size: var(--fs-13, 0.82rem);
    color: var(--text-subtle);
    line-height: 1.4;
    margin-bottom: 0.5rem;
}
.sw-card .sw-card-meta {
    font-size: var(--fs-11, 0.7rem);
    color: var(--text-faint);
    margin-top: 4px;
}
.sw-card .sw-card-plan {
    display: flex;
    align-items: flex-start;
    gap: 5px;
    font-size: var(--fs-12, 0.76rem);
    color: var(--text-muted);
    padding: 0;
    margin-bottom: 0.5rem;
    line-height: 1.35;
}
.sw-card .sw-card-plan svg { flex: 0 0 auto; margin-top: 1px; }
.sw-card .sw-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.sw-actions .sw-btn {
    padding: 0.3rem 0.7rem;
    border-radius: var(--r-6, 6px);
    font-size: var(--fs-12, 0.74rem);
    font-weight: 600;
    border: 1.25px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
.sw-actions .sw-btn:hover { background: var(--surface-2); }
.sw-actions .sw-btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-end, var(--accent-strong, var(--accent)))); color: var(--on-brand); border-color: var(--accent); }
.sw-actions .sw-btn.danger  { color: var(--danger); }

/* Inline quick-actions + reply (chat from the widget) */
.sw-card .sw-card-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 2px; }
.sw-act {
    padding: 0.3rem 0.7rem;
    border-radius: var(--r-6, 6px);
    font-size: var(--fs-12, 0.74rem);
    font-weight: 600;
    border: 1.25px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}
.sw-act:hover { background: var(--surface-2); }
.sw-act:disabled { opacity: 0.5; cursor: default; }
.sw-act.green   { background: var(--success); color: var(--text-inverse); border-color: var(--success); }
.sw-act.green:hover { background: var(--success-strong); }
.sw-act.red     { color: var(--danger); }
.sw-act.primary { background: linear-gradient(135deg, var(--accent), var(--accent-end, var(--accent-strong, var(--accent)))); color: var(--on-brand); border-color: var(--accent); }
.sw-act.primary:hover { background: var(--accent-strong); }
.sw-open-link { color: var(--link); text-decoration: none; }
.sw-open-link:hover { text-decoration: underline; }
.sw-reply { display: flex; gap: 0.35rem; align-items: center; margin-top: 0.45rem; }
.sw-reply-input {
    flex: 1;
    padding: 0.4rem 0.55rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-6, 6px);
    font-size: var(--fs-13, 0.8rem);
    font-family: inherit;
    line-height: 1.4;
    resize: vertical;
}
.sw-clickable { cursor: pointer; }
.sw-card-title.sw-clickable:hover { color: var(--link); text-decoration: underline; }

/* ---- in-widget conversation thread ---- */
.sw-thread { flex: 1; min-height: 0; flex-direction: column; }   /* shown via JS as flex */
.sw-thread-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    background: var(--surface-2);
}
.sw-thread-back {
    background: none; border: none; cursor: pointer; color: var(--link);
    width: 32px; height: 32px; border-radius: var(--r-8, 7px); padding: 0;
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.sw-thread-back:hover { background: var(--surface-3); }
.sw-thread-back svg { stroke: var(--link); pointer-events: none; }
.sw-thread-title { flex: 1; min-width: 0; font-weight: 700; font-size: var(--fs-14, 0.88rem); color: var(--text-strong); line-height: 1.25; }
/* Identity: every thread header says WHO is on the other end — people (green)
   or CoPilot (violet). Rendered by /js/copilot-thread.js, the one thread
   component every surface mounts. */
.sw-thread-idblock { flex: 1; min-width: 0; }
.sw-thread-idblock .sw-thread-title { display: block; }
.sw-thread-with { font-size: var(--fs-11, 0.68rem); color: var(--text-muted); margin-top: 2px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; line-height: 1.3; }
.sw-thread-with .sw-with-role { color: var(--text-faint); font-weight: 400; }
.sw-who-chip { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; }
.sw-who-chip.person { color: var(--success); }
.sw-who-chip.bot { color: var(--violet); }
.sw-bubble-who.bot { color: var(--violet); display: inline-flex; align-items: center; gap: 3px; }
.sw-thread-err { font-size: var(--fs-12, 0.74rem); color: var(--danger); }
/* (The fixing page's task conversation sits in its own card beside the work —
   review-fixing.css .rv-chat-card — no longer a floating panel.) */
.sw-thread-close {
    background: none; border: none; cursor: pointer; color: var(--text-subtle);
    width: 32px; height: 32px; border-radius: var(--r-8, 8px); flex: 0 0 auto; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
}
.sw-thread-close:hover { background: var(--surface-3); }
.sw-thread-close svg { stroke: var(--text-subtle); pointer-events: none; }
/* In thread view the thread carries its own header (back + title + close), so
   hide the list's "CoPilot" header to avoid two stacked header bars. */
.sw-panel.thread-open .sw-panel-head { display: none; }
.sw-thread-msgs {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--chat-bg);   /* white in light — the inbox's conversation look */
}
.sw-bubble { max-width: 82%; padding: 7px 10px; border-radius: var(--r-12, 12px); font-size: var(--fs-13, 0.82rem); line-height: 1.4; }
.sw-bubble-text { white-space: pre-wrap; word-break: break-word; }
.sw-bubble-who { font-size: var(--fs-11, 0.66rem); font-weight: 700; opacity: 0.85; margin-bottom: 2px; }
.sw-bubble-time { font-size: var(--fs-11, 0.62rem); opacity: 0.85; margin-top: 3px; }
.sw-bubble.agent { align-self: flex-start; background: var(--chat-in-bg); border: 1px solid var(--chat-in-border); color: var(--chat-in-text); border-bottom-left-radius: var(--r-4, 4px); }
.sw-bubble.me    { align-self: flex-end;   background: var(--accent); color: var(--on-brand);     border-bottom-right-radius: var(--r-4, 4px); }
.sw-bubble.me .sw-bubble-time { color: var(--on-brand); }
.sw-sys { align-self: center; font-size: var(--fs-12, 0.72rem); color: var(--success); font-weight: 600; padding: 2px 0; }
/* An escalation reads as a status change, not a success. */
.sw-sys.warn { color: var(--warning); }
.sw-bubble a { color: inherit; text-decoration: underline; }
/* "CoPilot is thinking…" animated typing bubble */
.sw-bubble.sw-typing { padding: 9px 12px; }
.sw-typing-dots { display: inline-flex; gap: 4px; align-items: center; }
.sw-typing-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); display: inline-block; animation: sw-typing-bounce 1.2s infinite ease-in-out; }
.sw-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.sw-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sw-typing-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }
/* A freshly-arrived reply eases in, so it doesn't hard-cut from the typing dots. */
.sw-bubble.sw-bubble-new { animation: sw-bubble-in var(--dur-slow) var(--ease); }
@keyframes sw-bubble-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.sw-thread-foot { border-top: 1px solid var(--border-light); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.sw-thread-reply { display: flex; gap: 6px; align-items: center; position: relative; }
/* Teams-style @mention picker, anchored above the composer. Visibility is
   class-driven (.open) — never the hidden attribute, which loses to the
   display rule. */
.sw-mention-pop { position: absolute; bottom: calc(100% + 6px); left: 0; right: 0; display: none;
    flex-direction: column; gap: 1px; background: var(--surface); border: 1px solid var(--border-strong);
    border-radius: var(--r-12, 10px); box-shadow: var(--elev-3, 0 10px 28px rgba(0, 0, 0, 0.22)); padding: 4px; z-index: 6;
    max-height: 230px; overflow-y: auto; }
.sw-mention-pop.open { display: flex; }
.sw-mention-opt { display: flex; gap: 8px; align-items: center; padding: 6px 9px; border-radius: var(--r-8, 7px);
    cursor: pointer; font-size: var(--fs-13, 0.82rem); }
.sw-mention-opt.active, .sw-mention-opt:hover { background: var(--surface-2); }
.sw-mention-name { font-weight: 600; color: var(--text); }
.sw-mention-hint { margin-left: auto; font-size: var(--fs-11, 0.68rem); color: var(--text-faint); white-space: nowrap; }
/* An @mention inside a bubble. */
.sw-mention { font-weight: 700; color: var(--link); }
.sw-mention.bot { color: var(--violet); }
.sw-bubble.me .sw-mention, .sw-bubble.me .sw-mention.bot { color: inherit; text-decoration: underline; }

.sw-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--fs-14, 0.88rem);
}

/* Entity modal (per-watch / per-tray / per-sku detail) */
.sw-modal {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99993;
    padding: 1rem;
}
.sw-modal.open { display: flex; }
.sw-modal-card {
    background: var(--surface);
    border-radius: var(--r-16, 14px);
    box-shadow: var(--elev-4, 0 16px 48px rgba(16, 42, 94, 0.32));
    width: 560px;
    max-width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    outline: none;
    animation: sw-modal-in var(--dur) var(--ease);
}
@keyframes sw-modal-in {
    from { transform: scale(0.96); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}
.sw-modal-head {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sw-modal-title { margin: 0; font-size: var(--fs-16, 1rem); color: var(--text-strong); flex: 1; }
.sw-modal-close {
    background: none; border: none; cursor: pointer; color: var(--text-subtle);
    width: 32px; height: 32px; border-radius: var(--r-8, 8px);
    display: inline-flex; align-items: center; justify-content: center;
}
.sw-modal-close:hover { background: var(--surface-2); }
.sw-modal-close svg { pointer-events: none; }
.sw-modal-body {
    padding: 14px 16px;
    overflow-y: auto;
}
.sw-modal-body .sw-card { margin-bottom: 0.5rem; }

/* Inline entity badges (Phase 4): apply via JS to elements with
   data-copilot-watch-id, data-copilot-tray-id, data-copilot-sku. */
.sw-entity-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--warning);
    box-shadow: 0 0 0 2px #fff;
    margin-left: 6px;
    cursor: pointer;
    vertical-align: middle;
    transition: transform var(--dur-fast) var(--ease);
}
.sw-entity-badge:hover { transform: scale(1.35); }
.sw-entity-badge.critical { background: var(--danger); }
.sw-entity-badge.info     { background: var(--info); }

/* ════════════════════════════════════════════════════════════════════════════
   Unified panel: Chat tab + Today tab. The "Today" pane holds the existing work
   list + case-thread; the "Chat" pane is the free-form CoPilot Q&A (inventory
   + your work). Tokens only — themes light/dark like everything else.
   ════════════════════════════════════════════════════════════════════════════ */

/* Tab strip in the panel header (only present when the user can chat). */
.sw-tabs {
    display: inline-flex;
    gap: 2px;
    background: var(--surface-2);
    border: 1px solid var(--border-light);
    border-radius: var(--r-full, 999px);
    padding: 2px;
}
.sw-tab {
    border: none;
    background: none;
    cursor: pointer;
    font: 600 var(--fs-13, 0.8rem) var(--font-body, inherit);
    color: var(--text-subtle);
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 12px;
    border-radius: var(--r-full, 999px);
    line-height: 1.2;
}
.sw-tab:hover { color: var(--text-strong); }
.sw-tab.active, .sw-head-act[aria-expanded="true"] { background: var(--surface); color: var(--text-strong); box-shadow: var(--elev-1, 0 1px 2px rgba(16,42,94,.12)); }
/* History · New chat (owner, 2026-10-22: on the level of the Chat / Today switch):
   a capsule of two icon buttons with the switch's height, fill and hairline, as an
   Apple toolbar groups its items. Pressed while the history list is open (the
   rule above). Both work from Today too: they switch to Chat first. */
.sw-head-acts {
    display: inline-flex;
    flex: none;
    gap: 2px;
    padding: 2px;
    background: var(--surface-2);
    border: 1px solid var(--border-light);
    border-radius: var(--r-full, 999px);
}
.sw-head-act {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: var(--r-full, 999px);
    background: none;
    color: var(--text-subtle);
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.sw-head-act:hover:not([aria-expanded="true"]) { background: var(--surface-3); color: var(--text-strong); }
.sw-head-act svg { width: 15px; height: 15px; pointer-events: none; }
:is(.sw-tab, .sw-head-act, .sw-panel-head .sw-close):focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Panes fill the panel body below the header. Visibility is toggled in JS. */
.sw-pane { flex: 1; min-height: 0; flex-direction: column; }
.sw-pane-today { display: flex; }      /* default-visible until JS sets the tab */
.sw-pane-chat  { display: none; }

/* ---- Chat pane ---- */
/* the frame the history list drops into, just under the head */
.sw-pane-chat { position: relative; }

.sw-chat-thread {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    max-width: 100%;
    gap: 16px;
}
/* Restoring a chat after a page nav rebuilds the whole thread at once and snaps it
   to the bottom; fade it in so there's no empty-then-suddenly-there blip. */
@keyframes sw-chat-restore-in { from { opacity: 0; } to { opacity: 1; } }
.sw-chat-thread.sw-restoring { animation: sw-chat-restore-in var(--dur) var(--ease) both; }
/* The Chat tab reuses the shared .chat/.msg/.bubble vocab from app.css, which is
   tuned for the wide 860px full-page chat: bubbles stay content-width and the
   column is capped + centered. In the ~596px sidebar that leaves dead space, so
   scope two overrides to the widget — drop the 860px cap and let each bubble
   stretch to fill its row. Avatars + the alternating me/agent tint stay. */
/* app.css's .chat sets `margin:0 auto` + `max-width:860px` to centre the wide
   full-page chat. As a flex item in the panel's column, those auto side-margins
   DEFEAT align-items:stretch — the thread shrinks to its content and centres,
   so short messages cluster in the middle. Zero the margins + cap so the thread
   fills the panel; then let each bubble grow to use that width. */
.sw-chat-thread.chat { max-width: none; margin: 0; }
/* flex/min-width: let each bubble grow to use the panel width.
   white-space:pre-wrap: preserve the line breaks + whitespace the user typed and
   the model returned — the default white-space:normal collapses every newline to
   a space, flattening the structure. overflow-wrap keeps long unbroken tokens
   (URLs/SKUs) from forcing the bubble wider than the panel. */
.sw-chat-thread .bubble { flex: 1 1 auto; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.sw-chat-hint { margin: 4px 2px; }
.sw-chat-hint h3 { margin: 0; font: 700 var(--fs-20, 20px) var(--font-display); letter-spacing: -.02em; color: var(--text-strong); }
.sw-chat-hint p { margin: 6px 0 0; color: var(--muted); font-size: var(--fs-13, 13px); line-height: 1.45; }
.sw-chat-actions {
    margin-top: 8px; padding-top: 6px;
    border-top: 1px dashed var(--border-light);
    font-size: var(--fs-12, 0.74rem); color: var(--text-subtle);
}

.sw-chat-form {
    margin: 0;
    padding: 10px 12px;
    border-top: 1px solid var(--border-light);
    background: var(--surface);
    flex: 0 0 auto;
}
/* The composer box itself is Sally's box (app.css .composer.sally-compose — the dashboard
   widget's too). Sally's follow-ups sit under her answer, in line with the bubble. */
.sw-chat-thread .sally-follow { margin: -4px 0 6px 40px; }
.sw-chat-thread .sally-follow > .sally-chip { min-height: 30px; padding: 4px 12px; font-size: var(--fs-13, 13px); }

/* ---- Chat history dropdown ---- */
.sw-chat-sessions {
    position: absolute;
    top: 4px;
    left: 12px;
    right: 12px;
    max-height: 60vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-12, 12px);
    box-shadow: var(--elev-4, 0 16px 40px rgba(16, 42, 94, 0.22));
    padding: 6px;
    display: none;
    z-index: 6;
}
.sw-chat-sessions.open { display: block; }
.sw-sess { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-8, 8px); cursor: pointer; }
.sw-sess:hover { background: var(--surface-2); }
.sw-sess-main { flex: 1; min-width: 0; }
.sw-sess-title { font-size: var(--fs-13, 0.84rem); color: var(--text-strong); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sw-sess-meta { font-size: var(--fs-11, 0.7rem); color: var(--text-faint); margin-top: 2px; }
.sw-sess-del { background: none; border: none; cursor: pointer; color: var(--text-faint); width: 28px; height: 28px; border-radius: var(--r-8, 7px); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.sw-sess-del:hover { background: var(--surface-3); color: var(--danger); }
.sw-sess-del svg,.sw-sess-del i[data-lucide] { width: 15px; height: 15px; pointer-events: none; }
.sw-sess-empty { padding: 16px; text-align: center; color: var(--text-muted); font-size: var(--fs-13, 0.84rem); }

/* THE FLOATING INSPECTOR (owner, 2026-10-22: "the sally style is not yet done" —
   the approved mock): on a computer the panel is a rounded glass card
   --rail-inset in from the window's edges, the rail's mirror on the right. Docked
   (≥1100px) it runs from the top of the window beside the shortened top bar;
   as an overlay it starts under the bar. The blur sits on the panel itself: its
   slide transform already makes it the frame of anything fixed inside it. A
   phone keeps the full-screen sheet (mobile.css). */
@media (min-width: 769px) {
    .sw-panel {
        top: calc(var(--topbar-h) + var(--rail-inset)); right: var(--rail-inset); bottom: var(--rail-inset); height: auto;
        border: 1px solid var(--glass-line); border-radius: var(--r-16, 16px); overflow: hidden;
        background: color-mix(in srgb, var(--surface) 90%, transparent);
        -webkit-backdrop-filter: saturate(1.6) blur(30px); backdrop-filter: saturate(1.6) blur(30px);
        transform: translateX(calc(100% + 2 * var(--rail-inset)));
    }
    .sw-panel.open { transform: none; box-shadow: var(--shadow-lg); }
    /* Reduce transparency: the inspector is solid (app.css REDUCE TRANSPARENCY) */
    @media (prefers-reduced-transparency: reduce) {
        .sw-panel { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
    }
    .sw-panel-head { padding: 12px 10px 10px 14px; border-bottom: 0; }
    .sw-panel-head h3 .sally-tile { --sally-h: 28px; }
    .sw-chat-form { padding: 8px 12px 6px; border-top: 0; background: transparent; }
    .sw-panel .sw-foot { display: block; }
    /* the mock's one-line box: grows as you type (autoGrow), Send inside on the right */
    .sw-panel .sw-chat-form .composer-input { min-height: 44px; padding: 11px 84px 11px 14px; }   /* the mic + the round send */
    .sw-list { padding: 4px 12px 12px; }
}
@media (min-width: 1100px) {
    .sw-panel { top: var(--rail-inset); }
}
/* The head: Sally's tile, her name over a muted line, the Chat / Today switch
   and a round close — as in the mock. */
.sw-head-t { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.sw-head-t b { font: 600 var(--fs-15, 15px) var(--font-display); color: var(--text-strong); }
.sw-head-t small { font-size: var(--fs-12, 11.5px); font-weight: 400; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sw-panel-head h3 { min-width: 0; }
.sw-panel-head .sw-tabs { flex: none; }
/* Sally's name, then the switch, the History · New chat capsule and the close in
   one row. A narrow panel (the 380px dock, a phone) has no room for the muted
   line under the name; it leaves rather than ending in "…". */
.sw-panel-head { gap: 8px; container-type: inline-size; }
@container (max-width: 370px) { .sw-head-t small { display: none; } }
.sw-foot { display: none; margin: 0 0 10px; text-align: center; font-size: var(--fs-12, 11.5px); color: var(--muted); }
/* The empty chat's Suggestions (the mock): a group title over one rounded list of
   rows — an icon, the question, a chevron. A row asks its question. */
.sw-sugg-h { margin: 16px 2px 6px; font: 600 var(--fs-12, 12px) var(--font-display); color: var(--muted); }
.sw-sugg { border: 1px solid var(--border); border-radius: var(--r-12, 12px); background: var(--surface); overflow: hidden; }
.sw-sugg-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px; box-sizing: border-box; border: 0; border-bottom: 1px solid var(--border-light); background: transparent; color: var(--text); font: 500 var(--fs-14, 13.5px) var(--font-body); text-align: left; cursor: pointer; transition: background-color var(--dur-fast) var(--ease); }
.sw-sugg-row:last-child { border-bottom: 0; }
.sw-sugg-row:hover { background: var(--surface-2); }
.sw-sugg-row svg, .sw-sugg-row i[data-lucide] { width: 17px; height: 17px; flex: none; color: var(--accent); }
.sw-sugg-row span { flex: 1; min-width: 0; }
.sw-sugg-row .sw-sugg-go, .sw-sugg-row svg.lucide-chevron-right { width: 14px; height: 14px; color: var(--muted); }
