:root {
    --bg:          #000000;
    --composer:    #141210;
	--sidebar:     #0f0e0d;
    --surface:     #1e1d1c;
    --badge:       #4e4c4b;
    --bubble-a:    #2f2d2b;
    --bubble-u:    #0a84ff;
    --text:        #ffffff;
    --text-2:      #9d9a98;
    --text-3:      #686462;
    --text-beige:  #bb9281;   /* user prompt line in the session preview */
    --border:      #2f2d2bbb;
    --border-a:    #ffffff11;
    --accent:      #389cff;
    --user-orange: #bd522e;
    --claude-orange: #d97757;
    --selection:      #f04400;
    --danger:      #f00c00;
    /* RGB triplets (companions to the hex vars above) for rgba(var(--x-rgb), .N).
       Keep these in sync with the hex values when they change. */
    --user-orange-rgb:   189, 82, 46;   /* #bd522e */
    --claude-orange-rgb: 217, 119, 87;  /* #d97757 */
    --danger-rgb:        255, 12, 0;    /* #f00c00 */
    --alert-orange:      #ff9f0a;       /* status "alerta" / selection highlight */
    --alert-orange-rgb:  255, 159, 10;  /* #ff9f0a */
    --search-purp:       #76268f;       /* search accent: focus border, result icon, term highlight */
    --search-purp-rgb:   118, 38, 143;  /* #76268f */
	--search-pink: #c200ff;
    --radius-bub:  18px;

    --font-sans: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

/* Custom scrollbars: transparent rail/track, #48484f thumb, 5px. */
* {
    scrollbar-width: thin;                  /* Firefox */
    scrollbar-color: #48484f transparent;   /* thumb, track */
}
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #48484f; border-radius: 5px; }
::-webkit-scrollbar-corner { background: transparent; }

/* Text-selection highlight, every device/engine: a semitransparent tint of the
   alert orange so selected text stays legible over any background (text colour is
   left untouched). ::selection and ::-moz-selection MUST be separate rules — one
   unknown selector would invalidate the whole group. */
::selection      { background: var(--selection); color:var(--text); }
::-moz-selection { background: var(--selection); color:var(--text); }
input::selection,      textarea::selection      { background: var(--selection); color:var(--text); }
input::-moz-selection, textarea::-moz-selection { background: var(--selection); color:var(--text); }

html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text); font-weight: 300;
    font-family: var(--font-sans);
    /* Fill the FULL screen, including the strip under the home indicator, so the
       composer (bottom of the flex column) paints to the physical bottom edge and
       its env(safe-area-inset-bottom) padding clears the home indicator. iOS PWA
       quirk: a bare dynamic unit recomputes wrong on keyboard focus/blur (black
       --bg gap that only heals on rotation). height:100vh + min-height:100vh give a
       stable floor; min-height:100dvh refines it where supported — together they
       survive the focus/blur recompute. */
    height: 100vh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    /* iOS/WebKit auto-inflates font size per text block by its width, so wide
       table columns render larger than narrow ones. Pin it to 100% to keep all
       columns (and all text) at their authored size. */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
	font-size: 17px;
}

body {
    display: flex;
    flex-direction: column;
}

/* Paint the top safe-area (status bar / dynamic island) with the header color. */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-top);
    background: var(--surface);
    z-index: 100;
    pointer-events: none;
}
a {
	color:#e8693e;
}
/* ── Two-column shell (sidebar + main) ─────────────────────── */
#app {
    /* Anchor the shell to the LAYOUT viewport (position:fixed → initial containing
       block), not to a dynamic height unit. On iOS PWA, 100dvh/100% recompute on
       keyboard focus/blur and leave a black --bg strip under the composer (it only
       "heals" on rotation, which forces a correct recompute). A fixed inset:0 box
       stays pinned to the physical screen edges through focus/blur, so the composer
       always reaches the bottom and its env() padding clears the home indicator. */
    position: fixed;
    inset: 0;
    display: flex;
    flex: 1;
    min-height: 0;          /* let panes own their scroll */
    transition: opacity .15s ease;
	height:100dvh;
}
/* Task 12: a floating options menu (⋮) is open over the view → dim the content
   behind it. The menus are siblings of #app, so they stay fully opaque. */
#app.view-dimmed {
	/*opacity: .35;*/
}
#app.view-dimmed::before {
	content:'';
	position: absolute; top:0; left:0; width: 100%; height: 100%; z-index: 5;
	background: rgba(0, 0, 0, .8);
	backdrop-filter: blur(1px);
}
#sidebar {
    display: flex;
    flex-direction: column;
	width:25vw;
    max-width: 460px;
    flex-shrink: 0;
    min-height: 0;
    border-right: 1px solid var(--border);
    background: var(--sidebar);
}
#sidebar[hidden] { display: none; }
/* The desktop-only push-enable card (#push-card) reuses the .update-card visual
   (see task 18) — icon left, title + sub right, whole card clickable. */
#sidebar-view {
    flex: 1;
    min-height: 0;
    /* Column so the list scrolls and the (optional) toolbar pins to the bottom.
       The list owns the scroll now, so this stays clipped. */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;   /* anchors the pull-to-refresh indicator (task 7) */
}
#main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 0;
    position: relative;   /* positioning context for the floating scroll-to-bottom button */
}

/* Floating "scroll to bottom" button: centered in the chat, just above the
   composer/turn-bar (its `bottom` is set in JS to clear them). Shown only when
   the user is >100vh above the bottom. The [hidden] rule is required because the
   author `display:flex` would otherwise override the UA `[hidden]{display:none}`. */
#scroll-bottom {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 84px;
    z-index: 20;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #fafaff;
    color: #000000;
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.65);
    opacity: 1;
    visibility: visible;
    transition: opacity .15s ease, visibility .15s ease;
}
/* Fade in/out instead of an instant show/hide. The element is position:absolute,
   so keeping it laid out (display:flex) while hidden costs no layout — opacity +
   visibility do the hiding, and visibility's delayed switch lets the fade play. */
#scroll-bottom[hidden] {
    display: flex;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
/* Scroll-end button states (task: autoscroll + status beacon). Processing →
   claude-orange with a spinning black sunburst; awaiting a user interaction →
   blue with a (static) sunburst. */
#scroll-bottom.state-processing { background: var(--claude-orange); color: #000000; }
#scroll-bottom.state-awaiting   { background: var(--user-orange); color: #ffffff; }
/* Search-nav: jump to the next matching turn (hold = last). */
#scroll-bottom.state-search     { background: var(--search-purp); color: #ffffff; }
#scroll-bottom .sunburst { display: inline-flex; color: inherit; }
#scroll-bottom .sunburst svg { display: block; width: 24px; height: 24px; transform-origin: center; }
#scroll-bottom .sunburst.spin svg { animation: sb-spin 1.4s linear infinite; }

/* Mobile: one pane at a time, chosen by #app.show-sidebar / .show-main */
@media (max-width: 899px) {
    #sidebar { width: 100%; max-width: none; border-right: 0; }
    #app.show-sidebar > #main { display: none; }
    #app.show-main > #sidebar { display: none; }

    /* Hide the chat scrollbar on mobile (it still scrolls) — same trick as the
       composer textarea. */
    #view { scrollbar-width: none; -ms-overflow-style: none; }
    #view::-webkit-scrollbar { width: 0; height: 0; display: none; }
}

/* Desktop: both panes; no back button. The bars span full width while their
   content aligns to the same 980px column as #chat-col (via symmetric padding),
   so the scrollbar can stay at the main's edge. */
@media (min-width: 900px) {
	body{font-size: 14px;}
    #back-btn { display: none; }
    /* Desktop: the user avatar lives only in the main header (top-right, chat &
       empty views); hide the sidebar copy. On mobile both stay so it's persistent
       per single-pane view. */
    #user-btn { display: none; }
    #header {
        padding-left: max(12px, env(safe-area-inset-left), calc((100% - 980px) / 2));
        padding-right: max(12px, env(safe-area-inset-right), calc((100% - 980px) / 2));
    }
}

/* Header */
#header, #sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: env(safe-area-inset-top) 12px 8px 12px;
    padding-top: calc(env(safe-area-inset-top) + 8px);
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
/* Pull the leftmost titlebar button tight to the edge (offset the 12px padding). */
#header > button:first-child,
#sidebar-header > button:first-child { margin-left: -12px; }

#header h1, #sidebar-header h1 {
    font-size: 17px;
    font-weight: 600;
    margin: 0;
    line-height: 36px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Sidebar title + a small context sublabel below it (project | subject). The box
   owns the row's flex slot; the h1 tightens its line-height so two lines fit. */
.sidebar-titlebox {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
#sidebar-header .sidebar-titlebox h1 {
    flex: 0 0 auto;
    line-height: 1.25;
}
.sidebar-sublabel {
    font-size: 12px;
    color: var(--text-2);   /* light gray */
    line-height: 1.25;
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-sublabel:empty { display: none; }   /* no context → don't reserve a line */

button.ic {
    background: transparent;
    border: 0;
    color: var(--text);
    font-size: 24px;
    line-height: 1;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 8px;
    min-width: 34px;
	font-weight: bold;
}
button.ic:active { background: var(--border); }

/* Task 6: circular user avatar (1st initial) that opens the user menu. */
button.ic.user-avatar {
    padding: 0; margin: 2px;
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 50%;
    background: var(--user-orange);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}
button.ic.user-avatar:active { background: color-mix(in srgb, var(--user-orange) 78%, #000); }
/* The author `display:inline-flex` above would override the UA [hidden] rule, so
   the avatar wouldn't hide on the login screen / when auth is disabled. */
button.ic.user-avatar[hidden] { display: none; }

/* Header "⋮" floating menus (main + sidebar) + user menu */
#menu, #sidebar-menu, #user-menu, #model-menu {
    position: fixed;
    z-index: 50;
    min-width: 210px;
    max-width: calc(100vw - 24px);
    padding: 6px;
    /* A touch lighter than --surface so the floating menu stays distinct from
       the dimmed (opacity .35) view behind it. */
    background: #26262a;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}
#menu[hidden], #sidebar-menu[hidden], #user-menu[hidden], #model-menu[hidden] { display: none; }
/* Model picker (task 1B): two-line items, so allow more width + wrapping. */
#model-menu { min-width: 280px; max-width: min(360px, calc(100vw - 24px)); }
#model-menu .menu-item { white-space: normal; align-items: flex-start; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: 0;
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15px;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
}
.menu-item:active { background: var(--border); }
.menu-item:disabled { color: var(--text-2); cursor: default; }
.menu-item.danger { color: var(--danger); }
.menu-item .check {
    flex-shrink: 0;
    width: 16px;
    color: var(--user-orange);
}
.menu-item .mi-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.menu-item .label {
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Second line (e.g. model version + tagline) in the model picker. */
.menu-item .mi-sub {
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.3;
    color: var(--text-2);
    white-space: normal;
}
.menu-sep {
    height: 1px;
    margin: 4px 6px;
    background: var(--border);
}

/* Main view: full-width scroll region (scrollbar hugs the main's edge). */
#view {
    flex: 1;
    min-height: 0;   /* allow the scroll area to shrink so the composer stays put */
    overflow-y: auto;
    overscroll-behavior-y: contain;   /* don't chain overscroll to the page (task 7) */
    -webkit-overflow-scrolling: touch;
    padding: 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
}
/* The chat content lives in a centered container; the scroll stays on #view. */
#chat-col {
    width: 100%;
    max-width: 980px;
    margin-left: auto;
    margin-right: auto;
}
/* Live date divider: a sticky "day" pill inserted when the calendar day rolls
   over between consecutive root bubbles (black pill, white, smaller font). */
.chat-day-divider {
    position: sticky;
    top: 0;
    z-index: 5;
    width: fit-content;
    margin: 10px auto;
    padding: 4px 14px;
    background: var(--sidebar);
    color: #fff;
    font-size: 12px;
    line-height: 1.5;
    border-radius: 999px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

/* Sessions list */
/* Action bar pinned to the BOTTOM of the sidebar pane (only shown in select
   mode). Without the [hidden] rule the author `display:flex` would override the
   UA `[hidden]{display:none}` and reserve an empty strip at the top. */
.sessions-toolbar {
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.sessions-toolbar[hidden] { display: none; }

/* The scrolling list fills the space above the toolbar. */
.sessions-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;   /* don't chain overscroll to the page (task 7) */
    -webkit-overflow-scrolling: touch;
    padding-left: env(safe-area-inset-left);
}

/* Task 7 — elastic pull-to-refresh indicator (app sunburst). Fixed at the pulled
   edge of the scroll host; the scroller itself translates for the rubber-band
   feel while this fades/rotates in. Spins (sb-spin) while the refresh runs. */
.pull-indicator {
    position: absolute;
    left: 50%;
    top: 10px;
    transform: translateX(-50%);
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    color: #fff;
    transition: opacity .15s ease;
}
.pull-indicator.at-bottom { top: auto; bottom: 10px; }
.pull-indicator .sunburst { display: inline-flex; color: inherit; }
.pull-indicator .sunburst svg { display: block; width: 26px; height: 26px; transform-origin: center; }

/* Desktop refresh button: mobile uses the elastic pull gesture, so hide it there. */
.refresh-btn { display: none; }
@media (min-width: 900px) {
    .refresh-btn:not([hidden]) { display: inline-flex; align-items: center; }
}

/* Task 18 — "new SDK version" card pinned at the bottom of the sidebar lists.
   Leaf icon (eco) on the left; new version + "Clique para instalar" on the right. */
.update-card {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    border: 0;
    border-top: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    padding: 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.update-card[hidden] { display: none; }
.update-card:hover { background: var(--bubble-a, #26262a); }
.update-card .uc-icon { flex-shrink: 0; font-size: 28px; color: var(--user-orange); }
.update-card .uc-body { min-width: 0; }
.update-card .uc-title { font-weight: 600; font-size: 14px; line-height: 1.2; }
.update-card .uc-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.update-card.installing { opacity: .7; pointer-events: none; }
.update-card.installing .uc-icon { animation: uc-flip 1.4s ease-in-out infinite; }
/* Horizontal flip (rotate around the vertical axis) while the SDK update installs,
   instead of a flat spin. */
@keyframes uc-flip { to { transform: rotateY(360deg); } }
/* Installed & awaiting a manual restart — green leaf, still clickable. */
.update-card.installed .uc-icon { color: #49975a; }
/* Non-actionable "a new major exists, update manually" note (option 1). */
.update-card.warn { cursor: default; }
.update-card.warn:hover { background: var(--surface); }
.update-card.warn .uc-icon { color: var(--text-2); }
/* Right-side "open changelog" button. margin-left:auto pins it to the far right;
   it carries its own hit area + hover so it reads as a distinct control inside the
   card (the rest of which installs/restarts). */
.update-card .uc-changelog {
    margin-left: auto;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text-2);
    cursor: pointer;
}
.update-card .uc-changelog:hover { background: var(--bubble-a); color: var(--text); }
.update-card .uc-changelog .material-symbols-outlined { font-size: 20px; line-height: 1; }
.toolbar-btn {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 14px;
    font-family: var(--font-sans);
    cursor: pointer;
}
.toolbar-btn:active { background: var(--bubble-a); }
.toolbar-btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.toolbar-btn:disabled { opacity: 0.4; }

.session-card {
    background: var(--composer);
    padding: 12px 6px 12px 14px;
    cursor: pointer;
    position: relative;   /* positioning context for the pin dot */
    /* Continuous list: no radius, no gaps — items are separated by a soft
       divider only. */
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: flex-start;
    /* Long-press enters selection mode — don't let the hold highlight text or
       trigger the iOS copy/define callout. */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* Top-right "pin to top" toggle. Unchecked: black fill + soft border.
   Checked: solid white circle + white border. The padding is the tap area. */
.pin-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    margin: 0;
    padding: 6px;
    background: transparent;
    border: 0;
    line-height: 0;
    cursor: pointer;
}
.pin-dot::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    box-sizing: border-box;
    border: 1.5px solid var(--border);
    background: var(--bg);
}
.pin-dot.pinned::before {
    border-color: #fff;
    background: #fff;
}
/* While selecting, the checkbox owns the row — hide the pin. */
.sessions-list.select-mode .pin-dot { display: none; }
.session-card .card-body { flex: 1; min-width: 0; }
.session-card .card-check {
    display: none;
    font-size: 22px;
    line-height: 30px;   /* match the icon's height so the check sits in its place */
    color: var(--user-orange);
    flex-shrink: 0;
    /* Same footprint as the leading icon (30px) so toggling select-mode doesn't
       shift the card body sideways; centered so ☐/☑ glyph widths don't either. */
    width: 30px;
    text-align: center;
}
.sessions-list.select-mode .session-card .card-check { display: block; }
/* In selection mode the checkbox TAKES THE PLACE of the leading icon (session
   wand / project tile / subject glyph) — hide the icon so the row doesn't gain an
   extra element. The non-selectable "Sem assunto" bucket has no checkbox, so it
   keeps its icon. */
.sessions-list.select-mode .session-card .session-ic,
.sessions-list.select-mode .session-card .card-icon,
.sessions-list.select-mode .subject-card:not(.subject-bucket) .subject-ic { display: none; }
/* Square texticon avatar (projects list): --user-orange tile, black initial. */
.session-card .card-icon {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--user-orange);
    color: #000;
    font-weight: 800;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
}
.session-card .session-ic { color: var(--claude-orange); font-size: 30px; line-height: 1; flex-shrink: 0; font-variation-settings: 'FILL' 0, 'wght' 200, 'GRAD' 0, 'opsz' 40; margin-top:-3px; }
.sessions-list.select-mode .session-card .chevron { display: none; }
.session-card.selected { border-color: var(--user-orange); background: var(--bubble-a); }
/* Session currently open in the main view: subtle fill + left accent bar. The
   bar is an inset shadow so it never shifts the card body (unlike a border). */
.session-card.active {
    background: var(--surface);
    box-shadow: inset 3px 0 0 0 var(--user-orange);
}
.session-card.active .title { color: var(--text); }
.session-card .chevron {
    color: var(--text-2);
    font-size: 22px;
    line-height: 1.2;
    flex-shrink: 0;
    align-self: center;
}
.session-card:active { background: var(--bubble-a); }
.session-card .title {
    font-weight: 600; font-size: 1.07em;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.session-card .preview,
.session-card .preview-reply {
    font-size: 14px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.session-card .preview {
    color: var(--text-beige);   /* start of the user's prompt */
    margin-bottom: 2px;
}
.session-card .preview-reply {
    color: var(--text-2);       /* start of Claude's latest reply */
    margin-bottom: 6px;
}
.session-card .preview-reply:empty {
    display: none;              /* no reply yet → don't reserve a blank line */
}
.session-card .card-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 13px; font-weight: 400;
    color: var(--text-3);                 /* idle "Esperando sua vez" → gray */
}
.session-card .card-status.active { color: var(--claude-orange); }   /* working → orange */
.session-card .card-status.pending { color: var(--user-orange); }  /* turn left waiting on the user → static sunburst, --user-orange */
.session-card .card-status:empty { display: none; }
.session-card .card-status .sunburst { display: inline-flex; flex-shrink: 0; color: inherit; }
.session-card .card-status .sunburst svg { display: block; width: 14px; height: 14px; transform-origin: center; }
.session-card .meta {
    color: var(--text-2);
    font-size: 12px;
}
.session-card .cwd {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-2);
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Subjects (task 19): cards reuse the session-card layout; a leading folder-ish
   icon stands in for the pin/check column. */
.subject-card { align-items: flex-start; }   /* icon pinned to the top-left */
.subject-card .subject-ic { color: var(--user-orange); font-size: 30px; line-height: 1; flex-shrink: 0; font-variation-settings: 'FILL' 0, 'wght' 200, 'GRAD' 0, 'opsz' 40; margin-top:-3px; }   /* thinner strokes */
/* The "Sem assunto" bucket isn't a real subject → not selectable; dim it while selecting. */
.sessions-list.select-mode .subject-bucket { opacity: .5; }

/* Chat header: muted "assunto / " prefix before the session title. */
.title-subject { color: var(--text-2); font-weight: 400; }

/* One-shot subject linker (chat ⋮ → "Vincular a um assunto…"). */
.subject-linker {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    padding: 0;
    min-width: 260px;
    max-width: min(90vw, 360px);
}
.subject-linker::backdrop { background: rgba(0, 0, 0, 0.5); }
.subject-linker .sl-head { padding: 14px 16px 8px; font-weight: 600; }
.subject-linker .sl-list { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; }
.subject-linker .sl-opt {
    display: flex; align-items: center; gap: 8px;
    background: none; border: 0; color: var(--text);
    text-align: left; font: inherit; padding: 10px 16px; cursor: pointer;
}
.subject-linker .sl-opt:hover { background: var(--bubble-a); }
.subject-linker .sl-empty { padding: 12px 16px; color: var(--text-2); font-size: 13px; }
.subject-linker .sl-opt .check { font-size: 18px; width: 18px; color: var(--user-orange); }
.subject-linker .sl-actions { display: flex; justify-content: space-between; gap: 8px; padding: 10px 16px 14px; }
.subject-linker .sl-new, .subject-linker .sl-close {
    background: none; border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font: inherit; padding: 6px 12px; cursor: pointer;
}
.subject-linker .sl-new:hover, .subject-linker .sl-close:hover { background: var(--bubble-a); }

.empty { color: var(--text-2); text-align: center; padding: 40px; }
.spinner { color: var(--text-2); text-align: center; padding: 20px; }
/* View-loading placeholder: a centered, larger spinning sunburst. */
.spinner-sunburst { padding: 32px 20px; color: var(--claude-orange); }
.spinner-sunburst .sunburst { margin: 0; }
.spinner-sunburst .sunburst svg { width: 34px; height: 34px; }

/* "Load more" pill at the top of a windowed chat history */
.load-more {
    display: block;
    width: 100%;
    margin: 0 0 10px;
    padding: 8px;
    background: var(--surface);
    color: var(--user-orange);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: var(--font-sans);
    font-size: 13px;
    cursor: pointer;
}
.load-more:active { background: var(--bubble-a); }
.load-more[hidden] { display: none; }

/* Chat */
.bubble {
    max-width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-bub);
    margin-bottom: 10px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.bubble.user {
    /* Shrink to content so min-width acts as a real floor (a plain block would
       always fill ~max-width, making min-width a no-op). margin-left:auto then
       right-aligns the now content-sized bubble. */
    width: -webkit-fit-content;
    width: fit-content;
    min-width: 40px;
    max-width: 92%;
    background: var(--user-orange);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 0px;
	margin-top: 40px;
}
.bubble.user + .bubble.user {
	margin-top: 10px;
}
/* Collapse long user messages past a height limit, with a fade + toggle. */
.bubble.user.collapsed .bubble-text {
    max-height: 200px;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent);
    mask-image: linear-gradient(to bottom, #000 72%, transparent);
}
.bubble-toggle {
    display: none;
    margin-top: 6px;
    padding: 0;
    background: transparent;
    border: 0;
    color: #fff;
    opacity: 0.9;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.bubble.user.collapsible .bubble-toggle { display: block; }

/* Initial-instructions turn: the session's "Instruções Iniciais" sent to Claude
   as the first message. Centered, "system"-style, Claude orange — visually
   distinct from a normal (blue) user message. */
.bubble.initial {
    max-width: 92%;
    margin: 18px auto 12px;
    padding: 12px 16px;
    background: rgba(var(--claude-orange-rgb), 0.10);
    border: 2px solid var(--user-orange);
    border-radius: 14px;
    color: var(--text);
}
.initial-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--user-orange);
}
/* Orange "command" bubble: a slash command that was executed, + live status. */
.bubble.command {
    max-width: 85%;          /* chat notification width policy (mobile → 92vw below) */
    margin: 12px auto;
    padding: 6px 14px;
    background: rgba(var(--claude-orange-rgb), 0.10);
    border: 2px solid var(--user-orange);
    border-radius: 10px;
    color: var(--text);
    /* Lay out children in a row so the status sits on the same line as the
       command; args (order:2, full width) wrap to their own line below. */
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 8px;
    row-gap: 2px;
}
.cmd-label {
    order: 0;
    /* Allow the label to shrink/wrap: a flex item defaults to min-width:auto,
       which (together with flex-shrink:0) pins it to its content width and lets a
       long command token overflow horizontally on mobile instead of wrapping. */
    flex-shrink: 1;
    min-width: 0;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 14px;
    color: var(--user-orange);
    overflow-wrap: anywhere;
    word-break: break-word;
}
.cmd-args {
    order: 2;
    flex-basis: 100%;
    min-width: 0;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-2);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.cmd-status { order: 1; margin-left: auto; font-size: 12px; color: var(--user-orange); }
.cmd-status.running::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
    margin-right: 6px;
    vertical-align: 0;
    animation: tc-pulse .55s ease-in-out infinite;   /* white blinking bullet, like tool-calls */
}
.cmd-status.err { color: var(--danger); }
.cmd-marker {
    max-width: 85%;
    margin: 12px auto;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--claude-orange);
    opacity: 0.85;
}
/* Task 1B: inline "Modelo: <version>" note before a user turn. */
.model-marker {
    max-width: 85%;
    margin: 14px auto 6px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--claude-orange);
    opacity: 0.85;
}

/* Last-turn caption: small, transparent, dark-gray line under the final reply,
   showing its date/time + the model (e.g. "10/06/2026 14:32 com Opus 4.8"). */
.turn-caption {
    max-width: 85%;
    margin: 2px auto 10px;
    text-align: center;
    font-size: 11px;
    color: var(--text-3);
    background: transparent;
}

/* Compact post-process bubble: a collapsed disclosure holding the /compact
   summary (uses the orange command-bubble look). */
.compact-bubble { display: block; padding: 0; overflow: hidden; }   /* not the command flex row */
.compact-bubble > summary {
    display: flex;
    align-items: baseline;
    gap: 8px;
    cursor: pointer;
    list-style: none;
}
.compact-bubble > summary::-webkit-details-marker { display: none; }
.compact-bubble > summary::after {
    content: 'chevron_right';
    font-family: 'Material Symbols Outlined';
    font-feature-settings: 'liga';
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    font-size: 20px; line-height: normal;
    margin-left: auto;
    align-self: center;
    color: var(--claude-orange);
    transition: transform .15s ease;
}
.compact-bubble[open] > summary::after { transform: rotate(90deg); }
/* Inline summary note for the /compact disclosure ONLY. Scoped to .compact-bubble
   so its nowrap/ellipsis/mono styling does NOT leak into the standalone
   auto-compact suggestion pill (also .compact-note), which must wrap freely. */
.compact-bubble .compact-note {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--user-orange);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.compact-summary {
    border-top: 1px solid rgba(var(--claude-orange-rgb), 0.35);
    padding: 10px 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text-2);
    white-space: pre-wrap;
    max-height: 320px;
    overflow-y: auto;
}

.bubble.initial .bubble-text,
.bubble.user .bubble-text { white-space: pre-wrap; }   /* keep the user's line breaks */
.bubble.initial.collapsed .bubble-text {
    max-height: 200px;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent);
    mask-image: linear-gradient(to bottom, #000 72%, transparent);
}
.bubble.initial.collapsible .bubble-toggle { display: block; color: var(--claude-orange); }

.bubble.assistant {
    max-width: 100%;
    background: var(--bubble-a);
    color: var(--text);
    margin-right: auto;
    border-bottom-left-radius: 0px;
}
.bubble.assistant pre {
    background: #0d0d0e;
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 13px;
}
.bubble.assistant code:not(pre code) {
    background: #56565b;
    padding: 2px 5px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
}
.bubble.assistant p { margin: 0 0 6px 0; }
.bubble.assistant p:last-child { margin-bottom: 0; }
.bubble.assistant h1, .bubble.assistant h2, .bubble.assistant h3 {
    font-size: 1.05em;
    margin: 8px 0 4px 0;
}
.bubble.assistant ul, .bubble.assistant ol { padding-left: 22px; margin: 4px 0; }

/* Tables: horizontal scroll on mobile + borders, subtle zebra, bold header */
.bubble.assistant .md-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    margin: 6px 0;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.bubble.assistant table {
    border-collapse: collapse;
    width: max-content;       /* size to content so wide tables scroll */
    min-width: 100%;
    font-size: 12px;
    background: var(--composer);      /* a touch darker than the bubble (--bubble-a) */
}
.bubble.assistant th,
.bubble.assistant td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    text-align: left;
    white-space: nowrap;      /* keep columns intact → scroll instead of squish */
}
.bubble.assistant thead th {
    background: rgba(var(--user-orange-rgb), 0.14);
	color: var(--user-orange);
    font-weight: 600;
}
.bubble.assistant tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.055);   /* subtle zebra */
}

.tool-call {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
	border-bottom-left-radius: 0px;
    margin: 10px 0;
    overflow: hidden;
    max-width: 100%;
}
.tool-call summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    list-style: none;          /* hide the native disclosure triangle */
}
.tool-call summary::-webkit-details-marker { display: none; }
.tc-label {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-2);
    background: var(--badge);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1px 7px;
    line-height: 1.5;
    white-space: nowrap;
    text-transform: uppercase;
}
.tc-summary {
    flex: 1;
    min-width: 0;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-2);            /* child tool-call: gray */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* status: a filled colored bullet. running = white, softly blinking; ok = green;
   err = red; alert = orange. */
.tc-status { flex-shrink: 0; font-size: 13px; line-height: 1; }
.tc-status.ok,
.tc-status.err,
.tc-status.alert,
.tc-status.pending,
.tc-status.running {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 0;
}
.tc-status.ok { background: #49975a; }
.tc-status.err { background: var(--danger); }
.tc-status.alert { background: var(--alert-orange); }      /* Alerta */
.tc-status.pending { background: var(--claude-orange); }   /* turn interrupted while waiting on the user */
/* Resolved interactive records: green border = allowed/answered, red = denied/gave up,
   orange = interrupted (server died waiting on a question/permission). */
.tool-call.tc-resolved-allow { border-color: #49975a; }
.tool-call.tc-resolved-deny  { border-color: var(--danger); }
.tool-call.tc-resolved-pending { border-color: var(--claude-orange); }
.tc-status.running {                            /* execução em andamento */
    background: #fff;
    animation: tc-pulse .55s ease-in-out infinite;
}
@keyframes tc-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }

/* Aggregated child statuses on the (collapsed) root group summary: one bullet
   per distinct color present among the children. */
.tg-status {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

.tc-body { border-top: 1px solid var(--border); }
.tc-body:empty { display: none; }

/* Disclosure caret (native marker is hidden) — everything starts collapsed, so
   a visible affordance matters. Rotates when its <details> is open. */
.tool-call summary::before,
.tool-group > summary::before {
    content: 'chevron_right';
    font-family: 'Material Symbols Outlined';
    font-feature-settings: 'liga';
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    flex-shrink: 0;
    color: var(--text-2);
    font-size: 20px;
    line-height: 1;
    transition: transform .12s ease;
}
.tool-call[open] > summary::before,
.tool-group[open] > summary::before { transform: rotate(90deg); }
#chat-col > .tool-group > summary::before { color: var(--text); }

/* Parent grouping a turn's run of non-edit tool-calls. */
.tool-group {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    border-bottom-left-radius: 0px;
    margin: 10px 0;
    overflow: hidden;
    max-width: 100%;
}
.tool-group[open] { background: var(--bubble-a); }
/* A run of consecutive tool-call groups reads as one seamless stack: no gap, square
   inner corners, and a single shared 1px divider between them (the not-first group
   drops its top border so the previous group's bottom border is the only line). The
   first keeps its rounded top and the last its rounded bottom. */
.tool-group:has(+ .tool-group) {   /* not last in the run → square bottom, no gap */
    margin-bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}
.tool-group + .tool-group {        /* not first in the run → square top, collapse border */
    margin-top: 0;
    border-top: 0;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}
.tool-group > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    cursor: pointer;
    user-select: none;
    list-style: none;
}
.tool-group > summary::-webkit-details-marker { display: none; }
.tg-label {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: #1c1c1e;              /* black font */
    background: #98989f;         /* gray badge (TOOLS) */
    border: 1px solid #98989f;
    border-radius: 6px;
    padding: 1px 7px;
    line-height: 1.5;
    text-transform: uppercase;
}
/* Write runs ("GRAVAR") are flagged with a claude-orange badge on the root
   group only; the child tool-calls keep the default badge. */
.tool-group.write-group > summary .tg-label {
    background: var(--claude-orange);
    border-color: var(--claude-orange);
    color: #1c1c1e;
}
.tg-count {
    flex: 1;
    min-width: 0;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text);              /* root tool-call: white */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tg-body { border-top: 1px solid var(--border-a); }

/* The AskUserQuestion record and its interactive bubble swap visibility. */
.tool-call[hidden], .perm-card[hidden] { display: none !important; }

/* A tool-call nested inside a group: flat — no bubble (border/radius/bg) and no
   outer spacing, to save room inside the root group. Only its summary collapses;
   children are separated by a thin rule. */
.tool-call.tc-child {
    background: none;
    border: none;
    border-radius: 0;
    border-top: 1px solid var(--border-a);
    margin: 0;
    max-width: 100%;
    overflow: visible;
}
.tool-call.tc-child:first-child { border-top: none; }
.tool-call.tc-child > summary { padding: 5px 10px; gap: 6px; }
.tool-call.tc-child > .tc-body { border-top: none; }

/* Sub-blocks (Comando/Saída, Caminho/Conteúdo, …): plain label + content, always
   visible when the parent tool-call is open — never collapsible. */
.tc-sections { display: flex; flex-direction: column; }
.tc-sections:empty { display: none; }
.tc-section-head {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-2);
    padding: 4px 10px;
}

.tool-call pre,
.perm-body pre {
    margin: 0;
    padding: 8px 12px;
    background: #0d0d0e;
    color: var(--text-2);
    font-size: 13px;
    font-family: var(--font-mono);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 320px;
    overflow: auto;
}

/* Inline approval request: a bubble in the transcript (no modal) so the chat
   stays readable. Blue border + dark background. */
.perm-card {
    border: 1.5px solid var(--user-orange);
    background: var(--composer);
    border-radius: 12px;
    margin: 10px 0;
    overflow: hidden;
    max-width: 100%;
    /* Flash the blue border a couple times on arrival to draw attention. */
    animation: perm-flash 0.85s ease-in-out 2;
}
.perm-card.resolved { animation: none; }
@keyframes perm-flash {
    0%, 100% { border-color: var(--user-orange); box-shadow: 0 0 0 0 rgba(var(--user-orange-rgb), 0); }
    50%      { border-color: #ec7a52;        box-shadow: 0 0 0 3px rgba(var(--user-orange-rgb), 0.45); }
}
.perm-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
}
/* Question/permission badge: filled green with black text. */
.perm-head .tc-label {
    background: var(--user-orange);
    color: #FFF;
    border-color: var(--user-orange);
}
.perm-summary {
    flex: 1;
    min-width: 0;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--user-orange);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.perm-body { border-top: 1px solid var(--border); }
.perm-body:empty { display: none; }
.perm-q {
    padding: 8px 12px 4px;
    font-size: 13px;
    color: var(--text);
}
.perm-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 6px 12px 10px;
}
.perm-deny, .perm-allow {
    border-radius: 8px;
    padding: 7px 18px;
    font-size: 14px;
    font-family: var(--font-sans);
    cursor: pointer;
    border: 1px solid var(--border);
}
.perm-deny { background: transparent; color: var(--text); }
.perm-deny:active { background: var(--border); }
.perm-allow { background: var(--user-orange); color: #fff; border-color: var(--user-orange); }
.perm-allow:active { filter: brightness(0.9); }
.perm-result { font-size: 13px; color: var(--text-2); }
.perm-card.allowed .perm-result { color: #49975a; }
.perm-card.denied .perm-result { color: var(--danger); }
/* Resolved bubble border follows the outcome: allowed/answered = green, denied/gave up = red. */
.perm-card.allowed { border-color: #49975a !important; }
.perm-card.denied { border-color: var(--danger) !important; }
.perm-card.resolved { opacity: 0.8; }
.perm-card.sending { animation: none; }
.perm-card.sending .perm-deny, .perm-card.sending .perm-allow,
.perm-card.sending .q-submit, .perm-card.sending .q-opt, .perm-card.sending .q-other {
    opacity: 0.5;
    cursor: default;
}
.perm-pending {
    font-size: 13px;
    color: var(--text-2);
    align-self: center;
}
.perm-error {
    padding: 6px 12px 10px;
    font-size: 12px;
    color: var(--danger);
    border-top: 1px solid var(--border);
}
.tc-code code { font-family: var(--font-mono); background: none; padding: 0; }
.tc-note {
    padding: 6px 12px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-2);
    word-break: break-word;
}
.tc-result { border-top: 1px solid var(--border); }
.tc-more { padding: 4px 12px; font-size: 11px; color: var(--text-2); }
.tc-sep { height: 1px; margin: 6px 12px; background: var(--border); }

/* Edit/MultiEdit diff */
.tc-diff {
    font-family: var(--font-mono);
    font-size: 13px;
    background: #0d0d0e;
    padding: 6px 0;
    max-height: 360px;
    overflow: auto;
}
.tc-diff > div {
    padding: 1px 12px;
    white-space: pre-wrap;
    word-break: break-word;
}
.diff-del { background: rgba(255, 69, 58, 0.13); color: #ff8b82; }
.diff-add { background: rgba(52, 199, 89, 0.13); color: #5be584; }
.diff-del::before { content: '- '; opacity: .6; }
.diff-add::before { content: '+ '; opacity: .6; }

/* TodoWrite list */
.tc-todos { list-style: none; margin: 0; padding: 8px 12px; }
.tc-todos li {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    font-size: 13px;
    padding: 2px 0;
    color: var(--text);
}
.tc-todos .todo-mark { flex-shrink: 0; color: var(--text-2); }
.tc-todos .todo-completed { color: var(--text-2); text-decoration: line-through; }
.tc-todos .todo-completed .todo-mark { color: #49975a; }
.tc-todos .todo-in_progress { color: var(--user-orange); }

/* AskUserQuestion: readable questions + options (instead of raw JSON) */
.tc-qs { padding: 8px 12px; display: flex; flex-direction: column; gap: 12px; }
.tc-q { display: flex; flex-direction: column; gap: 4px; }
.tc-q-header {
    align-self: flex-start;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    font-family: var(--font-mono);
    line-height: 1.5;
    color: #000;
    background: var(--claude-orange);
    border: 1px solid var(--claude-orange);
    border-radius: 6px;
    padding: 1px 7px;
}
.tc-q-text { font-size: 14px; color: var(--text); font-weight:300; }
.tc-q-multi { font-size: 11px; color: var(--text-2); }
.tc-opts { display: flex; flex-direction: column; gap: 6px; margin-top: 2px; }
.tc-opt {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 10px;
    background: var(--surface);
}
.tc-opt-label { font-size: 13px; font-weight: 600; color: var(--text); }
.tc-opt-desc { font-size: 12px; color: var(--text-2); margin-top: 2px; }
/* Optional "Observações" the user posted with the answers — shown in --user-orange. */
.tc-obs { padding: 0 12px 8px; font-size: 13px; color: var(--user-orange); }
.tc-obs-label { font-weight: 600; }

/* Answered (allowed) question reads GREEN in BOTH the post-answer tool-call record
   and the question bubble: the header pill (at 0.8 opacity) + the chosen-answer
   borders. Gave-up/denied keeps its red treatment. */
.tool-call.tc-resolved-allow .tc-section-body .tc-q-header,
.perm-card.question.allowed .tc-q-header {
    background: #49975a;
    border-color: #49975a;
    opacity: 0.8;
}
.tool-call.tc-resolved-allow .tc-section-body .tc-opt,
.perm-card.question.allowed .q-opt.sel {
    border-color: #49975abb;
}
.perm-card.question.allowed .q-opt.sel {
    background: rgba(52, 199, 89, 0.14);
}

/* AskUserQuestion tool-call record (post-answer): orange badge + summary, matching
   the interactive question bubble's header. */
.tool-call[data-tool="AskUserQuestion"] > summary > .tc-label {
    background: #49975a;
    color: #000;
    border-color: #49975a;
}
.tool-call[data-tool="AskUserQuestion"] > summary > .tc-summary { color: var(--user-orange); }

/* Resolved records colour the badge + summary by outcome (green = allowed/answered,
   red = denied/gave up). Placed AFTER the orange AskUserQuestion rules above so it
   wins by order at equal specificity. */
.tool-call.tc-resolved-allow > summary > .tc-label {
    background: #1e8e3e; color: #fff; border-color: #1e8e3e;   /* darker green badge */
}
.tool-call.tc-resolved-allow > summary > .tc-summary { color: #49975a; }
.tool-call.tc-resolved-deny > summary > .tc-label {
    background: #b3140c; color: #fff; border-color: #b3140c;   /* darker red badge */
}
.tool-call.tc-resolved-deny > summary > .tc-summary { color: var(--danger); }
.tool-call.tc-resolved-pending > summary > .tc-label {
    background: var(--claude-orange); color: #000; border-color: var(--claude-orange);   /* orange badge */
}
.tool-call.tc-resolved-pending > summary > .tc-summary { color: var(--claude-orange); }

/* Interactive AskUserQuestion card (clickable options) */
.perm-card.question .q-body { padding: 8px 12px; display: flex; flex-direction: column; gap: 14px; }
.q-block { display: flex; flex-direction: column; gap: 6px; }
/* Single optional "Observações" field at the end of the question card — separated
   from the questions by a top divider, with a muted (non-pill) label. */
.q-notes-block { border-top: 1px solid var(--border); padding-top: 12px; }
.q-notes-label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.q-options { display: flex; flex-direction: column; gap: 6px; }
.q-opt {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    text-align: left;
    cursor: pointer;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-family: var(--font-sans);
}
.q-opt:active { background: var(--bubble-a); }
.q-opt.sel { border-color: var(--user-orange); background: rgba(var(--user-orange-rgb), 0.14); }
.q-opt-label { font-size: 13px; font-weight: 600; }
.q-opt-desc { font-size: 12px; color: var(--text-2); }
.q-other {
    width: 100%;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 14px;
    font-family: var(--font-sans);
    line-height: 1.4;
    min-height: 38px;
    resize: vertical;
    outline: none;
}
.q-other:focus { border-color: var(--user-orange); }
/* Filled custom answer → same transparent-orange tint as a selected option. */
.q-other.filled { border-color: #49975abb; background: rgba(var(--user-orange-rgb), 0.14); }
.q-submit:disabled { opacity: 0.5; cursor: default; }

/* Cancel-with-partial decision bubble: shown when the user hits ✕ after Claude
   already produced output. Reuses the .q-opt option buttons; the turn keeps
   running in the background until an option is chosen. */
.cancel-decision {
    align-self: stretch;
    max-width: 92%;
    margin: 8px auto 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bubble-a);
}
.cancel-decision .cd-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 8px;
}

/* Unified "alert" box for every error/warning line in the chat history: they all
   share ONE shape — a semi-transparent fill, a matching border, and text — driven
   by a single colour token (--alert-rgb); only the hue changes per variant. */
.error-line, .interrupted-line {
    --alert-rgb: var(--danger-rgb);   /* default hue: danger (red) */
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 8px 12px;
    margin: 20px auto;
    max-width: 85%;          /* chat notification width policy (mobile → 92vw below) */
    color: rgb(var(--alert-rgb));
    background: rgba(var(--alert-rgb), 0.12);
    border: 2px solid rgba(var(--alert-rgb), 0.55);
    border-radius: 12px;
}

/* Marker for a turn that ended without the assistant's final response (warn hue). */
.interrupted-line { --alert-rgb: var(--claude-orange-rgb); font-size: 12px; }

/* "Continuar" shortcut on the interrupted alert: re-opens a pending question (drops
   the stale record, reinserts the card; answering it starts a new turn). */
.interrupted-continue {
    margin-left: auto;
    flex: 0 0 auto;
    padding: 4px 12px;
    font: inherit;
    font-size: 12px;
    color: rgb(var(--alert-rgb));
    background: rgba(var(--alert-rgb), 0.14);
    border: 1px solid rgba(var(--alert-rgb), 0.5);
    border-radius: 6px;
    cursor: pointer;
}
.interrupted-continue:hover { background: rgba(var(--alert-rgb), 0.24); }

/* The error footer inside a permission card keeps its in-card placement, but its
   icon + text line up the same way as the standalone alert lines. */
.perm-error { display: flex; align-items: center; gap: 8px; }

/* The 'error' material-symbols glyph (circle-!) that leads every alert line
   (.error-line, .interrupted-line, .perm-error). Inherits the line colour, sized a
   touch above the text and vertically centred with it (the flex row centres it). */
.err-ic {
    font-size: 1.4em;
    line-height: 1;
    flex: 0 0 auto;
}

/* "Thinking" / reasoning block — left-aligned, below the user bubble */
.think {
    margin: 2px auto 8px 0;   /* left-aligned */
    max-width: 100%;
    color: var(--text-2);
}
.think-head {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 0;
    padding: 2px 0;
    color: var(--text-2);
    font-family: var(--font-sans);
    font-size: 13px;
    cursor: pointer;
}
.think-caret { display: none; transition: transform .15s; }
/* Combined selector beats the base .material-symbols-outlined (loaded later). */
.think-caret.material-symbols-outlined { font-size: 18px; }
.think.has-content .think-caret { display: inline-block; }
.think.collapsed .think-caret { transform: rotate(-90deg); }
.think.collapsed .think-body { display: none; }
.think-body {
    white-space: pre-wrap;
    margin-top: 4px;
    padding: 2px 0 2px 10px;
    border-left: 2px solid var(--border);
    color: var(--text-2);
    font-size: 13px;
    line-height: 1.45;
}
.think-body:empty { display: none; }
/* Live reasoning bubble: streams right below the user message (which is scrolled
   to the top). Outline only, dark gray, italic. Collapses to the "Raciocínio ▸"
   toggle once the answer/tool starts. */
.think.reasoning-live > .think-head { display: none; }
.think.reasoning-live > .think-body {
    margin-top: 0;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-3);
    font-style: italic;
    max-height: 40vh;
    overflow-y: auto;
}
/* animated dots while actively thinking */
.think-dots { display: none; gap: 3px; align-items: center; }
.think.thinking .think-dots { display: inline-flex; }
.think-dots i {
    width: 4px; height: 4px; border-radius: 50%;
    background: var(--text-2);
    animation: think-dot 1s infinite ease-in-out;
}
.think-dots i:nth-child(2) { animation-delay: .15s; }
.think-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes think-dot {
    0%, 100% { opacity: .3; transform: translateY(0); }
    50%      { opacity: 1;  transform: translateY(-2px); }
}

/* Smooth streaming: fade-in the live bubble + a blinking caret while streaming */
.bubble.assistant.streaming { animation: bubble-fade .18s ease-out; }
.bubble.assistant.streaming::after {
    content: '▋';
    margin-left: 1px;
    color: var(--text-2);
    animation: caret-blink .55s ease-in-out infinite;
}
@keyframes bubble-fade { from { opacity: .35; } to { opacity: 1; } }
@keyframes caret-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Per-turn stats: elapsed time + token usage */
.turn-stats {
    margin: 0 auto 10px 0;
    color: var(--text-2);
    font-family: var(--font-mono);
    font-size: 11px;
}

/* Turn bar: pinned just above the composer while a turn is in flight.
   Shows the live "thinking" status + reasoning (expandable) and a cancel ✕. */
#turn-bar {
    flex-shrink: 0;
    background: var(--composer);
    border-top: 1px solid var(--border);
    padding: 4px 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
}
#turn-bar[hidden] { display: none; }
/* Centered container, matching #chat-col / .composer-col. */
.turn-col {
    width: 100%;
    max-width: 980px;
    margin-left: auto;
    margin-right: auto;
}
#turn-bar .turn-top {
    display: flex;
    align-items: center;
    gap: 8px;
	min-height: 34px;

}
#turn-bar .think-head { flex: 1; min-width: 0; cursor: default; }
#turn-bar.has-reasoning .think-head { cursor: pointer; }
#turn-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#turn-stats {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-beige);
    white-space: nowrap;
}
#turn-stats:empty { display: none; }

/* Micro sunburst: blue, spins while the session is working; static & dim when
   idle ("Esperando sua vez"). */
.sunburst { flex-shrink: 0; display: inline-flex; color: var(--user-orange); margin-top:2px; }
.sunburst svg {
    display: block;
    width: 20px;
    height: 20px;
    transform-origin: center;
}
#turn-bar:not(.idle) .sunburst svg,
.sunburst.spin svg { animation: sb-spin 1.4s linear infinite; }
@keyframes sb-spin { to { transform: rotate(360deg); } }

/* Animated boot splash: spinning sunburst + app name, centered. Fades out and is
   removed by app.js (hideSplash) once the first view is ready. */
#splash {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1c1e1d;   /* matches manifest background_color / theme-color */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    opacity: 1;
    transition: opacity .55s ease;
}
#splash.hide { opacity: 0; pointer-events: none; }
/* Cold-open gate (set in <head> before paint): skip the splash on recent reloads. */
html.no-splash #splash { display: none !important; }
.splash-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: splash-in .35s ease-out both;
}
/* Wrapper does the one-time entrance flourish (rotate + scale + fade); the inner
   <svg> keeps spinning continuously. Two layers so the transforms don't fight. */
.splash-sunburst {
    color: var(--claude-orange);
    display: inline-flex;
    transform-origin: center;
    animation: sunburst-enter 1.2s ease-in-out;
}
.splash-sunburst svg {
    display: block;
    width: 96px; height: 96px;
    transform-origin: center;
    /* Continuous spin from the first frame — the wrapper's entrance only scales
       and fades, so nothing interrupts the rotation. */
    animation: sb-spin 3s linear infinite;
}
.splash-name {
    font-family: var(--font-sans);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -1px;
    color: var(--text);
    /* Settle in after the sunburst, then breathe. */
    animation: splash-name-in .6s ease-out .9s both,
               splash-pulse 1.6s ease-in-out 1.1s infinite;
}
@keyframes splash-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes sunburst-enter {
    0%   { opacity: 0; transform: scale(.2); }
    60%  { opacity: 1; transform: scale(1.8); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes splash-name-in {
    from { opacity: 0; letter-spacing: 20px; }
    to   { opacity: 1; letter-spacing: -1px; }
}
@keyframes splash-pulse {
    0%, 100% { opacity: .6; }
    50%      { opacity: 1; }
}
/* Working/awaiting → Claude orange; idle ("Esperando sua vez") → blue. */
#turn-bar:not(.idle) .sunburst { color: var(--claude-orange); }
#turn-bar:not(.idle) #turn-label { color: var(--claude-orange); }
#turn-bar.idle .sunburst { color: var(--text-3); opacity: 0.6; }
/* Idle state: just a status label (blue) — no cancel, no reasoning. */
#turn-bar.idle #turn-cancel { display: none; }
#turn-bar.idle #turn-label { color: var(--text-3); }
/* caret only when there is reasoning to expand */
#turn-bar .think-caret { display: none; }
#turn-bar.has-reasoning .think-caret { display: inline-block; }
#turn-bar.collapsed .think-caret { transform: rotate(-90deg); }
#turn-reasoning {
    max-height: 28vh;
    overflow-y: auto;
    margin-top: 6px;
}
#turn-reasoning:empty { display: none; }
#turn-bar.collapsed #turn-reasoning { display: none; }
#turn-cancel {
    background: transparent;
    border: 0;
    color: var(--claude-orange);
    font-size: 22px;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 16px;
    cursor: pointer;
    flex-shrink: 0;
}
#turn-cancel:active { background: var(--border); }
#turn-cancel:disabled { opacity: .5; cursor: default; }
/* tab_close_right points the other way — mirror it horizontally. */
#turn-cancel .material-symbols-outlined { display: inline-block; transform: scaleX(-1); font-size: 24px; }

/* Composer */
/* Full-width bar; its content lives in a centered container (.composer-col),
   matching #chat-col so the input lines up with the chat column. */
#composer {
    padding: 6px 12px;
    /* Bottom clearance adapts per platform via the safe-area inset (populated
       because the PWA runs full-screen under `black-translucent`): ~34px above
       the iPhone home indicator in standalone, and 0 in the browser — so the old
       fixed 26px (a dead gray band in Safari, too small in the PWA) is gone. The
       6px floor keeps a little breathing room where there's no home indicator. */
    padding-bottom: max(6px, calc(env(safe-area-inset-bottom) - 6px));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    background: var(--composer);
    border-top: 1px solid rgba(var(--border), .8);
    flex-shrink: 0;
}
#composer[hidden] { display: none; }
.composer-col {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
    max-width: 980px;
    margin-left: auto;
    margin-right: auto;
}
#composer-input {
    flex: 1;
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--border);
    border-radius: 20px;
    padding: 8px 14px;
    font-family: var(--font-sans);
    font-size: 1.05em;  /* 16px to avoid iOS zoom on focus */
    resize: none;
    max-height: 40vh; min-height: 40px;
    overflow-y: auto;
    line-height: 1.4;
    outline: none;
}
#composer-input:focus { border-color: var(--user-orange); }
/* Hide the composer textarea's scrollbar (it still scrolls). */
#composer-input { scrollbar-width: none; -ms-overflow-style: none; }
#composer-input::-webkit-scrollbar { width: 0; height: 0; display: none; }
/* Match the ghost-suggestion colour so the placeholder and the ghost don't clash
   when both show at once. opacity:1 keeps Firefox from dimming it. */
#composer-input::placeholder { color: var(--text-3, var(--text-2)); opacity: 1; }
#composer-send {
    background: var(--user-orange);
    color: white; font-weight: bold;
    border: 0;
    /* The JS toggles a `.empty` STATE class here when the composer has no text;
       that name collides with the generic `.empty` placeholder utility
       (padding: 40px). The fixed 36×36 button must never inherit it. */
    padding: 0;
    width: 45px;
    height: 40px;
    border-radius: 18px 18px 4px 18px;
    font-size: 22px;
    cursor: pointer;
    flex-shrink: 0;
}
#composer-send:disabled { background: var(--border); }
/* Task 20 — turn-active button states. During a turn the button stays clickable
   (no hard-disable) so it can ENQUEUE: with text → queue icon; empty → dimmed
   code icon (no-op). Background goes gray either way (per spec), distinguishing
   it from the normal orange "send". */
#composer-send.turning { background: var(--border); color: #fff; }
#composer-send.turning.empty { color: var(--text-2); cursor: default; }

/* Task 20 — post queue: whole posts staged while a turn is active, shown above
   the composer. Each item looks like the input (rounded surface) with an X to
   cancel. Capped to half the chat history (max-height set in JS) → scrolls. */
/* Full-bleed scroll container (mirrors #view); the inner .pq-col centers the
   actual items at the 980px content width (mirrors #chat-col). */
.post-queue {
    flex-shrink: 0;
    width: 100%;
    /* Same padding as the thinking-bar (#turn-bar). */
    padding: 4px 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    overflow-y: auto;
    overscroll-behavior-y: contain;
    background: var(--composer);
}
.post-queue[hidden] { display: none; }
.pq-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
    padding: 0;
}
/* Long-press drag: the hold must NEVER start a text selection or iOS callout.
   iOS Safari only reliably honours -webkit-user-select when it's on the element
   AND every descendant, and is overridden by inline defaults — hence the `*`
   reach and !important. */
.post-queue,
.post-queue * {
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
}
.queue-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--user-orange);
    border: 2px solid var(--user-orange);
    border-radius: 14px;
    padding: 6px 8px 6px 14px;
    opacity: .9;
}
.queue-item .qi-text {
    flex: 1; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    color: var(--text); font-size: .92em;
}
.queue-item .qi-att {
    flex-shrink: 0;
    display: inline-flex; align-items: center; gap: 1px;
    color: var(--text-2); font-size: .82em;
}
.queue-item .qi-att .material-symbols-outlined { font-size: 16px; }
.queue-item .qi-x {
    flex-shrink: 0;
    background: transparent; border: 0; color: #000;
    cursor: pointer; display: inline-flex; align-items: center;
    padding: 2px; border-radius: 50%; font-size: 18px;
}
.queue-item .qi-x:hover { color: var(--text); background: var(--bubble-a, #26262a); }
/* Long-press drag-and-drop (task 20): reorder, or drop on the chat history to post. */
.queue-item.qi-dragging {
    opacity: .75;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
    pointer-events: none;           /* let the pointer fall through to siblings/history */
    cursor: grabbing;
}
.qi-placeholder {
    border: 2px dashed var(--user-orange);
    border-radius: 14px;
    opacity: .5;
    box-sizing: border-box;
}
.post-queue.qi-dragging-active { touch-action: none; }   /* suppress scroll while dragging */
/* Chat history flagged as the "drop here to post" zone during an idle drag. */
.qi-drop-target { box-shadow: inset 0 0 0 2px var(--user-orange); }

/* Task 3 — reply-suggestion ghost text. The textarea is wrapped so a mirror div
   (#composer-ghost) can sit exactly under it: the textarea goes transparent (its
   border stays), the mirror paints the --surface background plus the muted
   suggestion remainder after a transparent copy of the typed text. Box metrics
   (padding/border/font/line-height/wrapping) must match the textarea exactly. */
#composer-input-wrap {
	position: relative; flex: 1; min-width: 0; display: flex;
	align-items: center;
}
#composer-input-wrap > #composer-input {
    flex: 1;
    width: 100%;
    position: relative;
    z-index: 1;
    background: transparent;
}
#composer-ghost {
    position: absolute;
    inset: 0;
    z-index: 0;
    margin: 0;
    pointer-events: none;
    overflow: hidden;
    padding: 8px 14px;
    border: 2px solid transparent;
    border-radius: 18px;
    background: var(--surface);
    font-family: var(--font-sans);
    font-size: 16px;        /* matches #composer-input (kept 16px even on desktop) */
    line-height: 1.3;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}
#composer-ghost .rs-typed { color: transparent; }
#composer-ghost .rs-rest  { color: var(--text-3, var(--text-2)); }

/* 1A 'Add' action: attachment chips (above input) + action bar (below input).
   Both share the centered 980px column so they line up with .composer-col. */
.composer-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    max-width: 980px;
    margin: 0 auto 6px;
}
.composer-attachments[hidden] { display: none; }

/* Task 8 — auto-compact suggestion: a SINGLE always-interactive chat bubble
   (centered info bubble). Its Compactar/Adiar buttons never go away, so the user
   can scroll to it and compact whenever; it resurfaces at the bottom each multiple. */
.compact-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: fit-content;
    max-width: 85%;          /* chat notification width policy (mobile → 92vw below) */
    margin: 10px auto;
    padding: 8px 14px;
    background: rgba(var(--user-orange-rgb), 0.14);   /* user-orange, semitransparent (padrão das bolhas) */
    border: 1px solid var(--user-orange);
    border-radius: 14px;
    font-size: 13px;
    text-align: center;
}
.compact-note .cn-msg { color: var(--user-orange); }
.compact-note button {
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 13px;
    cursor: pointer;
    background: var(--border);
    color: var(--text);
}
.compact-note .cn-ok { background: var(--user-orange); border-color: var(--user-orange); color: #fff; font-weight: 600; }
.compact-note .cn-no { color: var(--text); }

/* Class collision: the /compact disclosure reuses .compact-note for its inline
   summary note (a <span> inside the command bubble), but the auto-compact
   suggestion above styles .compact-note as an orange pill. Any note INSIDE a
   command bubble is plain inline text — strip the pill's border/fill/padding
   (and the bleeding flex/width/margin) so it renders inline again. */
.bubble.command .compact-note {
    display: inline;
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
}

/* Unified width policy for chat-stream notification bubbles (command, markers,
   error/warn lines, auto-compact pill): 85% on desktop (set in each base rule
   above), 92vw on mobile. Placed after all base rules so it wins at equal
   specificity. The .update-card lives in the sidebar and is intentionally
   excluded. The inline .bubble.command .compact-note is re-neutralised. */
@media (max-width: 899px) {
    .bubble.command,
    .cmd-marker,
    .model-marker,
    .error-line,
    .interrupted-line,
    .compact-note { max-width: 85vw; }
    .bubble.command .compact-note { max-width: none; }
	.error-line > [class*=material-symbols], .interrupted-line  > [class*=material-symbols] { font-size:20px; }
}

/* Settings: auto-compact threshold fields. */
.ac-fields { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.ac-field input[type="number"] { width: 140px; }

/* Attachment cards (task 2, unified with 1A): ≤50px tall. Image → its own
   thumbnail; otherwise a --claude-orange square with the uppercase type/ext.
   Used both in the composer staging strip and above the user bubble. */
.attach-card {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 50px;
    max-width: 240px;
    padding-right: 6px;
    background: color-mix(in srgb, var(--user-orange) 24%, transparent);
    border: 1px solid var(--user-orange);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
}
.attach-card:active { background: color-mix(in srgb, var(--user-orange) 28%, transparent); }
.attach-thumb {
    position: relative;       /* anchor the orange tint overlay */
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0.8; }
/* Tint the image thumbnail toward the orange theme (mix-blend-mode 'color' keeps
   the photo's luminance but recolours hue/saturation; opacity controls strength).
   Only on image thumbs — the .type square is already solid --claude-orange. */
.attach-thumb:not(.type)::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--user-orange);
    mix-blend-mode: color;
    opacity: .9;
    pointer-events: none;
}
.attach-thumb.type {
    background: var(--claude-orange);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
}
.attach-name {
    min-width: 0;
    flex: 1;
    font-size: 13px;
    color: var(--user-orange);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.attach-remove {
    background: transparent;
    border: 0;
    color: var(--user-orange);
    font-size: 16px;
    line-height: 1;
    width: 22px;
    height: 22px;
    border-radius: 11px;
    cursor: pointer;
    flex-shrink: 0;
}
.attach-remove:active { background: color-mix(in srgb, var(--user-orange) 28%, transparent); }
.attach-remove:disabled { opacity: .4; cursor: default; }

/* Card row rendered just above a user bubble (right-aligned, like the bubble). */
.bubble-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
    margin: 40px 0 -30px;
}

/* Task 2 — lightweight attachment preview modal (task-14 viewer supersedes it). */
.attach-preview {
    width: min(900px, calc(100vw - 24px));
    max-height: 86vh;
    padding: 0;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}
.attach-preview::backdrop { background: rgba(0, 0, 0, .6); }
.attach-preview-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
.attach-preview-head h3 {
    margin: 0;
    flex: 1;
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.attach-preview-head .ic { text-decoration: none; }
.attach-preview-body { padding: 12px; overflow: auto; max-height: calc(86vh - 54px); }
.attach-preview-body img { max-width: 100%; height: auto; display: block; margin: 0 auto; border-radius: 8px; }
.attach-preview-body pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
}

/* Session file manager dialog (opened from "Arquivos (N)"). */
.files-dialog {
    width: min(520px, calc(100vw - 24px));
    max-height: 80vh;
    padding: 0;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}
.files-dialog::backdrop { background: rgba(0, 0, 0, .5); }
.files-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}
.files-head h3 { margin: 0; font-size: 16px; }
.files-close {
    background: transparent; border: 0; color: var(--text-2);
    font-size: 18px; cursor: pointer; line-height: 1;
}
.files-list { padding: 6px; overflow-y: auto; max-height: calc(80vh - 52px); }
.files-empty { padding: 20px; text-align: center; color: var(--text-2); }
.files-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
}
.files-row:hover { background: var(--bg); }
.files-ref { display: flex; align-items: center; flex-shrink: 0; }
.files-meta { flex: 1; min-width: 0; }
.files-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-size { font-size: 12px; color: var(--text-2); }
.files-action {
    flex-shrink: 0;
    background: transparent;
    border: 0;
    color: var(--text);
    text-decoration: none;
    font-size: 16px;
    width: 30px; height: 30px;
    border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.files-action:active { background: var(--border); }
.files-action.danger { color: var(--danger); }

.composer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 980px;
    margin: 10px auto 0;
}
.composer-add {
    background: var(--composer);
    color: var(--claude-orange);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    font-size: 26px;
	font-weight: bold;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .12s ease;
	padding:0;
}
.composer-add:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); }
.composer-add:active { background: var(--border); }
.composer-add:disabled { opacity: .5; cursor: default; }

/* Task 1B: model picker button below the input (opens #model-menu upward). */
.composer-model {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;   /* push the model picker to the right edge of the row */
    background: var(--composer);
    color: var(--claude-orange);
    border: none;
    height: 32px;
    padding: 0 10px;
    border-radius: 4px;
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 1;
    min-width: 0;
    max-width: 48%;
    transition: background .12s ease;
}
.composer-model:hover { background: rgba(255, 255, 255, 0.08); }
.composer-model[hidden] { display: none; }
.composer-model .cm-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap; font-weight: bold;
}
.composer-model .cm-caret { color: var(--text-3); font-size: 22px; flex-shrink: 0; }
.composer-model:active { background: var(--border); }

/* Floating '/' command + '@' path completion, anchored above the composer */
#composer-suggest {
    position: fixed;
    z-index: 60;
    max-height: 40vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
    padding: 4px;
}
#composer-suggest[hidden] { display: none; }
.suggest-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: 0;
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}
.suggest-item.active { background: var(--border); }
.suggest-label { font-family: var(--font-mono); white-space: nowrap; flex-shrink: 0; }
.suggest-hint {
    flex: 1;
    min-width: 0;
    color: var(--text-2);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.suggest-loading { padding: 10px 12px; color: var(--text-2); font-size: 13px; }

/* Dialogs */
dialog {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 0;
    box-sizing: border-box;
    /* Mobile-first: the dialog fills the screen with a uniform margin (native
       <dialog> centers itself via margin:auto). Desktop overrides below. */
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    height: calc(100dvh - 24px);
    max-height: calc(100dvh - 24px);
}
@media (min-width: 900px) {
    /* Desktop: size to content but never thinner than 640px; cap the height so
       tall forms scroll internally (the sticky title/footer stay put). */
    dialog {
        width: auto;
        min-width: 640px;
        /* Variable width, but never wider than 980px. */
        max-width: min(90vw, 980px);
        height: auto;
        max-height: 86vh;
    }
}
dialog::backdrop {
    background: rgba(0,0,0,0.8);
	backdrop-filter: blur(1px);
}
/* Three-part dialog: a FIXED header, a SCROLLABLE middle (.dialog-body) and a
   FIXED footer (menu). The dialog itself never scrolls — only .dialog-body does.
   The dialog is a flex column so the form fills it even when its height is
   content-sized (desktop), letting the middle shrink and scroll under max-height.
   Scoped to form-based dialogs so the dynamic list dialogs (.filelist-dialog,
   .files-dialog) keep their own layout untouched. */
/* Only when OPEN — otherwise `display: flex` would override the UA's
   `dialog:not([open]) { display: none }` and the dialog would show permanently. */
dialog[open]:has(> form) { display: flex; flex-direction: column; overflow: hidden; }
dialog > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding: 0;
    box-sizing: border-box;
}
/* The scrollable middle — the ONLY part that scrolls. min-height:0 lets it shrink
   inside the flex column so the fixed header/footer always stay visible. */
dialog .dialog-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    box-sizing: border-box;
}
dialog h3 { margin: 0 0 12px 0; font-size: 17px; }
dialog h4 { margin: 8px 0; font-size: 14px; color: var(--text-2); }
dialog section { padding: 8px 0; border-top: 1px solid var(--border); }
dialog section:first-of-type { border-top: 0; }
dialog label { display: block; padding: 4px 0; }
dialog input[type=radio], dialog input[type=checkbox] {
    accent-color: var(--user-orange);
    margin-right: 8px;
}
/* Fixed footer toolbar: a flex item at the bottom of the column, centered and
   always visible (it sits outside .dialog-body, so it never scrolls). */
dialog menu {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-shrink: 0;
    margin: 0;
    padding: 12px 16px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}
dialog button {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    font-family: var(--font-sans);
}
.btn-allow { background: var(--user-orange) !important; border-color: var(--user-orange) !important; }
.btn-deny  { background: var(--danger)   !important; border-color: var(--danger)   !important; color: white; }

/* Every text-like control inside a dialog reads dark (matches the theme). The
   per-field rules below add layout tweaks; this guarantees number inputs and any
   un-classed field don't fall back to the OS default white box. */
dialog input:not([type=checkbox]):not([type=radio]),
dialog textarea,
dialog select {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-family: var(--font-sans);
    font-size: 16px;   /* 16px avoids iOS zoom on focus */
    outline: none;
}
dialog input:not([type=checkbox]):not([type=radio]):focus,
dialog textarea:focus,
dialog select:focus { border-color: var(--user-orange); }

#perm-input {
    background: #0d0d0e;
    border-radius: 8px;
    padding: 10px;
    font-family: var(--font-mono);
    font-size: 12px;
    max-height: 240px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.presets {
    display: flex;
    gap: 6px;
    margin: 8px 0;
}
.presets button {
    flex: 1;
    padding: 6px 8px;
    font-size: 12px;
}

#tools-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
}
#tools-list label {
    font-size: 14px;
}

/* Model radios in both settings dialogs: same two-line look as the composer
   model picker — short name on top, muted SDK tagline beneath. */
#settings-models .model-opt,
#scope-models .model-opt {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 0;
}
#settings-models .model-opt input[type=radio],
#scope-models .model-opt input[type=radio] {
    margin: 3px 0 0;          /* align with the first text line; drop the default right margin */
    flex-shrink: 0;
}
#settings-models .model-opt .mo-body,
#scope-models .model-opt .mo-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
#settings-models .model-opt .mo-sub,
#scope-models .model-opt .mo-sub {
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.3;
    color: var(--text-2);
}

.hint-global {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-2);
}
.pref-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 14px;
}
.pref-row input { margin-top: 3px; }
.pref-row small { color: var(--text-2); font-size: 12px; }
.pref-row kbd {
    font-family: var(--font-mono);
    font-size: 0.85em;
    padding: 1px 5px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bubble-a);
}

/* Fixed header: a flex item at the top of the column (it sits outside
   .dialog-body, so it never scrolls). Border spans edge to edge. */
dialog header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding: 10px 16px 10px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
/* Title takes the row; the close (✕) button sits on the RIGHT (order:1). */
dialog header h3 { margin: 0; flex: 1; order: 0; }
dialog header button.ic { order: 1; }
/* Permission dialog has no <header>; its <h3> is the fixed title, so it needs the
   side/top padding the form no longer provides (the <pre> sits in .dialog-body). */
#perm-dialog > form > h3 { padding: 16px 16px 0; }
.field { display: block; padding: 8px 0; }
.field > span {
    display: block;
    font-size: 13px;
    color: var(--text-2);
    margin-bottom: 4px;
}
.field input[type=text],
.field textarea {
    width: 100%;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-family: var(--font-sans);
    font-size: 16px;  /* 16px avoids iOS zoom on focus */
    resize: vertical;
    outline: none;
}
.field textarea { font-family: var(--font-mono); font-size: 13px; line-height: 1.45; }
.field input[type=text]:focus,
.field textarea:focus { border-color: var(--user-orange); }
.field input:disabled { opacity: 0.55; }
.form-error { color: var(--danger); font-size: 13px; margin: 8px 0 0; }

/* Notification settings block (project/session forms + global dialog). The
   <select> is themed to match the text inputs: native chrome removed and a
   custom caret drawn so it reads dark instead of the OS default white box. */
.notify-field select {
    width: 100%;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 32px 8px 10px;
    font-family: var(--font-sans);
    font-size: 16px;                /* 16px avoids iOS zoom on focus */
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%2398989f' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    background-size: 12px;
}
.notify-field select:focus { border-color: var(--user-orange); }
/* Themed dropdown list where the browser honours it (Firefox/Windows; macOS &
   iOS render the open list with system chrome regardless). */
.notify-field select option { background: var(--surface); color: var(--text); }
.notify-field .ntfy-topic { padding-top: 8px; }
.notify-field .ntfy-row { display: flex; gap: 6px; align-items: center; }
.notify-field .ntfy-row input[type=text] { flex: 1; }
.notify-field .ntfy-row .toolbar-btn { padding: 8px 10px; flex-shrink: 0; }
.hint { font-size: 12px; color: var(--text-2); margin: 6px 0 0; line-height: 1.4; }
.hint a { color: var(--user-orange); }
.notify-push-hint { color: var(--claude-orange); }

/* Notification-config bullet before the chat title (main view header):
   gray=off, blue=default, green=ntfy. */
.notify-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 7px;
    vertical-align: middle;
    flex-shrink: 0;
    background: var(--text-2);          /* off / unknown → gray */
}
.notify-dot.mode-default { background: var(--user-orange); }   /* blue */
.notify-dot.mode-ntfy { background: #5eead4; }            /* green */

/* Login screen */
.login-form {
    max-width: 320px;
    margin: 12vh auto 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.login-form h2 { margin: 0 0 4px; font-size: 20px; }
.login-form input {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 16px;  /* 16px avoids iOS zoom on focus */
    font-family: var(--font-sans);
    outline: none;
}
.login-form input:focus { border-color: var(--user-orange); }
.login-form button {
    padding: 12px;
    border: 0;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    color: white;
}
.login-form .form-error { margin: 0; }

/* hljs override for transparency inside bubbles */
.hljs { background: transparent !important; padding: 0 !important; }

/* ── Task 14 — file viewer ────────────────────────────────────────────────── */
.fv-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}
.fv-overlay[hidden] { display: none; }
.fv-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    padding-top: max(10px, env(safe-area-inset-top));
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}
.fv-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.fv-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fv-path {
    font-size: 11px;
    color: var(--text-2);
    font-family: var(--font-mono);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fv-path[hidden] { display: none; }
.fv-head .ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    color: var(--text);
    text-decoration: none;
    font-size: 22px;
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
}
.fv-head .ic:active { background: var(--border); }
.fv-body { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; }

/* image kind: fit by default; .zoomed shows natural size (scrollable). */
.fv-imgwrap {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 12px;
}
.fv-img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; }
.fv-imgwrap.zoomed { display: block; }
.fv-imgwrap.zoomed .fv-img { max-width: none; max-height: none; cursor: zoom-out; }

/* Image background toggle (transparency): checker → light → dark. The checker
   reveals black- and white-on-transparent images alike. The .fv-bg swatch in
   the header mirrors the current mode. */
.bg-checker {
    background-color: #2b2b2b;
    background-image:
        linear-gradient(45deg, #3c3c3c 25%, transparent 25%),
        linear-gradient(-45deg, #3c3c3c 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #3c3c3c 75%),
        linear-gradient(-45deg, transparent 75%, #3c3c3c 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.bg-light { background: #ffffff; }
.bg-dark { background: var(--bg); }
.fv-bg.bg-checker { background-size: 10px 10px; background-position: 0 0, 0 5px, 5px -5px, -5px 0; }

.fv-bg {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid var(--border);
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
}
.fv-bg[hidden] { display: none; }

/* text kind: line-number gutter + highlighted code. */
.fv-codewrap { height: 100%; overflow: auto; -webkit-overflow-scrolling: touch; }
.fv-code {
    display: flex;
    align-items: flex-start;
    min-height: 100%;
    min-width: 100%;
    width: max-content;
    background: #282c34;             /* atom-one-dark base, matches hljs theme */
    color: #abb2bf;
    font: 13px/1.5 var(--font-mono);
}
.fv-gutter {
    position: sticky;
    left: 0;
    flex-shrink: 0;
    padding: 12px 10px;
    text-align: right;
    white-space: pre;
    color: #5c6370;
    background: #282c34;
    border-right: 1px solid rgba(255, 255, 255, .08);
    user-select: none;
    -webkit-user-select: none;
}
.fv-pre { margin: 0; padding: 12px 14px; white-space: pre; }
.fv-code code.hljs { overflow: visible; }   /* let .fv-codewrap own the scroll */
.fv-loading, .fv-unsupported { padding: 16px; color: var(--text-2); }
.fv-note { padding: 8px 14px; color: var(--claude-orange); font-size: 12px; }
.fv-fallback-link { color: var(--accent); }
.fv-source.active, .fv-status.active { color: var(--user-orange); }

/* task 17 — backlog status table */
.st-summary { padding: 4px 4px 12px; color: var(--text-2); font-size: 12px; }
.st-table td { white-space: normal; vertical-align: top; }
.st-table .st-group { color: var(--text-2); font-size: 12px; white-space: nowrap; }
.st-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.st-chip.st-ok { background: rgba(52, 199, 89, .16); color: #49975a; }
.st-chip.st-wip { background: rgba(var(--claude-orange-rgb), .18); color: var(--claude-orange); }
.st-chip.st-pending { background: rgba(255, 255, 255, .08); color: var(--text-2); }
.st-chip.st-na { background: rgba(255, 255, 255, .05); color: var(--text-3, var(--text-2)); }
.st-chip.st-unknown { background: transparent; color: var(--text-3, var(--text-2)); }

/* task 26 — backlog/phase badges (sticky, bottom-left of the chat view) */
#backlog-badge {
    position: absolute;
    left: 12px;
    bottom: 200px;          /* mirrors #scroll-bottom */
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    pointer-events: none;  /* rows re-enable; empty area stays click-through */
}
#backlog-badge[hidden] { display: none; }
.bb-row {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0;
    background: #4a4a4d;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .55);
    overflow: hidden;
    cursor: pointer;
    max-width: min(70vw, 420px);
}
.bb-tag {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border: 0;
    background: var(--user-orange);
    color: #fff;
    font-weight: 800;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.bb-num {
    padding: 0 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.bb-name {
    display: none;
    border: 0;
    background: none;
    color: var(--text);
    font-size: 12px;
    padding: 0 4px 0 0;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.bb-name:hover { text-decoration: underline; }
.bb-row.open .bb-name { display: block; }
.bb-dot {
    flex-shrink: 0;
    width: 7px; height: 7px;
    border-radius: 50%;
    margin: 0 8px 0 2px;
    align-self: flex-end;
    margin-bottom: 5px;
}

/* task 23 — sidebar search */
#sidebar-search { display: flex; align-items: center; gap: 6px; padding: 0; flex-shrink: 0; }
#sidebar-search-input {
    flex: 1; min-width: 0; margin: -1px -1px -1px 0; z-index: 1;
    background: transparent; border: 1px solid var(--border); color: var(--text);
    padding: 12px; font-size: 14px; outline: none;
    -webkit-appearance: none; appearance: none;
}
#sidebar-search-input::placeholder { color: var(--text-3, var(--text-2)); }
#sidebar-search-input:focus { border-color: var(--search-purp); }
.session-card.search-hidden { display: none; }
.search-status, .search-head, .search-hint { padding: 10px 14px; color: var(--text-2); font-size: 13px; }
.search-hint { color: var(--text-3, var(--text-2)); font-size: 12px; border-bottom: 1px solid var(--border); }
.search-snippet { font-size: 12px; color: var(--text-2); margin: 2px 0; line-height: 1.4; }
/* Result-card icon (left) + the term highlight in snippets and in-chat slices all
   use the search accent. */
.session-card.search-result .search-ic { color: var(--search-purp); font-size: 26px; line-height: 1; flex-shrink: 0; margin-top: -2px; }
.search-snippet mark,
mark.search-hit { background: rgba(var(--search-purp-rgb), .75); border-bottom: 3px solid var(--search-pink); color: var(--text); border-radius: 2px; padding: 0 1px; }

/* phases/rounds — expandable sub-rows under a task (task 24-adjacent) */
.st-table tr.st-haschild { cursor: pointer; }
.st-table .st-caret {
    background: none; border: 0; padding: 0; margin-right: 4px; cursor: pointer;
    color: var(--text-2); vertical-align: middle; line-height: 1;
}
.st-table .st-caret .material-symbols-outlined {
    font-size: 18px; display: inline-block; transition: transform .15s;
}
.st-table tr.st-open .st-caret .material-symbols-outlined { transform: rotate(90deg); }
.st-table .st-phasecount {
    display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 999px;
    font-size: 11px; white-space: nowrap;
    color: var(--text-3, var(--text-2)); background: rgba(255, 255, 255, .06);
}
.st-table .st-subrow > td { background: rgba(255, 255, 255, .02); }
.st-table .st-subrow .st-subname { padding-left: 26px; color: var(--text-2); font-size: 12px; }

/* task 17 — markdown render */
.fv-markdown { padding: 16px 18px; max-width: 900px; margin: 0 auto; line-height: 1.6; }
.fv-markdown h1, .fv-markdown h2, .fv-markdown h3 { line-height: 1.25; margin: 1.2em 0 .5em; }
.fv-markdown h1 { font-size: 1.5em; }
.fv-markdown h2 { font-size: 1.3em; }
.fv-markdown h3 { font-size: 1.12em; }
.fv-markdown p, .fv-markdown ul, .fv-markdown ol { margin: .5em 0; }
.fv-markdown li { margin: .2em 0; }
.fv-markdown a { color: var(--accent); }
.fv-markdown code { font-family: var(--font-mono); font-size: .92em; background: var(--bubble-a); padding: 1px 5px; border-radius: 4px; }
.fv-markdown pre { background: #282c34; padding: 12px; border-radius: 8px; overflow: auto; }
.fv-markdown pre code { background: transparent; padding: 0; }
.fv-markdown blockquote { margin: .6em 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--text-2); }
.fv-markdown table { border-collapse: collapse; width: 100%; margin: .8em 0; }
.fv-markdown th, .fv-markdown td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.fv-markdown th { background: var(--surface); font-weight: 600; }
.fv-markdown img { max-width: 100%; height: auto; }

/* task 17 — csv/tsv table */
.fv-tablewrap { padding: 12px; overflow: auto; }
.fv-table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 13px; }
.fv-table th, .fv-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; white-space: pre; }
.fv-table th { background: var(--surface); font-weight: 600; position: sticky; top: 0; }
.fv-table tbody tr:nth-child(even) { background: rgba(255, 255, 255, .03); }

/* file bubble (task 14) — orange ext square + name/mime/path. */
.file-bubble {
    display: flex;
    align-items: stretch;
    gap: 0;
    width: 100%;
    text-align: left;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    margin: 6px 0;
}
.file-bubble:active { filter: brightness(1.15); }
.file-bubble-type {
    flex-shrink: 0;
    width: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--claude-orange);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .5px;
}
.file-bubble-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    padding: 8px 12px;
    background: var(--bubble-a);   /* light-gray panel behind the asset data */
}
.file-bubble-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-bubble-sub { font-size: 11px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-bubble-mime { font-size: 11px; color: var(--text-2); }
.file-bubble-path {
    font-size: 11px;
    color: var(--text-3, var(--text-2));
    font-family: var(--font-mono);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* clickable file path inside tool-call cards. */
.tc-note.tc-path {
    cursor: pointer;
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
}
.tc-note.tc-path:active { color: var(--user-orange); }

/* assets dialog (filelist). */
.filelist-dialog {
    width: min(880px, calc(100vw - 24px));
    max-height: 84vh;
    padding: 0;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}
.filelist-dialog::backdrop { background: rgba(0, 0, 0, .6); }
.filelist-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}
.filelist-head h3 { margin: 0; font-size: 16px; flex: 1; }
.filelist-body { padding: 12px; overflow: auto; max-height: calc(84vh - 56px); }
.filelist-empty { color: var(--text-2); padding: 8px; }
/* view toggle: cards = responsive grid of tiles; list = stacked compact rows. */
.filelist-body.view-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 10px; }
.filelist-body.view-cards .file-bubble { margin: 0; height: 100%; }
.filelist-body.view-list .file-bubble-type { width: 42px; font-size: 10px; }
.filelist-body.view-list .file-bubble-meta { padding: 5px 12px; }
.filelist-body.view-list .file-bubble-path { display: none; }

/* ===== Task 21 — usage panel + budget gauge ===== */

/* Settings: small explanatory note above a field group. */
.field-note { margin: 2px 0 8px; font-size: 12px; color: var(--text-2); }
.field-note small { color: var(--text-3); }

/* The "Uso" dialog: wider, scrollable, header matches the other dialogs. */
#usage-dialog { width: 640px; }
#usage-dialog header {
    display: flex; align-items: center; gap: 8px;
    padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
#usage-dialog header h3 { margin: 0; flex: 1; }
.usage-loading { padding: 24px 8px; color: var(--text-2); text-align: center; }

.usage-card { padding: 12px 0; border-top: 1px solid var(--border); }
.usage-card:first-of-type { border-top: 0; }
.usage-card-head { display: flex; align-items: baseline; gap: 8px; }
.usage-card-head h4 { margin: 0; font-size: 14px; color: var(--text); }
.usage-sub { margin-left: auto; font-size: 11px; color: var(--text-2); }

.usage-total { display: flex; align-items: baseline; gap: 6px; margin: 8px 0 6px; }
.usage-total .ut-num { font-size: 26px; font-weight: 800; line-height: 1; }
.usage-total .ut-unit { font-size: 12px; color: var(--text-2); }
.usage-total .ut-cost { margin-left: auto; font-size: 13px; color: var(--text-2); }
.usage-total .ut-cost small { font-size: 10px; opacity: .7; }

.usage-teto { margin: 6px 0 8px; }
.usage-plan .usage-teto { margin: 10px 0 6px; }
.usage-plan .usage-teto .usage-card-head h4 { font-size: 13px; font-weight: 600; color: var(--text-2); }
.usage-bar {
    height: 8px; border-radius: 6px; overflow: hidden;
    background: var(--bubble-a);
}
.usage-bar > span {
    display: block; height: 100%; border-radius: 6px;
    background: var(--user-orange); transition: width .3s ease;
}
.usage-bar.warn > span { background: #f04f00; }
.usage-bar.over > span { background: var(--danger); }
.usage-teto-cap { margin-top: 3px; font-size: 11px; color: var(--text-2); font-family: var(--font-mono); }

.usage-breakdown { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.usage-breakdown b { color: var(--text); font-variant-numeric: tabular-nums; }

.usage-models { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.usage-model-row {
    display: flex; gap: 8px; font-size: 12px; color: var(--text-2);
    font-family: var(--font-mono);
}
.usage-model-row .um-name { flex: 1; color: var(--text); font-family: var(--font-sans); }
.usage-model-row .um-cost { width: 64px; text-align: right; }

.usage-note { margin: 12px 0 0; font-size: 11px; color: var(--text-3); line-height: 1.4; }

/* Floating budget gauge in the turn-bar: 40×2px, right-aligned under the token
   labels. Hidden unless a teto is configured (toggled in chat.js). */
#turn-budget {
    width: 8vw; min-width:80px; height: 3px; margin: 0 0 6px auto; border-radius: 2px;
    background: var(--bubble-a); overflow: hidden;
}
#turn-budget[hidden] { display: none; }
#turn-budget .tb-fill {
    display: block; height: 100%; width: 0;
    background: var(--claude-orange); transition: width .3s ease;
}
#turn-budget.warn .tb-fill { background: #f04f00; }
#turn-budget.over .tb-fill { background: var(--danger); }
