/* Sub-Etha PWA app shell -- mobile-first. A two-pane layout (conversation list +
   thread) that collapses to a single pane on phones (toggled by [data-view] on
   #app) and sits side-by-side from the tablet breakpoint up. Dark, system-font,
   safe-area aware. Responsive refinement continues in the mobile-first story;
   this establishes the shell structure + the phone single-pane behaviour. */

:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --surface: #121821;
  --surface-2: #1a2330;
  --line: #243042;
  --text: #e6edf3;
  --muted: #8aa0b6;
  --accent: #4ea1ff;
  --danger: #ff6b6b;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* Fluid type: scales between phone and desktop without hard jumps. */
  --fs-brand: clamp(17px, 1rem + 0.4vw, 20px);
  --fs-base: clamp(15px, 0.9rem + 0.2vw, 16px);
  /* Readable thread column cap on wide screens. */
  --thread-max: 1100px;
  --navrail-w: 200px;
  --sidebar-w: clamp(240px, 22vw, 320px);
  --rightpanel-w: 300px;
  --dpanel-w: 0px; /* column D track width; 0 = closed. Set by .app.dpanel-open. */
  --dpanel-w-open: min(460px, 40vw); /* user's chosen open width (resize handle) */
}

/* ---- Themes (Padre msg 671): switchable via data-theme on <html>, picked in the
   account menu, persisted in localStorage. A theme = a variable block (+ a few
   element tweaks). Default (no attribute) is the Sub-Etha dark above. Add a new
   theme by adding one block here and one <option> to #acc-theme. ---- */
/* THEMES:START -- the extra themes, kept between these markers so
   scripts/port_client_features.py in the subetha repo can copy the whole set into the
   apps built from this template. Add a theme HERE and it propagates; add it outside
   the markers and it stays in this app only. The default and sn-light live outside on
   purpose: they are part of the shell, not of the set that travels. */
/* Grey: the middle of the range. The default dark is nearly black and blue-tinted; this
   sits well above it while staying clearly a dark theme, and the hue is pulled almost
   out -- a trace of blue is kept so large flat areas do not read as dead newsprint, but
   nothing here is a colour you would name. The accent is the one exception: a link has
   to be findable, and a grey link is not a link. */
:root[data-theme='grey'] {
  color-scheme: dark;
  --bg: #2e3236;
  --surface: #383d42;
  --surface-2: #43494f;
  --line: #565d64;
  --text: #e8eaec;
  --muted: #a6adb4;
  --accent: #86b3d6;
  --danger: #e0736b;
}

/* Solarized dark, close to Ethan Schoonover's original: the background is base03 and the
   panels base02, so the whole surface is a dark cyan-blue rather than black, and the
   accent is Solarized's own cyan.
   Two values are lifted a little from the canonical ones. Body text is base1 nudged up
   (5.6:1 against base03 in the original, 7:1 here) and muted sits between base01 and
   base00 so it clears 4.5:1 -- this palette was designed for code, where every line is
   short, and a chat asks the eye to read paragraphs of it. */
:root[data-theme='solarized'] {
  color-scheme: dark;
  --bg: #002b36;
  --surface: #073642;
  --surface-2: #0d4653;
  --line: #14586a;
  --text: #a6b3b3;
  --muted: #7d9296;
  --accent: #2aa198;
  --danger: #dc322f;
}

/* Amber phosphor: the P3 monitor. One hue, from the unlit tube through to the brightest
   character. The background is not black but a very dark warm brown -- an amber CRT's
   glass never went truly black, it held the colour of the phosphor behind it, and that is
   what stops this reading as "black theme with orange text".
   Only danger leaves the hue, and only just: a warning has to be a different thing, not a
   brighter shade of the same thing. */
:root[data-theme='amber'] {
  color-scheme: dark;
  --bg: #1a1206;
  --surface: #241a0a;
  --surface-2: #2f2210;
  --line: #4d3818;
  --text: #ffbf40;
  --muted: #c08f36;
  --accent: #ffd479;
  --danger: #ff7043;
}

/* Hercules green: the other monochrome tube, and the reason a generation squinted. Same
   idea, one hue -- but green phosphor was much brighter than amber, so the text sits at
   the top of the range where amber sits in the middle. */
:root[data-theme='green'] {
  color-scheme: dark;
  --bg: #071206;
  --surface: #0c1c0a;
  --surface-2: #12280f;
  --line: #1f4a1c;
  --text: #43e043;
  --muted: #35a03a;
  --accent: #7dff7d;
  --danger: #ff6b5f;
}

/* What actually made those screens look like that: the phosphor did not stop at the edge
   of a character, it bloomed. A shadow of the text's own colour, at a radius small enough
   to read as glow rather than as a blur, is the whole trick -- and it is scoped to these
   two themes, so nothing else in the app inherits a 1980s monitor.
   Kept off the inputs: a glow under a caret is a distraction, not nostalgia. */
:root[data-theme='amber'] body,
:root[data-theme='green'] body {
  text-shadow: 0 0 3px currentColor;
}
:root[data-theme='amber'] input,
:root[data-theme='amber'] textarea,
:root[data-theme='green'] input,
:root[data-theme='green'] textarea {
  text-shadow: none;
}

/* Two things escape the palette on a monochrome theme, and both only showed up in a
   screenshot: an unstyled placeholder falls back to the browser's own neutral grey, and
   the "version is current" line is a hard-coded green. On every other theme neither is
   worth noticing; here each is the single object on screen that is not the one colour,
   which is exactly what the eye finds. Scoped to these two, so nothing else moves. */
:root[data-theme='amber'] ::placeholder,
:root[data-theme='green'] ::placeholder {
  color: var(--muted);
  opacity: 1; /* Firefox dims placeholders by default, on top of the colour */
}
:root[data-theme='amber'] .nav-account__version.is-current,
:root[data-theme='green'] .nav-account__version.is-current {
  color: var(--accent);
}

/* THEMES:END */
:root[data-theme='sn-light'] {
  color-scheme: light;
  --bg: #eceff1;
  --surface: #ffffff;
  --surface-2: #f1f4f6;
  --line: #d4dde2;
  --text: #1b2a33;
  --muted: #5a6b77;
  --accent: #18605c;
  --danger: #c0392b;
}
/* ServiceNow-style dark teal header bar over the light body. */
:root[data-theme='sn-light'] .topbar {
  background: #1d3b3a;
}
:root[data-theme='sn-light'] .topbar,
:root[data-theme='sn-light'] .topbar * {
  color: #ffffff;
}
:root[data-theme='sn-light'] .topbar .iconbtn,
:root[data-theme='sn-light'] .topbar button {
  border-color: rgba(255, 255, 255, 0.25);
}
.app.dpanel-open {
  --dpanel-w: var(--dpanel-w-open);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden; /* the app is a fixed 100dvh frame -- only inner columns scroll */
}

body {
  background: var(--bg);
  color: var(--text);
  font: var(--fs-base) / 1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

/* App frame: single column on phones; the visible pane is chosen by data-view.
   100dvh tracks the *dynamic* viewport so the mobile browser's collapsing URL
   bar never clips the composer; 100vh is the fallback for older engines. */
.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* clip any column overflow -- inner columns scroll, not the page */
}
/* App-wide top bar. */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  /* Wraps rather than squeezing. The eight built-in tabs fit on one line at any usual
     width and nothing moves; it is added tabs and narrow windows that overflow, and a
     strip that drops to a second row beats one whose last label is cut in half. */
  flex-wrap: wrap;
  row-gap: 6px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar .brand {
  margin: 0;
  font-size: 1.05rem;
  white-space: nowrap;
}
.topbar__spacer {
  flex: 1;
}
/* Workspace below the top bar. Phone: a flex column (nav rail on top, chats fill);
   one logical pane at a time via data-view. Desktop turns it into a 4-column grid. */
.workspace {
  position: relative; /* overlays (.browse) cover the workspace, not the top bar */
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.navrail,
.sidebar,
.thread,
.rightpanel {
  min-height: 0;
  min-width: 0;
  overflow-x: hidden; /* no horizontal scroll inside a column -- Padre resizes it instead */
  display: flex;
  flex-direction: column;
}
.navrail {
  flex: none;
  overflow-y: auto;
}
.sidebar,
.thread {
  flex: 1;
}
.rightpanel {
  display: none; /* phone: hidden; desktop media shows it */
}

/* Phone: show one logical pane at a time. */
.app[data-view="list"] .thread {
  display: none;
}
.app[data-view="thread"] .navrail,
.app[data-view="thread"] .sidebar {
  display: none;
}

/* ---- Nav rail (column 1): agent + project selectors ---- */
.navrail {
  position: relative; /* anchor for the resize handle */
  background: var(--bg);
  border-right: 1px solid var(--line);
  padding: 10px;
  gap: 8px;
}
.navrail__resize {
  display: none;
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 6;
}
.navrail__resize:hover,
.navrail__resize.dragging {
  background: var(--accent);
  opacity: 0.35;
}
.nav-dd {
  position: relative;
}
.nav-dd__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.nav-dd__trigger:hover {
  border-color: var(--accent);
}
.nav-dd__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-dd__caret {
  flex: none;
  color: var(--muted);
  padding: 2px 4px;
  margin: -2px -4px -2px 0;
  border-radius: 5px;
  cursor: pointer;
}
.nav-dd__caret:hover {
  color: var(--accent);
  background: var(--surface-2);
}
.nav-dd__label {
  flex: 1;
}
/* Inline "+" add affordance on the Userek / Csapatok triggers. */
.nav-dd__add-inline {
  flex: none;
  padding: 0 7px;
  font-size: 1rem;
  line-height: 1;
  color: var(--accent);
  border-radius: 5px;
  cursor: pointer;
}
.nav-dd__add-inline:hover {
  background: var(--surface-2);
}
.nav-dd__menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}
.nav-dd__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  font: inherit;
  font-size: 0.86rem;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
}
.nav-dd__item:hover,
.nav-dd__item--active {
  background: var(--surface-2);
}
.nav-dd__item--off {
  opacity: 0.55;
}
.nav-dd__dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  margin-right: 6px;
}
.nav-dd__dot.on {
  background: #3fb950;
}
/* Agent avatar circle (Telegram-style) in the agent dropdown; ring = running. */
.agent-av {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  margin-right: 8px;
  background: var(--surface-2);
  background-size: cover;
  background-position: center;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  border: 2px solid transparent;
}
.agent-av.on {
  border-color: #3fb950;
}
/* Dropdown row with a trailing kebab (select on the left, ⋮ actions on the right). */
.nav-dd__row {
  display: flex;
  align-items: stretch;
}
.nav-dd__row .nav-dd__item {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-dd__kebab {
  flex: none;
  padding: 0 10px;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
}
.nav-dd__kebab:hover {
  color: var(--accent);
}
/* "+ Új …" action row at the bottom of a dropdown. */
.nav-dd__add {
  color: var(--accent);
  border-top: 1px solid var(--line);
  font-weight: 600;
}
/* Floating action menu (per-row kebab); reuses .convo__menu, position set inline. */
.row-menu {
  max-height: 340px;
  overflow-y: auto;
  min-width: 180px;
}
/* ---- Bottom account menu (Claude-style, opens upward) ---- */
.nav-account {
  position: relative;
  margin-top: auto; /* pin to the bottom of the nav rail */
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.nav-account__trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  font: inherit;
  color: var(--text);
  background: none;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}
.nav-account__trigger:hover {
  background: var(--surface-2);
}
.nav-account__avatar {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}
.nav-account__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}
.nav-account__who {
  max-width: 100%;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
}
/* Always-visible version + update-status under the identity (Padre msg 621). */
.nav-account__ver {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.64rem;
  color: var(--muted);
}
.nav-account__ver.has-update {
  color: var(--accent);
  font-weight: 600;
}
/* Badge text comes from data-badge (set by checkVersion via tr()) so it is i18n-able. */
.nav-account__ver.has-update::after {
  content: " " attr(data-badge);
}
.nav-account__ver.is-current::after {
  content: " " attr(data-badge);
  color: #3fb950;
}
.nav-account__caret {
  flex: none;
  color: var(--muted);
}
.nav-account__menu {
  position: fixed; /* fixed (not absolute) so the navrail's overflow can't clip it */
  z-index: 40;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.nav-account__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  font: inherit;
  font-size: 0.86rem;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
}
.nav-account__item:hover {
  background: var(--surface-2);
}
/* The Frissítés item, highlighted when a newer version is available. */
.nav-account__item.has-update {
  color: var(--accent);
  font-weight: 600;
}
.nav-account__item.has-update::after {
  content: " ●";
  font-size: 0.7em;
}
/* display:block above would override the UA [hidden]; guard so hidden actions
   (e.g. Telepítés when not installable, Bejelentkezés when logged in) stay gone. */
.nav-account__item[hidden] {
  display: none;
}
.nav-account__sep {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}
/* Version info block in the account menu: running version + (always) the latest
   available one; accent when an update is ready (Padre). */
.nav-account__version {
  padding: 7px 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.7rem;
  line-height: 1.5;
  color: var(--muted);
}
.nav-account__version.has-update {
  color: var(--accent);
}
.nav-account__version.has-update strong {
  font-weight: 700;
}
.nav-account__version.is-current {
  color: #3fb950;
}
/* Theme picker row in the account menu. */
.nav-account__theme {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  font-size: 0.86rem;
  color: var(--text);
}
.nav-account__theme select {
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 6px;
  cursor: pointer;
}
.nav-account__version {
  padding: 6px 12px 8px;
  font-size: 0.7rem;
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
/* (Account actions are kept in the top bar for now -- the bottom menu duplicates
   them. Padre 2026-06-16: restore topbar login/logout; remove duplication later.) */

/* ---- Sidebar (column 2: chats) ---- */
.sidebar {
  position: relative; /* anchor for the resize handle */
  background: var(--surface);
  border-right: 1px solid var(--line);
}
/* Draggable resize handle on the sidebar's right edge (desktop only). */
.sidebar__resize {
  display: none;
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 6;
}
.sidebar__resize:hover,
.sidebar__resize.dragging {
  background: var(--accent);
  opacity: 0.35;
}
/* Right details panel (files / links / details -- desktop, collapsible). */
.rightpanel {
  position: relative; /* anchor for the resize handle */
  display: none;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--line);
}
/* Resize handle on the right panel's LEFT edge (desktop only). */
.rightpanel__resize {
  display: none;
  position: absolute;
  top: 0;
  left: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 6;
}
.rightpanel__resize:hover,
.rightpanel__resize.dragging {
  background: var(--accent);
  opacity: 0.35;
}
/* D sits between the thread and the details panel. Its resize handle is on its
   LEFT edge (the thread|D seam) -- NOT the right edge, because that seam already
   carries the details panel's own handle and the two would overlap (the later
   one in the DOM wins, so D would never get the drag). Dragging the left edge
   widens D leftward; its right edge stays pinned to the details panel. */
.dpanel__resize {
  display: none;
  position: absolute;
  top: 0;
  left: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 6;
}
.dpanel__resize:hover,
.dpanel__resize.dragging {
  background: var(--accent);
  opacity: 0.35;
}
/* Switchable modes inside the right panel. */
.rp-mode {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px;
}
.rp-mode--notes {
  padding: 0;
  display: flex;
  flex-direction: column;
}
/* The author display:flex above overrides UA [hidden]{display:none}; guard it so
   an inactive mode (esp. notes) is truly hidden. */
.rp-mode[hidden] {
  display: none;
}
.rightpanel__head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.rightpanel__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.rightpanel__body .placeholder {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}
.rp-section {
  margin: 10px 0 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.rp-section:first-child {
  margin-top: 0;
}
/* Collapsible section header: a full-width clickable row with a caret. */
.rp-section--toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--muted);
  text-align: left;
}
.rp-section--toggle:hover {
  color: var(--text);
}
.rp-sec-caret {
  font-size: 0.6rem;
  width: 0.7em;
  flex: none;
}
.rp-sec-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rp-sec-body[hidden] {
  display: none;
}
.rp-item {
  display: block;
  padding: 7px 9px;
  margin-bottom: 4px;
  font-size: 0.82rem;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rp-item:hover {
  border-color: var(--accent);
}
/* One compact framed row per file: F-badge, image.png name, date.time +
   #<last4 sys-id>, and the download/kebab/delete controls -- all inline so the
   same-named images stay distinguishable without extra vertical space. */
.rp-file {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
/* Plain filename text inside the frame (no own box); shrinks first via ellipsis. */
.rp-file__view {
  flex: 1 1 auto;
  min-width: 0;
  margin-bottom: 0;
  font-size: 0.76rem;
  color: var(--accent);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.rp-file__view:hover { text-decoration: underline; }
.rp-file__meta {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
.rp-file__when { font-size: 0.6rem; color: var(--muted); white-space: nowrap; }
.rp-file__sysid { font-size: 0.58rem; padding: 0 4px; }
/* Compact controls inside the file frame. */
.rp-file .rp-ref { min-width: 22px; padding: 0 2px; font-size: 0.62rem; }
.rp-file .rp-file__dl { width: 20px; font-size: 0.78rem; }
.rp-file .rp-file__act { width: 18px; font-size: 0.82rem; }
.rp-file__dl {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  font-size: 1rem;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
}
.rp-file__dl:hover {
  border-color: var(--accent);
}
/* Reference number badge (F1, L1..) -- a stable, monospace handle (Padre msg 658). */
.rp-ref {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  padding: 0 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
/* Row action buttons: kebab (rename) and "-" (delete). */
.rp-file__act {
  flex: none;
  width: 28px;
  font-size: 1rem;
  line-height: 1;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.rp-file__act:hover {
  color: var(--text);
  border-color: var(--accent);
}
.rp-file__del:hover {
  color: #f85149;
  border-color: #f85149;
}
/* Section header row: the collapsible toggle + optional action buttons (e.g. "+"). */
.rp-sec-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 4px;
}
.rp-sec:first-child .rp-sec-head {
  margin-top: 0;
}
.rp-sec-head .rp-section--toggle {
  flex: 1;
  min-width: 0;
  margin: 0;
}
.rp-sec-actions {
  position: relative;
  flex: none;
  display: flex;
  gap: 4px;
}
.rp-sec-menu {
  top: calc(100% + 4px);
  right: 0;
}
.rp-filter-btn {
  width: 26px;
  height: 22px;
  font-size: 0.95rem;
  line-height: 1;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.rp-filter-btn:hover { color: var(--text); }
.rp-filter-menu {
  position: fixed;
  z-index: 1000;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  padding: 4px 0;
}
.rp-filter-menu__row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.rp-filter-menu__row:hover { background: var(--surface-2); }
.rp-filter-menu__row input[type=checkbox] {
  appearance: none;
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border: 1px solid var(--muted);
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
}
.rp-filter-menu__row input[type=checkbox]:checked {
  background: var(--accent, #0b77ce);
  border-color: var(--accent, #0b77ce);
}
.rp-filter-menu__row input[type=checkbox]:checked::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 9px;
  line-height: 1;
}
.rp-sec-act {
  width: 24px;
  height: 22px;
  font-size: 1rem;
  line-height: 1;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.rp-sec-act:hover {
  color: var(--accent);
  border-color: var(--accent);
}
/* Per-column collapse toggles: hidden on phone, enabled on desktop. Each column
   (nav rail / chat list / details) has its own toggle in the top bar. */
.col-toggle {
  display: none;
}
.col-toggle svg {
  width: 18px;
  height: 18px;
  display: block;
}
/* Top-bar action buttons: monochrome SVG icons (pending / selftest / notes /
   skills / notify), matching the column toggles -- no emoji. */
.topbar-icon {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
}
.topbar-icon svg {
  width: 19px;
  height: 19px;
  display: block;
}
.topbar-icon:hover {
  color: var(--text);
}
/* A toggle whose column is collapsed reads as "off" (muted, hollow). */
.col-toggle.is-collapsed {
  color: var(--muted);
}
.col-toggle:not(.is-collapsed) {
  color: var(--accent);
}
/* Magnifier inside the search field (icon set per Padre). */
.search-row {
  position: relative;
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}
.search-row .search-input {
  padding-left: 32px;
}
.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  border-bottom: 1px solid var(--line);
}
.brand {
  margin: 0;
  font-size: var(--fs-brand);
  letter-spacing: 0.5px;
}
.sidebar__head-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.who {
  font-size: 12px;
  color: var(--muted);
}
.install-btn {
  padding: 5px 10px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
}
.install-btn:active {
  background: var(--surface-2);
}
.install-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.sidebar__filters {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
/* author display:flex would override the UA [hidden] -- guard it so an empty
   (no-category) filter row fully collapses. */
.sidebar__filters[hidden] {
  display: none;
}
.sidebar__filters::-webkit-scrollbar {
  display: none;
}
.chip {
  flex: 0 0 auto;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.chip[aria-selected="true"] {
  color: var(--text);
  border-color: var(--accent);
}

.search-row {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.search-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.search-input::placeholder {
  color: var(--muted);
}
.sidebar__actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}
.sidebar__actions .new-convo-btn {
  flex: 1;
  margin: 0;
}
.sidebar__actions .new-project-btn {
  text-align: center;
}
.new-project-btn {
  flex: none;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.new-project-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.new-convo-btn {
  margin: 0 12px 8px;
  padding: 9px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.new-convo-btn:active {
  background: var(--surface-2);
}
.new-convo-btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.search-results {
  flex: 1;
  overflow-y: auto;
}
.search-group {
  padding: 8px 16px 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.result {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.result--memory {
  cursor: default;
}
.result--stalled {
  border-left: 3px solid var(--danger);
}
.badge-stalled {
  color: var(--danger);
  font-weight: 600;
}
.result__meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
}
.result__snippet {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-empty {
  padding: 16px;
  color: var(--muted);
}
@media (hover: hover) {
  .result:hover {
    background: var(--surface-2);
  }
}

.sidebar__filter[hidden] {
  display: none;
}
.sidebar__filter {
  margin: 6px 12px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
}
.sidebar__filter:focus {
  outline: none;
  border-color: var(--accent);
}
.convo[hidden],
.convo-group[hidden] {
  display: none;
}

.convo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}
.convo-list__empty {
  padding: 16px;
  color: var(--muted);
}
/* Login / start-a-chat call-to-action in the empty conversation list. */
.convo-list__cta {
  line-height: 1.6;
}
.convo-list__cta strong {
  color: var(--text);
}
.convo-list__cta code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 6px;
  font-size: 0.85em;
}
/* Section header separating Ágensek from Beszélgetések in the sidebar list. */
.convo-group {
  padding: 9px 16px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text);
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}
/* When a project header's kebab menu is open, lift this sticky header (and its
   absolutely-positioned dropdown) above sibling headers -- otherwise the next
   grey sticky header, a later stacking context, paints over the dropdown. */
.convo-group--menu-open {
  z-index: 40;
}
/* Extra-clear divider above the chats section (separates it from agents). */
.convo-group:not(:first-child) {
  margin-top: 8px;
  border-top: 3px solid var(--accent);
}
/* Project header (#149): a stronger band above its agent/chat sub-groups. */
.convo-group--project {
  font-size: 0.82rem;
  color: var(--accent);
  background: var(--bg);
  border-top: 1px solid var(--accent);
  border-bottom: none;
  padding-top: 12px;
}
.convo-group--project:not(:first-child) {
  margin-top: 10px;
  border-top: 1px solid var(--accent);
}
/* Project header row: name grows, sys-id chip + kebab + add sit at the right. */
.convo-group--project {
  display: flex;
  align-items: center;
  gap: 8px;
}
.convo-group__name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* A clickable project header name jumps to that project (like picking it in the
   A-column). Signal it's interactive. */
.convo-group__name--clickable {
  cursor: pointer;
}
.convo-group__name--clickable:hover {
  text-decoration: underline;
}
.group-sysid {
  flex: none;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.66rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  cursor: pointer;
}
.group-sysid:hover {
  border-color: var(--accent);
}
.convo-group__menu,
.convo-group__add {
  flex: none;
  font: inherit;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
}
.convo-group__add {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
}
.convo-group__menu {
  font-size: 1.05rem;
}
.convo-group__menu:hover,
.convo-group__add:hover {
  color: var(--text);
}
.convo {
  position: relative;
  /* Room on the right for everything that sits there, measured rather than guessed:
     the kebab ends 30px in, the star 54px, and the status dot 64px. 58px was set when
     the row held only the star and the kebab, and never grew when the dot arrived -- so
     a long title ran straight under it ("SN-PostBoy-start.3 - Snowbear"). 70px clears
     the dot with a little air after it. */
  padding: 12px 70px 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
/* The open conversation: an accent left bar (inset box-shadow, so no layout shift)
   plus a highlighted background, so it is clear which chat is active in the B column. */
.convo--active {
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--accent);
}
.convo--active .convo__title { color: var(--accent); }
/* Per-conversation kebab (3-dot) menu trigger. */
.convo__kebab {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%); /* rightmost, vertically centered on the one-line row */
  width: 26px;
  height: 26px;
  line-height: 1;
  font-size: 18px;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.55; /* always discoverable (also on touch where :hover never fires) */
}
/* Status dot, just left of the favourite star. Red = an unread reply arrived,
   orange = the user flagged the chat. Deliberately small and quiet (Padre). */
.convo__dot {
  position: absolute;
  top: 50%;
  right: 56px;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
}
.convo__dot.unread { background: #e5534b; }
.convo__dot.flagged { background: #d29922; }
/* Header flag button: outline circle, filled once the chat is flagged. */
.thread-flag svg { width: 15px; height: 15px; }
.thread-flag.on { color: #d29922; }
.thread-flag.on svg circle { fill: currentColor; }
/* Favourite star (bottom-right of a chat row; monochrome, no emoji). */
.convo__fav {
  position: absolute;
  top: 50%;
  right: 32px;
  transform: translateY(-50%); /* just to the LEFT of the kebab, same line (Padre) */
  width: 22px;
  height: 22px;
  line-height: 1;
  font-size: 14px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.5;
}
.convo__fav.on {
  color: var(--accent);
  opacity: 1;
}
.convo__fav:hover {
  opacity: 1;
}
/* Favourites toolbar (SN Favorites style): live filter + move-mode toggle, at the
   top of the Favorit view. */
.fav-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  /* Pin to the top of the scrolling list so it stays put while the favourites
     scroll under it (like the All-conversations bar). Opaque column background so
     rows do not show through. (Padre) */
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
}
.fav-filter-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
}
.fav-filter {
  flex: 1;
  min-width: 0;
  padding: 6px 30px 6px 10px; /* right room for the clear (x) button */
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.fav-filter:focus {
  outline: none;
  border-color: var(--accent);
}
.fav-filter-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
.fav-filter-clear:hover {
  color: var(--text);
}
.fav-move {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.fav-move:hover {
  color: var(--text);
}
.fav-move.is-active {
  color: var(--accent);
  border-color: var(--accent);
}
/* A favourite row in move mode: a drag handle on the left, grab cursor, and a
   dimmed look while it is the row being dragged. */
.convo.is-reorderable {
  padding-left: 78px; /* room for the drag handle + the to-top/to-bottom buttons */
  cursor: grab;
}
.convo.is-reorderable:active {
  cursor: grabbing;
}
.convo__drag {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  cursor: grab;
}
/* "Move to top" / "move to bottom" buttons, shown only in reorder mode, beside
   the drag handle. */
.convo__totop,
.convo__tobottom {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
.convo__totop {
  left: 28px;
}
.convo__tobottom {
  left: 50px;
}
.convo__totop:hover,
.convo__tobottom:hover {
  color: var(--accent);
}
.convo.is-dragging {
  opacity: 0.5;
}
/* B-column mode tabs (Mind / Favorit / History). */
.bmode {
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.bmode__tab {
  flex: 1;
  padding: 6px 8px;
  font: inherit;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}
.bmode__tab.is-active {
  color: var(--text);
  background: var(--bg);
  border-color: var(--accent);
}
.bmode__tab:hover {
  color: var(--text);
}
.convo:hover .convo__kebab,
.convo:focus-within .convo__kebab {
  opacity: 1;
}
.convo__kebab:hover {
  background: var(--surface-2);
  color: var(--text);
}
.convo__menu {
  position: absolute;
  top: 30px;
  right: 8px;
  z-index: 30;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.convo__menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap; /* let the menu grow to the longest label instead of wrapping it */
}
.convo__menu-item:hover {
  background: var(--surface-2);
}
/* Move submenu: a scrollable list of project + agent targets. */
.convo__menu--move {
  min-width: 170px;
  max-height: 320px;
  overflow-y: auto;
}
.convo__menu-filter {
  display: block;
  width: calc(100% - 16px);
  margin: 6px 8px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
}
.convo__menu-filter:focus {
  outline: none;
  border-color: var(--accent);
}
/* Pinned to the top of a dropdown that scrolls.
 *
 * The filter is the first child of the menu, so in a menu with its own scrollbar it
 * scrolled away with the list -- you type, scroll to look, and the box you were typing
 * in is gone. Sticky keeps it against the top edge.
 *
 * Margins are traded for padding here on purpose: a sticky element with a top margin
 * leaves a transparent strip above itself, and the rows slide through that gap. Full
 * width with an opaque background and a bottom rule reads as a header instead, which is
 * what it now behaves like. */
.nav-dd__menu .convo__menu-filter,
.convo__menu--move .convo__menu-filter,
.row-menu .convo__menu-filter {
  position: sticky;
  top: 0;
  z-index: 2;
  width: 100%;
  margin: 0;
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
}
/* The focus cue moves with it: with no border left to colour, the bottom rule carries it. */
.nav-dd__menu .convo__menu-filter:focus,
.convo__menu--move .convo__menu-filter:focus,
.row-menu .convo__menu-filter:focus {
  border-bottom-color: var(--accent);
}
.convo__menu-item[hidden],
.convo__menu-head[hidden] {
  display: none;
}

.convo__menu-head {
  padding: 7px 12px 3px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.convo__menu-head:not(:first-child) {
  border-top: 1px solid var(--line);
  margin-top: 3px;
}
.convo__menu-item.is-active {
  color: var(--accent);
  font-weight: 600;
}
.convo__menu-item.is-active::after {
  content: " ✓";
}
/* Fleet skills list. */
.skills-filter {
  margin-left: auto;
  margin-right: 10px;
  padding: 4px 10px;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-width: 220px;
}
.skill-row {
  padding: 9px 11px;
  margin-bottom: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.skill-row__name {
  font-weight: 600;
  font-size: 0.9rem;
}
.skill-row__desc {
  margin-top: 3px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}
/* Notes scratchpad. */
.notes-text {
  flex: 1;
  min-height: 0;
  width: 100%;
  resize: none;
  padding: 14px 16px;
  border: none;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  line-height: 1.5;
}
.notes-text:focus {
  outline: none;
}
.notes-status {
  margin-left: auto;
  margin-right: 10px;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 400;
}
/* Self-test / status rows. */
.selftest-row {
  display: grid;
  grid-template-columns: 22px 130px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.selftest-row__icon {
  font-weight: 700;
  text-align: center;
}
.selftest-row--ok .selftest-row__icon {
  color: #3fb950;
}
.selftest-row--bad .selftest-row__icon {
  color: #f85149;
}
.selftest-row__label {
  font-weight: 600;
}
.selftest-row__detail {
  font-size: 0.82rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.convo:focus-visible {
  background: var(--surface-2);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
/* Hover effects only where a real pointer can hover -- avoids sticky hover on
   touchscreens (where :hover lingers after a tap). */
@media (hover: hover) {
  .convo:hover {
    background: var(--surface-2);
  }
}
.convo__title {
  font-weight: 600;
  /* Keep the row a single line even when the agent name is appended to the title
     ("Chat neve - Aster") -- truncate with an ellipsis instead of wrapping, so the
     row height never grows (Padre B-column refinement). */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* The " - Aster" agent suffix on a chat title: normal weight (only the chat name is
   bold), so the agent reads as a quiet qualifier next to the name (Padre refinement). */
.convo__title-agent {
  font-weight: 400;
}
.convo__meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* ---- Thread ---- */
.thread {
  background: var(--bg);
}
.thread__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(12px + var(--safe-top)) 12px 12px;
  border-bottom: 1px solid var(--line);
}
.thread__title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
/* Breadcrumb of the chat's parents (agent / project). */
.thread__crumb {
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Chat sys-id chip in the header (copies the full reference). */
.sysid-chip {
  flex: none;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.7rem;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
  cursor: pointer;
}
.sysid-chip:hover {
  border-color: var(--accent);
}
.endpoint-badge {
  font-size: 11px;
  color: var(--accent);
}
/* Header context-usage badge: 'ctx NN%', turns red above 80% (handoff prompt). */
.ctx-wrap { position: relative; flex: none; display: inline-flex; }
/* Header model-selector (owner, agent chats): compact, matches the ctx badge. */
.model-select {
  flex: none;
  /* Width follows the longest option (local model labels carry size + purpose),
     bounded so the header never gets pushed around. The extra right padding keeps
     the label from running underneath the native dropdown arrow. */
  width: auto;
  min-width: 160px;
  max-width: 340px;
  font-family: inherit;
  font-size: 0.72rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 22px 2px 6px;
  text-overflow: ellipsis;
  cursor: pointer;
}
.model-select:hover { border-color: var(--accent); }
.model-select[hidden] { display: none; }

.ctx-badge {
  flex: none;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
  cursor: pointer;
}
.ctx-badge:hover { border-color: var(--accent); }
.ctx-badge:hover { border-color: var(--accent); }
/* Amber warning tier: an earlier restart nudge from 60% (Padre) -- red still means
   mandatory from 80%. is-warm and is-hot are mutually exclusive (set in JS). */
.ctx-badge.is-warm {
  color: #fff;
  background: #e07a1a;
  border-color: #e07a1a;
}
.ctx-badge.is-hot {
  color: #fff;
  background: var(--danger, #d93025);
  border-color: var(--danger, #d93025);
}
.ctx-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 200px;
  max-width: 300px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  padding: 6px;
}
.ctx-menu[hidden] { display: none; }
.ctx-menu__head {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 4px 8px 6px;
}
.ctx-menu__empty { font-size: 0.8rem; color: var(--muted); padding: 4px 8px 8px; }
.ctx-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: none;
  border: none;
  border-radius: 6px;
  padding: 7px 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ctx-menu__item:hover { background: var(--surface-2); color: var(--accent); }

/* File-browser row + inline Run button. */
.fb-entry { display: flex; align-items: center; gap: 4px; }
.fb-entry .fb-row { flex: 1; min-width: 0; }
.fb-row__run {
  flex: none;
  font: inherit;
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 9px;
  cursor: pointer;
}
.fb-row__run:hover { border-color: var(--accent); color: var(--accent); }
#convo-delete { margin-left: auto; }
.iconbtn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

/* Live handoff / fresh-restart indicator strip under the thread header. Minimal,
   non-noisy: a thin coloured line with a short status + optional HANDOFF.md link. */
.handoff-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.handoff-bar[hidden] { display: none; }
.handoff-bar__label { color: var(--muted); }
.handoff-bar__link { color: var(--accent); text-decoration: none; }
.handoff-bar__link:hover { text-decoration: underline; }
.handoff-bar--running .handoff-bar__label { color: var(--accent); }
.handoff-bar--done .handoff-bar__label { color: #3fb950; }
.handoff-bar--failed { background: color-mix(in srgb, var(--danger) 14%, var(--surface-2)); }
.handoff-bar--failed .handoff-bar__label { color: var(--danger); }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.placeholder {
  color: var(--muted);
  margin: auto;
}
.msg {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  white-space: pre-wrap;
  word-break: break-word;
}
.msg--me {
  align-self: flex-end;
  background: var(--surface-2);
}
.msg--cmd {
  align-self: stretch;
  max-width: 100%;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  background: #0a0d11;
}

/* ---- Pending pasted attachments (above the composer) ---- */
.pending-atts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px 0;
}
.pending-att {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 220px;
}
.pending-att__thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 5px;
  flex: none;
}
.pending-att__name {
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pending-att__rm {
  flex: none;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 2px;
}
.pending-att__rm:hover {
  color: var(--danger);
}
/* Caption shown under an attachment image (the text that came with it). */
.msg__caption {
  margin-top: 5px;
}

/* ---- Composer ---- */
.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.composer__input {
  flex: 1;
  resize: none;
  max-height: 140px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.composer__send {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #04101f;
  font-size: 20px;
  cursor: pointer;
}
.composer__send:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---- Banner ---- */
.banner {
  position: fixed;
  left: 50%;
  bottom: calc(16px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 16px;
  max-width: 90%;
  font-size: 14px;
}
.banner--error {
  border-color: var(--danger);
  color: var(--danger);
}

/* ---- Tablet / desktop: three panes side by side (left | thread | right) ---- */
@media (min-width: 760px) {
  /* 4-column workspace: nav rail | chats | thread | right panel. */
  .workspace {
    display: grid;
    grid-template-columns: var(--navrail-w) var(--sidebar-w) minmax(0, 1fr) var(--dpanel-w, 0px) var(--rightpanel-w);
  }
  .navrail,
  .sidebar,
  .thread {
    height: 100%;
    flex: none;
  }
  /* Each column collapses independently -- its grid track shrinks to 0. The 8
     combinations of nav-rail / chat-list / details cover every mix. */
  .app.navrail-collapsed .workspace {
    grid-template-columns: 0 var(--sidebar-w) minmax(0, 1fr) var(--dpanel-w, 0px) var(--rightpanel-w);
  }
  .app.sidebar-collapsed .workspace {
    grid-template-columns: var(--navrail-w) 0 minmax(0, 1fr) var(--dpanel-w, 0px) var(--rightpanel-w);
  }
  .app.rightpanel-collapsed .workspace {
    grid-template-columns: var(--navrail-w) var(--sidebar-w) minmax(0, 1fr) var(--dpanel-w, 0px) 0;
  }
  .app.navrail-collapsed.sidebar-collapsed .workspace {
    grid-template-columns: 0 0 minmax(0, 1fr) var(--dpanel-w, 0px) var(--rightpanel-w);
  }
  .app.navrail-collapsed.rightpanel-collapsed .workspace {
    grid-template-columns: 0 var(--sidebar-w) minmax(0, 1fr) var(--dpanel-w, 0px) 0;
  }
  .app.sidebar-collapsed.rightpanel-collapsed .workspace {
    grid-template-columns: var(--navrail-w) 0 minmax(0, 1fr) var(--dpanel-w, 0px) 0;
  }
  .app.navrail-collapsed.sidebar-collapsed.rightpanel-collapsed .workspace {
    grid-template-columns: 0 0 minmax(0, 1fr) var(--dpanel-w, 0px) 0;
  }
  .app:not(.rightpanel-collapsed) .rightpanel {
    display: flex;
  }
  /* Pin EVERY column to an explicit track so collapsing one (display:none) does
     not reflow the rest. Auto-placed items slide into the first free track when a
     sibling is removed, so collapsing the nav rail used to drag the chat list
     into the rail's zero-width track (Padre msg 663), and D's track did the same
     on the right. Explicit columns keep each panel put; its own track collapses
     to 0 via the grid-template-columns combos. 1=rail 2=list 3=thread 4=D 5=details. */
  .navrail {
    grid-column: 1;
  }
  .sidebar {
    grid-column: 2;
  }
  .thread {
    grid-column: 3;
  }
  .dpanel {
    grid-column: 4;
  }
  .rightpanel {
    grid-column: 5;
  }
  .col-toggle {
    display: inline-flex;
  }
  .navrail__resize,
  .sidebar__resize,
  .rightpanel__resize {
    display: block;
  }
  /* D's resize handle only when D is actually open (otherwise it would float
     at the thread/details seam over a zero-width track). */
  .app.dpanel-open .dpanel__resize {
    display: block;
  }
  .app[data-view="list"] .thread,
  .app[data-view="thread"] .navrail,
  .app[data-view="thread"] .sidebar {
    display: flex;
  }
  /* Collapse wins over the view-based display above (equal specificity, later). */
  .app.navrail-collapsed .navrail {
    display: none;
  }
  .app.sidebar-collapsed .sidebar {
    display: none;
  }
  .iconbtn.back {
    display: none;
  }
  /* Use the full thread-column width on wide screens (don't squeeze to the
     centre) -- the side space is for the right panel + future add-ons. A little
     inline padding keeps it from touching the edges. */
  .messages,
  .composer {
    width: 100%;
    max-width: none;
    padding-inline: 24px;
  }
}

/* The app fills the full viewport width (no centered cap) -- the thread messages
   keep their own readable max-width, but the workspace uses the whole screen. */

/* ---- Landscape phones: trim vertical chrome so the thread keeps room. ---- */
@media (max-height: 480px) and (orientation: landscape) {
  .sidebar__head,
  .thread__head {
    padding-top: calc(6px + var(--safe-top));
    padding-bottom: 6px;
  }
  .sidebar__filters {
    padding-block: 4px;
  }
}

/* ---- Respect reduced-motion: kill smooth-scroll/animation for users who
   asked for less movement. ---- */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Per-message body + meta (sender · date+time · #ref). */
.msg__body {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Long message, folded down.
 *
 * A wall of text pushes everything else off the screen, so a message past this height
 * is shown cut with a "read more" underneath. What is cut is CLIPPED, never removed:
 * the text stays in the DOM, so selecting across the message and copying still takes
 * all of it, and the Copy button was never affected -- it copies the raw body.
 *
 * The height is here rather than in the script on purpose: the script only asks
 * whether the body outgrew the box, so this number is the one place that decides. */
.msg__body--clip {
  --msg-clip: 26rem;
  max-height: var(--msg-clip);
  overflow: hidden;
  /* Fades the last lines out, so the cut reads as "there is more" instead of a message
     that happens to end mid-sentence. Masking rather than a gradient overlay, so it
     works on any bubble colour. */
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 3.5rem), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 3.5rem), transparent);
}

@media (max-height: 700px), (max-width: 700px) {
  .msg__body--clip {
    --msg-clip: 18rem;
  }
}

.msg__more {
  /* The bubble is a block, not a flex column, so the button lands on its own line after
     the body without any alignment help; inline-block keeps it as wide as its label. */
  display: inline-block;
  margin-top: 2px;
  padding: 2px 8px;
  font: inherit;
  font-size: 0.72rem;
  line-height: 1.6;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--line, currentColor);
  border-radius: 999px;
  cursor: pointer;
  opacity: 0.85;
}

.msg__more:hover {
  opacity: 1;
}
.msg__meta {
  margin-top: 4px;
  font-size: 0.68rem;
  color: var(--muted);
  opacity: 0.85;
}
/* Date separator between days in the thread. */
.msg-daysep {
  align-self: center;
  margin: 8px 0 2px;
}
.msg-daysep span {
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 12px;
}
/* Threading chip: a reply ties back to the message it answers (clickable jump). */
.msg__replyto {
  display: inline-block;
  margin-bottom: 5px;
  padding: 1px 7px;
  font-size: 0.68rem;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.msg__replyto:hover {
  border-color: var(--accent);
}
/* Brief highlight when jumping to the answered message. */
.msg--flash {
  animation: msg-flash 1.2s ease-out;
}
@keyframes msg-flash {
  0% { box-shadow: 0 0 0 2px var(--accent); }
  100% { box-shadow: 0 0 0 2px transparent; }
}
/* "Agent is working" transient bubble (typing-style animated dots). */
.msg--working {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
}
/* "Stop waiting" button on the working indicator (hides it; does not abort the
   agent's processing). */
.msg__working-stop {
  font: inherit;
  font-style: normal;
  font-size: 0.72rem;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 8px;
  cursor: pointer;
}
.msg__working-stop:hover { border-color: var(--accent); }
/* "still working, no reply yet" -- the indicator stayed past the safety
   timeout instead of vanishing, so the user can tell the agent is long-running,
   not dead. Amber tint distinguishes it from the fresh "dolgozik" state. */
.msg--working-stale { color: var(--warn, #c9962f); }
.msg--working-stale .msg__dots i { animation-duration: 2.4s; }
/* Real liveness says the agent is NOT working (idle/stopped/unreachable): drop the
   amber "still working" hue for danger red and stop the activity dots -- nothing is
   processing, so an animated indicator would keep lying (ticket 7b3e1d90). */
.msg--working-dead { color: var(--danger); }
.msg--working-dead .msg__dots { display: none; }
/* Non-actionable "restart may be needed" hint shown beside the Stop button when the
   agent is not actually working. */
.msg__working-hint {
  font-style: normal;
  font-size: 0.68rem;
  color: var(--muted);
  opacity: 0.85;
}
/* Edit affordance in a message's meta row (own messages only). */
.msg__edit {
  font: inherit;
  font-size: 0.66rem;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  cursor: pointer;
  vertical-align: middle;
}
.msg__edit:hover { border-color: var(--accent); }
/* A message cleared to empty shows a muted placeholder instead of a blank bubble. */
.msg__empty { color: var(--muted); font-style: italic; }
/* Edit-mode banner above the composer + the composer's editing accent. */
.edit-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 10px;
  font-size: 0.74rem;
  color: var(--muted);
  background: var(--surface-2);
  border-top: 1px solid var(--line);
}
/* [hidden] must beat the display:flex above (else the banner never hides). */
.edit-hint[hidden] { display: none; }
.edit-hint__cancel {
  font: inherit;
  color: var(--accent);
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 8px;
  cursor: pointer;
}
.edit-hint__cancel:hover { border-color: var(--accent); }
.composer--editing { outline: 2px solid var(--accent); outline-offset: -2px; }
.msg__dots {
  display: inline-flex;
  gap: 3px;
}
.msg__dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: msg-dot 1.2s infinite ease-in-out both;
}
.msg__dots i:nth-child(2) { animation-delay: 0.16s; }
.msg__dots i:nth-child(3) { animation-delay: 0.32s; }
@keyframes msg-dot {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}
/* Agent picker rows (new-conversation overlay). */
.agent-pick {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
}
.agent-pick:hover {
  border-color: var(--accent);
}
.agent-pick--off {
  opacity: 0.6;
}
.agent-pick__name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
}
.agent-pick__desc {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-pick__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.agent-pick__dot.on {
  background: #3fb950;
}
/* Code/script block in a message: monospace box + Copy button (#154). */
.msg__code {
  position: relative;
  margin: 6px 0;
  background: #0a0d11;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden; /* clip the header strip to the rounded corners */
}
/* Header strip: language label (left) + Copy (right). The code body is always
   dark, so the header uses fixed dark-context colors (not theme vars). */
.msg__codehead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px 4px 10px;
  background: #11161d;
  border-bottom: 1px solid #222c39;
}
.msg__code pre {
  margin: 0;
  padding: 10px 12px;
  /* Wrap long lines instead of clipping them behind a horizontal scrollbar --
     in a narrow chat panel a non-wrapping <pre> hides most of the content. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #cdd9e5; /* brighter than inherited body text for code readability */
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  tab-size: 2;
}
.msg__copy {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 8px;
  font-size: 0.7rem;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.85;
}
.msg__copy:hover {
  border-color: var(--accent);
  opacity: 1;
}
/* Inside the code header the Copy button sits in normal flow (not absolute),
   with fixed dark-context colors so it stays legible in both themes. */
.msg__codehead .msg__copy {
  position: static;
  top: auto;
  right: auto;
  color: #8ec5ff;
  background: #1a2330;
  border-color: #2a3950;
  opacity: 0.95;
}
.msg__codehead .msg__copy:hover {
  border-color: #4ea1ff;
}
.msg__codelang {
  font-size: 0.66rem;
  color: #7d8fa3;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
/* Message-level copy button (in the meta row) -- copies the whole raw body. */
.msg__copymsg {
  /* Framed like the other chips on this line (check, trust-but-verify, the sys-id):
     it is a button, and it was the one that did not look like one. */
  font: inherit;
  font-size: 0.66rem;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  vertical-align: middle;
}
/* Small copy icon inside the message + sys-id copy buttons. */
.copy-ico {
  width: 12px;
  height: 12px;
  flex: none;
}
.msg__copymsg:hover {
  border-color: var(--accent);
}
/* Sys-id chip: clearly a copy button (border + hover), copies the full ref. */
.msg__sysid {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.66rem;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  vertical-align: middle;
}
.msg__sysid:hover {
  border-color: var(--accent);
}
/* Trust-but-verify "check" button in the message meta row: a small chip that
   sends the message to the quick local reviewer. */
.msg__check {
  font: inherit;
  font-size: 0.66rem;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  cursor: pointer;
  vertical-align: middle;
}
.msg__check:hover {
  border-color: var(--accent);
}
.msg__check:disabled {
  opacity: 0.6;
  cursor: default;
}
/* Trust-but-verify "strong" review button: same chip, accent border to signal
   it is the stronger (Momus/Fable 5) reviewer. */
.msg__tbv {
  font: inherit;
  font-size: 0.66rem;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  cursor: pointer;
  vertical-align: middle;
}
.msg__tbv:hover {
  border-color: var(--accent);
}
.msg__tbv:disabled {
  opacity: 0.6;
  cursor: default;
}
/* Yeti supervisor review button: same chip shape as trust-but-verify. */
.msg__human {
  font: inherit;
  font-size: 0.66rem;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  cursor: pointer;
  vertical-align: middle;
}
.msg__human:hover { border-color: var(--accent); }
.msg__human:disabled { opacity: 0.6; cursor: default; }

.msg__yeti {
  font: inherit;
  font-size: 0.66rem;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  cursor: pointer;
  vertical-align: middle;
}
.msg__yeti:hover {
  border-color: var(--accent);
}
.msg__yeti:disabled {
  opacity: 0.6;
  cursor: default;
}
/* Light markdown rendering inside message text (cosmetic). */
.md-h {
  font-weight: 700;
  line-height: 1.3;
  margin: 6px 0 2px;
}
.md-h1 { font-size: 1.15rem; }
.md-h2 { font-size: 1.05rem; }
.md-h3 { font-size: 0.97rem; color: var(--text); }
.md-h4 { font-size: 0.9rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.md-p { margin: 2px 0; }
.md-sp { height: 6px; }
.md-ul,
.md-ol {
  margin: 2px 0;
  padding-left: 22px;
}
.md-ul { list-style: disc; }
.md-ol { list-style: decimal; }
.md-ul li,
.md-ol li { margin: 1px 0; }
.md-bq {
  margin: 4px 0;
  padding: 4px 12px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}
.md-tablewrap {
  position: relative;
  margin: 6px 0;
}
.md-tablewrap .msg__copy {
  top: 2px;
  right: 2px;
}
.md-table {
  border-collapse: collapse;
  margin: 0;
  font-size: 0.86rem;
  display: block;
  overflow-x: auto;
  max-width: 100%;
}
.md-table th,
.md-table td {
  border: 1px solid var(--line);
  padding: 4px 9px;
  text-align: left;
}
.md-table th {
  background: var(--surface-2);
  font-weight: 600;
}
.msg__text code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 5px;
}
.msg__text a { color: var(--accent); }
/* Attachment messages: inline image + download link. */
.msg__img {
  max-width: 260px;
  max-height: 260px;
  border-radius: var(--radius);
  display: block;
  margin-bottom: 4px;
}
.msg__file {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
}
.msg__file:hover {
  text-decoration: underline;
}

/* "Több" button: open the full conversation list in the big area. */
.more-btn {
  margin: 4px 12px 8px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.more-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* Browse overlay: full conversation list shown over the main area. */
.browse {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
/* The .browse display:flex above is an author rule and overrides the UA
   [hidden] { display:none }, so without this guard the overlay renders
   fullscreen on every load and covers the whole app (black screen). */
.browse[hidden] {
  display: none;
}
.browse__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.browse__list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}
/* ---- Project file browser ---- */
.browse__head .fb-crumb {
  margin-left: 12px;
  font-weight: 400;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fbrowser__body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  min-height: 0;
}
.fbrowser__list--drop {
  outline: 2px dashed var(--accent);
  outline-offset: -6px;
}

.fbrowser__list {
  overflow-y: auto;
  border-right: 1px solid var(--line);
}
.fb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 16px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
}
.fb-row:hover {
  background: var(--surface-2);
}
.fb-row.is-active {
  color: var(--accent);
}
.fb-row__icon {
  flex: none;
  width: 18px;
  color: var(--muted);
}
.fb-row__name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fb-row__size {
  flex: none;
  font-size: 0.72rem;
  color: var(--muted);
}
.fbrowser__editor {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.fbrowser__editbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
}
.fb-filename {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fb-status {
  font-size: 0.75rem;
  color: var(--muted);
}
.fbrowser__text {
  flex: 1;
  width: 100%;
  resize: none;
  border: none;
  outline: none;
  padding: 14px;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.5;
  tab-size: 2;
}
.fbrowser__empty {
  padding: 24px 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---- Modal dialog (create-ticket form) ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 16px;
}
.modal[hidden] {
  display: none; /* author display:flex would override the UA [hidden] */
}
.modal__panel {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.modal__body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
/* New-project workdir picker (Padre msg 696). */
.newproj-wd {
  display: flex;
  gap: 6px;
}
.newproj-wd input {
  flex: 1;
  min-width: 0;
}
.newproj-fs {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface-2);
}
/* When the picker is the standalone overlay, let it own the panel chrome. */
#fs-picker {
  z-index: 70; /* above the new-project modal (60) when opened from it */
}
#fs-picker .modal__panel {
  max-width: 560px;
}
/* Wider panel for the Adminisztráció window. A FIXED height so the window does not
   jump between tabs (e.g. short on Csapatok, tall on Email) -- every tab is the same
   size and the body scrolls when its content is longer (Padre: uniform = comfier). */
.modal__panel--wide {
  max-width: 620px;
}
.modal__panel--wide.modal__panel--tabbed {
  height: min(680px, 88vh);
}
/* Personal Beállítások: lighter content -> its own fixed height (still constant
   across its tabs, just not as tall as the Admin window). */
.modal__panel--tabbed:not(.modal__panel--wide) {
  height: min(520px, 85vh);
}
/* Tabbed panel: the body scrolls (not the whole panel), so the head + tab rail stay
   fixed and clickable even with a tall pane. Used by Adminisztráció + Beállítások. */
.modal__panel--tabbed {
  overflow: hidden;
}
.modal__panel--tabbed .modal__body {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
/* Tab rail inside a modal (Adminisztráció / future tabbed windows). */
.modal__tabs {
  display: flex;
  gap: 2px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  flex: none; /* never let the flex column shrink the tab rail (caused a stray scrollbar) */
  overflow-x: auto;
  overflow-y: hidden; /* horizontal scroll only when many tabs -- no vertical scrollbar */
}
/* Keep the head + tab rail at their natural height inside a tabbed panel; only the
   body absorbs the height (it scrolls). */
.modal__panel--tabbed .modal__head {
  flex: none;
}
.modal__tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  padding: 10px 8px;
  white-space: nowrap;
  cursor: pointer;
}
.modal__tab:hover {
  color: var(--text);
}
.modal__tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.admin-pane {
  padding-top: 4px;
}
/* Inside a tabbed window the body already scrolls -- don't cap the inner list to a
   cramped 220px with its own scrollbar; let it use the full pane (Padre bug). */
.admin-pane .users-list {
  max-height: none;
  overflow: visible;
}
/* Clickable modal header title (e.g. "Adminisztráció" -> back to the main page). */
.modal__head-title {
  appearance: none;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}
.modal__head-title:hover {
  text-decoration: underline;
}
.admin-home__list {
  margin: 8px 0;
  padding-left: 18px;
  line-height: 1.6;
}
/* Language picker (Beállítások > Megjelenés): flag + native name, one selected. */
.lang-select {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.lang-opt {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.lang-opt:hover {
  border-color: var(--accent);
}
.lang-opt.is-active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.lang-opt .flag {
  width: 22px;
  height: 15px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  display: block;
  flex: none;
}
#fs-picker .newproj-fs__list {
  max-height: 50vh;
}
.newproj-fs__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.newproj-fs__bar span {
  font-size: 0.78rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.newproj-fs__list {
  max-height: 160px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}
.newproj-fs__row {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  border-radius: 6px;
}
.newproj-fs__row:hover {
  background: var(--surface);
}
.newproj-fs__main {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 5px 8px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.newproj-fs__kebab {
  flex: 0 0 auto;
  padding: 2px 8px;
  font-size: 1rem;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
}
.newproj-fs__row:hover .newproj-fs__kebab,
.newproj-fs__kebab:focus {
  opacity: 1;
}
.newproj-fs__kebab:hover {
  color: var(--text);
  background: var(--bg);
}
.newproj-fs__menu {
  position: absolute;
  top: 100%;
  right: 6px;
  z-index: 20;
  min-width: 130px;
  display: flex;
  flex-direction: column;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}
.newproj-fs__menu-item {
  text-align: left;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.newproj-fs__menu-item:hover {
  background: var(--bg);
}
.newproj-fs__menu-item.danger {
  color: #e5534b;
}
.newproj-fs__empty {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 6px 8px;
}
.newproj-fs__new {
  display: flex;
  gap: 6px;
}
.newproj-fs__new input {
  flex: 1;
  min-width: 0;
}
.field > span {
  font-size: 0.8rem;
  color: var(--muted);
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 10px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.field textarea {
  resize: vertical;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
/* Password field with a show/hide (eye) toggle (Padre msg: jelszo szem-ikon). */
.pw-wrap {
  position: relative;
  display: block;
}
.pw-wrap input {
  padding-right: 40px; /* room for the toggle so text never sits under it */
}
.pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
}
.pw-toggle:hover {
  color: var(--text);
}
.pw-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.pw-toggle svg {
  width: 18px;
  height: 18px;
}
.pw-toggle .icon-eye-off {
  display: none;
}
.pw-toggle.pw-toggle--on .icon-eye {
  display: none;
}
.pw-toggle.pw-toggle--on .icon-eye-off {
  display: inline;
}
.modal__status {
  font-size: 0.82rem;
  color: var(--muted);
  min-height: 1em;
}
.modal__foot {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
}
.notif-incognito {
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
}
/* Settings: avatar upload. */
.avatar-edit {
  display: flex;
  align-items: center;
  gap: 16px;
}
.avatar-edit__preview {
  flex: none;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  background-size: cover;
  background-position: center;
}
.avatar-edit__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.notif-steps {
  margin: 6px 0;
  padding-left: 20px;
  line-height: 1.6;
}
.notif-steps li {
  margin-bottom: 4px;
}
#notif-modal .modal__body p {
  margin: 8px 0;
}

/* ---- Column D: file-content viewer ---- */
/* Phone: a full-screen overlay (no room for a 5th column). Desktop turns it into
   a real grid column to the right of C (see the desktop media query). */
/* Default (desktop): column D is a real grid track to the LEFT of C. position
   is relative (not static) only so the resize handle can anchor to it; relative
   still participates in grid placement. The phone overlay (position:fixed) is
   opted in under the narrow media query below -- keeping it here would lose to
   source order on desktop. */
.dpanel {
  position: relative;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  background: var(--surface);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.dpanel[hidden] {
  display: none; /* author display:flex would override the UA [hidden] */
}
/* Phone: no 5-track grid here, so D shows as a fullscreen overlay. */
@media (max-width: 759px) {
  .dpanel {
    position: fixed;
    inset: 0;
    z-index: 50;
  }
}
.dpanel__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.dpanel__name {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Selection containment: a marked region is a self-contained selection island, so
   dragging over a file's name or content cannot bleed into other panes. `contain`
   is honoured by Firefox; Chromium/WebKit fall back to `text` here and are held to
   the region by the JS guard in app.js (installSelectionContainment). */
[data-select-scope] {
  -webkit-user-select: text;
  user-select: text;
  user-select: contain;
}
.dpanel__dl {
  flex: none;
  color: var(--accent);
  text-decoration: none;
  font-size: 1.1rem;
}
.dpanel__body {
  flex: 1;
  overflow: auto;
  padding: 12px;
}
.dpanel__body img {
  max-width: 100%;
  height: auto;
  display: block;
}
.dpanel__body pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
}
.dpanel__empty {
  color: var(--muted);
}
/* Sticky file-view header: wraps the action toolbar AND the find bar so BOTH stay
   pinned while the file scrolls under them (Padre: keep the buttons stuck too, not
   just the search). Negative margins cover the body's 12px padding so scrolled
   content can't peek past it. */
.dpanel__filehead {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface);
  margin: -12px -12px 10px;
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dpanel__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
/* Find-in-file bar: a plain row inside the sticky .dpanel__filehead (which does the
   pinning), so the search field + counter stay reachable with the toolbar. */
.dpanel__find {
  display: flex;
  align-items: center;
  gap: 6px;
}
.dpanel__find-input {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  font: inherit;
  font-size: 0.8rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.dpanel__find-input:focus { outline: none; border-color: var(--accent); }
.dpanel__find-nav {
  flex: 0 0 auto;
  padding: 4px 8px;
  font: inherit;
  line-height: 1;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.dpanel__find-nav:hover { background: var(--line); }
.dpanel__find-count { flex: 0 0 auto; min-width: 3.5em; text-align: center; font-size: 0.78rem; color: var(--muted); }
.dpanel__body mark.dfind-hit {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  color: inherit;
  border-radius: 2px;
}
.dpanel__body mark.dfind-current {
  background: var(--accent);
  color: #fff;
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: 2px;
}
.dpanel__btn {
  padding: 5px 10px;
  font: inherit;
  font-size: 0.8rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.dpanel__btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.dpanel__btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.dpanel__btn.primary:hover {
  color: #fff;
  filter: brightness(1.05);
}
.dpanel__btn.danger {
  color: var(--danger, #e5534b);
  border-color: color-mix(in srgb, var(--danger, #e5534b) 45%, var(--line));
}
.dpanel__btn.danger:hover {
  color: #fff;
  background: var(--danger, #e5534b);
  border-color: var(--danger, #e5534b);
}
.dpanel__warn {
  margin-bottom: 10px;
  padding: 6px 8px;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 6px;
}
.pw-reveal {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: 8px;
}
.pw-reveal__title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 8px;
}
.pw-reveal__row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.pw-reveal__input {
  flex: 1;
  min-width: 0;
  padding: 7px 9px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.pw-reveal__note {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}
.dpanel__editor {
  width: 100%;
  min-height: 60vh;
  resize: vertical;
  box-sizing: border-box;
  padding: 10px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.notes-in-d {
  width: 100%;
  height: 100%;
  min-height: 360px;
  resize: none;
  border: none;
  outline: none;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  line-height: 1.5;
  padding: 0;
}
/* C panel: separator + project working-directory tree (Padre msg 643). */
.rp-sep {
  height: 1px;
  background: var(--line);
  margin: 12px 8px;
}
/* Copyable full workdir path under the WORKING DIRECTORY header (Padre). Monospace,
   click-to-copy, wraps so a long path stays fully visible. */
.rp-wd-path {
  display: block;
  width: 100%;
  text-align: left;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  margin: 2px 0 6px;
  cursor: copy;
  word-break: break-all;
  user-select: all;
}
.rp-wd-path:hover { border-color: var(--accent); color: var(--text); }

.rp-tree {
  display: flex;
  flex-direction: column;
}
/* A workdir file that has changed since it was last opened. Red until it is opened,
   ordinary afterwards -- two states, because a third colour was one more thing to
   decode and said nothing the first two did not. */
.is-file-new {
  color: #e5534b;
  font-weight: 600;
}
.is-file-updated {
  color: #e5534b;
}
.rp-wd-findrow {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 6px 10px;
}
.rp-wd-findrow .rp-wd-find {
  flex: 1;
  width: auto;
  margin: 0;
}
.rp-wd-unread {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted, var(--text));
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}
.rp-wd-unread:hover {
  border-color: var(--accent);
}
.rp-wd-unread.is-on {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.rp-wd-find {
  display: block;
  width: calc(100% - 20px);
  margin: 6px 10px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
}
.rp-wd-find:focus {
  outline: none;
  border-color: var(--accent);
}

.rp-tree__row {
  position: relative;
  display: flex;
  align-items: center;
}
.rp-tree__row:hover {
  background: var(--surface-2);
}
.rp-tree__main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 4px 5px 0;
  font: inherit;
  font-size: 0.84rem;
  color: var(--text);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
}
.rp-tree__kebab {
  flex: none;
  width: 22px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0;
}
.rp-tree__row:hover .rp-tree__kebab { opacity: 1; }
/* Placed by placePopupNearAnchor() in app.js: mounted on the body and fixed to the
   viewport, because a column that scrolls clips an absolutely positioned popup before the
   window ever gets the chance to. The offsets below are only the fallback for the moment
   between creation and placement. */
.rp-tree__menu {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  min-width: 130px;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.rp-tree__menu-item {
  text-align: left;
  font: inherit;
  font-size: 0.8rem;
  padding: 6px 10px;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
}
.rp-tree__menu-item:hover { background: var(--surface); }
.rp-tree__menu-item.danger { color: #ff6b6b; }
.rp-tree__ic {
  flex: none;
  width: 14px;
  color: var(--muted);
}
.rp-tree__nm {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rp-tree__err {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.85rem;
}
.rp-tree__empty {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

/* Repository section (C-column): git status + commit/push. */
.repo { padding: 6px 10px 10px; display: flex; flex-direction: column; gap: 8px; }
.repo__link { display: block; font-size: 0.8rem; color: var(--accent); text-decoration: none; word-break: break-all; margin-bottom: 4px; }
.repo__link:hover { text-decoration: underline; }
.repo__branch { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.repo__clean { font-size: 0.82rem; color: var(--muted); }
.repo__files { display: flex; flex-direction: column; gap: 2px; max-height: 180px; overflow: auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.76rem; }
.repo__file { white-space: pre; color: var(--text); }
.repo__file--untracked { color: #d29922; }
.repo__warn { font-size: 0.76rem; color: #d29922; line-height: 1.4; }
.repo__err { white-space: pre-wrap; font-size: 0.76rem; color: #f85149; margin: 0; }
.repo__msg { width: 100%; resize: vertical; font: inherit; font-size: 0.82rem; padding: 6px 8px; box-sizing: border-box; }
.repo__btn { align-self: flex-start; }

/* SN project panel (Phase 2): instances + UpdateSet hierarchy in the C column. */
.rp-sn-inst { padding: 5px 8px; border-bottom: 1px solid var(--line); }
.rp-sn-inst:last-child { border-bottom: none; }
.rp-sn-inst__head { display: flex; align-items: center; gap: 6px; }
.rp-sn-inst__name { flex: 1; min-width: 0; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; }
.rp-sn-inst__name .sn-row__badge { margin-left: 6px; }
.rp-sn-inst__url { display: block; margin-top: 2px; font-size: 0.72rem; color: var(--accent); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-sn-inst__url:hover { text-decoration: underline; }
.rp-us { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; margin: 0 6px 6px; }
.rp-us__head { display: flex; align-items: center; gap: 6px; }
.rp-us__caret { flex: none; width: 18px; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.8rem; padding: 0; }
.rp-us__title { flex: 1; min-width: 0; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-us__items { margin-top: 4px; padding-left: 8px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 3px; }
.rp-us__items[hidden] { display: none; }
.rp-us__item { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--muted); }
.rp-us__item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-us__empty { margin-top: 4px; font-size: 0.72rem; color: var(--muted); }

/* W3 owner user-onboarding popup */
.users-list { max-height: 220px; overflow: auto; margin-bottom: 8px; }
.users-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}
.users-row:last-child { border-bottom: none; }
.users-row__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.users-row--disabled .users-row__label { color: var(--muted); text-decoration: line-through; }
.users-row__kebab {
  flex: none;
  width: 22px;
  font-size: 1rem;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
}
.users-row__kebab:hover { color: var(--text); }
/* Per-user action dropdown (Szerkesztés / Törlés / Visszaállítás). */
.users-row__menu {
  position: absolute;
  top: 100%;
  right: 4px;
  z-index: 20;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.users-row__menu-item {
  text-align: left;
  font: inherit;
  font-size: 0.82rem;
  padding: 7px 10px;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
}
.users-row__menu-item:hover { background: var(--surface); }
.users-row__menu-item.danger { color: #ff6b6b; }
/* Inline user edit (screen name + trust). */
.users-row--editing { flex-wrap: wrap; }
.users-edit__name { flex: 1; min-width: 120px; padding: 4px 7px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; color: var(--text); font: inherit; font-size: 0.82rem; }
.users-edit__trust { padding: 4px 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; color: var(--text); font: inherit; font-size: 0.82rem; }
.users-edit__save, .users-edit__cancel { font: inherit; font-size: 0.78rem; padding: 3px 9px; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; }
.users-edit__save { color: var(--accent); background: var(--surface-2); }
.users-edit__cancel { color: var(--muted); background: none; }
/* ServiceNow Instances section in the settings modal (metadata only). */
.sn-instances { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.sn-instances__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-weight: 600; }
.sn-instances__note { margin-top: 8px; font-size: 0.72rem; color: var(--muted); }
.sn-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; }
.sn-row__main { flex: 1; min-width: 0; }
.sn-row__title { display: flex; align-items: center; gap: 6px; font-size: 0.88rem; }
.sn-row__badge { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); border: 1px solid var(--accent); border-radius: 5px; padding: 0 5px; }
.sn-row__url { font-size: 0.72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sn-row__sync { font-size: 0.7rem; margin-top: 2px; }
.sn-row__sync.ok { color: #4caf82; }
.sn-row__sync.fail { color: #ff6b6b; }
.sn-row__acts { display: flex; gap: 4px; flex: none; }
.sn-act { font: inherit; font-size: 0.72rem; padding: 2px 8px; color: var(--accent); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.sn-act:hover { border-color: var(--accent); }
.sn-act.danger { color: #ff6b6b; }
.sn-form { display: flex; flex-direction: column; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.sn-form__field { display: flex; flex-direction: column; gap: 3px; font-size: 0.78rem; color: var(--muted); }
.sn-form__field input { padding: 6px 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; color: var(--text); font: inherit; font-size: 0.85rem; }
.sn-form__acts { display: flex; gap: 8px; flex-wrap: wrap; }
.sn-form__ro { opacity: 0.6; cursor: not-allowed; }
.sn-form__hint { margin: 2px 0 0; font-size: 0.68rem; color: var(--muted); }
.sn-form__note { margin: 2px 0; font-size: 0.72rem; color: var(--muted); }
.sn-form__pwrow { display: flex; gap: 6px; }
.sn-form__pwrow input { flex: 1; min-width: 0; padding: 6px 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; color: var(--text); font: inherit; font-size: 0.85rem; }
.sn-form__eye { flex: none; width: 34px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.sn-form__eye:hover { border-color: var(--accent); }
.sn-form__check { display: flex; align-items: center; gap: 7px; font-size: 0.82rem; color: var(--text); cursor: pointer; }
.sn-form__check input { width: auto; flex: none; accent-color: var(--accent); }
.sn-form__result { font-size: 0.82rem; padding: 6px 8px; border-radius: 6px; background: var(--surface-2); }
.sn-form__result.ok { color: #4caf82; border: 1px solid #4caf82; }
.sn-form__result.fail { color: #ff6b6b; border: 1px solid #ff6b6b; }
.sn-form__result.warn { color: var(--muted); border: 1px solid var(--line); }
/* Grantable-resource checkboxes in the onboarding popup. */
.grant-checks { display: flex; flex-direction: column; gap: 4px; }
.grant-checks:empty { display: none; }
.grant-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.grant-group__title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-top: 4px;
}
.grant-check input:disabled { opacity: 0.4; }
.contacts-acts { display: flex; gap: 6px; flex: none; }
.contacts-open {
  flex: 1; min-width: 0; text-align: left;
  font: inherit; font-size: 0.85rem; color: var(--text);
  background: none; border: 0; padding: 5px 0; cursor: pointer;
}
.contacts-open:hover { color: var(--accent); }
.grant-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.85rem;
  cursor: pointer;
}
/* Reset the .field input{width:100%;...} rule so the checkbox renders native. */
.grant-check input {
  cursor: pointer;
  width: auto;
  flex: none;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  accent-color: var(--accent);
}
/* Initial-password reveal after onboarding (shown once, owner-only view). */
.users-pw {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  word-break: break-all;
}
.users-pw code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.95rem;
  color: var(--text);
}
.users-pw__copy {
  font-size: 0.7rem;
  color: var(--accent);
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 7px;
  cursor: pointer;
}
.users-pw__copy:hover { border-color: var(--accent); }
.users-pw__note { margin-top: 5px; font-size: 0.72rem; color: var(--muted); }

/* Email server settings (W6): compact owner-only form in the settings modal. */
.email-settings { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.email-settings__grp { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-top: 4px; }
.field--check { flex-direction: row; align-items: flex-start; gap: 8px; }
/* Reset the .field input{width:100%;padding...} rule so the checkbox renders
   native and does not eat the whole row (which squeezed the label to 0 width). */
.field--check input[type="checkbox"] {
  cursor: pointer;
  width: auto;
  flex: none;
  margin: 2px 0 0;
  padding: 0;
  border: none;
  background: none;
  accent-color: var(--accent);
}
.field--check span { flex: 1; font-size: 0.85rem; color: var(--muted); }
.email-settings__row { display: flex; gap: 8px; }
.email-settings__row .field { flex: 1; min-width: 0; }

/* A-column single-select: highlight the active category trigger (Padre A/B). */
.nav-dd--active .nav-dd__trigger {
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  font-weight: 600;
}
.nav-dd--active .nav-dd__label { color: var(--accent); }

/* Header macro menu: per-row fill button + kebab (edit/delete). Reuses .convo__menu;
   floatUnder() sets position:fixed inline so the header overflow doesn't clip it. */
.macro__menu { min-width: 220px; max-width: 340px; }
.macro__row { display: flex; align-items: stretch; }
.macro__row .macro__fill {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.macro__kebab {
  flex: 0 0 auto;
  width: 30px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.macro__kebab:hover { background: var(--surface-2); color: var(--text); }
/* The flag marker on a quick-jump row -- the same amber dot the conversation list uses
   (.convo__dot.flagged), here as a button so the list can also SET it. Unflagged it is
   a hollow ring: a marker only visible once it is on cannot be found to turn on. */
.macro__flag {
  flex: 0 0 auto;
  width: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
}
.macro__flag::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--muted);
  opacity: 0.5;
}
.macro__flag:hover::before { opacity: 1; }
.macro__flag.on::before {
  background: #d29922;
  border-color: #d29922;
  opacity: 1;
}
.macro__add {
  border-top: 1px solid var(--line);
  color: var(--accent);
  font-weight: 600;
}
.convo__menu-item.is-danger { color: #e5534b; }
.convo__menu-item.is-danger:hover { background: var(--surface-2); }

/* The macro button lives in the thread header (.iconbtn, not .topbar-icon), so the
   .topbar-icon svg sizing rule doesn't reach it -- size its icon explicitly. */
#macro-btn svg { width: 18px; height: 18px; display: block; }

/* When the nav rail (A) is collapsed, the account widget relocates to the bottom of
   the chat list (B); keep the 'All conversations' button visible above it there. */
.app.navrail-collapsed #more-convos:not([hidden]) { display: block; }
/* :not([hidden]) rather than !important: the override used to win over the
   hidden attribute, so the button showed with the rail collapsed and vanished
   with it open -- the same view, two different answers. */
.app.navrail-collapsed #sidebar .nav-account { margin-top: auto; }

/* Header favourite star (next to the macro button); ★ when favourited. */
#thread-fav { font-size: 17px; line-height: 1; color: var(--muted); opacity: .85; }
#thread-fav.on { color: var(--accent); opacity: 1; }
#thread-fav:hover { opacity: 1; }

/* "All conversations" browse table (name + kebab/star pulled right | project | agent | created | updated). */
.browse-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.browse-table th { text-align: left; padding: 9px 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); white-space: nowrap; }
.browse-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.browse-table .bt-date { color: var(--muted); font-size: 0.85rem; }
.browse-table .bt-name { position: relative; width: 42%; }
.bt-name-inner { display: flex; align-items: center; gap: 8px; }
.bt-title { flex: 1 1 auto; cursor: pointer; overflow: hidden; text-overflow: ellipsis; }
.bt-title:hover { color: var(--accent); }
.bt-actions { display: inline-flex; align-items: center; gap: 2px; flex: none; }
.bt-kebab, .bt-star { border: none; background: none; cursor: pointer; font-size: 15px; line-height: 1; color: var(--muted); padding: 2px 5px; }
.bt-kebab:hover, .bt-star:hover { color: var(--text); }
.bt-star.on { color: var(--accent); }
.browse-row:hover td { background: var(--surface-2); }

/* Browse table toolbar: funnel toggles the per-column filter row + syntax legend. */
.browse-bar { display: flex; align-items: center; gap: 12px; padding: 6px 12px 2px; justify-content: flex-start; }
.browse-hint { margin-right: auto; font-size: 0.78rem; color: var(--muted); }
.browse-funnel { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: var(--radius); padding: 5px 8px; cursor: pointer; }
.browse-funnel.on { color: var(--accent); border-color: var(--accent); }
.browse-funnel:hover { color: var(--text); }
/* Sortable headers + indicator + per-column filter inputs. */
.browse-table th.bt-sortable { cursor: pointer; user-select: none; }
.browse-table th.bt-sortable:hover .bt-h-label { color: var(--text); }
.bt-h-label { margin-right: 5px; }
.bt-sort-ind { font-size: 0.7rem; color: var(--line); }
.bt-sort-ind.active { color: var(--accent); }
.bt-filter-row th { padding: 2px 8px 8px; position: static; }
.bt-colfilter { width: 100%; box-sizing: border-box; padding: 4px 6px; font: inherit; font-size: 0.82rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; color: var(--text); }
.bt-colfilter:focus { outline: none; border-color: var(--accent); }

/* Browse table: row-number column + total count + 50/page pager (Servus-style). */
.browse-count { margin-right: auto; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.browse-table th.bt-num, .browse-table td.bt-num { width: 1%; white-space: nowrap; text-align: right; color: var(--muted); font-size: 0.85rem; padding-right: 14px; }
.browse-table th.bt-num { cursor: default; }
.browse-pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 14px; }
.browse-pg-btn { font: inherit; font-size: 0.85rem; padding: 5px 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: var(--radius); cursor: pointer; }
.browse-pg-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.browse-pg-btn:disabled { opacity: 0.4; cursor: default; }
.browse-pg-label { font-size: 0.85rem; color: var(--muted); }

/* Header conversation-actions kebab: relative wrapper so openConvMenu's absolute
   dropdown anchors under the button (same menu as the B-column row kebab). */
.thread-menu-wrap { position: relative; display: inline-flex; align-items: center; }

/* Macro edit modal: comfortable multi-line content textarea. */
.macro-edit__text {
  min-height: 120px;
  line-height: 1.45;
}

/* Topbar "frequently used" pins dropdown trigger (centered between two spacers). */
.topbar-pins {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.topbar-pins:hover { color: var(--text); border-color: var(--accent); }
.topbar-pins svg { width: 16px; height: 16px; display: block; }
.topbar-pins__caret { font-size: 0.7rem; opacity: 0.7; }
.pins__menu .macro__empty {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Follow-up chat modal: a bit wider so the note line doesn't wrap awkwardly. */
#followup-modal .modal__panel {
  max-width: 580px;
}
#followup-modal .sn-form__note {
  line-height: 1.5;
  margin: 8px 0 4px;
}

/* Move menu: async-loading agent list placeholder. */
.convo__menu-loading {
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

/* Mailbox (POP3 inbox) list + detail. */
#inbox-list { display: flex; flex-direction: column; }
.inbox-row {
  display: grid;
  grid-template-columns: minmax(90px, 160px) 1fr auto;
  gap: 10px;
  align-items: baseline;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.inbox-row:hover { background: var(--surface-2); }
.inbox-row--unseen { font-weight: 600; }
.inbox-row--priority { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.inbox-row__flag { color: var(--accent); }
.inbox-row__ref {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 4px;
  padding: 0 4px;
  vertical-align: middle;
}
.inbox-detail__actions { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.email-settings textarea {
  width: 100%;
  resize: vertical;
  font: inherit;
  font-size: 0.85rem;
  padding: 6px 8px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.inbox-view-btns .install-btn.is-active,
#inbox-view-inbox.is-active,
#inbox-view-spam.is-active { background: var(--accent); color: #fff; }
.inbox-row__from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-row__subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.inbox-row__date { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.inbox-back { background: none; border: none; color: var(--accent); font: inherit; cursor: pointer; padding: 4px 0; margin-bottom: 8px; }
.inbox-detail__subj { font-size: 1.05rem; font-weight: 600; margin-bottom: 4px; }
.inbox-detail__meta { color: var(--muted); font-size: 0.82rem; margin-bottom: 12px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.inbox-detail__body pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: inherit; font-size: 0.9rem; line-height: 1.5; }

/* Build date under the version in the account menu: its own readable line, so the
   date is not something you have to decode from the version string. */
.acc-built {
  margin-top: 2px;
  font-size: 0.7rem;
  color: var(--muted);
}


/* Find inside the open conversation. The box only exists while it is in use, so the
   header keeps its shape the rest of the time. */
.thread-find { display: inline-flex; align-items: center; gap: 4px; }
/* An inline SVG with only a viewBox collapses to nothing: every icon in this file is
   sized by an explicit rule, and this one was missing -- the button was there, its
   icon was 0x0, so the control was invisible while every automated check passed. */
.thread-find svg { width: 18px; height: 18px; display: block; }
.thread-find__box { display: inline-flex; align-items: center; gap: 4px; }
/* A display rule on the element outranks the [hidden] attribute, so closing the box
   left it on screen. Both of these need the guard, not just one of them. */
.thread-find[hidden],
.thread-find__box[hidden] { display: none; }
.thread-find__input {
  width: 180px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
}
.thread-find__input:focus { outline: none; border-color: var(--accent); }
.thread-find__count { color: var(--muted); font-size: 0.78rem; min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.findhit { background: rgba(255, 214, 0, 0.28); border-radius: 3px; color: inherit; }
.findhit--on { background: var(--accent); color: #fff; }
@media (max-width: 700px) {
  .thread-find__input { width: 120px; }
}


/* A [name] in a message body is a reference to a file the message carries: it looks
   like the other chips, and it takes you to the picture it names. */
.msg__ref {
  font: inherit;
  font-size: 0.9em;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 6px;
  cursor: pointer;
  vertical-align: baseline;
}
.msg__ref:hover { border-color: var(--accent); }
.att-flash { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---- End-of-session actions, under the composer ------------------------------------- */

/* Two things wanted at the END of a piece of work: distil what was learned, and carry a
   client change out to the template. They sit under the composer because that is where
   the eye already is when a session finishes. Quiet by default -- these are occasional
   actions, not part of writing a message. */
.endbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 8px;
  flex-wrap: wrap;
}

.endbar__btn {
  font: inherit;
  font-size: 0.72rem;
  padding: 2px 10px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.endbar__btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent);
}

.endbar__btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.endbar__status {
  font-size: 0.7rem;
  color: var(--muted);
  /* The port report is several lines of plain text; let it wrap rather than stretch the
     row, and keep its line breaks. */
  white-space: pre-wrap;
  flex: 1 1 100%;
}

.endbar__status.is-bad { color: var(--danger, #e5534b); }

/* ---- Middle-column switch and its panes ---------------------------------------------- */

/* The strip between the Frequent and Apps buttons, and the panes it drives. Brought over
   from the app template so the shell is the same shape everywhere: in Sub-Etha only AI
   carries content today, and the rest are real panes waiting for a job rather than
   placeholders that would have to be built before anything could be put in them. */
.topbar-seg {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  /* Scrolls instead of clipping. With the eight built-in tabs this never triggers, but
     the Admin pane can add more, and `overflow: hidden` cut the last label in half --
     a tab reading "Üte" looks like a rendering fault rather than a full strip. */
  overflow-x: auto;
  scrollbar-width: none; /* the strip is short; a scrollbar under it would be louder than the tabs */
  max-width: 100%;
}
.topbar-seg::-webkit-scrollbar { display: none; }
.topbar-seg__btn { flex: none; white-space: nowrap; }

.topbar-seg__btn {
  padding: 4px 12px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.topbar-seg__btn:first-child { border-left: 0; }
.topbar-seg__btn:hover { color: var(--text); }
.topbar-seg__btn.is-on { background: var(--accent); color: #fff; }
.topbar-seg__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.pane {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.pane__inner { max-width: 560px; }
.pane__title { margin: 0 0 6px; font-size: 1rem; font-weight: 600; }
.pane__hint { margin: 0 0 18px; color: var(--muted); font-size: 0.9rem; }
.pane__form { display: grid; gap: 6px; }
.pane__form label { color: var(--muted); font-size: 0.8rem; margin-top: 8px; }
.pane__form input,
.pane__form textarea {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.pane__form button {
  margin-top: 14px;
  justify-self: start;
  padding: 8px 18px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}
.pane__form button:hover { filter: brightness(1.06); }

.pane--wide .pane__inner { max-width: none; }
.pane__head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.pane__head .pane__title { margin: 0; }
.pane__action {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.pane__action:hover { color: var(--text); border-color: var(--accent); }
.pane__badge {
  margin-left: auto;
  color: var(--muted);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.8rem;
}

/* Table pane */
.pane__table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.pane__table th,
.pane__table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.pane__table th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.pane__table tbody tr:hover { background: var(--surface-2); }
.pane__table .state { font-size: 0.78rem; color: var(--muted); }
.pane__table .state--on { color: var(--accent); }

/* Result pane */
.pane__output {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  white-space: pre;
  overflow-x: auto;
}

/* List + detail pane */
.pane__list { list-style: none; margin: 0; padding: 0; }
.pane__list li {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
}
.pane__list li:hover { border-color: var(--accent); }
.pane__list .li-sub { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.pane__detail dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.pane__detail dt { color: var(--muted); font-size: 0.85rem; }
.pane__detail dd { margin: 0; font-size: 0.9rem; }

/* Dashboard pane */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.card__label { color: var(--muted); font-size: 0.78rem; }
.card__value { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 4px; }
.bars { margin-top: 20px; display: grid; gap: 10px; max-width: 520px; }
.bar { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; font-size: 0.85rem; }
.bar__track { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar__fill { height: 100%; background: var(--accent); }
.bar__num { color: var(--muted); font-variant-numeric: tabular-nums; }

/* What the switch actually does. !important because the chat's own parts have their own
   hidden rules (the composer appears only with a conversation open, attachments only when
   there are any) -- leaving AI has to win over those, and returning hands control back. */
.center-off { display: none !important; }

/* ---- The Admin pane ------------------------------------------------------------------ */

/* Taken from the app template unchanged: the same controls should look the same in
   every app built on it. */
.admin-group { margin-bottom: 26px; }
.admin-group__title { margin: 0 0 8px; font-size: 0.85rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.admin-note { margin: 0 0 10px; color: var(--muted); font-size: 0.82rem; }
.admin-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 0.9rem; }
.admin-row > span { flex: 0 0 150px; color: var(--muted); font-size: 0.85rem; }
.admin-row input[type='text'],
.admin-row select {
  flex: 1 1 auto;
  max-width: 280px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.admin-row input[type='color'] { width: 44px; height: 30px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.admin-checks { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 14px; }
.admin-checks label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.88rem; }
.admin-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 0.85rem; }

/* The added tabs, listed in the Admin pane: name, the id an app fills it by, and the way
   to remove it. */
.admin-extras { display: grid; gap: 6px; margin-bottom: 12px; }
.admin-extra { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; }
.admin-extra__name { flex: 0 0 150px; }
.admin-extra__id { flex: 1; color: var(--muted); font-size: 0.78rem; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* Where a runner puts its button.
 *
 * The chat client draws no button and runs nothing: it only marks a code block whose first
 * line carries the fleet's READ-ONLY / MODIFIES DATA banner, and leaves an empty slot in
 * the block's header. The ScriptBoy extension fills that slot. Empty it takes no space, so
 * a block nobody augments looks exactly as it always did. */
.msg__codeslot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.msg__codeslot:empty { display: none; }

/* Dragging a workdir entry onto a folder. Quiet while nothing is happening: the tree is
   read far more often than it is rearranged. */
.rp-tree__row.is-dragging { opacity: 0.45; }
.rp-tree__row.is-droptarget {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  outline: 1px solid var(--accent);
  outline-offset: -1px;
  border-radius: 4px;
}
/* What just moved, and one button to reverse it. A misdrop in a tree is silent -- the row
   is simply not where it was -- so the move says so out loud for a few seconds. */
.wd-undo {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 0.8rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.wd-undo__btn {
  font: inherit;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}

/* Renaming a tab, next to the checkbox that shows it. Narrow on purpose: a tab name that
   does not fit here would not fit in the topbar either. */
.admin-rename {
  width: 9rem;
  margin-left: 8px;
  padding: 2px 6px;
  font: inherit;
  font-size: 0.78rem;
  color: inherit;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
}
