/* Nerd Font symbols (powerline separators, devicons, etc.) as a fallback so
   prompt glyphs render; normal monospace still handles text. */
@font-face {
  font-family: 'Symbols Nerd Font Mono';
  src: url('./fonts/SymbolsNerdFontMono.ttf') format('truetype');
  font-display: swap;
}

:root {
  --bg: #0d1117;
  --bg-2: #11161d;
  --panel: #161b22;
  --border: #21262d;
  --text: #c9d1d9;
  --muted: #8b949e;
  --accent: #d97757;       /* Claude clay/orange */
  --accent-dim: #b45f44;
  --green: #3fb950;
  --red: #f85149;
  --sel: #1f6feb33;
  font-size: 14px;
}

* { box-sizing: border-box; }

/* ---------- Scrollbars ---------- */
* {
  scrollbar-width: thin;                       /* Firefox */
  scrollbar-color: #30363d var(--bg-2);
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb {
  background: #30363d;
  border-radius: 6px;
  border: 2px solid var(--bg-2);
}
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }
::-webkit-scrollbar-corner { background: var(--bg-2); }
/* terminal panes sit on the darker --bg */
.term-pane ::-webkit-scrollbar-track,
.term-pane ::-webkit-scrollbar-corner { background: var(--bg); }
.term-pane ::-webkit-scrollbar-thumb { border-color: var(--bg); }
.term-pane { scrollbar-color: #30363d var(--bg); }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

#app {
  /* Fixed = out of the document flow, so the document never has anything to
     scroll. Focus calls can scroll even an overflow:hidden root a few px,
     which shifted the whole layout: the WCO drag band stopped lining up with
     the window top and the terminal spilled past the window bottom. */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  display: grid;
  grid-template-columns: 360px 1fr;
  height: 100vh;
  height: 100dvh; /* track mobile browser chrome */
}

/* ---------- Window Controls Overlay (PWA) ---------- */
/* When installed with WCO, the app's own top row IS the title bar: the sidebar
   header and the tab strip live in the draggable overlay band, and the OS
   window controls sit at the far right. The band geometry (--tb-*) is set from
   navigator.windowControlsOverlay in JS and follows the buttons live on every
   geometrychange — env(titlebar-area-*) goes stale on maximize/restore in
   Chromium, which used to let tabs slide under the buttons. */
#app.wco .side-head,
#app.wco #tabs {
  -webkit-app-region: drag;
  app-region: drag;
}
#app.wco .side-head {
  min-height: var(--tb-h, 33px);
  /* line the brand up with the window-controls band on the left (macOS) */
  padding-left: calc(14px + var(--tb-left, 0px));
}
/* buttons stay clickable; the brand/title area drags the window */
#app.wco .side-head .icon-btn {
  -webkit-app-region: no-drag;
  app-region: no-drag;
}
#app.wco #tabs {
  /* end the strip (and the tabstrip scrollport with it) before the OS buttons */
  padding-right: calc(var(--tb-right, 0px) + 8px);
  min-height: max(38px, var(--tb-h, 33px));
}
#app.wco #tabs .tab,
#app.wco #tabs .nav-toggle {
  -webkit-app-region: no-drag;
  app-region: no-drag;
}

/* ---------- Sidebar ---------- */
#sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  min-height: 0;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  flex: 1 1 auto;
  min-width: 0;
}
/* The span always fills the leftover space (its box doesn't track its text),
   so the JS brand fitter can swap the label without resize feedback loops. */
.brand span {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}
.head-actions { flex: none; }

/* connection swapper */
#conn-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--muted);
  font-size: 12px;
  flex: none;
}
#conn-bar > i { font-size: 11px; }
#conn-select {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 7px;
  font-size: 12px;
  outline: none;
}
#conn-select:focus { border-color: var(--accent-dim); }
#conn-bar .icon-btn { font-size: 12px; padding: 2px 6px; }

.conn-list { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.conn-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 7px; }
.conn-row-label { font-weight: 600; }
.conn-row code { color: var(--muted); font-size: 11px; flex: 1; overflow: hidden; text-overflow: ellipsis; }
.conn-del { border: none; background: none; color: var(--muted); cursor: pointer; }
.conn-del:hover { color: var(--red); }
.conn-add { display: flex; gap: 6px; margin-top: 12px; align-items: center; }
.conn-add .modal-input { margin-top: 0; }
.conn-sub { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-top: 16px; margin-bottom: 4px; }
.conn-coord { border-top: 1px solid var(--border); margin-top: 14px; }
.conn-coord .modal-input { margin-top: 8px; }
.conn-coord .m-btn.ok { margin-top: 10px; }
.conn-link { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 11px; text-transform: none; letter-spacing: 0; }
.conn-seen { font-size: 10.5px; color: var(--muted); }

/* swappable sidebar views + bottom tab switcher */
#sidebar-body { flex: 1 1 auto; min-height: 0; display: flex; }
.sb-view { display: none; flex-direction: column; flex: 1; min-width: 0; min-height: 0; padding-top: 6px; }
.sb-view.active { display: flex; }

.list { list-style: none; margin: 0; padding: 4px 8px 10px; overflow-y: auto; }
#terminal-list { flex: 1 1 auto; min-height: 0; }
.folders { flex: 1 1 auto; min-height: 0; }

#sidebar-tabs { display: flex; border-top: 1px solid var(--border); background: var(--bg-2); flex: none; }
.sb-tab {
  flex: 1;
  padding: 9px 6px;
  background: none;
  border: none;
  border-top: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.sb-tab:hover { color: var(--text); background: #1c2230; }
.sb-tab.active { color: var(--text); border-top-color: var(--accent); background: var(--bg); }
.sb-badge { font-size: 10px; background: var(--panel); padding: 0 6px; border-radius: 9px; color: var(--muted); min-width: 16px; text-align: center; }
.sb-badge:empty { display: none; }

.filter {
  margin: 0 12px 8px;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.filter:focus { border-color: var(--accent-dim); }

/* terminal rows */
.term-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 7px;
  cursor: pointer;
  margin-bottom: 2px;
}
.term-row:hover { background: #1c2230; }
.term-row.active { background: var(--sel); }
.term-row .tdot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.term-row.dead .tdot { background: var(--red); }
.term-row .tinfo { min-width: 0; flex: 1; }
.term-row .ttitle { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.term-row .tcwd { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.term-row .tkill { opacity: 0; color: var(--muted); border: none; background: none; cursor: pointer; font-size: 14px; }
.term-row:hover .tkill { opacity: 1; }
.term-row .tkill:hover { color: var(--red); }

/* folders */
.folder { margin-bottom: 2px; }
.folder-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
}
.folder-head:hover { background: #1c2230; }
.folder-head .chev { color: var(--muted); font-size: 9px; width: 12px; text-align: center; transition: transform .12s; }
.folder.open .chev { transform: rotate(90deg); }
.folder-head .fname { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.folder-head .fcount { font-size: 11px; color: var(--muted); background: var(--bg); padding: 1px 7px; border-radius: 10px; }
.folder-head .fopen { opacity: 0; border: none; background: none; color: var(--muted); cursor: pointer; font-size: 12px; }
.folder-head:hover .fopen { opacity: 1; }
.folder-head .fopen:hover { color: var(--accent); }
.fpath { font-size: 10px; color: var(--muted); padding: 0 8px 4px 26px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sessions { display: none; padding-left: 14px; }
.folder.open .sessions { display: block; }

.session {
  padding: 6px 9px;
  border-left: 2px solid var(--border);
  margin-left: 6px;
  cursor: pointer;
  border-radius: 0 6px 6px 0;
}
.session:hover { background: #1c2230; border-left-color: var(--accent); }
.session .ssum { font-size: 12.5px; line-height: 1.35; }
.session .smeta { font-size: 10.5px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; }

/* footer */
/* usage bars */
#usage {
  padding: 8px 14px 9px;
  border-top: 1px solid var(--border);
  flex: none;
}
.usage-head { display: flex; align-items: center; justify-content: space-between; font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 6px; }
.usage-est.live { color: var(--green); border-color: var(--green); }
.usage-est.paused { color: #d6a429; border-color: #d6a429; }
.usage-live {
  text-transform: none;
  letter-spacing: 0;
  font-size: 10px;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 5px;
  padding: 1px 7px;
  cursor: pointer;
}
.usage-live:hover { color: var(--text); border-color: var(--accent-dim); }
.usage-est {
  text-transform: none;
  letter-spacing: 0;
  font-size: 9px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 4px;
}
.usage-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }
.usage-row:hover .ubar { box-shadow: 0 0 0 1px var(--accent-dim); }
.usage-row .ul { font-size: 11px; color: var(--muted); width: 16px; flex: none; }
.ubar { flex: 1 1 auto; height: 7px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.ufill { height: 100%; width: 0; background: var(--green); border-radius: 4px; transition: width 0.4s; }
.ufill.warm { background: #d6a429; }
.ufill.hot { background: var(--red); }
.usage-row .upct { font-size: 10.5px; color: var(--muted); width: 34px; text-align: right; flex: none; font-variant-numeric: tabular-nums; }

.side-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  flex: none;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--green); }
.dot.bad { background: var(--red); }

/* buttons */
.icon-btn, .ghost-btn {
  background: none; border: 1px solid transparent; color: var(--muted);
  cursor: pointer; border-radius: 6px;
}
.icon-btn { font-size: 16px; padding: 2px 7px; }
.icon-btn:hover { color: var(--text); background: #1c2230; }
.ghost-btn { font-size: 12px; padding: 3px 9px; border-color: var(--border); }
.ghost-btn:hover { color: var(--text); border-color: var(--accent-dim); }

/* ---------- Main / terminal ---------- */
#main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }

#tabs {
  display: flex;
  gap: 4px;
  padding: 6px 8px 0;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  min-height: 38px;
}
/* Inner scroller: keeps overflowing tabs inside the strip (they clip at the
   scrollport edge instead of sliding under the WCO window controls) and never
   shows a scrollbar — wheel scrolling + focus auto-scroll navigate it. */
#tabstrip {
  display: flex;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
#tabstrip::-webkit-scrollbar { display: none; }
.tab {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--muted);
  max-width: 230px;
}
.tab.active { background: var(--bg); color: var(--text); }
.tab .tabname { overflow: hidden; text-overflow: ellipsis; }
.tab .x { border: none; background: none; color: inherit; cursor: pointer; opacity: .6; font-size: 14px; }
.tab .x:hover { opacity: 1; color: var(--red); }

#term-host { position: relative; flex: 1 1 auto; min-height: 0; }
.term-pane { position: absolute; inset: 0; display: none; }
.term-pane.active { display: block; }
/* Terminal padding lives on the .xterm element, NOT the pane: the fit addon
   sizes the grid from the pane's border-box height minus the .xterm padding,
   so pane padding would be invisible to it and the last row would overflow
   the window by that many pixels. */
.term-pane .xterm { height: 100%; padding: 6px 4px 4px 8px; }

.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.empty-inner { text-align: center; max-width: 420px; color: var(--muted); }
.empty-inner h1 { color: var(--text); font-size: 20px; margin-bottom: 8px; font-weight: 600; }
.empty-inner p { line-height: 1.6; }
kbd { background: var(--panel); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; color: var(--text); font-size: 12px; }

/* ---------- File explorer pane ---------- */
.fs-pane {
  padding: 0;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
}
/* Beat the generic `.term-pane.active { display: block }` so the flex
   column (and therefore the scrollable list) survives when active. */
.term-pane.fs-pane.active { display: flex; }
.fs-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex: none;
}
.fs-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 13px;
  cursor: pointer;
  flex: none;
}
.fs-btn:hover:not(:disabled) { border-color: var(--accent-dim); }
.fs-btn:disabled { opacity: 0.35; cursor: default; }
.fs-shell { margin-left: auto; }

.fs-crumbs {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: nowrap;
  overflow-x: auto;
  font-size: 12.5px;
  min-width: 0;
  padding: 0 4px;
}
.crumb { padding: 2px 6px; border-radius: 6px; cursor: pointer; white-space: nowrap; color: var(--muted); }
.crumb:hover { background: #1c2230; color: var(--text); }
.crumb.cur { color: var(--text); font-weight: 600; cursor: default; }
.crumb.cur:hover { background: none; }
.crumb-sep { color: var(--border); }

.fs-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 0; }
.fs-row {
  display: grid;
  grid-template-columns: 22px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 5px 14px;
  cursor: default;
  font-size: 13px;
  user-select: none;
}
.fs-row:hover { background: #1c2230; }
.fs-row.err { opacity: 0.5; }
.fs-row .fi { text-align: center; color: var(--muted); }
.fs-row .fi .fa-folder, .fs-row .fi .fa-hard-drive { color: var(--accent); }
.fs-row .fn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-row .fsz { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.fs-row .fmt { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.fs-empty, .fs-error { padding: 24px; color: var(--muted); text-align: center; }
.fs-error b { color: var(--text); }

/* ---------- Monaco editor pane ---------- */
.ed-pane { padding: 0; background: var(--bg); }
.ed-pane .monaco-editor,
.ed-pane .monaco-editor .overflow-guard { width: 100% !important; height: 100% !important; }

/* ---------- Remote desktop pane ---------- */
.desk-pane { padding: 0; background: #000; outline: none; }
/* beat `.term-pane.active { display:block }` so the column layout applies */
.term-pane.desk-pane.active { display: flex; flex-direction: column; }
.desk-bar { display: flex; gap: 6px; padding: 5px 8px; background: var(--bg-2); border-bottom: 1px solid var(--border); flex: none; align-items: center; }
.desk-seg { background: var(--panel); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 4px 13px; cursor: pointer; font-size: 12px; }
.desk-seg.active { background: var(--accent); border-color: var(--accent); color: #061018; font-weight: 600; }
.desk-seg:disabled { opacity: 0.4; cursor: default; }
.desk-info { margin-left: auto; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.desk-view { position: relative; flex: 1 1 auto; min-height: 0; background: #000; display: flex; overflow: hidden; outline: none; }
.desk-img { max-width: 100%; max-height: 100%; display: block; margin: auto; } /* fit (contain) + center; box == media so coords stay exact */
.desk-status { position: absolute; top: 50%; left: 0; right: 0; transform: translateY(-50%); text-align: center; color: var(--muted); font-size: 13px; }
/* software cursor (GDI capture excludes the OS cursor) */
.desk-cursor {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid #38e06a;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #000;
  pointer-events: none;
  z-index: 5;
}
/* ---------- Remote browser pane ---------- */
.term-pane.brow-pane.active { display: flex; flex-direction: column; }
.brow-bar { display: flex; gap: 6px; padding: 6px 8px; background: var(--bg-2); border-bottom: 1px solid var(--border); flex: none; align-items: center; }
.brow-b { background: var(--panel); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 5px 9px; cursor: pointer; font-size: 12px; flex: none; }
.brow-b:hover:not(:disabled) { border-color: var(--accent-dim); }
.brow-b:disabled { opacity: 0.35; cursor: default; }
.brow-url { flex: 1 1 auto; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 7px; padding: 6px 10px; font-size: 13px; outline: none; }
.brow-url:focus { border-color: var(--accent-dim); }
.brow-view { position: relative; flex: 1 1 auto; min-height: 0; background: #000; display: flex; overflow: auto; outline: none; }

/* ---------- Session reader pane ---------- */
.term-pane.reader-pane.active { display: flex; }
.reader-pane { background: var(--bg); container-type: inline-size; }
.rd-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
/* Open-task sidebar: only when the session has open tasks AND the pane is
   wide enough (container query, so it also reacts to sidebar/drawer state). */
.rd-todos {
  display: none;
  flex: 0 0 250px;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-2);
}
@container (min-width: 860px) {
  .reader-pane.rd-has-todos .rd-todos { display: flex; }
}
.rd-todos-head {
  flex: none;
  padding: 10px 12px 8px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.rd-todo-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 0; padding: 8px 10px; list-style: none; }
.rd-todo { display: flex; gap: 8px; padding: 6px 6px; font-size: 12.5px; line-height: 1.4; border-radius: 6px; margin-bottom: 2px; }
.rd-todo i { margin-top: 3px; font-size: 10px; width: 12px; text-align: center; flex: none; color: var(--muted); }
.rd-todo.in_progress { background: var(--sel); }
.rd-todo.in_progress i { color: var(--accent); }
.rd-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px 14px 8px; }
.rd-older { display: block; margin: 0 auto 14px; }
.rd-msg {
  max-width: 900px;
  margin: 0 auto 10px;
  padding: 9px 13px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.55;
  border: 1px solid var(--border);
  background: var(--panel);
}
.rd-user { background: #1b2436; border-color: #2a3752; }
.rd-text { white-space: pre-wrap; overflow-wrap: break-word; }
.rd-text + .rd-text, .rd-text + details, .rd-msg details + .rd-text { margin-top: 8px; }
.rd-text code { background: var(--bg-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-size: 12px; }
.rd-code {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  margin: 6px 0;
  overflow-x: auto;
  font-size: 12px;
  white-space: pre;
}
.rd-h { display: block; margin-top: 6px; }
.rd-tblwrap { overflow-x: auto; margin: 8px 0; }
.rd-tbl { border-collapse: collapse; font-size: 12.5px; white-space: normal; }
.rd-tbl th, .rd-tbl td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; vertical-align: top; }
.rd-tbl th { background: var(--bg-2); font-weight: 600; }
.rd-tbl tbody tr:nth-child(even) td { background: #ffffff05; }
.rd-msg details { margin: 4px 0; }
.rd-msg summary { cursor: pointer; color: var(--muted); font-size: 12px; -webkit-user-select: none; user-select: none; }
.rd-msg details pre {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  margin: 6px 0 2px;
  max-height: 260px;
  overflow: auto;
  font-size: 11.5px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.rd-think summary { font-style: italic; }
.rd-result.err summary { color: var(--red); }

/* file-edit diff (CLI-style red/green) */
.rd-editblk { margin: 4px 0; }
.rd-editblk summary { font-size: 12px; }
.rd-diff {
  border: 1px solid var(--border);
  border-radius: 7px;
  margin: 6px 0 2px;
  max-height: 320px;
  overflow: auto;
  background: var(--bg-2);
  font-family: Consolas, "Cascadia Code", monospace;
  font-size: 11.5px;
  line-height: 1.45;
}
.rd-dl { padding: 0 8px; white-space: pre-wrap; overflow-wrap: break-word; }
.rd-dl.del { background: #67060c3d; color: #ffb3ad; }
.rd-dl.add { background: #0338164a; color: #85e0a3; }

/* grouped shell commands (collapsed, CLI-style) */
.rd-shgroup { max-width: 900px; margin: 0 auto 10px; font-size: 12.5px; }
.rd-shgroup > summary {
  cursor: pointer;
  color: var(--muted);
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  font-size: 12px;
  -webkit-user-select: none;
  user-select: none;
}
.rd-shgroup > summary:hover { color: var(--text); }
.rd-shgroup > summary i { margin-right: 6px; font-size: 10px; }
.rd-shgroup[open] > summary { border-radius: 10px 10px 0 0; }
.rd-shitems { border: 1px solid var(--border); border-top: none; border-radius: 0 0 10px 10px; background: var(--panel); padding: 9px 12px 4px; }
.rd-shitem { margin-bottom: 8px; }
.rd-shcmd { font-family: Consolas, "Cascadia Code", monospace; font-size: 11.5px; white-space: pre-wrap; overflow-wrap: break-word; }
.rd-shdesc { color: var(--muted); font-family: -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 11px; }
.rd-shout {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 9px;
  margin: 4px 0 2px;
  max-height: 200px;
  overflow: auto;
  font-size: 11px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  color: var(--muted);
}
.rd-shout.err { border-color: #67060c; color: #ffb3ad; }
.rd-hint { flex: none; color: var(--muted); font-size: 11px; padding: 3px 12px 0; }
.rd-hint:empty { display: none; }
.rd-inbar {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  flex: none;
  align-items: flex-end;
}
.rd-in {
  flex: 1 1 auto;
  min-width: 0;
  resize: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  max-height: 130px;
}
.rd-in:focus { border-color: var(--accent-dim); }

/* touch device in landscape: desktop/browser fill the screen (regardless of width) */
@media (orientation: landscape) and (pointer: coarse) {
  #app.desk-active .desk-pane.active,
  #app.desk-active .brow-pane.active { position: fixed; inset: 0; z-index: 1000; }
}

/* tab kinds */
.tab .ticon { font-size: 11px; opacity: 0.8; }
.tab-fs.active,
.tab-editor.active { box-shadow: inset 0 2px 0 var(--accent); }
.tab.dirty .tabname::before { content: '● '; color: var(--accent); font-size: 10px; }
.head-actions { display: flex; gap: 2px; }

/* ---------- Confirm modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: #000a;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  width: min(440px, 90vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 60px #000b;
  padding: 18px 18px 14px;
}
.modal-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.modal-msg { font-size: 13px; line-height: 1.55; color: var(--muted); }
.modal-msg br { content: ''; }
.modal-input {
  width: 100%;
  margin-top: 14px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.modal-input:focus { border-color: var(--accent); }
.modal-field { display: block; margin-top: 12px; }
.modal-field span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.modal-field .modal-input { margin-top: 0; }
.modal-err { color: var(--red); font-size: 12px; margin-top: 10px; min-height: 14px; }
.icon-btn.enrolled { color: var(--green); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.m-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.m-btn:hover { border-color: var(--accent-dim); }
.m-btn.ok { background: var(--accent); border-color: var(--accent); color: #fff; }
.m-btn.ok:hover { background: var(--accent-dim); }
.m-btn.ok.danger { background: var(--red); border-color: var(--red); }
.m-btn.ok.danger:hover { background: #c93c34; }

/* ---------- Context menu ---------- */
.ctx-menu {
  position: fixed;
  z-index: 2000;
  min-width: 210px;
  padding: 5px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: 0 10px 30px #000a;
  font-size: 13px;
  user-select: none;
}
.ctx-item {
  display: flex;
  align-items: center;
  padding: 7px 11px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--text);
}
.ctx-ic { width: 16px; text-align: center; margin-right: 10px; color: var(--muted); font-size: 13px; }
.ctx-item:hover { background: var(--sel); }
.ctx-item.danger { color: var(--red); }
.ctx-item.danger .ctx-ic { color: var(--red); }
.ctx-item.danger:hover { background: #f8514922; }
.ctx-sep {
  height: 1px;
  margin: 5px 8px;
  background: var(--border);
}

/* mobile terminal key bar (above the soft keyboard) */
#keybar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0; /* transform lifts it above the keyboard on iOS */
  z-index: 60;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
}
#keybar.show { display: flex; }
.kb-row { display: grid; gap: 4px; }
.kb-key {
  min-width: 0;
  padding: 10px 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 12px;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.kb-key:active { background: var(--sel); }
.kb-key.kb-mod { color: var(--muted); }
.kb-key.armed { background: var(--accent); color: #fff; border-color: var(--accent); }
@media (min-width: 761px) { #keybar { display: none !important; } }

/* mobile menu button (in the tab bar) + backdrop — hidden on desktop */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text);
  font-size: 16px;
  padding: 0 14px;
  cursor: pointer;
  flex: none;
}
#nav-backdrop { display: none; }

@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }

  /* sidebar becomes a slide-in drawer */
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    width: 86%;
    max-width: 340px;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  #app.nav-open #sidebar { transform: none; box-shadow: 2px 0 24px #000a; }
  #nav-backdrop { position: fixed; inset: 0; z-index: 40; background: #0007; }
  #app:not(.nav-open) #nav-backdrop { display: none; }
  #app.nav-open #nav-backdrop { display: block; }

  .nav-toggle { display: flex; }
  #tabs { min-height: 42px; }
  .tab { max-width: 52vw; padding: 9px 12px; }

  /* bigger touch targets */
  .icon-btn { padding: 6px 9px; font-size: 17px; }
  .sb-tab { padding: 12px 6px; }
  .term-row, .session, .folder-head, .ctx-item, .fs-row { padding-top: 9px; padding-bottom: 9px; }

  /* 16px inputs so iOS doesn't zoom on focus */
  .filter, #conn-select, .modal-input, .rd-in { font-size: 16px; }
  .modal { width: 94vw; }
}
