@font-face {
  font-family: "JetBrains Mono";
  src: url("/jbmono-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/jbmono-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/jbmono-600-latin.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/jbmono-600-latin-ext.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/jbmono-800-latin.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/jbmono-800-latin-ext.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* sinep.dev design language (direction C): one signal colour on near-black neutrals, one type
   family, no shadows, motion that winds up, snaps and recoils. */
:root {
  color-scheme: dark;
  /* neutrals */
  --void: #0a0b0d; /* app background */
  --ink: #111216; /* panels, header */
  --graphite: #15161b; /* cards */
  --raised: #1c1d23; /* inputs, hover */
  --line: #26282f; /* borders */
  --line-plus: #3a3c44; /* strong borders, idle */
  --ash: #8a8d96; /* secondary text */
  --bone: #f2efe8; /* primary text */
  /* signal and state */
  --signal: #ff6b2c; /* brand, primary action, working — one per view */
  --signal-hover: #ff8a55;
  --ok: #3fd68a;
  --wait: #f5c542;
  --fail: #ff4f6e;
  --info: #5cc8ff;
  /* radii */
  --r-chip: 4px;
  --r-control: 8px;
  --r-card: 12px;
  --r-panel: 20px;
  /* motion */
  --ease-windup: cubic-bezier(0.45, 0, 0.55, 1);
  --ease-snap: cubic-bezier(0.7, 0, 1, 0.6);
  --ease-recoil: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-flick: cubic-bezier(0.2, 0.8, 0.3, 1);
  --dur-flick: 120ms;
  --dur-snap: 180ms;
  --dur-hitstop: 90ms;
  --dur-crack: 1800ms;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  /* the names the rest of this sheet uses */
  --bg: var(--void);
  --bg-alt: var(--ink);
  --border: var(--line);
  --fg: var(--bone);
  --fg-dim: var(--ash);
  --accent: var(--signal);
  --add-bg: rgba(63, 214, 138, 0.12);
  --add-emph: rgba(63, 214, 138, 0.36);
  --del-bg: rgba(255, 79, 110, 0.12);
  --del-emph: rgba(255, 79, 110, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.5 var(--mono);
}

#root,
.app {
  height: 100vh;
  /* Safari mobile: 100vh includes the area behind the browser chrome, pushing the bottom dock
     off-screen. 100dvh tracks the actually-visible viewport. */
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Installed app (viewport-fit=cover): keep content out of the notch / rounded corners. The
   insets are 0 in a normal browser tab and on desktop. */
.app {
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  padding-top: calc(6px + env(safe-area-inset-top, 0px));
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}

/* Lockup: "> sinep.dev" with a blinking signal cursor block. */
.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35em;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.03em;
  color: var(--bone);
  margin-right: 8px;
  white-space: nowrap;
}
.brand .prompt { color: var(--signal); }
.brand .tld { color: var(--ash); }
.brand .cursor {
  display: inline-block;
  width: 0.5em;
  height: 0.78em;
  margin-left: 0.06em;
  background: var(--signal);
  animation: blink 1.1s linear infinite;
}
@keyframes blink {
  0%, 49.9% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.spacer {
  flex: 1;
}

.whoami {
  color: var(--fg-dim);
}

button,
select {
  background: var(--raised);
  color: var(--fg);
  border: 1px solid var(--line-plus);
  border-radius: var(--r-control);
  padding: 3px 10px;
  font: 600 12px/1.5 var(--mono);
  cursor: pointer;
  transition: background var(--dur-flick) var(--ease-flick), border-color var(--dur-flick) var(--ease-flick),
    color var(--dur-flick) var(--ease-flick);
}
input,
textarea {
  font-family: var(--mono);
}
button:hover:not(:disabled),
select:hover {
  border-color: var(--ash);
}
/* Focus: a 2px signal ring, offset 2px — no glows. */
:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline-offset: 0;
}
a {
  color: var(--info);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 260px;
  overflow: auto;
  border-right: 1px solid var(--border);
  background: var(--bg-alt);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.content {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

.terminal-section {
  height: 40%;
  min-height: 180px;
  border-top: 1px solid var(--border);
  background: var(--ink);
}

/* No padding here: this is the fit addon's parent, and with border-box its computed height
   includes padding — fit then adds rows that don't fit and the last one (tmux's status line)
   is clipped. The padding goes on the xterm element, which fit subtracts. */
.terminal-pane {
  height: 100%;
  overflow: hidden;
}
.terminal-pane > .xterm {
  height: 100%;
  padding: 4px;
}

/* file tree */
.tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 6px;
  cursor: pointer;
  white-space: nowrap;
}

.tree-row:hover {
  background: var(--raised);
}

.tree-icon {
  color: var(--fg-dim);
  width: 12px;
  display: inline-block;
}

.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: var(--r-chip);
  margin-left: auto;
}

.badge-modified {
  color: var(--wait);
}
.badge-untracked {
  color: var(--ok);
}
.badge-deleted {
  color: var(--fail);
}
.badge-conflicted {
  color: var(--fail);
}
.badge-renamed {
  color: var(--accent);
}
.badge-dir {
  color: var(--fg-dim);
}

.tree-empty,
.pane-message {
  color: var(--fg-dim);
  padding: 24px;
  text-align: center;
}

/* diff */
.diff-view {
  padding: 8px;
}

.diff-file {
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  margin-bottom: 12px;
  overflow: hidden;
}

.diff-file-header {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg-alt);
  cursor: pointer;
  font-family: ui-monospace, monospace;
}

.diff-status {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
}

.diff-status-modified {
  color: var(--wait);
}
.diff-status-added,
.diff-status-untracked {
  color: var(--ok);
}
.diff-status-deleted {
  color: var(--fail);
}
.diff-status-renamed {
  color: var(--accent);
}

.diff-counts {
  margin-left: auto;
}

.diff-counts .add {
  color: var(--ok);
}
.diff-counts .del {
  color: var(--fail);
}

.diff-hunk {
  width: 100%;
  border-collapse: collapse;
  font: 12px/1.45 var(--mono);
}

.hunk-header td {
  color: var(--accent);
  background: rgba(255, 107, 44, 0.08);
  padding: 2px 10px;
}

.diff-line .lineno {
  width: 40px;
  min-width: 40px;
  text-align: right;
  color: var(--fg-dim);
  padding: 0 6px;
  user-select: none;
  vertical-align: top;
}

.diff-line .code {
  white-space: pre-wrap;
  word-break: break-all;
  padding-right: 8px;
}

.diff-line .sign {
  display: inline-block;
  width: 14px;
  color: var(--fg-dim);
  user-select: none;
}

.diff-add {
  background: var(--add-bg);
}
.diff-del {
  background: var(--del-bg);
}
.emph-add {
  background: var(--add-emph);
  border-radius: 2px;
}
.emph-del {
  background: var(--del-emph);
  border-radius: 2px;
}

/* file view */
.file-view {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.file-view-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}

.file-view-path {
  font-family: ui-monospace, monospace;
}

.file-view-msg {
  color: var(--wait);
}

.file-view-editor {
  flex: 1;
  resize: none;
  border: 0;
  outline: none;
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.5 var(--mono);
  padding: 10px;
}

/* login */
.login {
  height: 100dvh;
  padding-top: env(safe-area-inset-top, 0);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.login-button {
  background: var(--signal);
  color: var(--ink);
  font-weight: 800;
  padding: 8px 28px;
  border-radius: var(--r-control);
  text-decoration: none;
}
.login-button::before { content: "> "; }
.login-button.login-oidc { background: var(--raised); color: var(--bone); border: 1px solid var(--line-plus); font-weight: 600; }
.login-button.login-oidc::before { content: none; }

/* staging */
.commit-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.commit-bar input {
  flex: 1;
  max-width: 480px;
  background: var(--bg-alt);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  padding: 5px 10px;
}

.commit-notice {
  color: var(--wait);
  font-size: 12px;
}

.diff-collapse {
  cursor: pointer;
  color: var(--fg-dim);
}

.hunk-actions {
  float: right;
  display: inline-flex;
  gap: 6px;
}

.diff-line {
  cursor: pointer;
}

.line-selected {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

/* modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  width: 460px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal h3 {
  margin: 0 0 4px;
}

.modal input,
.modal select {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg);
}

.modal-error {
  color: var(--fail);
  font-size: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* settings */
.settings-scroll {
  overflow: auto;
  height: 100%;
}

.settings {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px;
}

.settings section {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.settings h3 {
  margin: 0 0 6px;
}

.settings .hint {
  color: var(--fg-dim);
  font-size: 12px;
  margin: 2px 0 10px;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.settings-row input {
  flex: 1;
  padding: 5px 10px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
}

.settings-label {
  font-weight: 600;
  min-width: 120px;
}

.pubkey {
  font: 11px ui-monospace, monospace;
}

.settings-msg {
  color: var(--wait);
  margin-bottom: 10px;
}

button.danger {
  color: var(--fail);
}

/* agent configs */
.config-editor {
  width: 100%;
  min-height: 140px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  padding: 8px 10px;
  font: 12px/1.5 var(--mono);
  resize: vertical;
}

.config-preview {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.settings h4 {
  margin: 10px 0 6px;
  color: var(--fg-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.danger-zone {
  border-color: rgba(255, 79, 110, 0.4) !important;
}

/* terminal toolbar */
.terminal-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.term-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}

.bypass-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--fg-dim);
  cursor: pointer;
}

.terminal-wrap .terminal-pane {
  flex: 1;
  min-height: 0;
}

.editor-pane {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--ink);
}

.editor-pane .terminal-pane {
  flex: 1;
  min-height: 0;
  padding: 4px;
}

/* mobile (on-the-go layout: stacked panes, touch-sized controls) */
@media (max-width: 768px) {
  .topbar {
    flex-wrap: wrap;
    row-gap: 4px;
  }

  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: 26vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .terminal-section {
    height: 45%;
  }

  .modal {
    width: 92vw;
  }

  .settings {
    padding: 12px;
  }

  .settings-row {
    flex-wrap: wrap;
  }

  .settings-label {
    min-width: 0;
  }

  button,
  select,
  .settings-row input {
    min-height: 34px;
  }
}

@media (pointer: coarse) {
  .tree-row {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  button {
    min-height: 34px;
  }
}

/* tab strips (workspaces, views, files, terminals) */
.tab-strip {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  min-width: 0;
}

/* Tabs: text on the strip; the active one gets a 2px signal underline. */
.tab {
  padding: 4px 10px 5px;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--fg-dim);
  cursor: pointer;
  white-space: nowrap;
  font-size: 12px;
  user-select: none;
  transition: color var(--dur-flick) var(--ease-flick), border-color var(--dur-flick) var(--ease-flick);
}
.tab:hover {
  color: var(--fg);
}

.tab-active {
  color: var(--fg);
  border-bottom-color: var(--signal);
}

.tab-close {
  color: var(--fg-dim);
}

.tab-close:hover {
  color: var(--fail);
}

.ws-tabs {
  flex: 0 1 auto;
}

.view-tabs {
  padding: 6px 8px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.file-tabs {
  padding: 6px 8px 0;
  border-bottom: 1px solid var(--border);
}

.files-area {
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.file-pane {
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.file-pane .editor-pane {
  flex: 1;
  min-height: 0;
}

.term-tab-body {
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.term-stack {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.term-stack .terminal-pane {
  flex: 1;
  min-height: 0;
}

.term-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(255, 107, 44, 0.12);
  border-bottom: 1px solid var(--accent);
  font-size: 12px;
  overflow: hidden;
}

.term-banner a {
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}

/* fullscreen terminal */
.terminal-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--ink);
}

.settings-back {
  padding: 8px 12px 0;
}

@media (max-width: 768px) {
  .ws-tabs {
    order: 10;
    width: 100%;
  }
}

/* pane resize handles */
.resize-h {
  width: 5px;
  cursor: col-resize;
  background: transparent;
  flex: 0 0 auto;
  touch-action: none;
}

.resize-h:hover,
.resize-v:hover {
  background: var(--accent);
  opacity: 0.5;
}

.resize-v {
  height: 5px;
  cursor: row-resize;
  background: transparent;
  flex: 0 0 auto;
  touch-action: none;
}

.sidebar-modes {
  padding: 6px 6px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 160px;
}

.sidebar .file-tree {
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.terminal-section {
  flex: 0 0 auto;
}

.port-input {
  width: 70px;
  padding: 3px 8px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  font-size: 12px;
}

/* git bar */
.git-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.git-icon {
  color: var(--fg-dim);
}

.git-bar select {
  max-width: 240px;
}

.git-status {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.git-status .ahead {
  color: var(--ok);
}

.git-status .behind {
  color: var(--wait);
}

.git-status .up-to-date {
  color: var(--fg-dim);
}

.git-status .upstream-name {
  color: var(--fg-dim);
}

.git-msg {
  color: var(--wait);
}

/* port preview chips */
.port-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
}

.port-chip:hover {
  border-color: var(--accent);
}

/* xterm measures its glyph cell from an element that inherits the page line-height (1.5),
   which corrupts the cell height and clips box/block/braille glyphs. Reset it to normal. */
.terminal-pane,
.terminal-pane * {
  line-height: normal;
}

/* mobile bottom dock — hidden on desktop */
.mobile-dock {
  display: none;
}

@media (max-width: 768px) {
  .mobile-dock {
    display: flex;
    flex: 0 0 auto;
    /* The home-indicator inset comes on top of the dock, not out of it. */
    height: calc(54px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-alt);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .dock-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    border-radius: 0;
    color: var(--fg-dim);
    font-size: 10px;
  }

  .dock-item.active {
    color: var(--accent);
  }

  .dock-icon {
    font-size: 17px;
    line-height: 1;
  }

  /* Mobile single-pane: the content pane fills the screen; the terminal is shown full-screen
     only when the dock's term item is selected (data-term=1). No resize handle on mobile. */
  .resize-v {
    display: none;
  }
  .app[data-term="0"] .terminal-section {
    display: none;
  }
  .app[data-term="1"] .content {
    display: none;
  }
  .app[data-term="1"] .terminal-section {
    height: 100% !important;
    flex: 1;
  }
}

.chat-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--bg);
}

.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* Chat convention: messages sit at the BOTTOM, just above the composer, and grow upward. */
  justify-content: flex-end;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-empty {
  color: var(--fg-dim);
  text-align: center;
  margin: auto;
}

.chat-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

.chat-user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--void);
  border-bottom-right-radius: 4px;
}

.chat-asst {
  align-self: flex-start;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-sys {
  align-self: center;
  color: var(--fg-dim);
  font-size: 12px;
}

.chat-tool,
.chat-perm {
  align-self: flex-start;
  max-width: 92%;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--bg-alt);
  overflow: hidden;
}

.chat-tool-head,
.chat-perm-head {
  padding: 6px 10px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}

.chat-tool-body {
  margin: 0;
  padding: 8px 10px;
  font: 11px/1.4 ui-monospace, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow: auto;
  color: var(--fg-dim);
}

.chat-perm {
  border-color: var(--accent);
}

.chat-perm-actions {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
}

.chat-perm-actions button {
  flex: 1;
  padding: 8px;
  font-weight: 600;
}

.chat-perm-actions .approve {
  background: rgba(63, 214, 138, 0.2);
  color: var(--ok);
  border-color: var(--ok);
}

.chat-perm-actions .deny {
  background: rgba(255, 79, 110, 0.15);
  color: var(--fail);
  border-color: var(--fail);
}

.chat-perm-done {
  padding: 6px 10px;
  font-size: 12px;
}

.chat-perm-done.approve {
  color: var(--ok);
}
.chat-perm-done.deny {
  color: var(--fail);
}

.chat-result {
  align-self: center;
  font-size: 12px;
  color: var(--fg-dim);
}
.chat-result.chat-err {
  color: var(--fail);
}

.chat-typing {
  align-self: flex-start;
  color: var(--fg-dim);
  font-size: 12px;
  font-style: italic;
}

.chat-input {
  display: flex;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
}

.chat-input textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  padding: 9px 12px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 18px;
  font: inherit;
  line-height: 1.4;
}

.chat-input button {
  border-radius: 18px;
  padding: 0 16px;
}

/* elements owned by the mobile dock (settings) or too cramped on phones */
@media (max-width: 768px) {
  /* !important so it beats component rules like `.rail { display: flex }` */
  .desktop-only {
    display: none !important;
  }
}

/* login page */
.login-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 300px;
  max-width: 90vw;
  padding: 24px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
}

.login-card h1 {
  margin: 0 0 8px;
  text-align: center;
}
.login-card h1 .brand {
  font-size: 26px;
  margin: 0;
}
.login-mark {
  width: 64px;
  height: 64px;
  align-self: center;
}

.login-sub {
  margin: 0 0 6px;
  text-align: center;
  color: var(--fg-dim);
  font-size: 13px;
}

.login-card input {
  padding: 9px 12px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  font-size: 14px;
}

.login-card .login-button {
  border: none;
  cursor: pointer;
  text-align: center;
  margin-top: 4px;
}

.login-error {
  color: var(--fail);
  font-size: 12px;
  text-align: center;
}

.login-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
}

.login-divider {
  text-align: center;
  color: var(--fg-dim);
  font-size: 12px;
  margin: 2px 0;
}

.login-oidc {
  background: var(--raised);
  color: var(--fg);
}

/* work area: left icon rail + main column (content over pinned terminal) */
.workarea {
  flex: 1;
  display: flex;
  min-height: 0;
}

.workmain {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.rail {
  display: flex;
  flex-direction: column;
  width: 66px;
  flex: 0 0 auto;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
}

.rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 11px 0;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--fg-dim);
  font-size: 10px;
  cursor: pointer;
}

.rail-item.active {
  color: var(--accent);
  background: var(--bg);
  box-shadow: inset 2px 0 0 var(--accent);
}

.rail-icon {
  font-size: 18px;
  line-height: 1;
}

/* chat/editor fill the content area (which is flex:1 in the work column) */
.chat-pane {
  height: 100%;
}

/* chat stays mounted while hidden; fill the content area when shown.
   `.content` is a block box, so flex:1 wouldn't apply here — take its full height instead. */
.chat-host {
  height: 100%;
  min-height: 0;
  flex-direction: column;
}

.diff-note {
  color: var(--fg-dim);
  font-size: 12px;
  padding: 2px 4px 8px;
}

/* chat header: backend + session pickers */
.chat-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}
.chat-bar select[title="session"] {
  min-width: 0;
  flex: 1;
}
.chat-session-id {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  margin-left: auto;
  overflow-wrap: anywhere;
}

/* ---- file tree: git status tint, folder roll-up, ignored, active ---- */
.tree-row.st-modified .tree-name { color: var(--wait); }
.tree-row.st-untracked .tree-name { color: var(--ok); }
.tree-row.st-deleted .tree-name { color: var(--fail); text-decoration: line-through; }
.tree-row.st-conflicted .tree-name { color: var(--fail); font-weight: 600; }
.tree-row.st-renamed .tree-name { color: var(--accent); }
.tree-row .tree-dir { font-weight: 500; }
.tree-row.tree-ignored { opacity: 0.45; }
.tree-row.tree-active {
  background: rgba(255, 107, 44, 0.12);
  box-shadow: inset 2px 0 0 var(--accent);
}
.tree-row .badge {
  min-width: 18px;
  text-align: center;
  background: rgba(138, 141, 150, 0.12);
}
.tree-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--fg-dim);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.tree-legend { display: flex; gap: 10px; margin-left: auto; }
.tree-legend .st-modified { color: var(--wait); }
.tree-legend .st-untracked { color: var(--ok); }
.tree-legend .st-deleted { color: var(--fail); }

/* ---- rail / dock badges ---- */
.rail-item, .dock-item { position: relative; }
.pane-badge {
  position: absolute;
  top: 5px;
  right: 9px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--line);
  color: var(--fg);
  font: 600 10px/16px var(--mono);
  text-align: center;
}
.pane-badge.urgent { background: var(--fail); color: var(--ink); }
.pane-dot {
  position: absolute;
  top: 8px;
  right: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.pane-dot.busy { background: var(--accent); animation: sinep-pulse 1.2s ease-in-out infinite; }
.pane-dot.done { background: var(--ok); }
@keyframes sinep-pulse { 50% { opacity: 0.35; } }
.dock-item .pane-badge { top: 3px; right: calc(50% - 22px); }
.dock-item .pane-dot { top: 6px; right: calc(50% - 16px); }

/* ---- user menu ---- */
.user-menu { position: relative; }
.avatar {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  font-weight: 600;
  background: var(--raised);
  border-color: var(--line-plus);
  color: var(--bone);
}
.menu-backdrop { position: fixed; inset: 0; z-index: 40; }
.menu {
  position: absolute;
  right: 0;
  top: 34px;
  z-index: 41;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  box-shadow: none; border-color: var(--line-plus);
}
.menu-head {
  padding: 6px 10px 8px;
  font-size: 12px;
  color: var(--fg-dim);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu button { text-align: left; background: none; border: none; padding: 7px 10px; }
.menu button:hover { background: var(--raised); }
.palette-btn { font-size: 11px; color: var(--fg-dim); margin-right: 8px; }

/* ---- command palette ---- */
.palette-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 11, 13, 0.6);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 16px 0;
}
.palette {
  width: min(640px, 100%);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: none; border-color: var(--line-plus);
  overflow: hidden;
}
.palette-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  font-size: 15px;
  background: transparent;
  color: var(--fg);
  border: none;
  border-bottom: 1px solid var(--border);
  outline: none;
}
.palette-list { max-height: 50vh; overflow: auto; padding: 4px; }
.palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 10px;
  border-radius: var(--r-control);
  cursor: pointer;
}
.palette-item.active { background: rgba(255, 107, 44, 0.15); }
.palette-label { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-detail { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--fg-dim); }
.palette-label:has(+ .palette-kind) { flex: 1; }
.palette-kind { flex: 0 0 auto; margin-left: auto; font-size: 11px; color: var(--fg-dim); }
/* Prefix modes: > commands, # symbols, % text, @ agents, : line. */
.palette-modes { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.palette-mode { height: 24px; padding: 0 8px; font-size: 11px; font-weight: 400; color: var(--fg-dim); background: transparent; border-color: var(--line); border-radius: var(--r-chip); }
.palette-mode.active { color: var(--fg); border-color: var(--signal); }
.palette-prefix { color: var(--signal); font-weight: 800; margin-right: 5px; }
.palette-empty { padding: 12px; color: var(--fg-dim); text-align: center; }

/* ---- chat: markdown, harness messages, collapsible tools ---- */
.chat-asst.md { white-space: normal; }
.chat-asst.md > :first-child { margin-top: 0; }
.chat-asst.md > :last-child { margin-bottom: 0; }
.chat-asst.md p, .chat-asst.md ul, .chat-asst.md ol { margin: 0 0 8px; }
.chat-asst.md ul, .chat-asst.md ol { padding-left: 20px; }
.chat-asst.md h1, .chat-asst.md h2, .chat-asst.md h3 { font-size: 14px; margin: 10px 0 6px; }
.chat-asst.md code {
  font: 12px ui-monospace, monospace;
  background: rgba(138, 141, 150, 0.25);
  padding: 1px 4px;
  border-radius: 4px;
}
.chat-asst.md pre {
  background: var(--void);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  padding: 8px 10px;
  overflow-x: auto;
  margin: 0 0 8px;
}
.chat-asst.md pre code { background: none; padding: 0; white-space: pre; }
.chat-asst.md a { color: var(--accent); }
.chat-asst.md table { border-collapse: collapse; margin-bottom: 8px; font-size: 12px; }
.chat-asst.md th, .chat-asst.md td { border: 1px solid var(--border); padding: 3px 8px; }
.chat-asst.md blockquote { margin: 0 0 8px; padding-left: 10px; border-left: 3px solid var(--border); color: var(--fg-dim); }
.chat-meta {
  align-self: flex-end;
  max-width: 85%;
  font-size: 12px;
  color: var(--fg-dim);
}
.chat-meta summary { cursor: pointer; list-style: none; }
.chat-meta summary::-webkit-details-marker { display: none; }
.chat-meta[open] .chat-tool-body { border: 1px solid var(--border); border-radius: 8px; margin-top: 4px; }
details.chat-tool > summary { cursor: pointer; list-style: none; border-bottom: none; }
details.chat-tool > summary::-webkit-details-marker { display: none; }
details.chat-tool[open] > summary { border-bottom: 1px solid var(--border); }
.chat-tool-preview { color: var(--fg-dim); font-family: ui-monospace, monospace; font-size: 11px; }
.chat-perm { box-shadow: 0 0 0 1px var(--accent); }

/* ---- diff toolbar wraps on narrow screens instead of clipping ---- */
.commit-bar { flex-wrap: wrap; }
@media (max-width: 768px) {
  .commit-bar input { flex: 1 1 100%; max-width: none; }
  .palette-btn { display: none; }
}

/* ---- shared ---- */
/* Primary: signal, ink text, 800, starts with ">" — one per view. */
button.primary { background: var(--signal); border-color: var(--signal); color: var(--ink); font-weight: 800; }
button.primary::before { content: "> "; }
button.primary:hover:not(:disabled) { background: var(--signal-hover); border-color: var(--signal-hover); }
button.primary:disabled { background: var(--line); border-color: var(--line); color: var(--ash); opacity: 1; }
/* Ghost: transparent, ash. */
button.ghost { background: transparent; border-color: transparent; color: var(--ash); }
button.ghost:hover:not(:disabled) { color: var(--bone); background: var(--raised); }
/* Press: shrink 7%, snap to 106%, shake, settle. */
button.primary:active:not(:disabled) { animation: press var(--dur-crack) linear 1 both; animation-duration: 480ms; }
@keyframes press {
  0% { transform: scale(1); animation-timing-function: var(--ease-snap); }
  35% { transform: scale(0.93); animation-timing-function: var(--ease-snap); }
  50% { transform: scale(1.06); }
  60% { transform: scale(1.06) translate(-2px, 1px); }
  66% { transform: scale(1.05) translate(2px, -1px); }
  72% { transform: scale(1.04) translate(-1px, 0); animation-timing-function: var(--ease-recoil); }
  100% { transform: scale(1); }
}
@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .brand .cursor { animation: none; }
}
button.active { border-color: var(--accent); color: var(--accent); }
button.link { background: none; border: none; color: var(--fg-dim); padding: 0 4px; text-decoration: underline; }
.hint { color: var(--fg-dim); font-size: 12px; }
.error { color: var(--fail); font-size: 12px; margin: 6px 0; white-space: pre-wrap; }

/* ---- dialogs ---- */
.dialog {
  width: min(620px, 100%);
  max-height: 80vh;
  overflow: auto;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: none; border-color: var(--line-plus);
  padding: 16px 18px;
  box-sizing: border-box;
}
.dialog h3 { margin: 0 0 6px; font-size: 16px; }
.dialog .hint { margin: 0 0 10px; }
.task-prompt, .review-editor textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  padding: 8px 10px;
  font: 13px/1.45 var(--mono);
  resize: vertical;
}
.dialog-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 10px 0; font-size: 12px; color: var(--fg-dim); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.send-preview {
  max-height: 180px;
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  padding: 8px 10px;
  font: 11px/1.4 ui-monospace, monospace;
  white-space: pre-wrap;
  color: var(--fg-dim);
}
.send-targets { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 6px; }
.send-target { text-align: left; padding: 8px 10px; display: flex; gap: 6px; align-items: center; }

/* ---- sessions pane ---- */
.sessions-pane { max-width: 980px; margin: 0 auto; padding: 16px; }
.sessions-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sessions-head h2 { margin: 0; font-size: 18px; }
.sessions-empty { color: var(--fg-dim); padding: 24px 0; }
.session-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--bg-alt);
  cursor: pointer;
}
.session-row:hover { border-color: var(--line-plus); }
.session-row.state-needs_input { border-color: var(--wait); box-shadow: 0 0 0 1px rgba(245, 197, 66, 0.4); }
.session-state {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: var(--r-chip);
  background: var(--raised);
  border: 1px solid var(--line-plus);
  color: var(--fg);
  white-space: nowrap;
}
/* Agent state chips: raised, a state-coloured border and label, a dot (pulsing while working).
   Each state has its own keyframes name so a change of state restarts the one-off jolt. */
.session-state { display: inline-flex; align-items: center; gap: 6px; }
.session-state::before { content: ""; width: 6px; height: 6px; border-radius: 3px; background: currentColor; }
.state-needs_input .session-state, .session-state.state-needs_input { border-color: var(--wait); color: var(--wait); animation: jolt-a 300ms var(--ease-recoil); }
.state-limited .session-state, .session-state.state-limited { border-color: var(--wait); color: var(--wait); animation: jolt-b 300ms var(--ease-recoil); }
.state-working .session-state, .session-state.state-working { border-color: var(--signal); color: var(--signal); animation: jolt-c 300ms var(--ease-recoil); }
.state-working .session-state::before, .session-state.state-working::before { animation: pulse 0.7s ease-in-out infinite; }
.state-running .session-state, .session-state.state-running { border-color: var(--signal); color: var(--signal); animation: jolt-d 300ms var(--ease-recoil); }
.state-idle .session-state, .session-state.state-idle { border-color: var(--ok); color: var(--ok); animation: jolt-e 300ms var(--ease-recoil); }
.state-stale .session-state, .session-state.state-stale { color: var(--fg-dim); }
.state-stale .session-state::before, .session-state.state-stale::before { background: var(--line-plus); }
@keyframes jolt-a { 0% { transform: translate(-3px, 2px) scale(1.05); } 30% { transform: translate(3px, -1px) scale(1.04); } 60% { transform: translate(-2px, 0) scale(1.02); } 100% { transform: none; } }
@keyframes jolt-b { 0% { transform: translate(-3px, 2px) scale(1.05); } 30% { transform: translate(3px, -1px) scale(1.04); } 60% { transform: translate(-2px, 0) scale(1.02); } 100% { transform: none; } }
@keyframes jolt-c { 0% { transform: translate(-3px, 2px) scale(1.05); } 30% { transform: translate(3px, -1px) scale(1.04); } 60% { transform: translate(-2px, 0) scale(1.02); } 100% { transform: none; } }
@keyframes jolt-d { 0% { transform: translate(-3px, 2px) scale(1.05); } 30% { transform: translate(3px, -1px) scale(1.04); } 60% { transform: translate(-2px, 0) scale(1.02); } 100% { transform: none; } }
@keyframes jolt-e { 0% { transform: translate(-3px, 2px) scale(1.05); } 30% { transform: translate(3px, -1px) scale(1.04); } 60% { transform: translate(-2px, 0) scale(1.02); } 100% { transform: none; } }
.session-agent { flex: 0 0 90px; font-size: 12px; color: var(--fg-dim); }
.session-main { flex: 1; min-width: 0; }
.session-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-meta { font-size: 11px; color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-ws { color: var(--fg); }
.session-stop { flex: 0 0 auto; }

/* ---- PR / CI bar ---- */
.pr-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-alt);
  font-size: 12px;
}
.pr-bar.overall-failure { border-color: rgba(255, 79, 110, 0.6); }
.pr-bar.overall-success { border-color: rgba(63, 214, 138, 0.5); }
.pr-link { font-weight: 600; color: var(--accent); text-decoration: none; }
.pr-link.pr-merged { color: var(--info); }
.pr-link.pr-closed { color: var(--fail); }
.pr-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40ch; }
.pr-checks { display: flex; gap: 6px; align-items: center; }
.ck { font-weight: 600; }
.ck-success { color: var(--ok); }
.ck-failure { color: var(--fail); }
.ck-pending { color: var(--wait); }
.ck-skipped { color: var(--fg-dim); }
.pr-check-list { margin: -4px 0 10px; padding: 6px 10px; border: 1px solid var(--border); border-top: none; border-radius: 0 0 8px 8px; font-size: 12px; }
.pr-check { display: flex; gap: 8px; padding: 2px 0; align-items: baseline; }
.pr-check a { color: var(--fg); }

/* ---- checkpoints ---- */
.ckpt-panel { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; margin-bottom: 10px; max-height: 260px; overflow: auto; background: var(--bg-alt); }
.ckpt-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 12px; border-bottom: 1px solid rgba(38, 40, 47, 0.5); }
.ckpt-row:last-child { border-bottom: none; }
.ckpt-time { flex: 0 0 72px; color: var(--fg-dim); }
.ckpt-msg { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ckpt-moved { font-size: 10px; color: var(--wait); border: 1px solid var(--wait); border-radius: var(--r-chip); padding: 0 6px; }

/* ---- review comments ---- */
.lineno-new { position: relative; }
.add-comment {
  position: absolute;
  left: -2px;
  top: 0;
  width: 16px;
  height: 16px;
  line-height: 15px;
  text-align: center;
  border-radius: 4px;
  background: var(--signal);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  opacity: 0;
}
.diff-line:hover .add-comment { opacity: 1; }
@media (pointer: coarse) { .add-comment { opacity: 1; background: var(--raised); color: var(--signal); border: 1px solid var(--line-plus); } }
.comment-row td { padding: 4px 8px 6px 90px; background: var(--bg); }
.review-comment {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border: 1px solid var(--signal);
  border-left-width: 3px;
  border-radius: var(--r-control);
  padding: 6px 8px;
  font: 12px/1.45 var(--mono);
  white-space: pre-wrap;
  background: rgba(255, 107, 44, 0.08);
}
.review-text { flex: 1; }
.review-editor { display: flex; flex-direction: column; gap: 6px; }
.review-editor-actions { display: flex; gap: 8px; justify-content: flex-end; }
.review-tray {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--signal);
  border-radius: 8px;
  background: rgba(255, 107, 44, 0.08);
  font-size: 12px;
}
.run-btn { border-color: var(--ok); color: var(--ok); }

@media (max-width: 768px) {
  .comment-row td { padding-left: 8px; }
  .session-agent { display: none; }
  .sessions-pane { padding: 10px; }
}

/* ---- global views live in the top bar, not the workspace rail ---- */
.agents-btn { position: relative; margin-right: 8px; display: inline-flex; align-items: center; gap: 5px; }
.agents-btn.active { border-color: var(--accent); color: var(--accent); }
.agents-btn .pane-badge { top: -7px; right: -7px; }
.agents-btn .pane-dot { top: -3px; right: -3px; }
@media (max-width: 768px) {
  .agents-label { display: none; }
  .agents-btn { padding: 4px 9px; font-size: 15px; }
}

/* ---- no rubber-banding: the app is a fixed shell, only inner panes scroll ----
   With overscroll-behavior:auto, reaching the end of an inner scroller (diff, chat, terminal,
   tree) chained the scroll to the page and the whole UI bounced; on mobile it could also
   trigger pull-to-refresh. */
html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
.content,
.chat-log,
.file-tree,
.settings-scroll,
.palette-list,
.dialog,
.ckpt-panel,
.xterm-viewport {
  overscroll-behavior: contain;
}

/* ---- Inside import ---- */
.inside-dialog { width: min(680px, 100%); }
.inside-dialog h4 { margin: 14px 0 6px; font-size: 13px; }
.inside-dialog .grow { flex: 1; min-width: 0; }
.inside-task { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--bg); }
.inside-desc { margin-top: 4px; white-space: pre-wrap; }
.inside-options { display: flex; flex-direction: column; gap: 6px; }
.inside-option { display: flex; gap: 8px; align-items: center; font-size: 13px; flex-wrap: wrap; }
.inside-done p { margin: 4px 0; }
.inside-upload { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--border); }

/* ---- agent accounts ---- */
.account-agent { border-top: 1px solid var(--border); padding-top: 6px; margin-top: 6px; }
.account-chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); border-radius: var(--r-card); padding: 1px 4px 1px 9px; font-size: 12px; }
.account-chip.active { border-color: var(--ok); color: var(--ok); }
.account-chip .link { text-decoration: none; color: var(--fg); padding: 0; }
.account-limited { font-size: 11px; color: var(--wait); margin-right: 2px; }
.key-default { font-size: 12px; color: var(--wait); white-space: nowrap; }

/* ---- doomscroll ---- */
.doom-btn { margin-right: 8px; font-size: 12px; }
.doom-sites { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; }
.doom-site { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; background: var(--bg); }
.doom-return { display: flex; margin-top: 4px; }

/* ---- projects (several git clones in one workspace) ---- */
.project-picker { position: relative; flex: 0 0 auto; }
.project-btn { display: inline-flex; align-items: center; gap: 6px; max-width: 240px; }
.project-icon { color: var(--accent); }
.project-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-count {
  font-size: 10px; font-weight: 600; line-height: 16px; min-width: 16px; padding: 0 5px;
  border-radius: 8px; background: rgba(245, 197, 66, 0.2); color: var(--wait); text-align: center;
}
.project-backdrop { position: fixed; inset: 0; z-index: 40; }
.project-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 41;
  width: min(460px, calc(100vw - 32px)); max-height: 70vh; overflow: auto;
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--r-card);
  box-shadow: none; border-color: var(--line-plus); padding: 6px;
}
.project-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 7px 10px;
  border-radius: var(--r-control); cursor: pointer; font-size: 12px;
}
.project-row:hover { background: rgba(255, 107, 44, 0.08); }
.project-row.active { background: rgba(255, 107, 44, 0.15); }
.project-row .hint { font-size: 11px; }
.project-name { font-weight: 600; }
.project-branch { color: var(--fg-dim); font-family: var(--mono); font-size: 11px; }
.project-row .project-count, .project-section-head .project-count { margin-left: auto; }
.project-add { color: var(--accent); border-top: 1px solid var(--border); border-radius: 0 0 6px 6px; margin-top: 4px; }
.project-empty { padding: 8px 10px; }
.project-clone { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--border); margin-top: 4px; }
.project-clone input { flex: 1 1 100%; background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: var(--r-control); padding: 5px 8px; }
.project-clone input.project-dir { flex: 1 1 60%; }
.project-clone .error { flex: 1 1 100%; }
.project-section { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; }
.project-section-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer;
  background: var(--bg-alt); border-radius: 8px; position: sticky; top: 0; z-index: 2;
}
.project-section > .diff-view.embedded { padding: 8px 12px 4px; }
.all-bar .all-title { font-weight: 600; margin-right: 4px; }
.all-notice { font-size: 12px; color: var(--fg-dim); margin: -4px 0 10px; word-break: break-word; }
.tab-project { color: var(--fg-dim); }
.ckpt-projects { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 30ch; }
@media (max-width: 768px) {
  .project-btn { max-width: 140px; }
}
.project-row .ahead, .project-section-head .ahead { color: var(--ok); font-size: 11px; }
.project-row .behind, .project-section-head .behind { color: var(--wait); font-size: 11px; }
.import-sources { display: flex; gap: 4px; margin: 4px 0 12px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.import-connect { border: 1px dashed var(--border); border-radius: 8px; padding: 8px 12px; }
.import-connect p { margin: 0 0 8px; }
.install-cmd { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-control); padding: 4px 8px; font-size: 12px; user-select: all; overflow-x: auto; white-space: nowrap; max-width: 100%; }
/* ---- MR review mode ---- */
.review-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 6px 10px; margin-bottom: 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; }
.review-bar.clean { border-color: rgba(63, 214, 138, 0.5); }
.review-bar.conflicts { border-color: rgba(245, 197, 66, 0.7); }
.review-bar a { color: var(--accent); font-weight: 600; text-decoration: none; }
.review-ok { color: var(--ok); }
.review-warn { color: var(--wait); }
.cred-content { flex: 1; min-width: 0; background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: var(--r-control); padding: 6px 8px; font: 12px var(--mono); }
.tool-packs { flex-wrap: wrap; gap: 6px 16px; }
/* ---- file upload / download ---- */
.tree-actions { display: flex; align-items: center; gap: 6px; padding: 4px 6px 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-size: 12px; }
.tree-target { color: var(--fg-dim); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tree-btn { cursor: pointer; color: var(--fg-dim); text-decoration: none; padding: 1px 6px; border: 1px solid transparent; border-radius: 5px; font-size: 12px; }
.tree-btn:hover { color: var(--fg); border-color: var(--border); background: var(--bg-alt); }
.tree-row { position: relative; }
.tree-row-actions { margin-left: auto; display: none; gap: 2px; }
.tree-row:hover .tree-row-actions { display: inline-flex; }
.file-tree.drag-over { outline: 2px dashed var(--accent); outline-offset: -4px; }
.upload-list { display: flex; flex-direction: column; gap: 3px; padding: 4px 6px 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-size: 12px; }
.upload-row { display: flex; align-items: center; gap: 8px; }
.upload-path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-row progress { width: 90px; height: 8px; }
.upload-list button.link { align-self: flex-start; }

/* Clone-another-repo: repos of the user's connected forges. */
.forge-repos { flex: 1 1 100%; display: flex; flex-direction: column; max-height: 260px; overflow-y: auto; margin-top: 4px; }
.forge-repos > .hint { padding: 2px 6px; }
.forge-repo .project-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Phones: one header row (icons only, tabs scroll underneath) and a terminal bar whose extras
   fold behind ⋯. Desktop shows everything inline. */
.mobile-only { display: none; }
.term-extra { display: contents; }
@media (max-width: 768px) {
  .mobile-only { display: inline-flex; align-items: center; justify-content: center; }
  .topbar .brand, .topbar .btn-label { display: none; }
  .topbar { column-gap: 6px; }
  .topbar .project-btn { max-width: 30vw; }
  .topbar > button, .topbar .agents-btn, .topbar .project-btn { padding-left: 8px; padding-right: 8px; min-width: 0; }
  .topbar .spacer { flex: 1 1 0; min-width: 0; }
  .topbar .project-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .term-toolbar { flex-wrap: wrap; row-gap: 6px; }
  .term-toolbar > .tab-strip { flex: 1 1 100%; min-width: 0; }
  .term-extra { display: none; }
  .term-extra.open { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; }
  .term-extra.open .spacer { display: none; }
  .term-more.active { color: var(--accent); border-color: var(--accent); }
}

/* Prompt an agent (voice) */
.prompt-sheet { display: flex; flex-direction: column; gap: 10px; width: min(560px, 94vw); }
.prompt-sheet select, .prompt-text { width: 100%; }
.prompt-text { background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: var(--r-control); padding: 8px; font: inherit; font-size: 15px; resize: vertical; }
.prompt-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prompt-controls .prompt-lang { width: auto; }
.mic.listening { color: var(--fail); border-color: var(--fail); animation: mic-pulse 1.2s ease-in-out infinite; }
@keyframes mic-pulse { 50% { box-shadow: 0 0 0 4px rgba(255, 79, 110, 0.25); } }

/* iOS zooms into any focused field whose text is under 16 px (and the layout stays zoomed):
   touch devices get 16 px fields, including xterm's hidden input. */
@media (pointer: coarse) {
  input, textarea, select, .xterm .xterm-helper-textarea { font-size: 16px !important; }
}

/* The avatar stays a circle: touch devices raise every button to 34 px tall, so match the width,
   and a crowded header must not squeeze it. */
.avatar { flex: 0 0 auto; aspect-ratio: 1; }
@media (pointer: coarse) {
  .avatar { width: 34px; height: 34px; min-height: 34px; }
}
@media (max-width: 380px) {
  .topbar .project-btn { max-width: 24vw; }
  .topbar { column-gap: 4px; }
}

/* Chat: tool cards */
.tool-card { max-width: 100%; width: 100%; }
.tool-card > summary { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tool-icon { flex: 0 0 auto; width: 18px; text-align: center; color: var(--fg-dim); font-weight: 700; }
.tool-title { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg); }
.tool-title.mono { font-family: ui-monospace, monospace; font-size: 12px; }
.tool-detail { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-dim); font-size: 11px; }
.tool-count { flex: 0 0 auto; color: var(--fg-dim); font-size: 11px; font-family: ui-monospace, monospace; }
.tool-status { flex: 0 0 auto; margin-left: auto; font-size: 12px; font-weight: 700; }
.tool-status.ok { color: var(--ok); }
.tool-status.err { color: var(--fail); }
.tool-status.run { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--accent); border-right-color: transparent; animation: tool-spin 0.8s linear infinite; }
@keyframes tool-spin { to { transform: rotate(360deg); } }
.tool-card.tool-error { border-color: rgba(255, 79, 110, 0.5); }
.tool-card pre { margin: 0; padding: 8px 10px; font: 11px/1.45 ui-monospace, monospace; white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; }
.tool-card .tool-cmd { color: var(--fg); background: var(--bg); border-bottom: 1px solid var(--border); }
.tool-card .tool-body { color: var(--fg-dim); border-bottom: 1px solid var(--border); }
.tool-card .tool-out { color: var(--fg-dim); }
.tool-card .tool-out.err { color: var(--fail); }
.tool-diff .del { color: var(--fail); background: rgba(255, 79, 110, 0.08); display: block; }
.tool-diff .add { color: var(--ok); background: rgba(63, 214, 138, 0.08); display: block; }
.tool-diff { border-bottom: 1px solid var(--border); }
.tool-todos { list-style: none; margin: 0; padding: 6px 10px; font-size: 12px; }
.tool-todos li { display: flex; gap: 8px; padding: 2px 0; }
.tool-todos .todo-mark { width: 14px; flex: 0 0 auto; color: var(--fg-dim); }
.tool-todos .todo-completed { color: var(--fg-dim); text-decoration: line-through; }
.tool-todos .todo-completed .todo-mark { color: var(--ok); text-decoration: none; }
.tool-todos .todo-in_progress .todo-mark { color: var(--accent); }

/* Code tab */
.code-pane { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.code-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--bg-alt); }
.code-modes { display: flex; gap: 2px; }
.code-query { flex: 1 1 240px; min-width: 0; background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: var(--r-control); padding: 6px 10px; font: 13px ui-monospace, monospace; }
.code-query:focus { outline: none; border-color: var(--accent); }
.code-opts { display: flex; align-items: center; gap: 4px; }
.code-opt { font: 12px ui-monospace, monospace; min-width: 30px; padding: 4px 6px; }
.code-opt.on { color: var(--accent); border-color: var(--accent); background: rgba(255, 107, 44, 0.12); }
.code-glob { width: 130px; background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: var(--r-control); padding: 5px 8px; font: 12px ui-monospace, monospace; }
.code-results { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 6px 0 24px; }
.code-summary { padding: 4px 14px 8px; font-size: 12px; }
.code-empty { padding: 24px 14px; }
.code-file { margin-bottom: 4px; }
.code-file-head { display: flex; align-items: baseline; gap: 4px; padding: 5px 14px; cursor: pointer; position: sticky; top: 0; background: var(--bg); font-size: 12px; z-index: 1; }
.code-file-head:hover { background: var(--bg-alt); }
.code-caret { width: 12px; color: var(--fg-dim); }
.code-path { color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 0 1 auto; }
.code-name { color: var(--fg); font-weight: 600; white-space: nowrap; }
.code-count { margin-left: auto; color: var(--fg-dim); font-size: 11px; background: var(--bg-alt); border-radius: var(--r-chip); padding: 0 7px; }
.code-hit { display: flex; gap: 10px; padding: 2px 14px 2px 30px; cursor: pointer; font: 12px/1.6 ui-monospace, monospace; }
.code-hit:hover { background: var(--bg-alt); }
.code-line { flex: 0 0 auto; min-width: 34px; text-align: right; color: var(--fg-dim); }
.code-text { min-width: 0; white-space: pre; overflow: hidden; text-overflow: ellipsis; color: var(--fg); }
.code-text mark { background: rgba(245, 197, 66, 0.35); color: var(--fg); border-radius: 2px; }
@media (max-width: 768px) {
  .code-hit { padding-left: 14px; }
  .code-text { white-space: pre-wrap; word-break: break-all; }
}

.code-actions { margin-left: auto; display: flex; gap: 2px; flex: 0 0 auto; opacity: 0.35; }
.code-hit:hover .code-actions { opacity: 1; }
@media (pointer: coarse) { .code-actions { opacity: 0.8; } }
.code-act { min-width: 24px; min-height: 22px !important; padding: 0 4px; font-size: 12px; line-height: 1; }
.code-nav-head { display: flex; align-items: center; gap: 10px; padding: 6px 14px 8px; font-size: 13px; }
.code-loc { padding-left: 14px; }
.code-loc-path { flex: 0 0 auto; color: var(--accent); font: 12px ui-monospace, monospace; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-loc.external { cursor: default; opacity: 0.6; }
.code-sym { align-items: baseline; padding-left: 14px; }
.code-kind { flex: 0 0 auto; font-size: 10px; text-transform: uppercase; color: var(--fg-dim); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.code-sym-name { font-weight: 600; color: var(--fg); }
.code-sym-in { color: var(--fg-dim); font-size: 11px; }
.code-sym .code-loc-path { margin-left: auto; }

/* Session discovery stays readable and tappable on phones. */
.chat-entry .session-choice { display: block; width: 100%; text-align: left; margin: 6px 0; padding: 10px; white-space: normal; overflow-wrap: anywhere; }

/* Keep a retry action available for tmux selections in WebViews without clipboard permission. */
.terminal-pane { position: relative; }
.terminal-copy-button { position: absolute; top: 6px; right: 18px; z-index: 5; font-size: 12px; }
.terminal-copy-button[hidden] { display: none; }
.terminal-copy-dialog { max-width: min(600px, 90vw); background: var(--bg, #111216); color: var(--fg, #f2efe8); border: 1px solid #444; border-radius: 8px; padding: 18px; }
.terminal-copy-dialog textarea { display: block; width: 100%; height: 180px; margin: 12px 0; }

/* Agents pane: expandable row with a live screen peek and a reply composer. */
.session-item { margin-bottom: 8px; }
.session-item > .session-row { margin-bottom: 0; }
.session-item.open > .session-row { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.session-expand { flex: 0 0 auto; }
.session-peek {
  border: 1px solid var(--border); border-top: 0;
  border-radius: 0 0 8px 8px; padding: 10px; background: var(--bg-alt);
}
.session-screen {
  margin: 0 0 8px; max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font: 12px/1.35 var(--mono, ui-monospace, monospace); color: var(--fg-dim);
}
.session-compose { display: flex; gap: 6px; align-items: flex-end; }
.session-compose textarea { flex: 1 1 auto; min-width: 0; resize: vertical; }
.session-compose .mic.listening { border-color: var(--wait); }

/* Top bar actions: transparent wrapper on desktop; on phones one non-wrapping row under the
   brand, so the agents button and avatar can never fall onto a second line. The project button
   is what gives way when space runs out. */
.topbar-actions { display: contents; }
@media (max-width: 768px) {
  .topbar-actions { display: flex; flex: 1 1 100%; min-width: 0; flex-wrap: nowrap; align-items: center; gap: 6px; }
  .topbar-actions > * { flex: 0 0 auto; }
  .topbar-actions > .spacer { flex: 1 1 0; min-width: 0; }
  .topbar-actions > .project-picker { flex: 0 1 auto; min-width: 44px; }
  .topbar-actions .project-btn { max-width: 100%; min-width: 0; }
}
.session-stop { border-color: var(--fail); color: var(--fail); }
.session-peek-actions { margin-top: 8px; display: flex; justify-content: flex-end; }

/* Files dragged over a terminal, and its transient status line (uploading a pasted screenshot). */
.terminal-pane { position: relative; }
.terminal-pane.term-drop { outline: 2px dashed var(--accent); outline-offset: -4px; }
.term-toast {
  position: absolute; right: 10px; bottom: 10px; z-index: 5; max-width: 80%;
  padding: 6px 10px; border-radius: var(--r-control, 6px);
  background: var(--raised, #1c1d23); color: var(--fg); border: 1px solid var(--border);
  font: 12px/1.3 var(--mono, ui-monospace, monospace); pointer-events: none;
}

/* Start-agent dialog: saved sessions as a pick list, manual ID tucked away. */
.session-pick { display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow-y: auto; margin: 6px 0; }
.session-pick .session-choice { text-align: left; display: block; width: 100%; }
.session-pick .pick-title { overflow-wrap: anywhere; }
.manual-id { margin: 6px 0; }
.manual-id summary { cursor: pointer; color: var(--fg-dim); font-size: 13px; }

/* Admin screen */
.admin-user { border-bottom: 1px solid var(--border); padding: 4px 0; }
.admin-user .settings-row { flex-wrap: wrap; }
.audit-list { margin-top: 8px; max-height: 50vh; overflow: auto; font-size: 12px; }
.audit-row { display: flex; gap: 10px; flex-wrap: wrap; padding: 3px 0; border-bottom: 1px solid var(--border); }
.audit-who { min-width: 12ch; }
.audit-action { font-family: var(--mono, ui-monospace, monospace); }
.audit-detail { overflow-wrap: anywhere; }

/* File tree right-click menu */
.ctx-backdrop { position: fixed; inset: 0; z-index: 60; }
.ctx-menu {
  position: fixed; z-index: 61; min-width: 200px; max-width: 280px; padding: 4px;
  background: var(--bg-alt); border: 1px solid var(--line-plus); border-radius: var(--r-card);
  display: flex; flex-direction: column; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}
.ctx-title { padding: 4px 10px; font-size: 11px; color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-item { text-align: left; background: none; border: none; padding: 7px 10px; border-radius: var(--r-control); font-size: 13px; }
.ctx-item:hover { background: var(--raised); }
.ctx-danger { color: var(--fail); }
.ctx-sep { height: 1px; background: var(--border); margin: 3px 4px; }
.tree-more { font-weight: bold; }
@media (pointer: coarse) { .tree-row-actions { opacity: 1; } }
/* The tree fills its pane, so the empty space under the last row is still "the workspace root" for
   right-click, drag-and-drop and the menu. */
.file-tree { min-height: 100%; box-sizing: border-box; }

/* ---- Merge requests (Agents pane) ---- */
.sessions-sub { margin: 14px 0 8px; font-size: 14px; color: var(--fg-dim); font-weight: 600; }
.mrs-head { display: flex; align-items: center; gap: 8px; }
.mr-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 6px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-alt);
}
.mr-row:hover { border-color: var(--line-plus); }
.mr-checks { flex: 0 0 auto; width: 18px; text-align: center; font-weight: 700; color: var(--fg-dim); }
.mr-checks.ck-success { color: var(--ok); }
.mr-checks.ck-failure { color: var(--err, #e5484d); }
.mr-checks.ck-pending { color: var(--wait); }
.mr-draft { color: var(--fg-dim); font-size: 11px; border: 1px solid var(--line-plus); border-radius: var(--r-chip); padding: 0 6px; margin-right: 4px; }
.mr-row a.button { text-decoration: none; }
@media (max-width: 768px) { .mr-row { flex-wrap: wrap; } }


/* ---- Agent message history (Agents pane) ---- */
.session-history {
  max-height: 60vh; overflow-y: auto; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
  display: flex; flex-direction: column; gap: 8px; font-size: 13px; user-select: text;
}
.hist-msg { white-space: pre-wrap; overflow-wrap: anywhere; }
.hist-user { align-self: flex-end; max-width: 85%; padding: 6px 10px; border-radius: 8px; background: var(--raised); border: 1px solid var(--line-plus); }
.hist-asst { white-space: normal; }
.hist-tool { font-size: 11px; color: var(--fg-dim); }

/* ---- Hidden terminals popup (terminal bar) ---- */
.hidden-wrap { position: relative; display: inline-block; }
.hidden-pop {
  position: absolute; bottom: calc(100% + 4px); left: 0; z-index: 30; min-width: 280px; max-width: 90vw;
  padding: 6px; border: 1px solid var(--line-plus); border-radius: 8px; background: var(--bg-alt);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}
.hidden-row { display: flex; align-items: center; gap: 6px; padding: 4px 2px; }

/* Agent row: where it is working */
.session-where { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--fg-dim); margin-top: 2px; }
.session-where span { overflow-wrap: anywhere; }
.session-bypass { color: var(--wait); }

.mr-checks.ck-running { color: var(--signal); }
.mr-checks.ck-cancelled { color: var(--fg-dim); }
.pipe-running { border-color: var(--signal); }

/* Kill: armed state (second tap confirms) */
.session-stop.armed, .primary.armed { background: var(--fail); border-color: var(--fail); color: #fff; }
/* Open MRs of the repo, under the pipeline bar */
.repo-mrs { padding: 4px 10px; border-bottom: 1px solid var(--border); font-size: 12px; }
.repo-mrs-toggle { background: none; border: none; padding: 2px 0; color: var(--fg-dim); cursor: pointer; }
.repo-mrs .mr-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }

/* Toasts: agent finished / needs you / usage limit */
.toast-host { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; cursor: pointer;
  background: var(--bg-alt); border: 1px solid var(--line-plus); border-left-width: 4px; border-radius: var(--r-card);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45); animation: toast-in 0.18s ease-out; }
.toast-done { border-left-color: var(--ok, #3fb950); }
.toast-needs { border-left-color: var(--wait); }
.toast-error { border-left-color: var(--fail); }
.toast-icon { font-weight: bold; }
.toast-text { flex: 1; min-width: 0; }
.toast-title { font-size: 13px; font-weight: 600; }
.toast-body { font-size: 12px; color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-close { background: none; border: none; color: var(--fg-dim); font-size: 16px; line-height: 1; padding: 0 2px; cursor: pointer; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 768px) { .toast-host { left: 16px; right: 16px; bottom: 76px; width: auto; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* In-page prompt / confirm / notice (replaces native dialogs, which webviews can suppress) */
.ask-backdrop { z-index: 100; }
.ask-dialog { width: min(440px, 92vw); display: flex; flex-direction: column; gap: 10px; }
.ask-dialog h3 { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.ask-body { margin: 0; color: var(--fg-dim); font-size: 13px; line-height: 1.4; }
.ask-input { width: 100%; box-sizing: border-box; }
.ask-dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Agents page: "Missing an agent?" diagnostics */
.agent-diag { margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12px; }
.diag-ws { margin: 10px 0; }
.diag-ws h4 { margin: 4px 0; font-size: 13px; }
.diag-note { margin: 4px 0; color: var(--wait); }
.diag-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; padding: 2px 0; }
.diag-ok .diag-mark { color: var(--ok, #3fb950); }
.diag-no .diag-mark { color: var(--fail); }
.diag-name { font-family: var(--mono, ui-monospace, monospace); }
.diag-verdict { color: var(--fg-dim); }

/* Sinepy: toast avatar + corner pet (design: "Sinepy mascot") */
.sinepy { display: inline-block; line-height: 0; flex: none; }
.sinepy svg { width: 100%; height: 100%; overflow: visible; }
.sinepy .sy-body { fill: var(--accent); }
.sinepy .sy-body-off { fill: #3a3c44; }
.sinepy .sy-dark { fill: #111216; }
.sinepy .sy-w { fill: #f2efe8; }
.sinepy .sy-dim { fill: #8a8d96; font-family: var(--mono, monospace); font-weight: 800; }
.sinepy .sy-eye { fill: none; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.sinepy .sy-w-s { stroke: #f2efe8; }
.sinepy .sy-ok-s { stroke: var(--ok); }
.sinepy .sy-dim-s { stroke: #8a8d96; }
.sinepy .sy-band { fill: none; stroke: #111216; stroke-width: 5; }
.sinepy .sy-spk { fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linecap: round; }
.sinepy { animation: sy-bob 2s ease-in-out infinite; }
.toast-icon .sinepy { margin: -2px 2px -4px -2px; }
@keyframes sy-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.pet { position: fixed; left: 16px; bottom: 16px; z-index: 91; display: flex; align-items: flex-end; gap: 4px; pointer-events: none; animation: pet-in 0.35s cubic-bezier(.34, 1.56, .64, 1); }
.pet > * { pointer-events: auto; }
.pet-body { background: none; border: none; padding: 0; cursor: pointer; }
.pet-bubble { max-width: 260px; margin-bottom: 52px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px;
  background: #f2efe8; color: #111216; border-radius: 16px 16px 16px 4px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45); order: 2; }
.pet-text { font-size: 13px; line-height: 1.4; }
.pet-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pet-actions button { min-height: 30px; padding: 0 10px; border-radius: 8px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  background: transparent; color: #111216; border: 1px solid #c9c5bc; }
.pet-actions button.primary { background: var(--accent); border-color: var(--accent); color: #111216; font-weight: 800; }
.pet-hide { align-self: flex-start; background: none; border: none; padding: 0; font: inherit; font-size: 11px; color: #5a5c63; text-decoration: underline; cursor: pointer; }
@keyframes pet-in { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 768px) { .pet { bottom: 76px; } .pet-bubble { max-width: calc(100vw - 140px); } }
@media (prefers-reduced-motion: reduce) { .sinepy, .pet { animation: none; } }
.toast-body-wrap { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 9em; overflow-y: auto; text-overflow: clip; user-select: text; }
.pr-bar-hint { padding: 3px 10px; font-size: 11px; color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes sy-lash{
0%,55%{d:path("M83.2 72.1 L83.2 64.1 L84.6 57.1 L87.2 51.0 L90.8 45.8 L95.2 41.6 L100.2 38.4 L105.6 36.3 L111.1 35.5 L116.7 36.0 L122.1 37.8 L127.1 41.0 L129.7 44.0 L131.6 47.1 L132.6 50.1 L133.0 52.8 L132.7 55.3 L131.9 57.4 L130.6 59.0 L129.0 60.1 L127.1 60.6 L124.9 60.4 L122.3 59.4 L121.7 60.6 L124.5 61.9 L127.2 62.2 L129.7 61.7 L131.9 60.3 L133.5 58.3 L134.6 55.8 L135.1 52.8 L134.8 49.6 L133.8 46.1 L131.8 42.6 L128.9 39.0 L123.5 35.1 L117.5 32.7 L111.1 31.9 L104.7 32.6 L98.4 34.6 L92.5 38.0 L87.2 42.6 L82.8 48.4 L79.4 55.4 L77.3 63.3 L76.8 71.9 Z");animation-timing-function:cubic-bezier(.45,0,.55,1)}
63%{d:path("M83.1 73.1 L84.9 67.2 L87.4 61.7 L90.7 56.3 L94.7 51.1 L99.4 46.3 L104.6 41.8 L110.2 37.7 L116.3 34.2 L122.7 31.2 L129.4 28.9 L136.2 27.3 L139.6 27.0 L142.6 27.2 L145.2 27.8 L147.4 28.9 L149.2 30.3 L150.6 32.0 L151.6 34.0 L152.2 36.2 L152.4 38.6 L152.1 41.1 L151.3 43.8 L152.7 44.2 L153.6 41.4 L154.0 38.7 L153.9 35.9 L153.4 33.4 L152.3 31.0 L150.7 28.9 L148.6 27.1 L146.0 25.7 L143.0 24.9 L139.6 24.5 L135.8 24.7 L128.6 26.0 L121.5 28.1 L114.7 30.9 L108.2 34.4 L102.0 38.3 L96.3 42.8 L91.1 47.8 L86.5 53.2 L82.5 58.9 L79.3 64.9 L76.9 70.9 Z");animation-timing-function:cubic-bezier(.7,0,1,.6)}
68%,73%{d:path("M83.2 72.1 L83.4 62.4 L82.2 53.2 L79.9 44.7 L76.4 37.1 L71.9 30.5 L66.5 24.9 L60.3 20.4 L53.4 17.0 L46.0 14.9 L38.1 14.1 L29.9 14.7 L25.6 15.5 L21.9 16.6 L18.6 17.9 L15.7 19.4 L13.2 21.1 L11.1 23.0 L9.4 25.0 L7.9 27.1 L6.8 29.3 L5.9 31.6 L5.3 33.8 L6.7 34.2 L7.3 32.1 L8.2 30.0 L9.4 28.0 L10.7 26.1 L12.4 24.3 L14.4 22.7 L16.7 21.2 L19.5 19.8 L22.6 18.7 L26.1 17.9 L30.1 17.3 L38.0 17.0 L45.3 18.1 L52.1 20.3 L58.3 23.6 L63.8 27.9 L68.4 33.2 L72.2 39.4 L75.1 46.4 L76.8 54.1 L77.5 62.6 L76.8 71.9 Z");animation-timing-function:cubic-bezier(.34,1.56,.64,1)}
86%,100%{d:path("M83.2 72.1 L83.2 64.1 L84.6 57.1 L87.2 51.0 L90.8 45.8 L95.2 41.6 L100.2 38.4 L105.6 36.3 L111.1 35.5 L116.7 36.0 L122.1 37.8 L127.1 41.0 L129.7 44.0 L131.6 47.1 L132.6 50.1 L133.0 52.8 L132.7 55.3 L131.9 57.4 L130.6 59.0 L129.0 60.1 L127.1 60.6 L124.9 60.4 L122.3 59.4 L121.7 60.6 L124.5 61.9 L127.2 62.2 L129.7 61.7 L131.9 60.3 L133.5 58.3 L134.6 55.8 L135.1 52.8 L134.8 49.6 L133.8 46.1 L131.8 42.6 L128.9 39.0 L123.5 35.1 L117.5 32.7 L111.1 31.9 L104.7 32.6 L98.4 34.6 L92.5 38.0 L87.2 42.6 L82.8 48.4 L79.4 55.4 L77.3 63.3 L76.8 71.9 Z")}
}
.sinepy .sy-lash { animation: sy-lash 4s linear infinite; }
.login-card { position: relative; }
.login-sinepy { position: absolute; top: -62px; right: 22px; line-height: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .sinepy .sy-lash { animation: none; } }

/* admin: info above, actions below, labels never wrap */
.admin-pane button { white-space: nowrap; }
.admin-user { padding: 10px 0; }
.admin-info { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin-bottom: 8px; }
.admin-info .settings-label { min-width: 0; }
.admin-email { overflow-wrap: anywhere; }
.admin-meta { flex-basis: 100%; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-info .badge, .admin-info .hint { margin-left: 0; }
.admin-pane .settings-row { flex-wrap: wrap; }
.admin-pane .settings-row input { min-width: 140px; }
.admin-pane .settings-row input[type="checkbox"] { flex: none; min-width: 0; }
.admin-pane .settings-row input:not([type="checkbox"]) { min-width: 170px; }
