:root {
  --bg: #fafaf8;
  --pane: #ffffff;
  --border: #e5e3df;
  --text: #1f1d1a;
  --muted: #807a72;
  --accent: #b8541d;
  --accent-soft: #f7ecdf;
  --user-bg: #eef4ff;
  --user-border: #c5d6f5;
  --assistant-bg: #ffffff;
  --tool-bg: #f3f1ec;
  --tool-border: #d9d4cb;
  --error-bg: #fdecec;
  --error-border: #f0b4b4;
  --code-bg: #2b2a26;
  --code-text: #f5f1e8;
  --user-accent: #2c5fb6;
  --code-inline-bg: rgba(0, 0, 0, 0.06);
  --hl-bg: #ffe28a;
  --hl-text: #1f1d1a;
  --hl-current-bg: #ffb347;
  --danger: #c0392b;
  --danger-strong: #a93226;
  --danger-soft: #fdecec;
}

:root[data-theme="dark"] {
  --bg: #1a1917;
  --pane: #242320;
  --border: #38362f;
  --text: #ece8e1;
  --muted: #9b948a;
  --accent: #e07b43;
  --accent-soft: #392a1d;
  --user-bg: #1d2733;
  --user-border: #33455f;
  --assistant-bg: #242320;
  --tool-bg: #2a2823;
  --tool-border: #3d3a33;
  --error-bg: #3a2120;
  --error-border: #6a3a38;
  --code-bg: #141310;
  --code-text: #f3efe7;
  --user-accent: #74a7ff;
  --code-inline-bg: rgba(255, 255, 255, 0.09);
  --hl-bg: #e0a93c;
  --hl-text: #1a1917;
  --hl-current-bg: #ff9e2c;
  --danger: #e06b5c;
  --danger-strong: #c0392b;
  --danger-soft: #3a2120;
}

* { box-sizing: border-box; }

/* Accent-tinted scrollbars so they sit with the layout instead of the OS default. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 6px;
  border: 2px solid var(--pane);
}
::-webkit-scrollbar-thumb:hover { background: var(--accent-strong, var(--accent)); filter: brightness(1.12); }
::-webkit-scrollbar-corner { background: transparent; }

html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  display: grid;
  grid-template-columns: 260px 320px 1fr;
  grid-template-rows: 1fr auto;
  height: 100vh;
}
.pane {
  background: var(--pane);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#transcript { border-right: none; position: relative; }

.msg-nav {
  position: absolute;
  bottom: 28px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 20;
}
.msg-nav-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--pane);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0.7;
  transition: opacity 0.1s, border-color 0.1s, color 0.1s;
}
.msg-nav-btn:hover {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
}

.pane > header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.pane h1, .pane h2 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}
.muted { color: var(--muted); font-size: 12px; }

/* The transcript title doubles as the rename affordance once a session is open:
   click it to edit. The pencil hints at it on hover. */
#transcript-title { flex: 1; min-width: 0; }
#transcript-title.editable { cursor: text; }
#transcript-title.editable:hover { color: var(--text); }
#transcript-title.editable::after {
  content: " ✎";
  font-size: 0.85em;
  opacity: 0;
  transition: opacity 0.1s;
}
#transcript-title.editable:hover::after { opacity: 0.7; }

/* Projects header is two rows so the 6 action buttons never overlap the title
   when the column narrows (same fix as the sessions header). */
#projects > header { flex-direction: column; align-items: stretch; gap: 8px; }
.phead-title { display: flex; align-items: center; gap: 7px; }
.phead-title .brand-mark { flex: 0 0 auto; width: 22px; height: 22px; filter: drop-shadow(0 0 4px rgba(224, 123, 67, 0.45)); }
.phead-title h1 { flex: 1; min-width: 0; }
#projects .header-actions .hgap { flex: 1; }

/* Sessions header is two rows: the (possibly long) project name on top, the
   button toolbar below — so a long name never collides with the buttons. */
#sessions > header { flex-direction: column; align-items: stretch; gap: 8px; }
.shead-title { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
#sessions-title { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#sessions-count { flex: 0 0 auto; }
.shead-tools { display: flex; align-items: center; gap: 5px; }
/* Thin divider between the create/sort cluster and labels/topics/memória. */
.shead-tools .shead-gap { width: 1px; height: 16px; background: var(--border); margin: 0 2px; flex: 0 0 auto; }

/* Sessions-header overflow menu (⋯) — rare actions live here so the bar stays short. */
.overflow-wrap { position: relative; display: inline-flex; }
.overflow-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
  min-width: 210px; padding: 5px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--pane); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  display: flex; flex-direction: column; gap: 2px;
}
.overflow-menu .icon-btn {
  width: 100%; height: auto; justify-content: flex-start;
  gap: 10px; padding: 8px 10px; border: none; background: none; border-radius: 6px;
}
.overflow-menu .icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.overflow-menu .icon-btn svg { flex: 0 0 auto; }
.overflow-menu .ov-label { font-size: 13px; white-space: nowrap; }
/* Count badge sits inline at the row's right edge inside the menu. */
.overflow-menu .todos-count {
  position: static; margin-left: auto;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
}

/* Generic visibility helper for the resume/terminal controls. */
.hidden { display: none !important; }

/* ── Collapsible left columns (desktop "focus mode") ─────────────────────────
   A « in the projects/sessions header collapses that column to a 40px rail with
   a » expand button + vertical label; state persists in localStorage. Only on
   wide screens (>960px); below that the drawer / drill-down layout governs, so
   the collapse classes are inert there (see the responsive blocks). */
.pane-rail { display: none; }
.collapse-btn { margin-left: 2px; }
@media (min-width: 961px) {
  body[data-collapse-projects] { grid-template-columns: 40px 320px 1fr; }
  body[data-collapse-sessions] { grid-template-columns: 260px 40px 1fr; }
  body[data-collapse-projects][data-collapse-sessions] { grid-template-columns: 40px 40px 1fr; }

  body[data-collapse-projects] #projects > header,
  body[data-collapse-projects] #project-search,
  body[data-collapse-projects] #project-list { display: none; }
  body[data-collapse-projects] #projects .pane-rail { display: flex; }

  body[data-collapse-sessions] #sessions > header,
  body[data-collapse-sessions] #sessions > #session-tabs,
  body[data-collapse-sessions] #session-search,
  body[data-collapse-sessions] #tag-filter-bar,
  body[data-collapse-sessions] #session-list { display: none; }
  body[data-collapse-sessions] #sessions .pane-rail { display: flex; }

  .pane-rail {
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    height: 100%;
  }
  .rail-expand {
    width: 28px; height: 28px;
    border: 1px solid var(--border); border-radius: 7px;
    background: var(--pane); color: var(--muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex: none;
    transition: color 0.1s, border-color 0.1s;
  }
  .rail-expand:hover { color: var(--accent); border-color: var(--accent); }
  /* ⚡ live indicator on the rail — the only one visible when projects is collapsed. */
  .rail-live {
    position: relative;
    width: 28px; height: 28px;
    border: 1px solid var(--border); border-radius: 7px;
    background: var(--bg); color: var(--muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex: none;
    transition: color 0.1s, border-color 0.1s;
  }
  .rail-live:hover { color: var(--accent); border-color: var(--accent); }
  .rail-live.live-here { color: #3fb950; border-color: #3fb950; background: rgba(63, 185, 80, 0.14); }
  .rail-live.live-elsewhere { color: #d29922; border-color: #d29922; background: rgba(210, 153, 34, 0.14); }
  .rail-live-count {
    position: absolute; top: -6px; right: -6px;
    min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px;
    background: var(--accent); color: #fff;
    font: 700 9px/15px ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center;
  }
  .rail-live.live-here .rail-live-count { background: #3fb950; color: #10240f; }
  .rail-live.live-elsewhere .rail-live-count { background: #d29922; color: #241a05; }
  /* Sessions-rail badge buttons (📌 tópicos · 🧠 memória · 🗒 notas). */
  .rail-badge-btn {
    position: relative;
    width: 28px; height: 28px;
    border: 1px solid var(--border); border-radius: 7px;
    background: var(--bg); color: var(--muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex: none;
    transition: color 0.1s, border-color 0.1s;
  }
  .rail-badge-btn:hover { color: var(--accent); border-color: var(--accent); }
  .rail-label {
    writing-mode: vertical-rl;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--muted); user-select: none;
  }
  /* When showing the active session/project title (not the generic label). */
  .rail-label.active {
    color: var(--accent); text-transform: none; letter-spacing: 0.03em; font-size: 11px;
    max-height: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
}
.rail-live[hidden], .rail-badge-btn[hidden] { display: none; }

/* Breadcrumb (project name) above the transcript title — surfaces the project
   identity that's lost when the projects column is collapsed (focus mode). */
.transcript-project { display: none; }
@media (min-width: 961px) {
  body[data-collapse-projects] #transcript-project:not(:empty) {
    display: block;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--accent); margin-bottom: 2px;
  }
  body[data-collapse-projects] #transcript-project:not(:empty)::after {
    content: " ›"; opacity: 0.55;
  }
}

/* ── Project groups (collapsible, user-defined sections in the projects column) ── */
.group-head {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 8px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 9.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted); cursor: pointer; user-select: none; border-radius: 7px;
}
.group-head:hover { background: var(--bg); }
.group-head .gchev { font-size: 9px; width: 10px; flex: none; transition: transform 0.12s; }
.group-head.collapsed .gchev { transform: rotate(-90deg); }
.group-head .gdot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.group-head .gname { color: var(--ink-2, var(--text)); font-size: 10px; letter-spacing: 0.06em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-head .gcount { font-family: inherit; font-size: 9px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; color: var(--muted); flex: none; }
.group-head .gmore { margin-left: auto; opacity: 0; color: var(--muted); font-size: 14px; line-height: 1; padding: 0 4px; flex: none; }
.group-head:hover .gmore { opacity: 0.65; }
.group-head .gmore:hover { opacity: 1; color: var(--accent); }
.group-head.drop-target { background: var(--accent-soft); outline: 1.5px dashed var(--accent); outline-offset: -1px; }
.proj-sect.drop-target { background: var(--accent-soft); outline: 1.5px dashed var(--accent); outline-offset: -1px; border-radius: 7px; }
.project-list-item.in-group { margin-left: 10px; }
.project-list-item.dragging { opacity: 0.45; }
/* Move-to-group row action (revealed on hover, left of the favorite star). */
.proj-move {
  position: absolute; top: 8px; right: 38px;
  width: 22px; height: 22px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--pane); color: var(--muted);
  display: none; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
}
.proj-move svg { display: block; }
li[data-id]:hover .proj-move { display: flex; }
.proj-move:hover { color: var(--accent); border-color: var(--accent); }

/* Move-to-group picker (inside the modal). */
.grp-picker { display: flex; flex-direction: column; gap: 8px; }
.grp-opt {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px;
  font-size: 13px; cursor: pointer;
}
.grp-opt:hover { border-color: var(--accent); }
.grp-opt.on { border-color: var(--accent); background: var(--accent-soft); }
.grp-opt input { accent-color: var(--accent); margin: 0; }
.grp-opt .gdot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.grp-opt.grp-new { color: var(--accent); border-style: dashed; font-weight: 600; }
.grp-opt.grp-new .gplus { display: inline-flex; }
.grp-opt.grp-new .gplus svg { width: 14px; height: 14px; }
/* Group colour swatches (manage modal). */
.grp-swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.grp-swatch {
  width: 24px; height: 24px; border-radius: 7px; cursor: pointer;
  border: 2px solid transparent; padding: 0;
}
.grp-swatch.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--pane) inset; }
.grp-delete {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  margin-top: 6px; padding: 8px 12px; border-radius: 8px;
}

/* Transcript header gains a view toggle + resume button on the right; the
   title/meta become a single flex block on the left. Center-align so the
   segmented toggle and button sit neatly beside the text. */
#transcript > header { align-items: center; }
.transcript-head-text {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  overflow: hidden;
}
.transcript-head-text #transcript-meta { white-space: nowrap; }

/* Segmented Transcript|Terminal control (mirrors #session-tabs). */
/* Transcript-header controls are now uniform icon buttons (.icon-btn). The view
   toggle is two icon tabs; the active one gets the accent fill. */
.view-toggle { display: flex; gap: 4px; flex: none; }
.view-toggle .view-tab {
  width: 28px; height: 28px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--muted); border-radius: 6px; cursor: pointer;
}
.view-toggle .view-tab svg { display: block; }
.view-toggle .view-tab:hover { border-color: var(--accent); color: var(--accent); }
.view-toggle .view-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.resume-btn { flex: none; }
#tools-filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Danger icon button (terminate session). */
.icon-btn.danger { color: var(--danger); border-color: #f0c2bc; }
.icon-btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

#transcript-body.hide-tools .msg.tool { display: none; }

/* Live terminal fills the pane under the header. */
#terminal-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#terminal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}
/* flex:1 so the action buttons cluster to the RIGHT instead of being spread by
   the toolbar's space-between. */
#terminal-toolbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.tstatus { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; min-width: 0; }
.tstatus #terminal-status { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tdot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.tdot.on { background: #34c759; }
.tdot.warn { background: #c98a1d; }
.tdot.off { background: var(--muted); }
/* reattach warning: the live process kept its original flags (see ↻ relaunch). */
.reattach-chip {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  font-size: 10.5px; font-weight: 600;
  color: #9a6a12; background: var(--accent-soft);
  border: 1px solid #e8d3a6; border-radius: 999px; padding: 1px 8px;
  cursor: help;
}
:root[data-theme="dark"] .reattach-chip { color: #e0a93c; border-color: #5a4423; }
/* copy hint collapses to a small icon; the how-to lives in its tooltip. */
#terminal-copy-hint {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 6px;
  color: var(--muted); cursor: help; flex: none;
}
#terminal-copy-hint:hover { color: var(--accent); background: var(--accent-soft); }
#terminal-copy-hint svg { display: block; }
#terminal-host {
  flex: 1;
  min-height: 0;
  padding: 6px 4px 6px 8px;
  background: #1a1917;
  overflow: hidden;
}
/* xterm fills its host. */
#terminal-host .xterm,
#terminal-host .xterm-viewport { height: 100% !important; }

/* ── Detach the terminal into a floating window ───────────────────────────── */
/* Placeholder shown in the pane while the terminal is floating/PiP. */
#terminal-detached {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    repeating-linear-gradient(45deg, var(--pane), var(--pane) 12px, var(--bg) 12px, var(--bg) 24px);
}
#terminal-detached .td-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
}
#terminal-detached p { margin: 0; font-size: 13px; }

/* In-page floating shell (fallback A). position:fixed so it overlays the layout;
   moved geometry is persisted in localStorage. */
#terminal-float {
  position: fixed;
  z-index: 60;
  width: 720px;
  height: 460px;
  top: 90px;
  right: 28px;
  display: flex;
  flex-direction: column;
  background: var(--term-bg, #1a1917);
  border: 1px solid #000;
  border-radius: 10px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.42);
  overflow: hidden;
}
#terminal-float-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: #2a2823;
  color: #cfc8bb;
  font-size: 12px;
  cursor: move;
  user-select: none;
  border-bottom: 1px solid #000;
}
#terminal-float-head .tf-grip { color: #6b655c; }
#terminal-float-head .tf-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#terminal-float-head .tf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 22px;
  border: 1px solid #4a463f;
  border-radius: 5px;
  background: transparent;
  color: #cfc8bb;
  cursor: pointer;
}
#terminal-float-head .tf-btn:hover { border-color: var(--accent); color: var(--accent); }
#terminal-float-head .tf-btn.danger { color: #e2a09a; border-color: #5a2a28; }
#terminal-float-head .tf-btn.danger:hover { color: var(--danger); border-color: var(--danger); background: #3a1f1d; }
#terminal-float-head .tf-status { font-size: 11px; color: var(--muted); margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
#terminal-float-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* the moved per-terminal host fills the float/pip body */
#terminal-float-body > .term-host { flex: 1; min-height: 0; }
/* A terminal's own xterm host — the unit moved between pane ⇄ float on detach. */
.term-host { height: 100%; width: 100%; min-height: 0; }
.term-host .xterm, .term-host .xterm-viewport { height: 100% !important; }

/* ── Session summary view (heuristic timeline) ─────────────────────────────── */
#summary-view { flex: 1; min-height: 0; overflow: auto; background: var(--bg); }
.sum-wrap { padding: 14px 18px; width: 100%; }
.sum-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sum-title { font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); flex: 1; }
.sum-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.sum-chip { font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 5px 8px; border-radius: 7px; background: var(--pane); border: 1px solid var(--border); color: var(--muted); }
.sum-chip b { color: var(--text); }
.sum-chip.err { color: #ef7b72; border-color: #5a2a28; }
.sum-chip.cost { color: var(--accent); border-color: #5a3b27; }
/* timeline */
.sum-tl { display: flex; flex-direction: column; }
.sum-ti { position: relative; padding: 9px 8px 9px 22px; border-radius: 8px; cursor: pointer; }
.sum-ti:hover { background: var(--pane); }
.sum-ti::before { content: ""; position: absolute; left: 6px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--user-accent); box-shadow: 0 0 0 3px rgba(116, 167, 255, 0.15); }
.sum-ti::after { content: ""; position: absolute; left: 9.5px; top: 22px; bottom: -9px; width: 1px; background: var(--border); }
.sum-ti:last-child::after { display: none; }
.sum-ti .sum-t { font: 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.sum-ti .sum-q { font-size: 13px; color: var(--text); margin: 2px 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum-ti .sum-bdg { display: flex; gap: 8px; font: 600 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.sum-ti .sum-bdg .e { color: #ef7b72; }
.sum-ins { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.sum-ins-h { font: 600 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.08em; text-transform: uppercase; color: #5fc27e; margin-bottom: 7px; }
.sum-ins ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text); }
.sum-ins li { margin-bottom: 4px; }
/* brief highlight when jumping to a turn from the timeline */
.msg.flash { animation: msgflash 1.2s ease-out; }
@keyframes msgflash {
  0%, 30% { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); border-radius: 8px; }
  100% { background: transparent; box-shadow: none; }
}
#terminal-float-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 50%, #6b655c 50%, #6b655c 60%, transparent 60%, transparent 70%, #6b655c 70%, #6b655c 80%, transparent 80%);
}

/* Document PiP window body (styles are copied into the PiP document). */
.pip-body { margin: 0; height: 100vh; display: flex; flex-direction: column; background: #1a1917; }
.pip-body > .term-host { flex: 1; min-height: 0; }

@media (max-width: 960px) {
  #detach-btn { display: none !important; } /* floating only makes sense on desktop */
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}
.list li {
  position: relative;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.list li:hover { background: var(--accent-soft); }
.list li.active {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding-left: 13px;
}
/* Collapse + fade a row out in place (archive/delete) so the list closes the
   gap smoothly without a full re-render — keeps the scroll position. */
.list li.removing {
  overflow: hidden;
  opacity: 0;
  transform: translateX(-16px);
  pointer-events: none;
  padding-top: 0;
  padding-bottom: 0;
  border-bottom-width: 0;
  transition:
    max-height 0.28s ease,
    opacity 0.18s ease,
    transform 0.18s ease,
    padding 0.28s ease,
    border-bottom-width 0.28s ease;
}
.list .item-title {
  font-weight: 500;
  word-break: break-word;
  margin-bottom: 4px;
}
.list .item-sub {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
/* Session-row meta (Proposta C): line 2 = message counts + cost (right-aligned),
   line 3 = date/time on its own. */
.list .item-meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 3px;
}
.list .counts {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  font-variant-numeric: tabular-nums;
}
.list .cnt {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 600;
}
.list .cnt .ar { font-size: 10px; line-height: 1; }
.list .cnt.up .ar { color: var(--user-accent); }
.list .cnt.down .ar { color: var(--accent); }
.list .item-meta .cost { margin-left: auto; } /* push the value to the right edge */
.list .item-date { font-size: 10.5px; color: var(--muted); }
/* On hover the absolute action cluster appears top-right; reserve room so the
   title text reflows out from under it instead of being overlapped. */
.list li:hover .item-title { padding-right: 120px; }
.source-tag {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--bg);
}
.source-tag.source-win {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.rename-input {
  width: 100%;
  font: inherit;
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  padding: 3px 6px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--pane);
  color: var(--text);
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

#session-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 16px 0;
  background: var(--pane);
}
#session-tabs .tab {
  flex: 1;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
#session-tabs .tab:hover { border-color: var(--accent); }
#session-tabs .tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.item-actions {
  position: absolute;
  top: 8px;
  right: 10px;
  display: none;
  gap: 6px;
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 2px;
}
.list li:hover .item-actions { display: flex; }
.row-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--pane);
  color: var(--muted);
  cursor: pointer;
}
.row-btn svg { display: block; }
.row-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.row-btn.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}

#session-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--pane);
}
#session-search-input {
  flex: 1;
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  min-width: 0;
}
#session-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
#session-search-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
#session-search-status {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.snippet {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.4;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
.snippet-role {
  display: inline-block;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
  margin-right: 6px;
  color: var(--accent);
}
.snippet-role.user { color: var(--user-accent); }
.match-badge {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
}

.empty-badge {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 6px;
  border-radius: 10px;
  margin-right: 6px;
  vertical-align: middle;
}

/* Live-session dot: green = open in this FRIDAY, amber = running elsewhere.
   A soft pulse hints that the session is alive. */
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  flex: none;
}
.live-dot.live-here {
  background: #3fb950;
  box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.5);
  animation: live-pulse 2s ease-out infinite;
}
.live-dot.live-elsewhere {
  background: #d29922;
}
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.5); }
  70% { box-shadow: 0 0 0 5px rgba(63, 185, 80, 0); }
  100% { box-shadow: 0 0 0 0 rgba(63, 185, 80, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .live-dot.live-here { animation: none; }
}

.cost {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.cost-meta {
  cursor: help;
}

.cost-summary {
  max-width: none;
  margin: 0 0 20px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--pane);
}
.cost-summary .cs-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cost-summary .cs-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.cost-summary .cs-total {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.cost-summary table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.cost-summary td {
  padding: 4px 6px;
  border-top: 1px solid var(--border);
  vertical-align: top;
}
.cost-summary tr:first-child td { border-top: none; }
.cost-summary .cs-model {
  font-weight: 600;
  white-space: nowrap;
}
.cost-summary .cs-tokens {
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11.5px;
}
.cost-summary .cs-cost {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
}

mark.search-hit {
  background: var(--hl-bg);
  color: var(--hl-text);
  padding: 0 2px;
  border-radius: 2px;
}
mark.search-hit.current {
  background: var(--hl-current-bg);
  outline: 2px solid var(--accent);
}

/* In-pane find bar (transcript + resumo). */
.find-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-bottom: 1px solid var(--border); background: var(--pane);
}
.find-bar .find-ic { color: var(--muted); flex: none; }
.find-bar input {
  flex: 1; min-width: 0; font: inherit; font-size: 13px; padding: 5px 8px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); outline: none;
}
.find-bar input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.find-bar .find-count {
  font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted);
  flex: none; min-width: 36px; text-align: right;
}
.find-bar .icon-btn { width: 26px; height: 26px; }

#transcript-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  max-width: none;
}
.empty {
  color: var(--muted);
  text-align: center;
  margin-top: 80px;
}

.msg {
  margin: 0 0 16px;
  max-width: none;
  border-radius: 8px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  background: var(--pane);
}
.msg.user {
  background: var(--user-bg);
  border-color: var(--user-border);
}
.msg.assistant {
  background: var(--assistant-bg);
}
.msg.tool {
  background: var(--tool-bg);
  border-color: var(--tool-border);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
}
.msg.tool.error {
  background: var(--error-bg);
  border-color: var(--error-border);
}

.msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 8px;
}
.msg.user .msg-header { color: var(--user-accent); }
.msg.assistant .msg-header { color: var(--accent); }

.msg-body { line-height: 1.55; word-wrap: break-word; }
.msg-body p { margin: 0.4em 0; }
.msg-body p:first-child { margin-top: 0; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 10px 12px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12.5px;
}
.msg-body code {
  background: var(--code-inline-bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.92em;
}
.msg-body pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}
.msg-body ul, .msg-body ol { margin: 0.4em 0; padding-left: 1.4em; }
.msg-body blockquote {
  border-left: 3px solid var(--border);
  margin: 0.6em 0;
  padding: 0.2em 0 0.2em 0.8em;
  color: var(--muted);
}
.msg-body a { color: var(--accent); }

.tool-name { color: var(--accent); }
details { margin-top: 4px; }
details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  user-select: none;
  padding: 2px 0;
}
details[open] summary { margin-bottom: 6px; }
details pre {
  background: var(--code-inline-bg);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.truncated-marker {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--pane);
  border: 1px solid var(--border);
  border-radius: 16px;
  /* Project accent as a top edge — ties every modal to the app's colour. */
  border-top: 3px solid var(--accent);
  padding: 0;
  max-width: 400px;
  width: calc(100% - 48px);
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
}
/* Header: title + always-present close (✕). The ✕ is the canonical dismiss —
   Escape and backdrop clicks are intentionally disabled (no accidental close). */
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-title svg { flex: none; color: var(--accent); margin-right: 4px; }
.modal-close {
  flex: none;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  transition: color 0.1s, border-color 0.1s, background 0.1s;
}
.modal-close:hover { color: var(--accent); border-color: var(--accent); }
.modal-close svg { display: block; }
.modal-body {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  padding: 16px 18px;
}
.modal.wide { max-width: 500px; }
.purge-intro { margin: 0 0 12px; }
.purge-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.purge-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.purge-list li:last-child { border-bottom: none; }
.purge-open {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}
.purge-open:hover { text-decoration: underline; }
.purge-kind {
  font-size: 9.5px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.purge-proj {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.purge-sid {
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
}
.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn.danger:hover { background: var(--danger-strong); border-color: var(--danger-strong); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { filter: brightness(1.06); }

/* Single-instance guard overlay — sits above everything (search 200, modal 100). */
.instance-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.instance-overlay.hidden { display: none; }
.instance-card {
  background: var(--pane);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px 26px;
  max-width: 420px;
  width: calc(100% - 48px);
  text-align: center;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}
.instance-card h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--text);
}
.instance-card p {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  margin: 0 0 20px;
}
.instance-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.gsearch-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  z-index: 200;
}
.gsearch-overlay.hidden { display: none; }
.gsearch {
  background: var(--pane);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 640px;
  max-width: calc(100% - 48px);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
}
#gsearch-input {
  font: inherit;
  font-size: 16px;
  padding: 14px 16px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--pane);
  color: var(--text);
  outline: none;
}
#gsearch-input:focus {
  border-bottom-color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.gsearch-status {
  padding: 6px 16px;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
}
.gsearch-status:empty { display: none; }
.gsearch-tagbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}
.gsearch-tagbar.hidden { display: none; }
.gsearch-results {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}
.gsearch-results li {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.gsearch-results li:last-child { border-bottom: none; }
.gsearch-results li.selected,
.gsearch-results li:focus,
.gsearch-results li:hover { background: var(--accent-soft); }
.gsearch-row-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}
.gsearch-project {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.gsearch-title {
  font-weight: 500;
  word-break: break-word;
  flex: 1;
}
.gsearch-date {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.gsearch-capped {
  padding: 8px 16px;
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  cursor: default;
}

.icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.1s, color 0.1s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Empty (deletable) projects: de-emphasised so the live ones read first. */
.list li.project-empty .item-title { color: var(--muted); font-style: italic; }

/* Projects filter — same component as the sessions search (#session-search). */
#project-search {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--pane);
}
#project-search input {
  flex: 1; font: inherit; font-size: 13px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); outline: none; min-width: 0;
}
#project-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* Favoritos / Recentes section labels (B). */
.list li.proj-sect {
  padding: 9px 12px 3px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); cursor: default; border-bottom: 0;
}
.list li.proj-sect:hover { background: transparent; }

/* Favorite star (B): always gold for favorites, faint+hover-revealed otherwise. */
.proj-star {
  position: absolute; top: 8px; right: 10px;
  width: 22px; height: 22px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer;
  color: var(--border); opacity: 0; transition: opacity 0.1s, color 0.1s;
}
.proj-star svg { display: block; }
.proj-star.on { color: #e0a93c; opacity: 1; }
.list li:hover .proj-star { opacity: 1; }
.proj-star:hover { color: #e0a93c; }

/* Launch dialogs (new session / new project / channel choice). */
.launch-form { display: flex; flex-direction: column; gap: 9px; }
.launch-form label { font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.launch-form .tag-input { width: 100%; font-size: 13px; border-radius: 8px; padding: 7px 10px; }
.launch-form select.tag-input { appearance: auto; }
.launch-check { display: flex; align-items: center; gap: 7px; font-family: var(--sans, inherit); font-size: 12.5px; text-transform: none; letter-spacing: 0; color: var(--text); }
.launch-check input { width: auto; }
.launch-note { font-size: 11.5px; color: var(--muted); margin: 2px 0 0; }

/* Global live-sessions indicator in the projects header. */
.live-btn { width: auto; padding: 0 9px; gap: 5px; }
/* .icon-btn's display:flex would otherwise beat the [hidden] attribute's
   display:none, leaving the button visible when no session is live. */
.live-btn[hidden] { display: none; }
/* Soft tinted pill so it reads as a status, not just an icon. Colours work on
   both themes (bright fg + translucent bg). */
.live-btn.live-here { color: #3fb950; border-color: #3fb950; background: rgba(63, 185, 80, 0.14); }
.live-btn.live-elsewhere { color: #d29922; border-color: #d29922; background: rgba(210, 153, 34, 0.14); }
/* The active-session count, shown as a clear bold number + label beside the icon
   ("2 ativas"), instead of a tiny hard-to-read badge. */
.live-count {
  font-size: 12.5px; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.live-count::after { content: " ativas"; font-weight: 600; font-size: 10.5px; opacity: 0.85; }
.live-count.one::after { content: " ativa"; }
/* Live-sessions modal list. */
.live-manager { display: flex; flex-direction: column; gap: 8px; }
.live-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px;
}
.live-meta { flex: 1; min-width: 0; }
.live-title { font-weight: 600; font-size: 13px; }
.live-sub {
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.live-actions { display: flex; gap: 6px; flex: none; }
/* Last-interaction column in the live-sessions modal. */
.live-when {
  flex: none; font-size: 11px; color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap;
}
/* Per-project group headers inside the live-sessions modal. */
.live-group {
  display: flex; align-items: center; gap: 8px; margin: 13px 4px 3px;
}
.live-group:first-child { margin-top: 2px; }
.live-group .lg-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.live-group .lg-dot.live-here { background: #3fb950; }
.live-group .lg-dot.live-elsewhere { background: #d29922; }
.live-group .lg-label {
  font-size: 12px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto;
}
.live-group .lg-line { flex: 1; height: 1px; background: var(--border); }
.live-group .lg-count {
  flex: none; padding: 2px 7px; border-radius: 9px;
  font: 600 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--accent-soft); color: var(--accent);
}

/* Project picker (move-chat modal). */
.pick-list { display: flex; flex-direction: column; gap: 6px; }
.pickrow {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.pickrow:hover { background: var(--accent-soft); }
.pickrow.act { background: var(--accent-soft); border-color: var(--accent); }
.pickrow .radio {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--muted); flex: none;
}
.pickrow.act .radio {
  border-color: var(--accent);
  background: radial-gradient(circle, var(--accent) 0 3px, transparent 4px);
}
.pick-title { font-weight: 600; font-size: 13px; }
.pick-sub { font-size: 11px; color: var(--muted); margin-left: 6px; }

/* Per-response "copiar para memória" button (in the assistant msg header). */
.msg.assistant .msg-header { display: flex; align-items: center; gap: 8px; }
.mem-btn {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-family: inherit;
  padding: 2px 8px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--pane); color: var(--muted);
  cursor: pointer; opacity: 0; transition: opacity 0.1s, border-color 0.1s, color 0.1s;
}
.msg.assistant:hover .mem-btn,
.mem-btn:focus-visible { opacity: 1; }
.mem-btn:hover { border-color: var(--accent); color: var(--accent); }
.mem-btn svg { display: block; }

/* Fork affordance on user messages (mirrors .mem-btn). */
.fork-btn {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-family: inherit;
  padding: 2px 8px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--pane); color: var(--muted);
  cursor: pointer; opacity: 0.55; transition: opacity 0.1s, border-color 0.1s, color 0.1s;
}
.msg.user:hover .fork-btn,
.fork-btn:focus-visible { opacity: 1; }
.fork-btn:hover { border-color: var(--accent); color: var(--accent); }
.fork-btn svg { display: block; }
/* Fork-point preview inside the fork modal. */
.fork-ctx {
  font-size: 12px; color: var(--muted);
  background: var(--bg); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; word-break: break-word;
}

/* Memória panel (saved snippets list). */
.notes-manager { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.note-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px;
}
.note-text {
  flex: 1; min-width: 0; font-size: 12.5px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.note-del {
  flex: none; border: none; background: none; color: var(--muted);
  font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px;
}
.note-del:hover { color: var(--danger); }

.header-actions { display: flex; align-items: center; gap: 6px; }
#restart-btn:disabled { cursor: default; opacity: 0.5; }
#restart-btn.spinning { animation: friday-spin 0.8s linear infinite; }
@keyframes friday-spin { to { transform: rotate(360deg); } }

/* Usage bar — bottom strip mirroring the CLI HUD's rate-limit windows (5h / 7d).
   Lives in the body grid's second row, spanning all three columns; collapses to
   nothing when hidden (stale or no cache). Data comes from /api/usage. */
.usage-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 7px 16px;
  border-top: 1px solid var(--border);
  background: var(--pane);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}
.usage-bar.hidden { display: none; }
.usage-seg {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.usage-seg .usage-label {
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent);
}
.usage-track {
  width: 90px;
  height: 6px;
  border-radius: 3px;
  background: var(--accent-soft);
  overflow: hidden;
  flex: none;
}
.usage-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}
.usage-seg.warn .usage-fill { background: #d9890f; }
.usage-seg.crit .usage-label,
.usage-seg.crit .usage-pct { color: var(--danger); }
.usage-seg.crit .usage-fill { background: var(--danger); }
/* Stale window (cached data is past its reset): dimmed + muted fill, help cursor
   to invite the explanatory tooltip. */
.usage-seg.stale { opacity: 0.5; cursor: help; }
.usage-seg.stale .usage-fill { background: var(--muted); }
.usage-pct { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.usage-reset { color: var(--muted); }
.usage-div { color: var(--border); }

/* ─── Mobile back button ─────────────────────────────────────────────────────
   A "‹ Voltar" affordance in the sessions/transcript headers. Hidden on desktop
   (the 3-pane grid is always visible there); shown only at the mobile breakpoint
   where one pane is visible at a time. */
.mobile-back {
  display: none;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 4px 8px;
  margin-right: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--accent);
  cursor: pointer;
  flex: none;
  white-space: nowrap;
}
.mobile-back:hover { border-color: var(--accent); }

/* ─── Tablet: collapse to 2 columns (sessions + transcript) ──────────────────
   The projects pane becomes an off-canvas drawer toggled by the same back
   button, which here reads "Projetos" and opens the drawer instead of doing a
   level change. */
@media (max-width: 960px) and (min-width: 641px) {
  body {
    grid-template-columns: 300px 1fr;
  }
  #projects {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -290px;
    width: 280px;
    z-index: 150;
    transition: left 0.2s ease;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.18);
  }
  body[data-drawer="open"] #projects { left: 0; }
  /* Backdrop behind the open drawer. */
  body[data-drawer="open"]::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 140;
  }
  #sessions { grid-column: 1; }
  #transcript { grid-column: 2; }
  /* The sessions header gets the drawer toggle. */
  #back-to-projects { display: inline-flex; align-items: center; }
}

/* ─── Phone: one pane at a time (drill-down) ─────────────────────────────────
   Projetos → Sessões → Transcrição/Terminal. body[data-mobile-level] decides
   which single pane is on screen; JS flips it as the user drills in / backs out. */
@media (max-width: 640px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  /* Every pane stacks into the single column / single row; only the active one
     is shown via the level attribute below. */
  #projects, #sessions, #transcript {
    grid-column: 1;
    grid-row: 1;
    border-right: none;
  }
  #projects, #sessions, #transcript { display: none; }
  body[data-mobile-level="projects"] #projects { display: flex; }
  body[data-mobile-level="sessions"] #sessions { display: flex; }
  body[data-mobile-level="transcript"] #transcript { display: flex; }

  /* Back buttons drive the drill-up. */
  body[data-mobile-level="sessions"] #back-to-projects { display: inline-flex; align-items: center; }
  body[data-mobile-level="transcript"] #back-to-sessions { display: inline-flex; align-items: center; }

  /* Headers: keep title + count/back on one tidy row. */
  .pane > header { flex-wrap: wrap; row-gap: 6px; padding: 12px 14px; }
  #transcript > header { gap: 6px; }
  .transcript-head-text { flex-basis: 100%; }
  /* The toggle/resume/tools controls wrap under the title on a narrow screen. */
  #transcript-view-toggle, #resume-btn, #tools-filter-btn { margin-top: 2px; }

  /* Modals + global search: hug the viewport edges. */
  .modal { width: calc(100% - 28px); max-width: none; }
  .gsearch-overlay { padding-top: 6vh; }
  .gsearch { width: calc(100% - 24px); max-width: none; max-height: 82vh; }
  #gsearch-input { font-size: 16px; } /* keeps iOS from zooming on focus */

  /* Cost summary + messages use the full width. */
  .cost-summary, .msg { max-width: none; }
  #transcript-body { padding: 16px 12px; }

  /* msg-nav: smaller and lifted above the usage bar so it never traps content
     or sits under the on-screen keyboard. */
  .msg-nav { bottom: 14px; right: 12px; gap: 4px; }
  .msg-nav-btn { width: 34px; height: 34px; opacity: 0.85; }

  /* Usage bar: allow it to wrap rather than clip on a tiny width. */
  .usage-bar { gap: 10px 14px; flex-wrap: wrap; white-space: normal; padding: 6px 12px; }
  .usage-track { width: 64px; }

  /* Header actions stay compact. */
  .header-actions { gap: 4px; }
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.tag-chip {
  font-size: 11px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  color: #fff;
  background: var(--tag, #666);
  white-space: nowrap;
}

.tag-popover {
  position: fixed;
  z-index: 300;
  width: 220px;
  background: var(--pane);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tag-popover.busy { pointer-events: none; opacity: 0.6; }
.tag-pop-list {
  display: flex;
  flex-direction: column;
  max-height: 240px;
  overflow-y: auto;
}
.tag-pop-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.tag-pop-item:hover { background: var(--accent-soft); }
.tag-pop-item input { margin: 0; cursor: pointer; }
.tag-pop-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.tag-pop-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-pop-empty {
  font-size: 11px;
  color: var(--muted);
  padding: 6px;
}
.tag-pop-new {
  border-top: 1px solid var(--border, #333);
  padding-top: 6px;
}
.tag-pop-new .tag-input { width: 100%; }
.tag-input {
  font-size: 11px;
  border: 1px solid var(--border, #444);
  border-radius: 999px;
  padding: 2px 8px;
  background: transparent;
  color: inherit;
  width: 80px;
}

#tag-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border, #333);
}
#tag-filter-bar.hidden { display: none; }
.gsearch-datebar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border, #333);
  font-size: 11px;
  color: var(--muted);
}
.gsearch-datebar.active {
  background: var(--accent-soft);
}
.date-filter-icon { font-size: 13px; line-height: 1; }
.date-filter-sep { color: var(--muted); }
.gsearch-datebar input[type="date"] {
  font-size: 11px;
  font-family: inherit;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border, #555);
  background: var(--bg);
  color: inherit;
  color-scheme: light dark;
}
.date-clear {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border, #555);
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.date-clear.hidden { display: none; }
.tag-filter-chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--tag, #666);
  color: var(--tag, #ccc);
  background: transparent;
  cursor: pointer;
}
.tag-filter-chip.active {
  background: var(--tag, #666);
  color: #fff;
}
.tag-mode {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border, #555);
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.label-manager { display: flex; flex-direction: column; gap: 10px; }
.label-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.label-row .tag-chip { min-width: 80px; text-align: center; }
.pal-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.pal-swatch {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; padding: 0;
}
.pal-swatch.active { border-color: var(--text, #fff); }
.label-forget {
  background: none; border: none; color: var(--danger, #ef4444);
  cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px;
}
.label-rename {
  background: none; border: none; color: var(--muted, #888);
  cursor: pointer; font-size: 13px; line-height: 1; padding: 0 2px;
  opacity: 0.6;
}
.label-rename:hover { opacity: 1; color: var(--text); }
.label-rename-input { min-width: 60px; }
.label-new { display: flex; gap: 6px; margin-top: 6px; }
.label-new .tag-input { width: auto; flex: 1; }
/* Corner badge — absolutely positioned so the 15px icon stays centred at full size
   inside the 28px button (in-flow it competed for width and shrank the icon). */
.todos-count {
  position: absolute; top: -5px; right: -5px;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: 8px; font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--accent, #3b82f6); color: #fff;
  border: 1.5px solid var(--pane); box-sizing: content-box;
}
/* The explicit display above otherwise overrides the [hidden] attribute's
   display:none, so an empty backlog would still show a "0" badge. */
.todos-count[hidden] { display: none; }
.todos-manager { display: flex; flex-direction: column; gap: 10px; }
.todo-list { display: flex; flex-direction: column; gap: 6px; }
.todo-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px;
  background: var(--accent-soft, rgba(127,127,127,0.08));
}
.todo-text { flex: 1; white-space: pre-wrap; word-break: break-word; font-size: 13px; }
.todo-start, .todo-del { flex: none; }
.todo-new { display: flex; gap: 8px; align-items: center; margin-top: 2px; }
.todo-new input { flex: 1; }

/* A .btn that pairs an icon with a label (Adicionar, Abrir, …). */
.btn-icon { display: inline-flex; align-items: center; gap: 6px; }
.btn-icon svg { display: block; }

/* 🧠 Memória do projeto panel */
.mem-panel { display: flex; flex-direction: column; gap: 6px; }
.mem-score { display: flex; align-items: center; gap: 12px; padding: 4px 2px 12px; }
.mem-ring {
  width: 46px; height: 46px; border-radius: 50%;
  background: conic-gradient(var(--accent, #d08b3a) calc(var(--pct) * 1%), #2a2e37 0);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.mem-ring span {
  width: 36px; height: 36px; border-radius: 50%; background: var(--panel, #16181d);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px;
}
.mem-score-meta { font-size: 13px; line-height: 1.5; }
.mem-rows { display: flex; flex-direction: column; }
.mem-row { display: flex; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid #23272f; }
.mem-row:last-child { border-bottom: none; }
.mem-main { flex: 1; min-width: 0; }
.mem-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.mem-sub { font-size: 11px; color: #8a8f99; margin-top: 2px; }
.mem-pill { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 20px; white-space: nowrap; }
.mem-ok { background: #16331f; color: #5fd089; }
.mem-warn { background: #3a2f12; color: #e0b24a; }
.mem-bad { background: #3a1a1a; color: #ef6b6b; }
.mem-delg { background: #1f2733; color: #6aa3e0; }
.mem-unknown { background: #2a2e37; color: #9aa0ab; }
.mem-treat { font-size: 12px; white-space: nowrap; }
.mem-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid #2a2e37; }
.mem-foot-note { margin-top: 8px; }

/* Backlog panel */
.bk-panel { display: flex; flex-direction: column; }
.bk-sec { font-size: 10px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase; color: #8a8f99; margin: 14px 0 6px; display: flex; align-items: center; gap: 8px; }
.bk-sec:first-child { margin-top: 2px; }
.bk-link { font-weight: 400; text-transform: none; letter-spacing: 0; color: #6aa3e0; cursor: pointer; }
.bk-rows { display: flex; flex-direction: column; }
.bk-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #23272f; font-size: 12px; }
.bk-item:last-child { border-bottom: none; }
.bk-item.bk-dim { opacity: .65; }
.bk-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk-meta { font-size: 11px; color: #8a8f99; white-space: nowrap; }
.bk-src { font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 5px; white-space: nowrap; }
.s-man { background: #1f2733; color: #6aa3e0; }
.s-mem { background: #3a2f12; color: #e0b24a; }
.s-repo { background: #23302a; color: #5fd089; }
.s-detect { background: #2a2030; color: #c98fd0; }
.s-plan { background: #2a2e37; color: #9aa0ab; }
.bk-empty { padding: 8px 0; }
.bk-new { display: flex; gap: 8px; margin: 6px 0 2px; }
.bk-new input { flex: 1; min-width: 0; }
.bk-footer { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid #2a2e37; }

/* --- Workspace files: links, file chips, preview, terminal drop -------------- */

/* A: transcript links open in a new tab — mark them with a small ↗. */
.msg-body a[target="_blank"]::after,
.fp-md a[target="_blank"]::after { content: "↗"; font-size: 0.78em; margin-left: 2px; opacity: 0.6; }

/* B: file chip rendered for each Write/Edit the claude run produced. */
.filechip {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 9px;
  padding: 7px 9px; margin: 8px 0 0; font-family: system-ui, -apple-system, sans-serif;
}
.filechip .fc-ic {
  width: 30px; height: 30px; flex: none; border-radius: 7px;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.filechip .fc-meta { min-width: 0; flex: 1; }
.filechip .fc-fn {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.filechip .fc-det { font-size: 11px; color: var(--muted); }
.filechip .fc-acts { display: flex; gap: 6px; flex: none; }
.filechip.pending .fc-acts { opacity: 0.4; pointer-events: none; }
.filechip.missing { opacity: 0.55; }
.filechip.missing .fc-acts { display: none; }
.fc-acts .fc-dl { text-decoration: none; }

/* Inline image thumbnail (sits right after its chip). */
.fc-thumb {
  display: block; margin: 8px 0 0; max-width: min(320px, 100%); max-height: 220px;
  border: 1px solid var(--border); border-radius: 9px; cursor: zoom-in; object-fit: contain;
}

/* B: file preview in the modal shell. */
.fp-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.fp-bar .fp-size { font-size: 12px; color: var(--muted); }
.fp-bar .btn { margin-left: auto; }
.fp-img { text-align: center; }
.fp-img img { max-width: 100%; max-height: 70vh; border-radius: 8px; }
.fp-pre {
  margin: 0; padding: 12px 14px; background: var(--code-bg); color: var(--code-text);
  border-radius: 8px; font-size: 12.5px; max-height: 65vh; overflow: auto; white-space: pre-wrap;
  word-break: break-word;
}
.fp-md { max-height: 65vh; overflow: auto; }

/* C: terminal drop target highlight. */
.term-host { position: relative; }
.term-host.drag-over { outline: 2px dashed var(--accent); outline-offset: -6px; }
.term-host.drag-over::after {
  content: "⇣  Larga para partilhar com a sessão"; position: absolute; inset: 0;
  display: grid; place-items: center; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent); font: 600 14px system-ui, -apple-system, sans-serif; z-index: 5;
}
#terminal-host { position: relative; }

/* --- Artifacts tray panel (files & links) ----------------------------------- */
.artifacts { display: flex; flex-direction: column; gap: 4px; }
.art-sec { margin-top: 12px; }
.art-sec:first-child { margin-top: 2px; }
.art-lbl {
  display: flex; align-items: center; gap: 8px; margin: 0 0 8px;
  font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted);
}
.art-lbl .art-n {
  background: var(--tool-bg); border: 1px solid var(--tool-border); border-radius: 20px;
  font-size: 10.5px; padding: 0 7px; color: var(--muted);
}
.art-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 9px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--bg); margin-bottom: 7px;
}
.art-ic {
  width: 30px; height: 30px; flex: none; border-radius: 7px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.art-ic.link { background: var(--user-bg); color: var(--user-accent); }
.art-ic.up { background: var(--accent-soft); color: var(--accent); }
.art-thumb {
  width: 34px; height: 34px; flex: none; border-radius: 7px; object-fit: cover;
  border: 1px solid var(--border); background: var(--tool-bg);
}
.art-m { min-width: 0; flex: 1; }
.art-fn {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.art-fn.lk { color: var(--user-accent); }
.art-det { font-size: 11px; color: var(--muted); }
.art-acts { display: flex; gap: 6px; flex: none; }
.art-acts .icon-btn { width: 27px; height: 27px; }
.art-empty { margin: 0 0 6px; font-size: 12.5px; }

.art-bar { display: flex; margin: 2px 0 6px; }
.art-bar .btn { width: 100%; justify-content: center; }

/* --- Artifacts tray v2: master-detail ---------------------------------------- */
.modal.xwide { max-width: 820px; }
.a2 { display: grid; grid-template-columns: 200px 1fr; height: min(66vh, 560px); }
.a2-side {
  border-right: 1px solid var(--border); background: var(--pane2);
  display: flex; flex-direction: column; padding: 10px; gap: 2px; overflow: auto;
}
.a2-cat {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px;
  cursor: pointer; color: var(--muted); font-size: 13px; border: 1px solid transparent;
  background: transparent; text-align: left; width: 100%;
}
.a2-cat .a2-ci { display: flex; color: var(--faint); }
.a2-cat .a2-cl { flex: 1; }
.a2-cat .a2-cc {
  font-size: 11px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 20px; padding: 0 7px; color: var(--muted);
}
.a2-cat:hover { background: var(--bg); }
.a2-cat.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.a2-cat.on .a2-ci { color: var(--accent); }
.a2-grow { flex: 1; }
.a2-all { width: 100%; justify-content: center; margin-top: 8px; }

.a2-main { display: flex; flex-direction: column; min-width: 0; }
.a2-toolbar { display: flex; align-items: center; gap: 8px; padding: 11px 13px; border-bottom: 1px solid var(--border); }
.a2-search {
  flex: 1; display: flex; align-items: center; gap: 7px; min-width: 0;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; color: var(--muted);
}
.a2-search input { border: 0; background: transparent; color: var(--text); outline: none; width: 100%; font-size: 12.5px; }
.a2-tbtn {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap;
  border: 1px solid var(--border); background: var(--bg); color: var(--muted); border-radius: 8px; padding: 6px 9px; cursor: pointer;
}
.a2-tbtn.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.a2-chips { display: flex; gap: 7px; padding: 9px 13px 2px; flex-wrap: wrap; }
.a2-chip {
  font-size: 11.5px; border: 1px solid var(--border); background: var(--bg); color: var(--muted);
  border-radius: 20px; padding: 3px 10px; cursor: pointer;
}
.a2-chip.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.a2-list { flex: 1; overflow: auto; padding: 9px 13px 13px; }
.a2-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 9px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--bg); margin-bottom: 7px;
}
.a2-row.sel { border-color: var(--accent); background: var(--accent-soft); }
.a2-ck {
  width: 17px; height: 17px; flex: none; border-radius: 5px; border: 1.5px solid var(--border);
  display: grid; place-items: center; color: #1a1208; font-size: 11px; cursor: pointer;
}
.a2-ck.on { background: var(--accent); border-color: var(--accent); }
.a2-ric { width: 30px; height: 30px; flex: none; border-radius: 7px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.a2-ric.code { background: var(--user-bg); color: var(--user-accent); }
.a2-ric.link { background: var(--user-bg); color: var(--user-accent); }
.a2-thumb { width: 34px; height: 34px; flex: none; border-radius: 7px; object-fit: cover; border: 1px solid var(--border); background: var(--tool-bg); }
.a2-m { min-width: 0; flex: 1; }
.a2-fn { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a2-fn.lk { color: var(--user-accent); }
.a2-d { font-size: 11px; color: var(--faint); }
.a2-acts { display: flex; gap: 5px; flex: none; }
.a2 .mini {
  width: 27px; height: 27px; border-radius: 7px; border: 1px solid var(--border);
  background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; text-decoration: none;
}
.a2 .mini:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.a2 .mini.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.a2 .mini.ok { border-color: var(--success, #3a8a4f); color: var(--success, #3a8a4f); }
.a2-empty { padding: 14px 4px; }

.a2-bulk { display: flex; align-items: center; gap: 10px; padding: 10px 13px; border-top: 1px solid var(--border); background: var(--pane2); }
.a2-bn { font-size: 12.5px; color: var(--text); }
.a2-sp { flex: 1; }

.a2-pvhead { display: flex; align-items: center; gap: 9px; padding: 11px 13px; border-bottom: 1px solid var(--border); }
.a2-back { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; cursor: pointer; }
.a2-back:hover { border-color: var(--accent); color: var(--accent); }
.a2-pf { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a2-pvbody { flex: 1; overflow: auto; padding: 15px; }
.a2-pvimg { display: block; max-width: 100%; max-height: 60vh; margin: 0 auto; border-radius: 8px; }
.a2-pvfill { min-height: 100%; }

@media (max-width: 700px) {
  .a2 { grid-template-columns: 1fr; height: min(72vh, 560px); }
  .a2-side { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 8px; }
  .a2-cat { width: auto; white-space: nowrap; }
  .a2-cat .a2-ci { display: none; }
  .a2-grow, .a2-all { display: none; }
}

/* --- Attention: live indicator / status pills / sounds ----------------------- */
@keyframes friday-attn-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 169, 63, 0.5); }
  50% { box-shadow: 0 0 0 5px rgba(224, 169, 63, 0); }
}
/* ⚡ when a session needs you: amber + pulsing badge. */
.live-btn.live-attn, .rail-live.live-attn { border-color: var(--amber, #e0a93f); color: var(--amber, #e0a93f); }
.live-btn.live-attn .live-count, .rail-live.live-attn .rail-live-count {
  background: var(--amber, #e0a93f); color: #241a06; animation: friday-attn-pulse 1.2s ease-in-out infinite;
}
#sound-btn.muted { color: var(--muted); opacity: 0.7; }

/* Terminal status dot: activity states from the registry. */
.tdot.busy { background: var(--success, #5fbf7a); }
.tdot.wait { background: var(--amber, #e0a93f); animation: friday-attn-pulse 1.2s ease-in-out infinite; }

/* Live-modal: per-row state pill + waiting highlight. */
.live-row.attn { border-radius: 9px; background: var(--amber-soft, #3a2f17); box-shadow: inset 0 0 0 1px rgba(224,169,63,0.4); }
.live-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; border-radius: 20px; padding: 2px 9px; border: 1px solid var(--border); white-space: nowrap; flex: none; }
.live-pill .lp-d { width: 7px; height: 7px; border-radius: 50%; }
.live-pill.busy { color: var(--success, #5fbf7a); border-color: #2c5c3c; background: rgba(95,191,122,0.1); }
.live-pill.busy .lp-d { background: var(--success, #5fbf7a); }
.live-pill.wait { color: var(--amber, #e0a93f); border-color: #5c4a23; background: var(--amber-soft, #3a2f17); }
.live-pill.wait .lp-d { background: var(--amber, #e0a93f); }
.live-pill.idle { color: var(--muted); background: var(--pane2, #2a2823); }
.live-pill.idle .lp-d { background: var(--faint, #7c756a); }
.lg-attn { font-size: 10.5px; color: var(--amber, #e0a93f); background: var(--amber-soft, #3a2f17); border: 1px solid #5c4a23; border-radius: 20px; padding: 0 7px; margin-right: 6px; }
.live-attn-bar { margin: 0 0 10px; padding: 8px 11px; border-radius: 9px; font-size: 12.5px; color: var(--amber, #e0a93f); background: var(--amber-soft, #3a2f17); border: 1px solid #5c4a23; }

/* Painel Acesso remoto (🌐) — status bar compacta + config */
.tp-statusbar {
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 10px;
  background: var(--accent-soft);
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.tp-statusbar.is-on { border-left-color: #3a9d5d; }
.tp-statusbar.is-pending { border-left-color: var(--accent); }
.tp-statusbar.is-off { border-left-color: var(--muted); background: transparent; }
.tp-statusbar .tp-line { font-size: 13.5px; }
.tp-statusbar .tp-line strong { text-transform: uppercase; letter-spacing: .3px; }
.tp-url { font-size: 12px; color: var(--accent); text-decoration: none; word-break: break-all; }
.tp-url:hover { text-decoration: underline; }
.tp-note { font-size: 12px; color: var(--muted); }
.tp-actions { margin-top: 6px; }
.tp-actions:empty { display: none; }
.tp-actions .btn { width: 100%; justify-content: center; }
.tp-sep { border: 0; border-top: 1px solid var(--border); margin: 10px 0 4px; }
.tp-inwrap { display: flex; gap: 6px; align-items: center; }
.tp-inwrap .tag-input { flex: 1 1 auto; }
.tp-inwrap .icon-btn { flex: 0 0 auto; }
.icon-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* --- Acesso remoto: control (status + power toggle) -------------------------- */
.tp-control { border: 1px solid var(--border); border-radius: 11px; background: var(--bg); padding: 12px 13px; }
.tp-control.is-on { border-color: color-mix(in srgb, var(--success, #5fbf7a) 45%, var(--border)); }
.tp-control.is-conn { border-color: color-mix(in srgb, var(--amber, #e0a93f) 45%, var(--border)); }
.tp-ctl-head { display: flex; align-items: center; gap: 11px; }
.tp-ctl-ic { width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center; background: var(--pane2); color: var(--faint); }
.tp-control.is-on .tp-ctl-ic { background: rgba(95, 191, 122, 0.14); color: var(--success, #5fbf7a); }
.tp-control.is-conn .tp-ctl-ic { background: var(--amber-soft, #3a2f17); color: var(--amber, #e0a93f); }
.tp-ctl-tt { flex: 1; min-width: 0; font-size: 14px; }
.tp-ctl-tt strong { font-weight: 600; }
.tp-ctl-prov { color: var(--muted); font-weight: 400; font-size: 12px; }
.tp-power { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; cursor: pointer; border: 2px solid #4a463d; color: var(--faint); background: none; transition: border-color .15s, color .15s, box-shadow .15s; }
.tp-power:hover { filter: brightness(1.15); }
.tp-power.is-on { border-color: var(--success, #5fbf7a); color: var(--success, #5fbf7a); background: radial-gradient(circle at 50% 40%, rgba(95, 191, 122, 0.18), transparent 70%); box-shadow: 0 0 0 5px rgba(95, 191, 122, 0.08); }
.tp-power.is-conn { border-color: var(--amber, #e0a93f); color: var(--amber, #e0a93f); animation: friday-attn-pulse 1.2s ease-in-out infinite; }
.tp-power:disabled { cursor: default; }
.tp-ctl-url { display: flex; align-items: center; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.tp-ctl-url a { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; color: var(--user-accent, #6fb3e0); text-decoration: none; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.tp-ctl-url a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-url-copy { width: 28px; height: 28px; flex: none; }
.tp-url-copy.ok { color: var(--success, #5fbf7a); border-color: var(--success, #5fbf7a); }
.tp-control .tp-note { margin-top: 8px; font-size: 11.5px; color: var(--amber, #e0a93f); }
