@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;
}

:root {
  color-scheme: dark;
  --bg: #0d1117;
  --bg-alt: #161b22;
  --border: #30363d;
  --fg: #e6edf3;
  --fg-dim: #8b949e;
  --accent: #58a6ff;
  --add-bg: rgba(46, 160, 67, 0.18);
  --add-emph: rgba(46, 160, 67, 0.45);
  --del-bg: rgba(248, 81, 73, 0.15);
  --del-emph: rgba(248, 81, 73, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.5 -apple-system, 'Segoe UI', sans-serif;
}

#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;
}

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

.brand {
  font-weight: 700;
  color: var(--accent);
  margin-right: 8px;
}

.spacer {
  flex: 1;
}

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

button,
select {
  background: #21262d;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
}

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: #111418;
}

.terminal-pane {
  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: #1f2733;
}

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

.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 8px;
  margin-left: auto;
}

.badge-modified {
  color: #d29922;
}
.badge-untracked {
  color: #3fb950;
}
.badge-deleted {
  color: #f85149;
}
.badge-conflicted {
  color: #f85149;
}
.badge-renamed {
  color: #58a6ff;
}
.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: 6px;
  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: #d29922;
}
.diff-status-added,
.diff-status-untracked {
  color: #3fb950;
}
.diff-status-deleted {
  color: #f85149;
}
.diff-status-renamed {
  color: #58a6ff;
}

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

.diff-counts .add {
  color: #3fb950;
}
.diff-counts .del {
  color: #f85149;
}

.diff-hunk {
  width: 100%;
  border-collapse: collapse;
  font: 12px/1.45 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

.hunk-header td {
  color: var(--accent);
  background: rgba(88, 166, 255, 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: #d29922;
}

.file-view-editor {
  flex: 1;
  resize: none;
  border: 0;
  outline: none;
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.5 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 10px;
}

/* login */
.login {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.login-button {
  background: var(--accent);
  color: #0d1117;
  font-weight: 700;
  padding: 8px 28px;
  border-radius: 6px;
  text-decoration: 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: 6px;
  padding: 5px 10px;
}

.commit-notice {
  color: #d29922;
  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: #f85149;
  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: 6px;
}

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

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

.settings-msg {
  color: #d29922;
  margin-bottom: 10px;
}

button.danger {
  color: #f85149;
}

/* agent configs */
.config-editor {
  width: 100%;
  min-height: 140px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font: 12px/1.5 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  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(248, 81, 73, 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: #111418;
}

.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;
}

.tab {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 6px 6px 0 0;
  border-bottom: none;
  background: var(--bg);
  color: var(--fg-dim);
  cursor: pointer;
  white-space: nowrap;
  font-size: 12px;
  user-select: none;
}

.tab-active {
  background: var(--bg-alt);
  color: var(--fg);
  border-color: var(--accent);
}

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

.tab-close:hover {
  color: #f85149;
}

.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(88, 166, 255, 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: #111418;
}

.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: 6px;
  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: #3fb950;
}

.git-status .behind {
  color: #d29922;
}

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

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

.git-msg {
  color: #d29922;
}

/* port preview chips */
.port-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  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;
    height: 54px;
    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: #0d1117;
  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: 10px;
  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, 185, 80, 0.2);
  color: #3fb950;
  border-color: #3fb950;
}

.chat-perm-actions .deny {
  background: rgba(248, 81, 73, 0.15);
  color: #f85149;
  border-color: #f85149;
}

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

.chat-perm-done.approve {
  color: #3fb950;
}
.chat-perm-done.deny {
  color: #f85149;
}

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

.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: 10px;
}

.login-card h1 {
  margin: 0 0 4px;
  color: var(--accent);
  text-align: 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: 6px;
  font-size: 14px;
}

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

.login-error {
  color: #f85149;
  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: #21262d;
  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;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}
.chat-session-id {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  margin-left: auto;
}

/* ---- file tree: git status tint, folder roll-up, ignored, active ---- */
.tree-row.st-modified .tree-name { color: #d29922; }
.tree-row.st-untracked .tree-name { color: #3fb950; }
.tree-row.st-deleted .tree-name { color: #f85149; text-decoration: line-through; }
.tree-row.st-conflicted .tree-name { color: #f85149; font-weight: 600; }
.tree-row.st-renamed .tree-name { color: #58a6ff; }
.tree-row .tree-dir { font-weight: 500; }
.tree-row.tree-ignored { opacity: 0.45; }
.tree-row.tree-active {
  background: rgba(88, 166, 255, 0.12);
  box-shadow: inset 2px 0 0 var(--accent);
}
.tree-row .badge {
  min-width: 18px;
  text-align: center;
  background: rgba(139, 148, 158, 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: #d29922; }
.tree-legend .st-untracked { color: #3fb950; }
.tree-legend .st-deleted { color: #f85149; }

/* ---- 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: #30363d;
  color: var(--fg);
  font: 600 10px/16px system-ui, sans-serif;
  text-align: center;
}
.pane-badge.urgent { background: #f85149; color: #fff; }
.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: #3fb950; }
@keyframes sinep-pulse { 50% { opacity: 0.3; } }
.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: #1f6feb;
  border-color: #1f6feb;
  color: #fff;
}
.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: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.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: #1f2733; }
.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(1, 4, 9, 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: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  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: 6px;
  cursor: pointer;
}
.palette-item.active { background: rgba(88, 166, 255, 0.15); }
.palette-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-kind { font-size: 11px; color: var(--fg-dim); }
.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(110, 118, 129, 0.25);
  padding: 1px 4px;
  border-radius: 4px;
}
.chat-asst.md pre {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 6px;
  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), 0 0 16px rgba(88, 166, 255, 0.2); }

/* ---- 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 ---- */
button.primary { background: #238636; border-color: #2ea043; color: #fff; }
button.primary:hover:not(:disabled) { background: #2ea043; }
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: #f85149; 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: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  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: 6px;
  padding: 8px 10px;
  font: 13px/1.45 system-ui, sans-serif;
  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: 6px;
  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: #484f58; }
.session-row.state-needs_input { border-color: #d29922; box-shadow: 0 0 0 1px rgba(210, 153, 34, 0.4); }
.session-state {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: #30363d;
  color: var(--fg-dim);
  white-space: nowrap;
}
.state-needs_input .session-state, .session-state.state-needs_input { background: #d29922; color: #0d1117; }
.state-working .session-state, .session-state.state-working { background: rgba(88, 166, 255, 0.2); color: var(--accent); }
.state-running .session-state, .session-state.state-running { background: rgba(88, 166, 255, 0.1); color: var(--accent); }
.state-idle .session-state, .session-state.state-idle { background: rgba(63, 185, 80, 0.15); color: #3fb950; }
.state-stale .session-state { background: #30363d; color: var(--fg-dim); }
.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(248, 81, 73, 0.6); }
.pr-bar.overall-success { border-color: rgba(63, 185, 80, 0.5); }
.pr-link { font-weight: 600; color: var(--accent); text-decoration: none; }
.pr-link.pr-merged { color: #a371f7; }
.pr-link.pr-closed { color: #f85149; }
.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: #3fb950; }
.ck-failure { color: #f85149; }
.ck-pending { color: #d29922; }
.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(48, 54, 61, 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: #d29922; border: 1px solid #d29922; border-radius: 8px; 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: #1f6feb;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  opacity: 0;
}
.diff-line:hover .add-comment { opacity: 1; }
@media (pointer: coarse) { .add-comment { opacity: 0.55; } }
.comment-row td { padding: 4px 8px 6px 90px; background: var(--bg); }
.review-comment {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border: 1px solid #1f6feb;
  border-left-width: 3px;
  border-radius: 6px;
  padding: 6px 8px;
  font: 12px/1.45 system-ui, sans-serif;
  white-space: pre-wrap;
  background: rgba(31, 111, 235, 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 #1f6feb;
  border-radius: 8px;
  background: rgba(31, 111, 235, 0.08);
  font-size: 12px;
}
.run-btn { border-color: #2ea043; color: #3fb950; }

@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; }
}
