@font-face {
  font-family: "Monaspace Neon";
  src: url("/fonts/MonaspaceNeon-v1.400.woff2") format("woff2");
  font-weight: 200 800;
  font-stretch: 100% 125%;
  font-style: oblique -11deg 0deg;
  font-display: swap;
}
@font-face {
  font-family: "Monaspace Argon";
  src: url("/fonts/MonaspaceArgon-v1.400.woff2") format("woff2");
  font-weight: 200 800;
  font-stretch: 100% 125%;
  font-style: oblique -11deg 0deg;
  font-display: swap;
}
@font-face {
  font-family: "Monaspace Xenon";
  src: url("/fonts/MonaspaceXenon-v1.400.woff2") format("woff2");
  font-weight: 200 800;
  font-stretch: 100% 125%;
  font-style: oblique -11deg 0deg;
  font-display: swap;
}
@font-face {
  font-family: "Monaspace Radon";
  src: url("/fonts/MonaspaceRadon-v1.400.woff2") format("woff2");
  font-weight: 200 800;
  font-stretch: 100% 125%;
  font-style: oblique -11deg 0deg;
  font-display: swap;
}
@font-face {
  font-family: "Monaspace Krypton";
  src: url("/fonts/MonaspaceKrypton-v1.400.woff2") format("woff2");
  font-weight: 200 800;
  font-stretch: 100% 125%;
  font-style: oblique -11deg 0deg;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #1e1f24;
  --bg-panel: #26272e;
  --bg-hover: #2e3039;
  --border: #34363f;
  --text: #c8cdd8;
  --text-muted: #7d8391;
  --accent: #7aa2f7;
  --online: #9ece6a;
  --offline: #f7768e;
  --warn: #e0af68;
  --git-modified: #f59e0b;
  --on-accent: #1a1b1f;
  --editor-font: "Monaspace Neon", var(--mono);
  --editor-font-features: "calt" 1, "liga" 1, "ss01" 1, "ss02" 1, "ss03" 1, "ss04" 1, "ss05" 1, "ss06" 1, "ss07" 1, "ss08" 1, "ss09" 1, "ss10" 1;
  --editor-font-ligatures: normal;
  --mono: "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  /* Shared UI foundations; palette tokens above change with the theme. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --font-caption: 12px;
  --font-control: 13px;
  --font-section: 14px;
  --font-dialog: 18px;
  --control-height: 32px;
  --dialog-gutter: var(--space-6);
  --dialog-small: 380px;
  --dialog-standard: 480px;
  --dialog-wide: 720px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f7;
  --bg-panel: #ffffff;
  --bg-hover: #e9ebef;
  --border: #d5d9e0;
  --text: #2b2f38;
  --text-muted: #6b7280;
  --accent: #3565d8;
  --online: #2f9e44;
  --offline: #d64550;
  --warn: #e0af68;
  --git-modified: #f59e0b;
  --on-accent: #1a1b1f;
}

* {
  box-sizing: border-box;
}

/* All app scroll regions follow the active theme, including native inputs. */
* { scrollbar-color: var(--text-muted) var(--bg-panel); scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: var(--bg-panel); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border: 2px solid var(--bg-panel); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

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

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.app-body.is-resizing {
  user-select: none !important;
  cursor: col-resize !important;
}

.app-body.is-resizing * {
  user-select: none !important;
  cursor: col-resize !important;
}

.app-body.is-resizing iframe,
.app-body.is-resizing textarea,
.app-body.is-resizing input {
  pointer-events: none;
}

/* -- panel resizers (horizontal splitters) -------------------------------- */

.panel-resizer {
  width: 6px;
  margin: 0;
  cursor: col-resize;
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  z-index: 30;
  flex-shrink: 0;
  background: transparent;
  user-select: none;
  touch-action: none;
}

.panel-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2.5px;
  width: 1px;
  background: var(--border);
  transition: background-color 0.15s ease, width 0.15s ease;
}

.panel-resizer:hover::after,
.panel-resizer.is-active::after {
  background: var(--accent);
  width: 2px;
  left: 2px;
}

.spacer {
  flex: 1;
}

/* -- top bar ------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.logo {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.health-dot.online {
  background: var(--online);
}

.health-dot.offline {
  background: var(--offline);
}

/* -- sidebar --------------------------------------------------------------- */

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: none;
  padding: 12px;
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-section h2 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.section-header h2 {
  margin: 0;
}

.icon-btn {
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1;
  padding: 3px 5px;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.icon-btn[aria-pressed="true"] {
  background: var(--bg-hover);
  color: var(--accent);
  border-color: var(--accent);
}

.icon-btn[aria-pressed="true"]:hover {
  color: var(--accent);
}

.session {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
}

.session:hover {
  background: var(--bg-hover);
}

.session.active {
  background: var(--bg-hover);
  box-shadow: inset 2px 0 0 var(--accent);
}

.session-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.session-actions {
  display: none;
  gap: 2px;
}

.session:hover .session-actions,
.session.active .session-actions {
  display: inline-flex;
}

.empty {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

/* -- chat pane -------------------------------------------------------------- */

.chat-pane {
  display: flex;
  flex-direction: column;
  min-width: 260px;
  min-height: 0;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.messages .empty {
  margin: auto;
}

.message {
  max-width: 720px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
}

.message.user {
  align-self: flex-end;
  border-color: transparent;
  background: var(--bg-hover);
}

.msg-role {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.msg-body {
  line-height: 1.5;
  overflow-wrap: break-word;
}

.msg-body.plain {
  white-space: pre-wrap;
}

/* markdown */

.markdown > :first-child {
  margin-top: 0;
}

.markdown > :last-child {
  margin-bottom: 0;
}

.markdown p {
  margin: 0 0 8px;
}

.markdown pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
}

.markdown code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  border-radius: 4px;
  padding: 1px 4px;
}

.markdown pre code {
  background: none;
  padding: 0;
}

.markdown ul,
.markdown ol {
  margin: 0 0 8px;
  padding-left: 20px;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 {
  margin: 12px 0 6px;
  font-size: 15px;
}

.markdown a {
  color: var(--accent);
}

.markdown blockquote {
  margin: 0 0 8px;
  padding-left: 10px;
  border-left: 2px solid var(--border);
  color: var(--text-muted);
}

.markdown-table {
  max-width: 100%;
  overflow-x: auto;
  margin: 0 0 8px;
}

.markdown table {
  width: 100%;
  border-collapse: collapse;
  font-size: inherit;
}

.markdown th,
.markdown td {
  padding: 6px 10px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.markdown th {
  background: var(--bg-panel);
  font-weight: 600;
}

.chat-error {
  margin: 0 20px;
  padding: 8px 12px;
  border: 1px solid var(--offline);
  border-radius: 6px;
  color: var(--offline);
  font-size: 12px;
}

.form-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--font-caption);
  line-height: 1.5;
}


/* agent tool steps */

.tool-step {
  max-width: 720px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
  overflow: hidden;
}

.tool-step-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}

.tool-step-header.ok {
  color: var(--online);
}

.tool-step-header.err {
  color: var(--offline);
}

.tool-step-header.pending {
  color: var(--text-muted);
}

.tool-step-name {
  font-family: var(--mono);
  font-weight: 600;
}

.tool-step-summary {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-pending {
  padding: 6px 10px;
  color: var(--text-muted);
  font-size: 12px;
}

.tool-permission {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
}

.tool-permission .btn {
  padding: 3px 10px;
  font-size: 12px;
}

.stopped-marker {
  max-width: 720px;
  padding: 6px 10px;
  color: var(--text-muted);
  font-size: 12px;
}

.tool-result {
  padding: 6px 10px;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.tool-diff {
  max-height: 240px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}

.tool-diff-path {
  position: sticky;
  top: 0;
  padding: 4px 10px;
  background: var(--bg);
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

/* composer */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
}

.composer-input {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 160px;
  padding: 9px 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
}

.composer-input:focus {
  outline: none;
  border-color: var(--accent);
}

.model-select {
  flex-shrink: 0;
  height: 40px;
  max-width: 200px;
  padding: 0 8px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
}

.model-select:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-hover);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

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

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn.send {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn.stop {
  background: var(--offline);
  border-color: var(--offline);
  color: var(--on-accent);
}

.btn.approve {
  background: var(--online);
  border-color: var(--online);
  color: var(--on-accent);
}

.btn.deny {
  background: var(--bg-panel);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  margin: auto;
}

.empty-state h1 {
  font-family: var(--mono);
  font-size: 22px;
  color: var(--text);
  margin: 0 0 8px;
}

.empty-state p {
  margin: 4px 0;
}

.muted {
  font-size: 12px;
}

/* -- status bar --------------------------------------------------------------- */

.statusbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: auto;
  min-height: 36px;
  flex: none;
  padding: 2px 12px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

/* Keep the progress slot fixed so Output stays anchored at the right edge. */
.status-preparation { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 1.5em; width: 1.5em; }

.status.online {
  color: var(--online);
}

.status.offline {
  color: var(--offline);
}

.version {
  font-family: var(--mono);
  color: var(--text-muted);
}

.hint {
  font-size: 11px;
}

.git-status-widget {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
}

.git-branch-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.git-branch-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}

.git-divergence {
  color: var(--accent);
  font-size: 11px;
}

.git-sync-btn {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  cursor: pointer;
}

.git-sync-btn:hover {
  background: var(--accent);
  color: var(--on-accent);
}

.git-line-stats {
  display: flex;
  gap: 4px;
  font-size: 11px;
}

.git-insertions {
  color: #10b981;
}

.git-deletions {
  color: #ef4444;
}

.git-clean {
  color: #10b981;
  font-weight: bold;
}

.git-badge {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 0 4px;
  border-radius: 3px;
  line-height: 14px;
  flex-shrink: 0;
}

.git-badge-modified {
  color: var(--git-modified);
}

.git-badge-added {
  color: #10b981;
}

.git-badge-deleted {
  color: #ef4444;
}

.git-badge-untracked {
  color: #8b5cf6;
}

.git-badge-renamed {
  color: #3b82f6;
}

.git-badge-conflict {
  color: #ec4899;
  font-weight: bold;
}

.git-badge-dir {
  color: var(--git-modified);
  font-size: 14px;
  line-height: 10px;
}

/* -- tab bar (Rider-style project tabs) ---------------------------------- */

.tabbar-wrap {
  position: relative;
  display: flex;
}

.tabbar {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: 2px;
  height: auto;
  min-height: 36px;
  padding: 0 8px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
}

.tab-action {
  align-self: center;
  margin-right: 2px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-hover);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.tab-action:hover {
  border-color: var(--accent);
}

.tab-action.recent.open {
  border-color: var(--accent);
}

.recent-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
}

.recent-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 151;
  min-width: 260px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.recent-item:hover {
  background: var(--bg-hover);
}

.recent-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab {
  /* Keep absolute, screen-reader-only menu triggers inside the clipped strip. */
  position: relative;
  display: flex;
  min-height: 35px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
}

.tab:hover {
  background: var(--bg-hover);
}

.tab.active {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

.tab-mode {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tab-close {
  font-size: 10px;
  padding: 2px 4px;
}

/* -- file tree ------------------------------------------------------------- */

.file-tree {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: none;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.file-tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.file-tree-header h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.file-tree-actions {
  display: inline-flex;
  gap: 2px;
}

.file-tree-search {
  margin-bottom: 8px;
}

.search-input {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Match the search input's padding and border so the toggle aligns with it. */
.file-tree-search .icon-btn {
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
}

.file-tree-search .icon-btn[aria-pressed="true"] {
  border-color: var(--accent);
}

.tree-root {
  display: flex;
  flex-direction: column;
}

.tree-item {
    justify-content: flex-start;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-item:hover {
  background: var(--bg-hover);
}

.tree-item.selected {
  background: var(--bg-hover);
  box-shadow: inset 2px 0 0 var(--accent);
}

.tree-icon {
  width: 12px;
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
}

.tree-disclosure { display: inline-flex; width: var(--control-height); flex: none; }
.tree-disclosure .icon-btn { width: var(--control-height); height: var(--control-height); padding: 0; }

.tree-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-hit-path {
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-hit-line {
  color: var(--text-muted);
  font-size: 10px;
  flex-shrink: 0;
  min-width: 22px;
  text-align: right;
}

.tree-hit-text {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.tree-error {
  padding: 6px 8px;
  border: 1px solid var(--offline);
  border-radius: 6px;
  color: var(--offline);
  font-size: 12px;
  margin-bottom: 8px;
}

/* -- editor ---------------------------------------------------------------- */

.editor {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg);
  overflow: hidden;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.editor-path {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-save {
  flex-shrink: 0;
  padding: 4px 12px;
  font-size: 12px;
}

.editor-error {
  margin: 8px 12px 0;
  padding: 6px 10px;
  border: 1px solid var(--offline);
  border-radius: 6px;
  color: var(--offline);
  font-size: 12px;
}

/* The editor body: a highlighted overlay behind a transparent textarea. Both
   layers share identical font metrics and whitespace so the colored text stays
   pixel-aligned with the raw text the user edits. */
.editor-code {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.editor-scroll-surface {
  position: absolute;
  inset: 0;
  left: var(--editor-gutter-width, 40px);
  overflow: auto;
  scrollbar-gutter: stable;
  background: transparent;
  font-family: var(--mono);
  font-size: 13px;
}
.editor-scroll-extent { pointer-events: none; }

.editor-highlight {
  position: absolute;
  inset: 0;
  bottom: auto;
  height: var(--editor-viewport-height, 100%);
  z-index: 1;
  overflow: hidden;
  scrollbar-gutter: stable;
  pointer-events: none;
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  tab-size: var(--editor-tab-width, 4);
  white-space: pre;
  overflow-wrap: normal;
  color: var(--text);
  visibility: hidden;
}

.editor-highlight-content {
  padding: 12px 16px 12px var(--editor-gutter-width, 40px);
  min-height: 100%;
  min-width: 100%;
  width: max-content;
  transform: translate(var(--editor-scroll-x, 0px), var(--editor-scroll-y, 0px));
  will-change: transform;
}

.editor-code.highlight-ready .editor-highlight { visibility: visible; }
.editor-code.highlight-ready .editor-textarea { color: transparent; }
.editor-textarea.editor-visual-carets { caret-color: transparent; }
.editor-textarea.editor-source-selections::selection { background: transparent; }

/* Local native surrounding text is input-only; source paint owns its display. */
.editor-textarea[data-editor-native-bound="true"] {
  color: transparent;
  caret-color: transparent;
  transform: translate(var(--editor-native-ime-x, 0px), var(--editor-native-ime-y, 0px));
}
.editor-textarea[data-editor-native-bound="true"]::selection { background: transparent; }
.editor-textarea[data-editor-native-preparing="true"] { pointer-events: none; }

.editor-textarea {
  position: absolute;
  inset: 0;
  left: var(--editor-gutter-width, 40px);
  z-index: 2;
  width: var(--editor-input-width, calc(100% - var(--editor-gutter-width, 40px)));
  height: var(--editor-input-height, 100%);
  resize: none;
  overflow: hidden;
  border: none;
  outline: none;
  margin: 0;
  padding: 12px 16px 12px 0;
  background: transparent;
  /* Keep raw text readable until the current highlight frame is ready. */
  color: var(--text);
  caret-color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  tab-size: var(--editor-tab-width, 4);
  white-space: pre;
  overflow-wrap: normal;
}

/* Logical lines stay aligned; gutter paint compensates horizontal scrolling. */
.editor-source-line { display: block; position: relative; min-height: 1.5em; }
/* Fixed unwrapped row boxes match native line spacing without glyph-height drift. */
.editor-uniform-rows:not(.editor-word-wrap) .editor-source-line { height: 1lh; min-height: 1lh; }
.editor-source-line::before { content: attr(data-line); position: absolute; right: 100%; width: var(--editor-gutter-width, 40px); padding-right: 12px; height: 100%; text-align: right; color: var(--text-muted); background: var(--bg); z-index: 1; transform: translateX(calc(0px - var(--editor-scroll-x, 0px))); user-select: none; white-space: nowrap; }

/* syntax highlight token colors (Tokyo Night palette) */

.tok-keyword {
  color: #bb9af7;
}
.tok-type {
  color: #7dcfff;
}
.tok-string,
.tok-char {
  color: #9ece6a;
}
.tok-comment {
  color: #c7d1eb;
  font-style: italic;
}
.tok-number,
.tok-boolean {
  color: #ff9e64;
}
.tok-function,
.tok-macro {
  color: #7aa2f7;
}
.tok-operator {
  color: #89ddff;
}
.tok-punct {
  color: var(--text);
}
.tok-attribute {
  color: #e0af68;
}
.tok-lifetime {
  color: #f78c6c;
}

/* syntax highlight token colors (light theme) */

:root[data-theme="light"] .tok-keyword {
  color: #a626a4;
}
:root[data-theme="light"] .tok-type {
  color: #005cc5;
}
:root[data-theme="light"] .tok-string,
:root[data-theme="light"] .tok-char {
  color: #50a14f;
}
:root[data-theme="light"] .tok-comment {
  color: #374256;
}
:root[data-theme="light"] .tok-number,
:root[data-theme="light"] .tok-boolean {
  color: #c18401;
}
:root[data-theme="light"] .tok-function,
:root[data-theme="light"] .tok-macro {
  color: #4078f2;
}
:root[data-theme="light"] .tok-operator {
  color: #0184bc;
}
:root[data-theme="light"] .tok-attribute {
  color: #c18401;
}
:root[data-theme="light"] .tok-lifetime {
  color: #e45649;
}

.editor-empty {
  margin: auto;
  text-align: center;
  padding: 20px;
}

/* editor diff & header actions */

.editor-header-actions,
.editor-diff-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* =========================================================================
   UI Component System (Primitives: Buttons, Segmented Controls, Badges)
   ========================================================================= */

.ui-segmented-control {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.ui-seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}

.ui-seg-btn:hover:not(.active):not(:disabled) {
  color: var(--text);
  background: var(--bg-hover);
}

.ui-seg-btn.active {
  color: var(--text);
  background: var(--bg-panel);
  border-color: var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.ui-seg-btn:disabled {
  opacity: 0.4;
  cursor: default;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.editor-document-preview {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--mono);
}

.rich-preview-block {
  border-left: 3px solid transparent;
  margin-left: -15px;
  padding-left: 12px;
  display: flow-root;
}
.rich-preview-block.added { border-color: var(--online); }
.rich-preview-block.modified { border-color: var(--warn); }
.rich-preview-block.removed { border-color: var(--offline); }
.rich-preview-item, .rich-preview-row { position: relative; }
.rich-preview-item::before, .rich-preview-row::before {
  content: "";
  position: absolute;
  width: 3px;
  top: 0;
  bottom: 0;
  background: var(--warn);
}
.rich-preview-item::before { left: -35px; }
.rich-preview-row::before { left: 0; }
.rich-preview :is(.rich-preview-item, .rich-preview-row).added::before { background: var(--online); }
.rich-preview :is(.rich-preview-item, .rich-preview-row).removed::before { background: var(--offline); }
.rich-preview-block.removed {
  background: color-mix(in srgb, var(--offline) 12%, transparent);
}
.rich-preview-block.removed img, .rich-preview-block del img { opacity: 0.6; }
.rich-preview-block.added {
  background: color-mix(in srgb, var(--online) 12%, transparent);
}
.rich-preview ins {
  text-decoration: none;
}

.ui-seg-glyph {
  font-size: 11px;
}

.btn.sm {
  padding: 3px 10px;
  font-size: 11px;
}

.btn.md {
  padding: 6px 12px;
  font-size: 12px;
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
}

.btn.ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}

.editor-diff {
  flex: 1;
  overflow: auto;
  padding: 8px 0;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
}

.editor-intelligence-result > .editor-diff { flex: none; }

.diff-line {
  padding: 0 16px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.diff-line-marker {
  user-select: none;
  opacity: 0.75;
  display: inline-block;
  width: 14px;
}

.diff-line.add {
  background: color-mix(in srgb, var(--online) 15%, transparent);
  color: var(--online);
}

.diff-line.del {
  background: color-mix(in srgb, var(--offline) 15%, transparent);
  color: var(--offline);
}

.diff-word-del, .rich-preview :is(.rich-preview-block, .rich-preview-item, .rich-preview-row):not(.unchanged) del {
  background: color-mix(in srgb, var(--offline) 45%, transparent);
  border-radius: 2px;
  text-decoration: line-through;
}

.diff-word-del.tok-comment { background: color-mix(in srgb, var(--offline) 20%, transparent); }

.diff-word-add, .rich-preview :is(.rich-preview-block, .rich-preview-item, .rich-preview-row):not(.unchanged) ins {
  background: color-mix(in srgb, var(--online) 45%, transparent);
  border-radius: 2px;
  font-weight: 600;
}

.diff-word-add.tok-comment { background: color-mix(in srgb, var(--online) 20%, transparent); }

.editor-diff-side {
  display: flex;
  flex-direction: column;
}

.sbs-row {
  display: flex;
}

.sbs-cell {
  flex: 1;
  min-width: 0;
  padding: 0 12px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  border-right: 1px solid var(--border);
}

.sbs-cell:last-child {
  border-right: none;
}

.sbs-del {
  background: color-mix(in srgb, var(--offline) 15%, transparent);
  color: var(--offline);
}

.sbs-add {
  background: color-mix(in srgb, var(--online) 15%, transparent);
  color: var(--online);
}

.sbs-empty {
  background: var(--bg-panel);
}

.editor-content-view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 12px 16px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.editor-preview {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  padding: 16px 24px;
  -webkit-overflow-scrolling: touch;
}

.editor-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.editor-placeholder-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
  background: var(--bg);
  font-family: var(--mono);
  overflow-y: auto;
}

.placeholder-icon {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 16px;
  user-select: none;
}

.placeholder-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.placeholder-desc {
  font-size: 12px;
  padding: 2px 10px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--accent);
  margin-bottom: 16px;
}

.placeholder-hint {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 420px;
  line-height: 1.5;
  margin: 0 0 20px;
}

.placeholder-actions {
  display: flex;
  gap: 10px;
}

.placeholder-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-family: var(--mono);
}

.editor-media-preview {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  overflow: auto;
}

.editor-image-frame {
  max-width: 90%;
  max-height: 80%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: repeating-conic-gradient(var(--bg-panel) 0% 25%, var(--bg) 0% 50%) 50% / 16px 16px;
}

.editor-preview-image {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 4px;
}

.editor-media-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

.media-type-pill {
  padding: 1px 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 10px;
  text-transform: uppercase;
}


/* -- new-project form ------------------------------------------------------- */

.new-project-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
}

textarea.form-input {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
  font-family: var(--mono);
}

.mode-picker {
  display: flex;
  gap: 6px;
}

.mode-opt {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
}

.mode-opt.active {
  border-color: var(--accent);
  color: var(--text);
  background: var(--bg-hover);
}

.mode-opt input {
  margin: 0;
}

.form-actions {
  display: flex;
  gap: 6px;
}

.form-actions .btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 12px;
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* -- settings modal -------------------------------------------------------- */

.modal-overlay {
  --dialog-available-height: calc(var(--visible-height, 100dvh) - 2 * var(--dialog-gutter) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  box-sizing: border-box;
  height: var(--visible-height, 100dvh);
  padding: max(var(--dialog-gutter), env(safe-area-inset-top)) max(var(--dialog-gutter), env(safe-area-inset-right)) max(var(--dialog-gutter), env(safe-area-inset-bottom)) max(var(--dialog-gutter), env(safe-area-inset-left));
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  --dialog-width: var(--dialog-standard);
  box-sizing: border-box;
  width: min(var(--dialog-width), 100%);
  max-width: 100%;
  max-height: min(880px, var(--dialog-available-height));
  min-height: 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 15px;
}

.modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

/* Confirmation dialog (Phase 10) */
.modal-sm {
  --dialog-width: var(--dialog-small);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.confirm-message {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
}

.btn.danger {
  background: var(--offline);
  border-color: var(--offline);
  color: var(--on-accent);
}

.btn.danger:hover:not(:disabled) {
  opacity: 0.9;
  border-color: var(--offline);
}

/* Non-blocking message toast (Phase 10) */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--offline);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 200;
}

.toast-message {
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

.toast-close {
  flex-shrink: 0;
}

/* Path input + Browse button (new remote project) */
.path-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.path-row .form-input {
  flex: 1;
  min-width: 0;
}

/* Remote file browser modal (Phase 10) */
.browser-path {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--mono);
  word-break: break-all;
}

.browser-error {
  padding: 6px 8px;
  border: 1px solid var(--offline);
  border-radius: 6px;
  color: var(--offline);
  font-size: 12px;
}

.browser-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 42vh;
  overflow-y: auto;
}

.browser-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: default;
  user-select: none;
}

button.browser-item {
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  text-align: left;
}

.browser-item.dir {
  cursor: pointer;
}

.browser-item.dir:hover {
  background: var(--bg-hover, rgba(255, 255, 255, 0.06));
}

.browser-icon {
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}

.browser-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.browser-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px;
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-label {
  font-size: var(--font-control);
  font-weight: 500;
  color: var(--text);
}

/* -- top bar: user --------------------------------------------------------- */

.topbar-user {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-muted);
}

/* -- auth gate ------------------------------------------------------------- */

.auth-gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.auth-loading {
  color: var(--text-muted);
}

.auth-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 360px;
  max-width: calc(100vw - 32px);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.auth-logo {
  margin: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
}

.logo-mark.auth-brand-mark { width: 56px; height: 56px; align-self: center; }

.auth-subtitle {
  margin: 0 0 6px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.auth-error {
  margin: 0;
  font-size: 12px;
  color: var(--offline);
}

.auth-toggle {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  padding: 4px;
}

.auth-toggle:hover {
  text-decoration: underline;
}

/* -- center pane & terminal dock ------------------------------------------ */

.center-pane {
  flex: 1;
  min-width: 260px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  border-right: none;
  overflow: hidden;
}

.center-pane .editor {
  border-right: none;
}

.terminal-dock {
  height: 260px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  background: #141518;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  color: #e0e6ed;
  overflow: hidden;
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  padding: 0 10px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  user-select: none;
}

.terminal-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminal-glyph {
  color: var(--accent);
  font-weight: bold;
}

.terminal-label {
  font-weight: 600;
}

.term-status {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
}
.term-status.online {
  color: var(--online);
  background: color-mix(in srgb, var(--online) 12%, transparent);
}
.term-status.connecting {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}
.term-status.offline {
  color: var(--offline);
  background: color-mix(in srgb, var(--offline) 12%, transparent);
}

.btn.term-btn,
.btn.term-send-btn {
  font-family: var(--mono);
}

.terminal-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.terminal-output {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
  background: #141518;
  color: #d1d5db;
  font-family: var(--mono);
}

.terminal-line {
  min-height: 1lh;
}

.terminal-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
}

.terminal-prompt {
  color: var(--accent);
  font-weight: bold;
  font-family: var(--mono);
}

.terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

/* ANSI color styles */
.term-bold { font-weight: bold; }
.term-black { color: #1f2335; }
.term-red { color: #f7768e; }
.term-green { color: #9ece6a; }
.term-yellow { color: #e0af68; }
.term-blue { color: #7aa2f7; }
.term-magenta { color: #bb9af7; }
.term-cyan { color: #7dcfff; }
.term-white { color: #c0caf5; }
.term-bright-black { color: #565f89; }
.term-bright-red { color: #ff7a93; }
.term-bright-green { color: #b9f27c; }
.term-bright-yellow { color: #ff9e64; }
.term-bright-blue { color: #7da6ff; }
.term-bright-magenta { color: #c099ff; }
.term-bright-cyan { color: #b4f9f8; }
.term-bright-white { color: #ffffff; }

/* Status bar terminal toggle button */
.status-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--mono);
}
.status-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.status-btn.active {
  background: var(--bg-hover);
  color: var(--accent);
  border-color: var(--border);
}

/* =========================================================================
   Phase 12: TUI-Driven Chat Surface & Keyboard Workflow
   ========================================================================= */

.tui-pane {
  --tui-text-inset: 16px;
  font-family: var(--mono);
}

.tui-stream {
  padding: 12px 16px;
  gap: 12px;
}

/* Transcript entries retain their natural height; overflow belongs to the stream. */
.tui-stream > * {
  flex-shrink: 0;
}

.tui-stream-spacer {
  margin-top: auto;
  flex-shrink: 0;
  min-height: 0;
}

.tui-stream > :first-child {
  margin-top: auto;
}

.tui-stream-line {
  display: flex;
  flex-direction: column;
  gap: 4px;
  line-height: 1.5;
  font-family: var(--mono);
  font-size: 13px;
}

.tui-user {
  color: var(--text);
  padding: 8px;
  margin-inline: -8px 0;
  background: var(--bg-hover);
  border-radius: 4px;
}

.tui-user-prompt {
  display: flex;
  gap: calc(var(--tui-text-inset) - 8px);
  align-items: flex-start;
}

.tui-glyph {
  font-weight: 700;
  user-select: none;
}

.tui-glyph.user {
  flex: 0 0 8px;
  color: var(--accent);
}

.tui-attached-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  color: var(--accent);
  width: fit-content;
  margin-bottom: 2px;
}

.tui-user-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.tui-assistant-body {
  padding-left: var(--tui-text-inset);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.tui-assistant-body pre,
.tui-assistant-body code {
  font-family: var(--mono);
}

/* Thinking reasoning box */
.tui-thinking-box {
  margin: 4px 0 8px var(--tui-text-inset);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  overflow: hidden;
}

.tui-thinking-summary.active {
  color: var(--accent);
}

.tui-model-wait {
  display: flex; align-items: center; gap: var(--space-2);
  margin: var(--space-1) 0 var(--space-2) var(--tui-text-inset);
  color: var(--accent); font: inherit;
}

.ui-loading-status { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-muted); font-size: var(--font-caption); white-space: nowrap; }

.ui-spinner, .tui-spinner {
  display: inline-block;
  min-width: 1ch;
  color: var(--accent);
}

/* Braille frame cycling; browsers without animatable `content` show the
   static base frame. */
.ui-spinner::after, .tui-spinner::after {
  content: "⠋";
  animation: tui-spin 1s step-end infinite;
}

@media (prefers-reduced-motion: reduce) { .ui-spinner::after, .tui-spinner::after { animation: none; } }

@keyframes tui-spin {
  0% { content: "⠋"; }
  12.5% { content: "⠙"; }
  25% { content: "⠹"; }
  37.5% { content: "⠸"; }
  50% { content: "⠼"; }
  62.5% { content: "⠴"; }
  75% { content: "⠦"; }
  87.5% { content: "⠧"; }
}

.tui-think-badge {
  font-weight: 600;
}

.tui-think-meta {
  color: inherit;
  font: inherit;
}

.tui-thinking-trace {
  max-height: 240px;
  overflow-y: auto;
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.tui-thinking-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-muted);
}

/* Terminal tool box */
.tui-tool-box {
  margin: 6px 0 6px 16px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  font-family: var(--mono);
  font-size: 12px;
}

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

.tui-tool-tag {
  color: var(--accent);
  font-weight: 700;
}

.tui-tool-title {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tui-tool-spacer {
  flex: 1;
}

.tui-tool-status-badge {
  font-weight: 600;
  font-size: 11px;
}

.tui-tool-status-badge.ok {
  color: var(--online);
}

.tui-tool-status-badge.err {
  color: var(--offline);
}

.tui-tool-status-badge.awaiting {
  color: var(--warn);
}

.tui-tool-status-badge.running {
  color: var(--accent);
}

.tui-tool-inner {
  padding: 6px 10px;
}

.tui-tool-pending {
  color: var(--text-muted);
  font-size: 11px;
}

.tui-tool-summary-out {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  font-size: 11px;
}

.tui-tool-bottombar {
  display: none;
}

/* Inline diff within tool box */
.tui-diff-box {
  margin-top: 4px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  background: var(--bg);
}

.tui-diff-path {
  padding: 3px 8px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
}

.tui-diff-lines {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.4;
}

.tui-diff-line {
  padding: 1px 8px;
  white-space: pre;
}

.tui-diff-line.add {
  color: var(--online);
  background: color-mix(in srgb, var(--online) 10%, transparent);
}

.tui-diff-line.del {
  color: var(--offline);
  background: color-mix(in srgb, var(--offline) 10%, transparent);
}

/* Inline permission handshake */
.tui-permission-prompt {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--warn) 8%, transparent);
  border: 1px dashed var(--warn);
  border-radius: 4px;
}

.tui-perm-text {
  font-weight: 600;
  color: var(--warn);
}

.tui-perm-buttons {
  display: flex;
  gap: 8px;
}

.btn.tui-perm-btn {
  font-family: var(--mono);
  font-size: 12px;
  padding: 3px 10px;
}

/* Powerline statusline */
.tui-statusline {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  user-select: none;
}

.tui-mode-badge {
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 2px;
}

.tui-mode-badge.mode-normal {
  color: var(--online);
}

.tui-mode-badge.mode-running {
  color: var(--accent);
  animation: tui-pulse 1.2s infinite;
}

.tui-mode-badge.mode-awaiting {
  color: var(--warn);
  animation: tui-pulse 0.8s infinite;
}

@keyframes tui-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.tui-sep {
  color: var(--border);
}

.tui-model-name {
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  position: relative;
}

.tui-ctx-gauge.ctx-normal {
  color: var(--online);
}

.tui-ctx-gauge.ctx-warning {
  color: var(--warn);
}

.tui-ctx-gauge.ctx-danger {
  color: var(--offline);
}

.tui-speed {
  color: var(--accent);
}

/* Context pill bar above composer */
.tui-active-context-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
}

.pill-icon {
  font-size: 13px;
}

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

.pill-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
}

.pill-dismiss:hover {
  color: var(--text);
}

/* Composer tweaks for TUI */
.tui-composer {
  padding: 8px 12px;
  gap: 8px;
}

.tui-prompt-glyph {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  align-self: center;
  user-select: none;
}

.tui-input {
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 10px;
}

.tui-model-select {
  font-size: 11px;
  height: 36px;
}

.tui-btn-send,
.tui-btn-stop {
  height: 36px;
  font-family: var(--mono);
  font-size: 12px;
}

.chat-welcome { display: flex; flex: 1; min-height: 0; overflow: auto; padding: var(--space-6); }
.tui-empty-state { margin: auto; max-width: 480px; font-family: var(--mono); }
.chat-welcome-heading { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: var(--space-4); }
.logo-mark.chat-welcome-logo { width: 72px; height: 72px; }
.chat-welcome-tip { padding-top: var(--space-4); font-size: var(--font-control); }

.tui-stopped-marker {
  color: var(--offline);
  font-family: var(--mono);
  font-size: 12px;
}


.toast.toast-info { border-color: var(--accent); bottom: 76px; }

.terminal-visibility {
  display: contents;
}

.terminal-visibility.hidden {
  display: none;
}

.tui-model-menu { bottom: 100%; top: auto; min-width: 240px; }
.tui-connection-group .recent-item { width: 100%; text-align: left; justify-content: flex-start; }
.tui-connection-heading { font-weight: 600; }
.tui-connection-model { padding-left: 28px; }
.tui-connection-group .form-hint { display: block; padding: 6px 28px; }
.tui-connection-model[aria-current="true"] { background: var(--bg-hover); color: var(--accent); }

.model-setup summary { cursor: pointer; color: var(--text); margin-bottom: 12px; }
.model-settings-editor { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.model-setup .form-actions { margin: 12px 0; }

.approval-mode-picker { position: relative; flex-shrink: 0; }
.approval-mode-picker .tui-mode-badge { font: inherit; padding: 2px 6px; }
.approval-mode-menu { bottom: 100%; top: auto; }
.tui-run-state { color: var(--text-muted); }

/* Persistent vertical tool tabs; collapsed panels retain their mounted state. */
.panel-rail {
  width: 36px;
  flex: 0 0 36px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 2px;
  background: var(--bg-panel);
  border-inline: 1px solid var(--border);
  overflow-y: auto;
}
.btn.panel-tab {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  padding: 12px 7px;
  border: 0;
  border-radius: 3px;
  color: var(--text-muted);
  background: transparent;
  flex-shrink: 0;
}
.btn.panel-tab:hover { background: var(--bg-hover); color: var(--text); }
.btn.panel-tab.is-open { background: var(--bg-hover); color: var(--accent); box-shadow: inset -2px 0 var(--accent); }
.btn.panel-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.app-body.editor-collapsed .chat-pane { flex: 1 !important; width: auto !important; min-width: 260px; }
.app-body { overflow-x: auto; }

.panel-empty { flex: 1; min-width: 0; display: grid; place-items: center; color: var(--text-muted); }

.chat-tab {
  flex: none;
  margin-left: auto;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  border-radius: 0;
}

/* Use the shared ghost button treatment for checkpoint controls. */
.tui-rewind {
  align-self: flex-end;
  font-size: 11px;
  margin-top: -8px;
}

/* Run file review shares the chat surface and theme palette. */
.run-changes { margin: 6px 0 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-panel); }
.run-changes > summary, .run-change-hunk > summary { cursor: pointer; padding: 8px; color: var(--text-muted); }
.run-change { border-top: 1px solid var(--border); padding: 8px; }
.run-change-header, .run-change-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.run-change-path { margin-right: auto; font-family: var(--mono); overflow-wrap: anywhere; text-align: left; }
.run-change-hunk { margin-top: 6px; }
.run-change-hunk pre { font-family: var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; padding: 4px 8px; }
.run-change-removed { color: var(--offline); background: var(--bg); }
.run-change-added { color: var(--online); background: var(--bg); }
.run-change-actions { padding: 4px 8px; }


.context-breakdown-bar { display: flex; height: 18px; overflow: hidden; border-radius: 4px; background: var(--bg-hover); border: 1px solid var(--border); }
.context-segment { display: block; height: 100%; }
.context-key { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 2px; }
.context-category-0 { background: var(--accent); }
.context-category-1 { background: var(--online); }
.context-category-2 { background: var(--warn); }
.context-category-3 { background: var(--text-muted); }
.context-category-4 { background: var(--git-modified); }
.context-generated { background: var(--offline); }
.context-breakdown-list > div { display: flex; justify-content: space-between; gap: 12px; margin: 8px 0; }
.context-breakdown-list dd { font-family: var(--mono); margin: 0; }

.prompt-attachments { display: contents; }
.prompt-attachment-menu .ui-dropdown-trigger { min-height: 44px; }
.prompt-attachment-count { font-size: var(--font-caption); color: var(--accent); }
.prompt-attachment-menu .ui-dropdown-menu { padding: var(--space-2); min-width: 220px; max-width: min(360px, calc(100vw - 24px)); }
.prompt-editor-context { display: flex; align-items: center; gap: var(--space-2); font-family: var(--mono); font-size: var(--font-caption); }
.prompt-editor-context > span { flex: 1; overflow-wrap: anywhere; }
.prompt-image-list { display: flex; flex-wrap: wrap; gap: 8px; }
.prompt-image { display: flex; align-items: center; gap: 6px; margin-top: 6px; border: 1px solid var(--border); padding: 4px; max-width: 100%; }
.prompt-image img { width: 56px; height: 56px; object-fit: contain; }
.prompt-image span { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.prompt-history-image { max-width: 240px; max-height: 180px; object-fit: contain; border: 1px solid var(--border); }
.prompt-reference { margin: 6px 0; color: var(--text-muted); }
.prompt-reference pre { max-height: 180px; overflow: auto; white-space: pre-wrap; font-family: var(--mono); background: var(--bg-panel); padding: 8px; }
.mention-choices { position: absolute; bottom: 100%; left: 0; right: 0; max-height: 240px; overflow: auto; z-index: 20; background: var(--bg-panel); border: 1px solid var(--border); padding: 4px; }
.mention-choices .btn { display: block; width: 100%; text-align: left; }
.mention-choices .active { background: var(--bg-hover); color: var(--accent); }
.tui-prompt-queue { border-top: 1px solid var(--border); background: var(--bg-panel); padding: 8px; max-height: 180px; overflow-y: auto; }
.tui-queue-heading, .tui-queued-prompt { display: flex; align-items: center; gap: 6px; }
.tui-queue-heading strong { flex: 1; color: var(--text-muted); font-size: 12px; }
.tui-queued-prompt { padding-top: 4px; }
.tui-queue-kind { color: var(--accent); font-size: 11px; }
.tui-queue-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: 12px; }
.tui-prompt-edit { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; color: var(--text-muted); background: var(--bg-panel); border-top: 1px solid var(--border); font-size: 12px; }

.notification-status { color: var(--text-muted); font-size: 12px; margin: 0 0 16px; }

.tui-todo-plan { border: 1px solid var(--border); border-radius: 6px; background: var(--bg-panel); margin-bottom: 8px; font-size: 12px; }
.tui-todo-plan summary { padding: 6px 10px; cursor: pointer; color: var(--text-muted); }
.todo-items { max-height: 160px; overflow-y: auto; padding: 0 10px 8px; }
.todo-row { display: flex; gap: 8px; padding: 4px 0; overflow-wrap: anywhere; }
.todo-status { flex-shrink: 0; color: var(--text-muted); }
.todo-row.active .todo-status { color: var(--accent); }
.todo-row.completed { color: var(--text-muted); }
.todo-row.completed .todo-status { color: var(--online); }
.todo-notice { color: var(--text-muted); font-size: 12px; margin-bottom: 8px; }

.tui-tool-output .tui-tool-summary-out {
  margin: 0;
  max-height: 320px;
  overflow: auto;
  font-family: var(--mono);
}

.tui-tool-output-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.tui-copy-buffer {
  position: fixed;
  left: -10000px;
  top: 0;
}

.tui-turn-summary {
  padding: 4px 0;
  font-size: 11px;
  font-family: var(--mono);
}

/* The command dialogs use the shared modal, button and input styles. */
.command-search { width: 100%; }
.command-results { max-height: 360px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.command-option { width: 100%; justify-content: space-between; text-align: left; white-space: normal; }
.command-option.selected { background: var(--bg-hover); border-color: var(--accent); }
.command-unavailable { display: block; }
.command-option kbd, .shortcut-row kbd { font-family: var(--mono); font-size: 11px; color: var(--text-muted); }
.command-option kbd { flex-shrink: 0; margin-left: 12px; }
.shortcut-row { display: flex; gap: 16px; margin: 10px 0; }
.shortcut-row dt { min-width: 130px; }
.shortcut-row dd { margin: 0; }

.session-search { margin-bottom: 6px; }
.session-filters { margin-bottom: 6px; }
.session-list .session { flex-wrap: nowrap; }
.session-list .session-name { flex: 1 1 0; min-width: 0; justify-content: flex-start; text-align: left; overflow: hidden; text-overflow: ellipsis; }
.session-list .session-actions { margin-left: auto; }
.session-list .session-actions { display: inline-flex; visibility: hidden; }
.session-list .session:hover .session-actions, .session-list .session.active .session-actions, .session-list .session:focus-within .session-actions { visibility: visible; }

.tui-task-run {
  margin: 0.5rem 0;
  border-left: 2px solid var(--border);
  padding-left: 0.6rem;
}
.tui-task-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
}
.tui-task-content {
  padding: 0.5rem 0 0.25rem 0.4rem;
}

/* Tool windows keep their children mounted while moving or collapsing. */
.tool-panel { position: relative; flex: none; min-width: 0; min-height: 0; flex-direction: column; }
.tool-panel-center { flex: 1; }
.tool-panel-content { display: flex; flex: 1; min-width: 0; min-height: 0; }
.tool-panel-content > .center-pane { flex: 1; }
.tool-panel-heading { display: none; }
.panel-rail { order: 0; }
.panel-tab-group { display: flex; flex-direction: column; }
.panel-pin { padding: 2px; border: 0; font-size: 12px; }
.panel-empty { order: 60; }

.app { height: 100dvh; min-height: 0; overflow: hidden; }
.phone-layout .app-body { flex-direction: column; overflow: hidden; }
.phone-layout .panel-rail { width: 100%; flex: none; flex-direction: row; padding: 2px; overflow-x: auto; overflow-y: hidden; box-sizing: border-box; }
.phone-layout .panel-tab-group { flex: none; }
.phone-layout .panel-tab { writing-mode: horizontal-tb; transform: none; min-height: 44px; padding: 8px 12px; }
.phone-layout .panel-pin { display: none; }
.phone-layout .tool-panel { width: 100%; flex: 1; overflow: hidden; }
.phone-layout .tool-panel-content { overflow: hidden; }
.phone-layout .tool-panel-heading { justify-content: space-between; }
.phone-layout #panel-chat .tool-panel-heading { display: none; }
.phone-layout .panel-resizer { display: none; }
.phone-layout .chat-pane, .phone-layout .sidebar, .phone-layout .file-tree, .phone-layout .center-pane { width: 100% !important; min-width: 0 !important; flex: 1 !important; }
.phone-layout .btn, .phone-layout .icon-btn, .phone-layout .tree-item, .phone-layout .mode-opt { min-height: 44px; }
.phone-layout input, .phone-layout textarea, .phone-layout select { font-size: 16px; }
.phone-layout .topbar, .phone-layout .statusbar { flex-wrap: wrap; }
.phone-layout .tab-bar { overflow-x: auto; flex-shrink: 0; }

.phone-layout .setting-row { flex-wrap: wrap; }
.search-pane, .git-pane { display: flex; flex-direction: column; width: var(--tool-window-width, 320px); min-width: 0; min-height: 0; overflow: auto; background: var(--bg-panel); }
.git-files { flex: none; }
.btn.tree-item { background: transparent; font-family: inherit; font-weight: normal; color: var(--text); display: flex; justify-content: flex-start; width: 100%; text-align: left; gap: 6px; border: 0; border-radius: 5px; }
.git-diff-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px; border-block: 1px solid var(--border); }
#panel-terminal { width: var(--tool-window-width); }
#panel-terminal .terminal-visibility, #panel-terminal .terminal-dock { width: 100%; height: 100%; min-height: 0; flex: 1; }
.phone-layout .search-pane, .phone-layout .git-pane { width: 100%; flex: 1; }
.tui-model-picker { position: relative; min-width: 0; }
.btn.tui-model-name { font: inherit; padding: 2px 4px; max-width: 100%; overflow-wrap: anywhere; }
.phone-layout .tui-statusline { flex-wrap: wrap; gap: 4px 8px; }
.phone-layout .tui-statusline .tui-sep { display: none; }
.phone-layout .tui-model-picker { max-width: calc(100% - 84px); }
.phone-layout .recent-menu { min-width: min(240px, calc(100vw - 24px)); max-width: calc(100vw - 24px); }
.phone-layout .topbar { min-height: 44px; height: auto; }
.phone-layout .topbar .spacer { display: none; }
.phone-layout .topbar-user { overflow: hidden; text-overflow: ellipsis; max-width: 100px; }
.phone-layout .statusbar { min-height: 44px; height: auto; gap: 4px 12px; }
.phone-layout .status-btn, .phone-layout .git-branch-btn, .phone-layout .tab-actions .btn { min-height: 44px; }
.phone-layout .tui-composer { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.phone-layout .tui-input { min-width: 0; }
@media (max-width: 800px) {
  .auth-box { max-width: calc(100vw - 32px); box-sizing: border-box; }
}
.phone-layout .topbar { gap: 4px; }
.phone-layout .topbar .logo { flex: 1; }
.phone-layout .topbar-user { display: none; }
.phone-layout .icon-btn { min-width: 44px; }
.app:not(.phone-layout) .tool-panel-center { min-width: 260px; }
.phone-layout { height: var(--visible-height, 100dvh); }

/* -- composable dialogs and forms ----------------------------------------- */
.modal { border-radius: var(--radius-lg); }
.modal-wide { --dialog-width: var(--dialog-wide); }
.modal-header { padding: var(--space-4) var(--space-6); gap: var(--space-4); flex-shrink: 0; }
.modal-header h2 { font-size: var(--font-dialog); line-height: 1.35; font-weight: 600; }
.modal-description { margin: var(--space-1) 0 0; color: var(--text-muted); font-size: var(--font-caption); line-height: 1.5; }
.modal-header .icon-btn { flex-shrink: 0; min-width: var(--control-height); min-height: var(--control-height); }
.modal-body { padding: var(--space-6); gap: var(--space-6); min-height: 0; overscroll-behavior: contain; }
.modal-footer { padding: var(--space-4) var(--space-6); flex-shrink: 0; }
.modal .btn:not(.sm) { padding: var(--space-2) var(--space-3); font-size: var(--font-control); min-height: var(--control-height); border-radius: var(--radius-md); }
.modal .form-input { min-width: 0; min-height: var(--control-height); font: inherit; font-size: var(--font-control); border-radius: var(--radius-md); }
.modal textarea.form-input { min-height: 90px; font-family: var(--mono); }
.ui-section { min-width: 0; }
.ui-section + .ui-section { border-top: 1px solid var(--border); padding-top: var(--space-6); }
.ui-section-heading { margin-bottom: var(--space-4); }
.ui-section-heading h3 { margin: 0; font-size: var(--font-section); font-weight: 600; line-height: 1.4; }
.ui-section-heading .form-hint { margin-top: var(--space-1); }
.ui-section-content { display: grid; gap: var(--space-4); min-width: 0; }
.ui-form-grid > .ui-section-content { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ui-field { min-width: 0; gap: var(--space-2); margin: 0; }
.ui-field-group { border: 0; padding: 0; }
.ui-field-group legend { padding: 0; margin-bottom: var(--space-2); }
.ui-actions, .ui-inline-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.ui-actions { justify-content: flex-end; }
.ui-inline-actions .btn { flex: 0 1 auto; }
.ui-input-group { display: flex; gap: var(--space-2); align-items: center; min-width: 0; }
.ui-input-group .form-input { flex: 1; }
.ui-check { display: flex; align-items: flex-start; gap: var(--space-2); font-size: var(--font-control); cursor: pointer; }
.ui-check input { margin: 2px 0 0; accent-color: var(--accent); }
.ui-notice { padding: var(--space-3); border-inline-start: 3px solid var(--accent); border-radius: var(--radius-sm); background: var(--bg); color: var(--text-muted); font-size: var(--font-caption); line-height: 1.5; overflow-wrap: anywhere; }
.ui-notice.form-error { border-color: var(--offline); color: var(--offline); }
.ui-notice-success { border-color: var(--online); color: var(--text); }
.ui-notice-warning { border-color: var(--warn); color: var(--text); }
.ui-disclosure { border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-3); min-width: 0; }
.ui-disclosure > summary { font-size: var(--font-section); font-weight: 500; cursor: pointer; margin: 0; }
.ui-disclosure[open] > summary { margin-bottom: var(--space-4); }
.ui-disclosure > .ui-field, .ui-disclosure > .ui-check, .ui-disclosure > .form-hint { margin-top: var(--space-3); }
.model-setup, .model-settings-editor { display: flex; flex-direction: column; gap: var(--space-4); }
.model-settings-editor { margin: 0; padding-top: var(--space-4); }
.model-settings-editor .tool-budget { grid-column: 1 / -1; }
.model-wizard .model-setup-steps {
  flex: none;
  margin: 0;
  padding: var(--space-4) var(--space-6) 0;
}
.model-setup-pane[hidden] { display: none; }
.model-setup-pane:not(.model-review) > .ui-section > .ui-section-heading { display: none; }
.server-options { display: grid; gap: var(--space-3); min-width: 0; border: 0; margin: 0; padding: 0; }
.model-review { display: grid; gap: var(--space-3); }
.model-review h3, .model-review > .form-hint { margin: 0; }
.model-review-row > .ui-disclosure-toggle {
  flex-wrap: nowrap;
  min-height: 44px;
  padding: var(--space-3);
}
.model-review-summary { display: grid; gap: var(--space-1); min-width: 0; overflow-wrap: anywhere; }
.model-review-summary strong, .model-review-unsupported strong { color: var(--text); }
.model-review-row > .ui-disclosure-content { padding: 0 var(--space-3) var(--space-3); }
.model-review-unsupported {
  display: grid;
  gap: var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  color: var(--text-muted);
  font-size: var(--font-caption);
  overflow-wrap: anywhere;
}
.server-list { display: grid; gap: var(--space-3); }
.server-list-toolbar { display: flex; justify-content: flex-end; }
.server-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding-inline-end: var(--space-2);
}
.server-row:hover { background: var(--bg-hover); }
.server-row-saved { border-color: var(--accent); }
.server-configure {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 10rem) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  text-align: left;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.server-endpoint { display: grid; gap: var(--space-1); min-width: 0; }
.server-endpoint > *, .server-provider { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-endpoint > span, .server-provider { color: var(--text-muted); font-size: var(--font-caption); }
.server-configure-label { display: flex; align-items: center; gap: var(--space-1); color: var(--accent); font-size: var(--font-control); }
.server-saved-notice { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.server-saved-notice .btn.ghost { color: var(--accent); }
@media (max-width: 560px) {
  .model-wizard .model-setup-steps { padding-inline: var(--space-4); }
  .server-configure { grid-template-columns: minmax(0, 1fr) auto; row-gap: var(--space-1); }
  .server-endpoint { display: contents; }
  .server-endpoint > * { white-space: normal; overflow-wrap: anywhere; }
  .server-endpoint > span { grid-column: 1 / -1; }
  .server-configure-label { grid-column: 2; grid-row: 1; }
  .server-provider { grid-column: 1 / -1; }
}
.ui-steps { display: flex; flex-wrap: wrap; gap: var(--space-4); list-style: none; padding: 0; margin: 0; color: var(--text-muted); font-size: var(--font-control); }
.ui-steps li { display: flex; align-items: center; gap: var(--space-2); }
.ui-steps .is-current { color: var(--text); font-weight: 600; }
.ui-step-number { display: inline-flex; justify-content: center; align-items: center; width: var(--space-6); height: var(--space-6); border: 1px solid var(--border); border-radius: 50%; }
.ui-steps .is-current .ui-step-number { border-color: var(--accent); color: var(--accent); background: var(--bg-hover); }
.install-app-setting { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); }
.install-app-setting p { margin: 0; color: var(--text-muted); font-size: var(--font-caption); line-height: 1.5; }
.phone-layout { --control-height: 44px; }
@media (max-width: 799px) {
  .ui-form-grid > .ui-section-content { grid-template-columns: minmax(0, 1fr); }
  .modal-header, .modal-body, .modal-footer { padding: var(--space-4); }
  .modal .btn, .modal .form-input, .modal-header .icon-btn, .modal .mode-opt, .modal .ui-check { min-height: 44px; }
  .ui-steps { gap: var(--space-3); }
}
/* Dialog sizes share the app's desktop, compact and phone stops. */
@media (max-width: 1100px) { :root { --dialog-gutter: var(--space-4); } }
@media (max-width: 799px) {
  :root { --dialog-gutter: var(--space-2); }
  .modal { width: 100%; }
}
.phone-layout { --dialog-gutter: var(--space-2); }
.phone-layout .modal { width: 100%; }
.phone-layout .modal-header, .phone-layout .modal-body, .phone-layout .modal-footer { padding: var(--space-4); }

/* The same disclosure and compact actions serve reasoning and tool histories. */
.ui-icon { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; min-height: 28px; border-radius: var(--radius-sm); }
.ui-icon:focus-visible, .ui-disclosure-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sr-only { position: absolute; width: 1px; height: 1px; min-width: 0; min-height: 0; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.ui-disclosure-panel { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); overflow: hidden; }
.ui-disclosure-toggle { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: var(--space-2); width: 100%; padding: var(--space-2); text-align: left; font: inherit; font-size: var(--font-caption); color: var(--text-muted); background: var(--bg-panel); border: 0; cursor: pointer; }
.ui-disclosure-toggle:hover { color: var(--text); background: var(--bg-hover); }
.ui-disclosure-content[hidden] { display: none; }
.ui-disclosure-caret { flex: none; }
.tui-tool-group { margin: var(--space-1) 0 var(--space-2) var(--tui-text-inset); }
.tui-tool-count { padding: 2px var(--space-1); border-radius: var(--radius-sm); background: var(--bg-hover); font: inherit; font-family: var(--mono); color: var(--text); }
.tui-tool-group > .ui-disclosure-content { padding: var(--space-2); }
.tui-tool-group .tui-tool-box { margin-left: 0; }
.tui-prompt-actions { display: flex; justify-content: flex-end; gap: var(--space-1); }
.tui-prompt-actions:empty { display: none; }
.tui-tool-output { position: relative; }
.tui-tool-output .tui-tool-summary-out { padding-inline-end: 32px; }
.tui-output-copy { position: absolute; top: 0; right: 0; }
.phone-layout .ui-icon { min-width: 44px; min-height: 44px; }
.phone-layout .tui-tool-output .tui-tool-summary-out { padding-inline-end: 48px; }

/* A single resize boundary and a mounted view stack for each tool window. */
.files-panel { display: flex; flex-direction: column; width: var(--files-panel-width, 260px); min-width: 0; min-height: 0; background: var(--bg-panel); }
.files-view { display: flex; flex: 1; min-height: 0; min-width: 0; overflow: hidden; }
.files-view[hidden] { display: none; }
.files-view > .file-tree, .files-view > .search-pane, .files-view > .git-pane { width: 100% !important; min-width: 0; flex: 1; }
.phone-layout .files-panel { width: 100%; flex: 1; }
#panel-terminal .tool-panel-content > .terminal-visibility { width: 0; }

.tool-panel-heading { display: flex; align-items: center; gap: var(--space-2); box-sizing: border-box; min-height: calc(var(--control-height) + 2 * var(--space-2)); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); background: var(--bg-panel); font-family: system-ui, sans-serif; font-size: var(--font-caption); line-height: 1.4; }
.tool-panel-actions { display: flex; margin-left: auto; }
.app:not(.phone-layout) .tool-panel-heading > .btn { display: none; }
.tool-panel-heading .panel-minimize { flex: none; margin-left: auto; }
.tool-panel-heading .ui-action-menu + .panel-minimize,
.tool-panel-heading .ui-action-menu-context + .panel-minimize { margin-left: 0; }
.phone-layout .tool-panel-actions { display: none; }
.files-panel > .search-pane { width: 100%; flex: 1; overflow: hidden; }
.file-tree-search { display: flex; gap: var(--space-1); align-items: center; }
.file-tree-search .search-input { flex: 1; min-width: 0; }
.search-file-views { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.search-file-views[hidden], .search-results[hidden] { display: none; }

.tab.active, .btn.chat-tab.active { background: var(--bg-hover); color: var(--accent); border-color: var(--border); box-shadow: inset 0 -2px var(--accent); }
.tui-composer { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: end; flex: none; }
.tui-composer .tui-input { height: 44px; min-height: 44px; max-height: none; box-sizing: border-box; resize: none; overflow-y: auto; line-height: 20px; padding: 11px 10px; }
.tui-input-shell { position: relative; min-width: 0; }
.tui-input-shell .tui-input { display: block; width: 100%; }
.tui-inline-hint { position: absolute; inset: 0; overflow: hidden; pointer-events: none; padding: 11px 10px; border: 1px solid transparent; font-family: var(--mono); font-size: 13px; line-height: 20px; white-space: pre-wrap; overflow-wrap: break-word; color: var(--text-muted); }
.tui-hint-prefix { visibility: hidden; }
.tui-composer-actions > .btn { height: 44px; min-height: 44px; box-sizing: border-box; font-family: var(--mono); font-size: var(--font-caption); }
.tui-composer-actions { display: flex; align-items: flex-end; gap: var(--space-2); }
.panel-resizer:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.ui-icon-glyph { display: inline-flex; vertical-align: middle; flex: none; align-items: center; justify-content: center; pointer-events: none; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; min-height: 32px; }
.ui-tooltip { position: fixed; z-index: 10000; max-width: min(320px, calc(100vw - 16px)); padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-panel); color: var(--text); box-shadow: 0 4px 16px #0003; font-size: var(--font-caption); pointer-events: none; }
.ui-tooltip[hidden] { display: none; }
.topbar-action { display: inline-flex; align-items: center; gap: var(--space-2); }
.phone-layout .topbar-action > span:not(.ui-icon-glyph) { display: none; }
.phone-layout .topbar-action { min-width: 44px; min-height: 44px; }

.tool-panel-content > .search-pane { width: var(--files-panel-width); flex: none; overflow: hidden; }
.search-file-views > .files-panel { width: 100%; flex: 1; }
.phone-layout .tool-panel-content > .search-pane { width: 100%; flex: 1; }
.btn:has(.ui-icon-glyph):not(.tree-item), .status-btn:has(.ui-icon-glyph) { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1); }
.tree-icon { min-width: 20px; }

.tool-panel-heading > span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

#panel-terminal .terminal-dock { box-sizing: border-box; background: var(--bg); color: var(--text); }
.terminal-header { height: auto; min-height: var(--control-height); flex: none; flex-wrap: wrap; gap: var(--space-1); padding: var(--space-1) var(--space-2); }
.terminal-title, .terminal-actions { min-width: 0; flex-wrap: wrap; }
.terminal-input-bar { flex: none; }
.terminal-input { min-width: 0; height: 32px; }
.term-send-btn { height: 32px; }

/* Dock width and resize targets belong to the shared panel, not its contents. */
.tool-panel:not(.tool-panel-center) { width: var(--tool-window-width); }
.tool-panel-content > .sidebar, .tool-panel-content > .chat-pane, .tool-panel-content > .tui, .tool-panel-content > .search-pane { width: 100% !important; min-width: 0; flex: 1 !important; }
.phone-layout .tool-panel:not(.tool-panel-center) { width: 100%; }


/* Context toolbars share spacing; ToolPanel supplies the only panel title. */
.panel-toolbar { display: flex; align-items: center; justify-content: flex-start; gap: var(--space-2); flex: none; }
.session-search-toolbar { margin-bottom: var(--space-2); }
.session-search-toolbar .session-search { flex: 1; min-width: 0; margin: 0; }
.git-pane { padding: var(--space-3); }
.git-files .tree-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.git-diff-actions { padding: var(--space-2) 0; margin-top: var(--space-2); gap: var(--space-2); }
.git-diff-path { flex-basis: 100%; overflow-wrap: anywhere; color: var(--text-muted); font-size: var(--font-caption); }

.btn.tree-item:hover, .btn.tree-item.selected { background: var(--bg-hover); }


.branch-picker { display: inline-flex; align-items: center; gap: var(--space-1); min-width: 0; max-width: 100%; color: var(--text); }
.branch-picker .git-branch-select { min-width: 0; width: auto; max-width: 100%; margin: 0; padding: var(--space-1) var(--space-2); font-size: var(--font-caption); cursor: pointer; }
.statusbar .git-branch-select { border-color: transparent; background: transparent; }
.branch-picker .git-branch-select:hover { background: var(--bg-hover); }
.phone-layout .git-branch-select { min-height: 44px; }


/* All dropdowns use the Recent menu's surface, rows and interaction contract. */
.ui-dropdown { display: inline-flex; min-width: 0; max-width: 100%; vertical-align: middle; }
.ui-dropdown-trigger { display: inline-flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-width: 0; max-width: 100%; text-align: left; }
.ui-dropdown-indicator { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; flex: none; }
.ui-dropdown-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-dropdown-menu.recent-menu { position: fixed; top: 0; bottom: auto; left: 0; min-width: 0; max-width: calc(100vw - 16px); box-sizing: border-box; border-radius: var(--radius-md); }
.ui-dropdown-menu .recent-item, .app-menu-items .recent-item { display: flex; align-items: center; justify-content: flex-start; width: 100%; min-height: var(--control-height); gap: var(--space-2); padding: 6px 8px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text); font: inherit; font-size: var(--font-control); text-align: left; }
.ui-dropdown-menu .recent-item:hover:not(:disabled), .ui-dropdown-menu .recent-item:focus-visible, .app-menu-items .recent-item:hover:not(:disabled), .app-menu-items .recent-item:focus-visible { background: var(--bg-hover); outline: 2px solid var(--accent); outline-offset: -2px; }
.ui-dropdown-menu .recent-item[aria-checked="true"] { background: var(--bg-hover); color: var(--accent); box-shadow: inset 2px 0 var(--accent); }
.ui-dropdown-menu .recent-item:disabled { color: var(--text-muted); cursor: default; opacity: 0.65; }
.ui-dropdown-item-text { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; text-align: left; }
.ui-dropdown-item-description { color: var(--text-muted); font-size: var(--font-caption); line-height: 1.4; white-space: normal; }
.ui-dropdown-menu .form-hint { padding: var(--space-2); white-space: normal; }
.ui-field > .ui-dropdown { width: 100%; }
.ui-field > .ui-dropdown > .ui-dropdown-trigger { width: 100%; }
.ui-dropdown-menu .tui-connection-model { padding-left: var(--space-6); }
.phone-layout .ui-dropdown-trigger:not(.sr-only), .phone-layout .ui-dropdown-menu .recent-item, .phone-layout .ui-seg-btn { min-height: 44px; }

.panel-search-row { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3); margin: 0; }
.panel-search-row .panel-search-input { flex: 1; min-width: 0; width: 0; margin: 0; min-height: var(--control-height); padding: var(--space-2); font: inherit; font-size: var(--font-caption); }
.session-list .session-search-toolbar { margin: -12px -12px 0; }
.session-filters { margin: 0 0 var(--space-2); }
.files-panel > .files-panel-toolbar { margin: 0 var(--space-3) var(--space-2); }

/* Whitespace groups history; repeated reasoning/tool panels do not add rules. */
.tui-stream .ui-disclosure-panel { border: 0; }
.tui-stream .tui-thinking-trace { border-top: 0; }

.ui-dropdown-menu { font-family: system-ui, sans-serif; }

.ui-dropdown .ui-dropdown-trigger { justify-content: space-between; }

/* Secondary actions use a single inline overflow trigger. */
.ui-action-menu { margin-left: auto; flex: none; }
.ui-action-items { display: flex; flex-direction: column; }
.git-diff-actions .git-diff-path { flex: 1; min-width: 0; flex-basis: auto; }
.tui-prompt-actions { margin-left: auto; }
.phone-layout .ui-action-items button { min-height: 44px; }
.tui-user { position: relative; }
.tui-user .tui-prompt-actions { position: absolute; right: 4px; top: 0; bottom: 0; align-items: center; }
.tui-user .tui-user-text { padding-right: 36px; }

.ui-action-menu .ui-dropdown-label { display: flex; }

/* Row labels yield space to their inline overflow controls. */
.session-list .session-name { display: flex; }
.session-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-panel-toolbar > .ui-segmented-control { flex: 0 1 auto; min-width: 0; }
.git-diff-actions, .terminal-header { flex-wrap: nowrap; }
.terminal-title { flex: 1; }
.terminal-title .term-status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Server identity takes precedence over provider metadata in narrow rows. */

/* Terminal is a bottom dock, independent of the vertical pane ordering. */
.app-body:has(> .workspace-docks) { flex-direction: column; overflow: hidden; }
.workspace-docks { display: flex; flex: 1; min-width: 0; min-height: 0; overflow: auto; }
.phone-layout .workspace-docks { flex-direction: column; overflow: hidden; }
#panel-terminal.tool-panel { box-sizing: border-box; width: 100%; height: var(--tool-window-height); max-height: calc(100% - 180px); flex: none; border-top: 1px solid var(--border); }
#panel-terminal .tool-panel-heading > .btn { display: none; }
#panel-terminal .panel-resizer { top: 0; bottom: auto; left: 0; right: 0; width: 100%; height: 6px; cursor: row-resize; }
#panel-terminal .panel-resizer::after { top: 2px; left: 0; right: 0; bottom: auto; width: 100%; height: 1px; }
#panel-terminal .panel-resizer:hover::after, #panel-terminal .panel-resizer.is-active::after { height: 2px; }
.app-body.is-resizing:has(#panel-terminal > .is-active), .app-body.is-resizing:has(#panel-terminal > .is-active) * { cursor: row-resize !important; }
.status-btn:disabled { opacity: .5; cursor: default; }

.topbar-account .ui-dropdown-label { display: inline-flex; align-items: center; gap: var(--space-2); }
@media (max-width: 800px) { .topbar-account .topbar-user { display: none; } .topbar-account .ui-dropdown-indicator { display: none; } }

.editor-diff { min-height: 0; tab-size: var(--editor-tab-width, 4); }
.inline-track, .sbs-track { width: max-content; min-width: 100%; }
.editor-diff .diff-line, .sbs-cell { display: flex; align-items: flex-start; gap: 8px; min-height: 1.5em; padding: 0 12px 0 0; white-space: pre; overflow-wrap: normal; }
.editor-line-gutter { position: sticky; left: 0; z-index: 1; display: inline-flex; align-items: center; gap: 8px; flex: none; padding: 0 8px; background: var(--bg); min-height: 1.5em; }
.editor-line-number { width: var(--editor-number-width, 1ch); flex: none; text-align: right; color: var(--text-muted); user-select: none; white-space: nowrap; }
.editor-line-text { flex: 1; white-space: pre; overflow-wrap: normal; }
.editor-diff-side { flex-direction: row; padding: 0; overflow: hidden; }
.sbs-pane { flex: 1; min-width: 0; overflow: auto; padding: 8px 0; scrollbar-gutter: stable; }
.sbs-pane:first-child { border-right: 1px solid var(--border); }
.sbs-cell { border: none; }
.sbs-cell .editor-line-text { flex: none; }
.editor-find { border-bottom: 1px solid var(--border); flex: none; }
.editor-find .form-hint { flex: none; white-space: nowrap; }
.editor-find-match { outline: 2px solid var(--accent); outline-offset: -2px; }

.logo { display: inline-flex; align-items: center; gap: var(--space-2); white-space: nowrap; }
.logo-mark { display: inline-flex; width: 32px; height: 32px; flex: none; color: var(--accent); }
.logo-mark svg { display: block; width: 100%; height: 100%; }

/* Chat keeps primary controls compact and secondary actions in the panel menu. */
.tui-user { min-height: 40px; justify-content: center; }
.tui-user-prompt { align-items: center; }
.tui-user > .prompt-image-list:empty { display: none; }
.phone-layout .tui-user { min-height: 52px; }
.tui-pane { container-type: inline-size; }
.tui-statusline { white-space: nowrap; flex-wrap: nowrap; min-height: 30px; gap: 8px; overflow: hidden; }
.tui-statusline .tui-sep { display: none; }
.tui-statusline .btn { min-height: 24px; }
.tui-statusline > span { flex: none; }
.tui-statusline .tui-model-picker { flex: 1; min-width: 40px; max-width: 160px; }
.tui-statusline .tui-model-name { min-width: 0; width: 100%; }
.prompt-attachments { padding: 0; border: none; }

.tui-composer-actions > .btn.ui-icon { width: 44px; padding: 0; display: inline-flex; justify-content: center; align-items: center; }
@container (max-width: 600px) { .tui-statusline .tui-workspace-mode, .tui-statusline .tui-tools-count, .tui-statusline .tui-run-state { display: none; } }
@container (max-width: 420px) { .tui-statusline .tui-speed { display: none; } }

.phone-layout .tui-statusline { flex-wrap: nowrap; }

.phone-layout .tui-statusline .btn { min-height: 44px; }

/* Quiet inline fallback for pointer, keyboard and touch context menus. */
.tree-entry-menu { margin-left: auto; flex: none; }
.tree-entry-menu > .ui-dropdown-trigger { opacity: 0; }
.tree-item:hover .tree-entry-menu > .ui-dropdown-trigger,
.tree-item:focus-within .tree-entry-menu > .ui-dropdown-trigger,
.tree-entry-menu > .ui-dropdown-trigger[aria-expanded="true"] { opacity: 1; }
.tree-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (hover: none) {
  .tree-entry-menu > .ui-dropdown-trigger:not(.sr-only) { opacity: 1; min-width: 44px; min-height: 44px; }
}
.ui-action-menu-context { display: contents; }

.editor-pdf-preview { width: 100%; height: 100%; min-height: 200px; border: 0; background: var(--bg-panel); }

.editor-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 12px; border-top: 1px solid var(--border); background: var(--bg-panel); }
.editor-indentation-options { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.editor-rules-source { margin-left: auto; font-size: 11px; color: var(--text-muted); }

/* Fold controls share the editor's native scroll source and logical-row height. */
.editor-fold-column { position: absolute; left: 0; top: 12px; bottom: 0; width: 18px; z-index: 3; overflow: hidden; }
.editor-fold-track { transform: translateY(var(--editor-scroll-y, 0px)); }
.editor-fold-row { height: var(--editor-row-height, 19.5px); }
.editor-fold-control { width: 18px; height: 19.5px; min-width: 0; min-height: 0; padding: 0; border: 0; color: var(--text-muted); }
.editor-fold-control:hover, .editor-fold-control:focus-visible { color: var(--accent); background: var(--bg-hover); }

.editor-source-line.editor-active-line { background: var(--bg-hover); }
.editor-bracket-layer { position:absolute; inset:0; z-index:1; overflow:hidden; pointer-events:none; }
.editor-selection-layer { position:absolute; inset:0; z-index:1; overflow:hidden; pointer-events:none; clip-path:inset(0 0 0 var(--editor-gutter-width, 40px)); }
.editor-primary-selection, .editor-secondary-selection { position:absolute; background:color-mix(in srgb, var(--accent) 30%, transparent); }
.editor-primary-caret, .editor-secondary-caret { position:absolute; background:var(--accent); }
.editor-primary-caret { background:var(--text); animation:editor-caret-blink 1s steps(1) infinite; }
.editor-code:not(:focus-within) .editor-primary-caret { visibility:hidden; }
@keyframes editor-caret-blink { 50% { opacity:0; } }
@media (prefers-reduced-motion:reduce) { .editor-primary-caret { animation:none; } }
.editor-bracket-match { position:absolute; border:1px solid var(--accent); border-radius:2px; transform:translate(var(--editor-scroll-x, 0px), var(--editor-scroll-y, 0px)); }

.editor-source-line::after { content:""; position:absolute; left:0; top:0; bottom:0; width:calc(var(--editor-indent-columns, 0) * 1ch); pointer-events:none; background:repeating-linear-gradient(to right,var(--border) 0,var(--border) 1px,transparent 1px,transparent calc(var(--editor-indent-step, 4) * 1ch)); }

.editor-find-options, .editor-replace { flex: none; flex-wrap: wrap; }
.editor-find-options .ui-check { white-space: nowrap; }
.editor-replace .panel-search-input { min-width: 8ch; }

.editor-word-wrap .editor-textarea { white-space: pre-wrap; overflow-wrap: anywhere; }
.editor-word-wrap .editor-highlight { white-space: pre-wrap; overflow-wrap: anywhere; }
.editor-word-wrap .editor-highlight-content { width: calc(var(--editor-text-width, 100%) + var(--editor-gutter-width, 40px)); min-width: 0; }
.editor-space, .editor-tab, .editor-line-ending { position: relative; }
.editor-space::before, .editor-tab::before, .editor-line-ending::before { position: absolute; left: 0; top: 0; color: var(--text-muted); pointer-events: none; }
.editor-space::before { content: "·"; }
.editor-tab::before { content: "→"; }
.editor-line-ending::before { content: "↵"; }
.ui-check:has(input:disabled) { opacity: .45; cursor: default; }

/* File tabs share project tab selection and standard inline icon actions. */
/* Reserve room for classic horizontal scrollbars as well as overlay ones.
   A flex strip's intrinsic height otherwise excludes the native scroll track.
   Include its shared one-pixel bottom border in the reserved space. */
.editor-file-tabs { --editor-tab-height: 35px; flex: none; padding: 0 8px; height: calc(var(--editor-tab-height) + 11px); min-height: calc(var(--editor-tab-height) + 11px); }
.phone-layout .editor-file-tabs { --editor-tab-height: calc(var(--control-height) + 1px); }
.editor-file-tab { flex: none; height: var(--editor-tab-height); gap: 2px; padding: 0 4px 0 0; }
.btn.tab-select { display: flex; align-items: center; gap: 6px; min-width: 0; align-self: stretch; padding: 0 10px; border: 0; border-radius: 6px 0 0 0; background: transparent; color: inherit; }
.tab-select .tab-name { max-width: 24ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-tab-dirty { flex: none; width: 1em; text-align: center; visibility: hidden; font-size: 9px; color: var(--warn); }
.editor-tab-dirty.is-dirty { visibility: visible; }

/* Shared bounded text viewer for files outside interactive editor limits. */
.editor-large-file-page {
  font-family: var(--mono);
  color: var(--text);
  background: var(--bg-panel);
  white-space: pre;
  margin: 12px 0 0;
  padding: 12px;
}

/* Keep native caret layout, paint, gutters, and diffs on identical font features. */
.editor-code, .editor-scroll-surface, .editor-textarea, .editor-highlight,
.editor-diff, .editor-content-view, .editor-document-preview, .editor-large-file-page {
  font-family: var(--editor-font);
  font-feature-settings: var(--editor-font-features);
  font-variant-ligatures: var(--editor-font-ligatures);
}
.editor-code { font-size: 13px; }

/* Shared About content is also bundled as a standalone offline page. */
.about-content { color: var(--text); line-height: 1.5; overflow-wrap: anywhere; }
.about-content h2, .about-content h3 { margin: var(--space-6) 0 var(--space-3); }
.about-content a { color: var(--accent); }
.about-content code, .about-content pre { font-family: var(--mono); }
.about-build { margin: 0; }
.about-build div { display: grid; grid-template-columns: 5rem minmax(0, 1fr); gap: var(--space-2); }
.about-build dt { color: var(--text-muted); }
.about-build dd { margin: 0; }
.about-package { border-top: 1px solid var(--border); padding: var(--space-3) 0; }
.about-package summary { cursor: pointer; }
.about-package summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.about-package pre { white-space: pre-wrap; font-size: var(--font-caption); background: var(--bg-panel); padding: var(--space-3); }
.about-document { height: auto; min-height: 100%; overflow: auto; }
.about-page { height: auto; min-height: 100vh; overflow: auto; background: var(--bg); color: var(--text); }
.about-page main { max-width: var(--dialog-wide); margin: 0 auto; padding: var(--space-6); }
.about-tabs { margin: var(--space-3) var(--space-6) 0; flex-shrink: 0; }
.about-tabs .ui-seg-btn { font-family: inherit; white-space: normal; }
.about-page .about-tabs { margin: var(--space-4) 0; }
.about-content[hidden] { display: none; }

.about-modal { height: min(440px, var(--dialog-available-height)); }
.about-modal .about-body { padding: 0; overflow: hidden; flex: 1; }
.about-modal .about-content { padding: var(--space-6); min-height: 0; flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.about-modal .about-overview { display: flex; align-items: safe center; justify-content: safe center; text-align: center; }
.logo-mark.about-logo { width: 64px; height: 64px; margin-bottom: var(--space-3); }
.about-overview > div { min-width: 0; max-width: 100%; }
.about-overview .about-build div { display: flex; justify-content: center; flex-wrap: wrap; gap: 0 var(--space-2); margin-bottom: var(--space-2); }
.about-modal .modal-header, .about-modal .modal-footer { flex-shrink: 0; }

.slash-suggestions { max-height: 15rem; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-panel); margin: var(--space-2) var(--space-3); }
.slash-suggestions .ui-dropdown-item {
  display: flex; flex-wrap: wrap; gap: var(--space-2); width: 100%;
  padding: var(--space-2); text-align: start; background: transparent;
  color: var(--text); border: 1px solid transparent; cursor: pointer;
}
.slash-suggestions .ui-dropdown-item:is(.active, :hover) { background: var(--bg-hover); }
.slash-suggestions .ui-dropdown-item.active { border-color: var(--accent); }
.slash-suggestions .ui-dropdown-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.slash-suggestions .ui-dropdown-item code { color: var(--accent); }
.slash-hint { margin: var(--space-2) var(--space-3); overflow-wrap: anywhere; }

.tui-goal { margin: var(--space-2) var(--space-3); padding: var(--space-3); border: 1px solid var(--border); border-radius: 6px; overflow-wrap: anywhere; }
.tui-goal p { margin: var(--space-2) 0; }

/* On-demand controls share the same pane structure in local and remote projects. */
.tool-panel-heading[hidden], #project-search[hidden], .terminal-input-bar[hidden] { display: none; }
.files-panel > .search-pane { flex: 1; width: 100%; overflow: hidden; }
.search-file-views > .files-view { width: 100%; }
.panel-tab > .ui-icon-glyph { display: none; }
.tui-context-percent { flex: none; }
.tui-ctx-gauge { flex: none; font: inherit; white-space: nowrap; }
.tui-model-name .ui-dropdown-label { min-width: 0; overflow: hidden; }
.tui-model-name .ui-dropdown-label > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@container (max-width: 420px) { .tui-context-detail { display: none; } }
.phone-layout .tui-context-detail, .phone-layout .tui-speed, .phone-layout .tui-workspace-mode, .phone-layout .tui-tools-count, .phone-layout .tui-run-state { display: none; }
.phone-layout .panel-rail { order: 254; gap: 0; padding: 2px 0 max(2px, env(safe-area-inset-bottom)); overflow: visible; border-top: 1px solid var(--border); background: var(--bg-panel); }
.phone-layout .panel-tab-group { flex: 1; min-width: 0; }
.phone-layout .panel-tab { width: 100%; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 4px 2px; font-size: var(--font-caption); }
.phone-layout .panel-tab > .ui-icon-glyph { display: inline-flex; }
.phone-layout #panel-terminal.tool-panel { position: absolute; z-index: 30; inset: auto 0 0; height: min(65%, 480px); max-height: calc(100% - 44px); box-shadow: 0 -4px 16px var(--border); }
.phone-layout .app-body { position: relative; }

/* One app row; the phone drawer uses the shared modal focus and Escape policy. */
.app-navigation { gap: var(--space-2); min-height: 44px; height: auto; flex-wrap: nowrap; }
.app-navigation > .tabbar-wrap { flex: 1; min-width: 0; }
.app-navigation .tabbar-wrap, .app-navigation .tabbar { height: auto; min-height: 40px; border: 0; }
.app-navigation .tabbar { overflow-x: auto; }
.app-navigation .tabbar .tab { flex: none; max-width: 220px; }
.app-navigation .tab-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.app-navigation .tab-mode, .app-navigation .tab-close { flex: none; }
.app-navigation .logo { font-size: var(--font-control); padding: 4px; }
.app-navigation .logo-mark { width: 28px; height: 28px; }
.app-navigation .logo .ui-dropdown-label { display: inline-flex; align-items: center; gap: var(--space-2); }
.omnibar-trigger { position: relative; flex: 0 1 360px; min-width: 160px; color: var(--text-muted); }
.omnibar-field { box-sizing: border-box; width: 100%; gap: var(--space-2); padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg); }
.omnibar-field:focus-within { border-color: var(--accent); }
.omnibar-field .command-search { flex: 1; width: 0; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: var(--font-control); }
.omnibar-trigger kbd { flex: none; font-size: var(--font-caption); white-space: nowrap; }
.omnibar-panel { position: fixed; z-index: 151; display: flex; flex-direction: column; box-sizing: border-box; padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-panel); color: var(--text); box-shadow: 0 8px 24px rgba(0,0,0,.4); overflow: hidden; }
.omnibar-panel .command-results { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.app-navigation > .chat-tab { flex: none; }

.app-menu-heading, .ui-menu-heading { font-size: var(--font-caption); color: var(--text-muted); padding: var(--space-2); margin: 0; }
.app-menu .ui-dropdown-menu { min-width: 280px; max-height: calc(100dvh - 64px); overflow-y: auto; }
.app-menu-items { display: flex; flex-direction: column; }
.app-menu-items .recent-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-project-row { display: flex; align-items: center; min-width: 0; }
.recent-project-row > .recent-item { flex: 1; min-width: 0; }
.app-configuration [hidden] { display: none; }
.modal-overlay:has(> .app-drawer) { align-items: stretch; justify-content: flex-start; padding: 0; }
.phone-layout .app-navigation .brand-name, .phone-layout .app-navigation > .tabbar-wrap, .phone-layout .omnibar-trigger kbd { display: none; }
.phone-layout .app-navigation .omnibar-trigger { flex: 1; min-width: 0; }
.phone-layout .app-navigation .topbar-account { margin-left: auto; }
.phone-layout .app-drawer { width: min(340px, calc(100vw - 32px)); max-width: none; height: var(--visible-height, 100dvh); max-height: var(--visible-height, 100dvh); border-radius: 0; margin: 0; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); box-sizing: border-box; }
@media (max-width: 1100px) { .app-navigation .brand-name, .omnibar-trigger kbd { display: none; } }

.omnibar-entry { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.omnibar-entry-label, .omnibar-entry-detail { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.omnibar-entry-kind { flex: none; font-size: var(--font-caption); color: var(--text-muted); }
.omnibar .command-results { max-height: min(55dvh, 500px); overflow-y: auto; }
.omnibar .command-option { gap: var(--space-2); min-height: 44px; }
.phone-layout .omnibar .command-option kbd { display: none; }

.phone-layout .app-menu-items .recent-item { min-height: 44px; }

/* Compact panes share one tab/action row and the app footer. */
.editor-header { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-height: calc(var(--control-height) + 2 * var(--space-2)); padding: var(--space-2) var(--space-3); }
.editor-header .editor-file-tabs { flex: 1 1 120px; min-width: 0; border: 0; padding: 0; order: 1; }
.editor-header-actions { display: contents; }
.editor-header .editor-view-selector { order: 2; }
.editor-header [aria-label="Save file (Ctrl/⌘S)"] { order: 3; }
.editor-header [aria-label="Find in file (Ctrl/⌘F)"] { order: 4; }
.editor-header .ui-action-menu, .editor-header .ui-action-menu-context { order: 5; }
.editor-header .changes-display { order: 2; }
.editor-header .changes-baseline { order: 2; font-size: var(--font-caption); color: var(--text-muted); }
/* Background language feedback must not move the source during a pointer gesture. */
.editor-header .editor-language-feedback {
  order: 7;
  flex: 0 0 100%;
  min-width: 0;
  height: 1.4em;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Reserve the full three-choice width even when this file has no preview.
   Labels and availability must not resize the neighboring file tab strip. */
.editor-view-selector { flex: none; }
.editor-view-desktop { font: 500 11px var(--mono); inline-size: calc(14ch + 70px); }
.editor-view-selector .ui-seg-btn, .files-panel-toolbar .ui-seg-btn { white-space: nowrap; }
.files-panel-toolbar .ui-seg-btn { padding-inline: var(--space-1); }
.editor-view-narrow { display: none; inline-size: 112px; }
.editor-view-narrow .ui-dropdown-trigger { width: 100%; box-sizing: border-box; }
.editor-view-narrow .ui-dropdown-label { flex: 1; text-align: left; }
.status-editor-slot, .status-editor-slot > div { display: contents; }
.statusbar .editor-footer { border: 0; padding: 0; background: transparent; flex-wrap: nowrap; }
.statusbar { height: auto; min-height: 36px; flex-wrap: wrap; gap: var(--space-2); }
.editor-footer .ui-dropdown-menu { min-width: 280px; }
.editor-footer .editor-indentation-options { flex-wrap: wrap; padding: var(--space-2); }
.editor-footer .editor-rules-source { display: block; padding: var(--space-2); }
.compact-tree .tree-item { min-height: 24px; padding-block: 2px; }
.tab.active, .btn.chat-tab.active, .ui-seg-btn.active, .panel-tab.is-open { color: var(--accent); background: var(--bg-hover); }
.tab-select:focus-visible, .ui-seg-btn:focus-visible, .panel-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (max-width: 900px) {
    .editor-view-desktop { display: none; }
    .editor-view-narrow { display: block; }
}
.phone-layout .editor-view-desktop { display: none; }
.phone-layout .editor-view-narrow { display: block; }
.phone-layout .editor-header .btn, .phone-layout .editor-header .icon-btn { min-height: 44px; }
.phone-layout .statusbar { padding-bottom: max(var(--space-2), env(safe-area-inset-bottom)); }

.tree-line-stats { margin-left: auto; flex: none; display: flex; gap: var(--space-1); font-family: var(--mono); font-size: var(--font-caption); }
.tree-line-stats + .ui-action-menu-context .tree-entry-menu { margin-left: 0; }
.tree-icon.git-badge-modified { color: var(--git-modified); }
.tree-icon.git-badge-added, .tree-icon.git-badge-untracked { color: var(--online); }
.tree-icon.git-badge-deleted { color: var(--offline); }
.tree-icon.git-badge-renamed { color: var(--accent); }
.tree-icon.git-badge-conflict { color: var(--warn); }

.phone-layout .statusbar button { min-height: 44px; }
.tree-line-stats .git-insertions { color: var(--online); }
.tree-line-stats .git-deletions { color: var(--offline); }

.files-panel-toolbar { min-height: calc(var(--control-height) + 2 * var(--space-2)); }

/* Compact goal status opens the shared context-panel surface. */
.tui-statusline .tui-goal-status { flex: none; margin-left: auto; min-width: 0; }
.tui-goal-status .tui-goal-label { font: inherit; padding: 2px 4px; color: var(--accent); }
.tui-goal-menu { white-space: normal; overflow-y: auto; }
.tui-goal-menu .tui-goal { margin: 0; padding: var(--space-3); border: 0; }
.approval-mode-picker .approval-mode-manual, .approval-mode-menu .approval-mode-manual { color: var(--online); }
.approval-mode-picker .approval-mode-edits, .approval-mode-menu .approval-mode-edits { color: var(--accent); }
.approval-mode-picker .approval-mode-auto, .approval-mode-menu .approval-mode-auto,
.approval-mode-picker .approval-mode-always, .approval-mode-menu .approval-mode-always { color: var(--warn); }
.approval-mode-picker .approval-mode-yolo, .approval-mode-menu .approval-mode-yolo { color: var(--offline); }

@container (max-width: 600px) {
  .tui-statusline:has(.tui-goal-status, .tui-monitor-status) .tui-context-detail { display: none; }
  .tui-statusline:has(.tui-goal-status, .tui-monitor-status) .tui-model-picker { min-width: 0; }
  .tui-statusline:has(.tui-goal-status, .tui-monitor-status) .approval-mode-picker .ui-dropdown-label { max-width: 88px; overflow: hidden; text-overflow: ellipsis; }
}

/* Project memories share the Sessions sidebar and standard form controls. */
.project-memories, .project-skills { border-top: 1px solid var(--border); padding-top: var(--space-3); }
.project-memories .section-header h2, .project-skills .section-header h2 { margin: 0; }
.project-memories .ui-check, .project-skills .ui-check { align-items: center; color: var(--text-muted); font-size: var(--font-control); }
.memory-editor { display: grid; gap: var(--space-2); margin: var(--space-2) 0; }
.memory-editor .form-input { width: 100%; min-width: 0; box-sizing: border-box; }
.memory-entry { margin-top: var(--space-2); }
.memory-title { min-width: 0; overflow-wrap: anywhere; }
.memory-entry .ui-disclosure-content { padding: var(--space-2); }
.memory-content { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; color: var(--text-muted); }

.task-schedule { display: flex; width: 100%; }
.task-schedule .ui-seg-btn { flex: 1; justify-content: center; padding-inline: var(--space-1); white-space: nowrap; }
.task-weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); margin-block: var(--space-2); }
.task-weekdays .ui-check { display: flex; flex-direction: column; gap: var(--space-1); align-items: center; cursor: pointer; }
.phone-layout .task-weekdays .ui-check { min-height: 44px; justify-content: center; }

.chat-recap { margin: 0 0 12px; color: var(--text-muted); }
.chat-recap summary { cursor: pointer; }
.chat-followups, .chat-context-suggestions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chat-followups .btn { justify-content: flex-start; background: transparent; font-family: var(--mono); text-align: left; max-width: 100%; }
.chat-followups .btn:hover:not(:disabled) { background: var(--bg-hover); }
.chat-followups .btn > span:last-child { min-width: 0; overflow-wrap: anywhere; }

.git-draft-actions { padding: 6px 12px; border-bottom: 1px solid var(--border); }

.session-search-result { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.session-search-result .form-hint { white-space: normal; margin: 0; }

.cron-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 7rem), 1fr));
    gap: var(--space-2);
}
.cron-fields .form-input, .cron-preview { font-family: var(--mono); }
.cron-preview { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-muted); }

/* Chat detail dialogs reuse the context visualization and modal layout. */
.generation-rate { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); }
.generation-rate > span:first-child { font-family: var(--mono); font-size: 24px; color: var(--accent); }
.generation-chart { display: grid; gap: var(--space-2); }
.generation-chart-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) 72px; align-items: center; gap: var(--space-2); font-family: var(--mono); font-size: var(--font-caption); }
.generation-chart-row > span:last-child { text-align: right; }
.generation-chart-track { height: 12px; overflow: hidden; border-radius: 3px; background: var(--bg-hover); }
.generation-chart-track > span { display: block; height: 100%; background: var(--accent); }
.tui-statusline .tui-speed { flex: none; font: inherit; padding: 2px 4px; color: var(--accent); }

.generation-statistics { gap: var(--space-3); }
.generation-statistics > * { margin: 0; flex-shrink: 0; }

.ui-dialog-tabs { margin: var(--space-3) var(--space-6) 0; flex: none; align-self: stretch; width: auto; }
.ui-dialog-tabs .ui-seg-btn { flex: 1; justify-content: center; font-family: inherit; font-size: var(--font-control); min-height: var(--control-height); }
.ui-tabbed-modal { block-size: min(700px, 90dvh); }
.ui-tabbed-body { flex: 1; }
@media (max-width: 560px) {
    .ui-tabbed-modal .ui-dialog-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-inline: var(--space-3); }
    .ui-tabbed-modal .ui-dialog-tabs .ui-seg-btn { min-width: 0; min-height: 44px; padding-inline: var(--space-1); }
    .plugins-dialog .ui-dialog-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.ui-tab-panel { display: grid; gap: var(--space-6); align-content: start; min-width: 0; }
.ui-tab-panel[hidden] { display: none; }
@media (max-width: 799px) {
  .ui-dialog-tabs { margin-inline: var(--space-4); }
}
.phone-layout .ui-dialog-tabs { margin-inline: var(--space-4); }

.settings-host { gap: var(--space-3); }
.settings-disclosure > .ui-disclosure-toggle {
    flex-wrap: nowrap;
    gap: var(--space-3);
    min-height: 44px;
    padding: var(--space-3);
}
.settings-disclosure-label { display: grid; gap: var(--space-1); min-width: 0; }
.settings-disclosure-label strong { color: var(--text); font-size: var(--font-section); }
.settings-disclosure > .ui-disclosure-content { padding: var(--space-3); }
.settings-host .settings-disclosure > .ui-disclosure-content > .ui-section > .ui-section-heading > h3 { display: none; }
.settings-disclosure .ui-section > .ui-section-heading p { margin-block-start: 0; }
.settings-disclosure .ui-section + .ui-section { margin-block-start: var(--space-4); }
.plugins-dialog .ui-section-content > .form-hint { overflow-wrap: anywhere; }

.ui-tab-panel > dl { margin: 0; }
.keyboard-shortcuts > .form-hint, .keyboard-shortcuts .ui-tab-panel > .form-hint { margin: 0; }
.keyboard-shortcuts .shortcut-row { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(0, 2fr); gap: var(--space-4); padding-block: var(--space-2); margin: 0; border-bottom: 1px solid var(--border); }
.keyboard-shortcuts .shortcut-row:last-child { border: 0; }
.keyboard-shortcuts .shortcut-row dt { min-width: 0; }
.keyboard-shortcuts .shortcut-row kbd { overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .keyboard-shortcuts .shortcut-row { grid-template-columns: minmax(0, 1fr); gap: var(--space-1); }
}

.editor-header .panel-minimize { order: 6; flex: none; margin-inline-start: auto; }

/* Host administration uses the shared form/button system and theme tokens. */
.host-panel { border-bottom: 1px solid var(--border); padding: 8px 12px; background: var(--bg-panel); max-height: 45vh; overflow: auto; flex-shrink: 0; }
.host-resources { min-width: 0; }
.host-resource, .host-operation { border-top: 1px solid var(--border); padding: 6px 0; }
.host-resource summary, .host-operation summary { cursor: pointer; color: var(--text); }
.host-panel pre { font-family: var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-muted); }
.host-output { background: var(--bg); padding: 8px; }

.agent-questions { border: 1px solid var(--border); background: var(--bg-panel); padding: .75rem; max-height: 55vh; overflow: auto; }
.agent-question-form { display: grid; gap: .5rem; min-width: 0; }
.agent-question-form fieldset { min-width: 0; }
.agent-question-option { display: flex; gap: .5rem; align-items: start; color: var(--text); overflow-wrap: anywhere; }
.agent-question-option small { display: block; }
.agent-question-form textarea { width: 100%; box-sizing: border-box; }
/* Shared Git history panel: refs, topology and commit inspection. */
.git-history-toolbar { gap:4px; flex-wrap:nowrap; }
.git-history-search { flex:1; min-width:0; }
#panel-history .tool-panel-content > .git-history { width:100%; overflow:hidden; }
.git-working-tree { display:contents; }
.git-pane-tabs .active,.git-ref.active { color:var(--accent);background:var(--bg-hover); }
.git-history { flex:1;min-height:0;display:flex;flex-direction:column;--git-lane-0:var(--accent);--git-lane-1:var(--online);--git-lane-2:var(--warn);--git-lane-3:var(--git-modified);--git-lane-4:var(--offline);--git-lane-5:var(--text-muted); }
.git-history-search input { flex:1;min-width:50px; }
.git-history-body { display:flex;flex:1;min-height:0; }
.git-ref { display:block;text-align:left;width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap; }
.git-history-main { flex:1;min-width:0;min-height:0;display:flex;flex-direction:column; }
.git-history-list { overflow:auto;min-height:100px;flex:1;border-bottom:1px solid var(--border); }
.git-history-row { display:flex;align-items:center;gap:10px;width:100%;text-align:left;border-radius:0;height:32px;white-space:nowrap;border-bottom:1px solid var(--border); }
.git-history-row.selected { background:var(--bg-hover);color:var(--accent); }
.git-graph { flex-shrink:0; }
.git-commit-subject { flex:1;min-width:0;display:flex;flex-direction:column;gap:1px;overflow:hidden;line-height:13px; }
.git-commit-title,.git-history-row .git-commit-refs { overflow:hidden;text-overflow:ellipsis; }
.git-history-row code { flex-shrink:0; }
.git-commit-refs { color:var(--online);font-size:10px;margin-right:8px; }
.git-commit-author,.git-history-row time { color:var(--text-muted);font-size:11px; }
.git-history-row code,.git-commit-details code { font-family:var(--mono);font-size:11px; }
.git-commit-details { flex:1;overflow:auto;padding:12px;min-height:120px; }
.git-commit-details h3 { margin:0 0 8px;font-size:14px; }
.git-commit-details p { font-size:11px;overflow-wrap:anywhere; }
.git-commit-message { white-space:pre-wrap;font-family:var(--mono);font-size:12px; }
.git-parent-links { display:flex;flex-wrap:wrap;align-items:center;gap:4px;color:var(--text-muted);font-size:11px; }
.git-commit-file { display:flex;justify-content:space-between;gap:4px; }
.git-commit-file .btn:first-child { text-align:left;min-width:0;overflow-wrap:anywhere; }
.git-commit-file code { margin-right:8px;color:var(--accent); }
.git-history-diff { font:11px/1.6 var(--mono);overflow:auto;background:var(--bg-panel);padding:8px; }
.git-diff-added { color:var(--online); }.git-diff-deleted { color:var(--offline); }
.git-history-empty { padding:24px;text-align:center;color:var(--text-muted);font-size:12px; }
.git-history-error { color:var(--offline);padding:12px;overflow-wrap:anywhere; }
.git-history-more { margin:8px; }
.git-sync-toolbar,.git-history-heading,.git-history-ref-actions,.git-diff-filter { display:flex;align-items:center;gap:6px;padding:6px 8px;flex-wrap:wrap; }
.git-history-heading { justify-content:space-between;color:var(--text-muted);font-size:12px; }
.git-sync-result { font-size:11px;padding:8px;color:var(--text-muted); }
.git-sync-result pre { white-space:pre-wrap;overflow-wrap:anywhere; }
.git-diff-filter { justify-content:space-between;font-size:11px;color:var(--text-muted); }
.git-history-row { padding-top:0;padding-bottom:0; }
.git-commit-form { padding:8px;display:flex;flex-direction:column;gap:8px; }
.git-commit-heading { display:flex;align-items:center;justify-content:space-between;gap:8px; }
.git-history-limit { font-size:11px;color:var(--warn); }


.git-parent-links .active { color:var(--accent);background:var(--bg-hover); }
.git-history-row { gap:6px; }



.git-change-heading { display:flex;align-items:center;gap:6px; }
.git-change-heading > span { flex:1;min-width:0; }
.git-change-file,.git-stash-row { display:flex;align-items:center;min-width:0;gap:4px; }
.git-change-file > :first-child { flex:1;min-width:0; }
.git-stash-row > span { flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap; }
.git-stash-row,.git-changes .form-hint { padding:4px 8px; }

.git-history { container-type:inline-size; overflow:hidden; }
.git-history-reference { flex-shrink:0; padding:4px 8px; border-bottom:1px solid var(--border); }
.git-history-reference .ui-dropdown { min-width:0; flex:1; }
.git-history-reference .ui-dropdown-trigger { max-width:100%; }
.git-history-reference .ui-dropdown-trigger span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.git-history-main { width:100%; }
.git-history-list { flex: 0 1 auto; min-height: 0; max-height: 40%; }
.git-history-list > .ui-feedback-overlay { position: sticky; inset: auto; min-width: 0; width: auto; margin: var(--space-2); }
.git-history-row { padding:0 8px; }
.git-commit-details { flex:1 1 66%; padding:0; display:flex; flex-direction:column; overflow:hidden; min-height:160px; }
.git-inspector-heading { display:flex; align-items:center; gap:8px; padding:8px; font-size:12px; }
.git-inspector-heading strong { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.git-commit-metadata { padding:0 8px 6px; font-size:11px; color:var(--text-muted); max-height:30%; overflow:auto; }
.git-commit-metadata summary { cursor:pointer; }
.git-commit-inspector { display:flex; flex:1; min-height:0; border-top:1px solid var(--border); }
.git-commit-files { width:28%; min-width:140px; max-width:280px; overflow:auto; border-right:1px solid var(--border); padding:4px; }
.git-history-folder summary { display:flex; align-items:center; gap:4px; padding:4px; cursor:pointer; font-size:11px; }
.git-history-folder > div { padding-left:10px; }
.git-commit-file { align-items:center; }
.git-commit-file > button:first-child { display:flex; align-items:center; gap:4px; flex:1; white-space:nowrap; padding:4px; }
.git-commit-file > button:first-child span { overflow:hidden; text-overflow:ellipsis; }
.git-commit-file .selected { color:var(--accent); background:var(--bg-hover); }
.git-commit-file .icon-btn { flex-shrink:0; }
.git-readonly-diff { flex:1; min-width:0; min-height:0; display:flex; flex-direction:column; overflow:hidden; }
.git-readonly-diff .editor-diff { flex:1; min-height:0; font:12px/1.5 var(--mono); overflow:auto; }
.git-readonly-diff .git-diff-filter { flex-shrink:0; overflow-wrap:anywhere; border-bottom:1px solid var(--border); }
.git-file-history-modal { width:min(1200px,calc(100vw - 32px)); height:min(850px,calc(100dvh - 32px)); max-width:none; }
.git-file-history-modal .git-history { min-height:0; }
.git-file-timeline { display:flex; overflow:auto; flex-shrink:0; padding:8px; gap:2px; border-bottom:1px solid var(--border); }
.git-file-timeline button { display:flex; flex-direction:column; gap:4px; font-size:10px; white-space:nowrap; }
.git-timeline-dot { border-radius:50%; background:var(--accent); width:6px; height:6px; }
.git-file-timeline [aria-pressed=true] { background:var(--bg-hover); color:var(--accent); }
@container (max-width:426px) {
    .git-commit-inspector { flex-direction:column; }
    .git-commit-files { width:100%; max-width:none; min-width:0; max-height:26%; flex-shrink:0; border-right:0; border-bottom:1px solid var(--border); }
    .git-commit-author,.git-history-row time { display:none; }
}
@media(max-width:600px) { .git-file-history-modal { width:calc(100vw - 12px); height:calc(100dvh - 12px); } }

.git-history-folder:not([open]) > summary .git-folder-chevron { transform:rotate(-90deg); }
.git-folder-chevron { display:inline-flex; }
.git-file-timeline button { position:relative; }
.git-file-timeline button::before { content:""; position:absolute; top:13px; left:0; right:0; border-top:1px solid var(--border); }
.git-timeline-dot { position:relative; z-index:1; }

.ui-progress-slot { width: var(--control-height); height: var(--control-height); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ui-progress-slot .ui-loading-status > span:not(.ui-spinner) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.ui-feedback-overlay { position: absolute; z-index: 20; inset-inline-end: var(--space-3); top: var(--control-height); width: max-content; min-width: min(20rem, calc(100vw - 2 * var(--dialog-gutter))); max-width: min(40rem, calc(100vw - 2 * var(--dialog-gutter))); max-height: 50vh; overflow-wrap: anywhere; overflow: auto; padding: var(--space-3); background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius-md); }
.git-pane, .git-commit-form, .git-changes, .git-draft-actions { position: relative; }
.git-commit-heading > .ui-actions, .file-tree-header > .ui-actions { margin-inline-start: auto; }
.git-draft-actions { display: inline-flex; }
.git-pane-toolbar { flex-wrap: nowrap; }
.git-pane-toolbar > .branch-picker { flex: 1; min-width: 0; }
.git-pane-toolbar .git-branch-select { width: 100%; }
.git-pane-toolbar .git-branch-select .ui-dropdown-label { flex: 1; min-width: 0; text-align: start; }
.git-pane-toolbar .git-branch-select .ui-dropdown-label > span {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.git-pane-toolbar > .ui-actions, .git-commit-heading > .ui-actions { flex-wrap: nowrap; }
.git-commit-heading > .form-label, .git-commit-submit { white-space: nowrap; }
.git-commit-submit { align-self: start; }


.git-readonly-diff .diff-line:not(:has([data-line])):has(.editor-line-number:empty + .editor-line-number:empty) { border-top: 1px solid var(--border); color: var(--text-muted); background: var(--bg-panel); }
.panel-inline-inset { padding: var(--space-2) var(--space-3); }
.panel-search-row.panel-search-unpadded { padding: 0; }
.git-history-row { padding-inline: var(--space-3); }
.git-history-reference.panel-inline-inset { padding: var(--space-2) var(--space-3); }
.git-commit-files { flex: none; width: min(var(--history-tree-width), calc(100% - 266px)); min-width: 160px; max-width: 650px; padding: 0; border-inline-end: 0; }
.git-history-folder > div { padding-inline-start: var(--control-height); }
.git-history-folder > summary.tree-item, .git-commit-file > button.tree-item { justify-content: flex-start; text-align: start; overflow: hidden; padding: var(--space-1) var(--space-2); min-height: var(--control-height); }
.tree-name { min-width: 0; white-space: nowrap; flex: 1; }
.tree-icon { display: inline-flex; width: 20px; flex: none; }
.git-commit-file > .icon-btn { width: var(--control-height); flex: none; }
.git-commit-inspector > .panel-resizer { position: relative; flex: 0 0 6px; margin: 0; inset: auto; }
.modal.modal-available { width: 100%; --dialog-width: 100%; }
.modal-available.git-file-history-modal { height: var(--dialog-available-height); }
@container (max-width: 426px) {
    .git-commit-inspector { flex-direction: column; }
    .git-commit-files { width: 100%; min-width: 0; max-width: none; }
    .git-commit-inspector > .panel-resizer { display: none; }
}
.git-file-timeline { display: flex; flex-direction: column; overflow: visible; padding: var(--space-3); container-type: inline-size; }
.git-timeline-axis { height: calc(2 * var(--control-height)); position: relative; margin-inline: var(--space-4); border-top: 1px solid var(--border); }
.git-timeline-tick { position: absolute; top: var(--control-height); transform: translateX(-50%); color: var(--text-muted); font-size: var(--font-caption); white-space: nowrap; }
.git-timeline-cluster { position: absolute; top: 0; transform: translateX(-50%); }
.git-timeline-cluster > summary { min-height: var(--control-height); min-width: var(--control-height); display: flex; gap: var(--space-1); align-items: center; justify-content: center; cursor: pointer; }
.git-timeline-cluster .ui-feedback-overlay { position: absolute; top: var(--control-height); min-width: min(18rem, calc(50cqw - var(--space-4))); max-width: min(30rem, calc(50cqw - var(--space-4))); inset-inline-end: 0; }
.git-timeline-cluster[data-align=start] .ui-feedback-overlay { inset-inline-start: 0; inset-inline-end: auto; }
.git-timeline-cluster .ui-feedback-overlay .btn { width: 100%; white-space: normal; text-align: start; }
.git-timeline-cluster .btn::before { display: none; }
.git-readonly-diff, .git-history-list { position: relative; }
.git-history-applied-filter { flex: none; color: var(--text-muted); font-size: var(--font-caption); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn.tree-item, .modal .btn.tree-item { justify-content: flex-start; padding: var(--space-1) var(--space-2); }
.tree-item.tree-row-depth, .modal .btn.tree-item.tree-row-depth { padding-inline-start: calc(var(--space-2) + var(--tree-depth) * var(--space-3)); font-size: var(--font-caption); }
.git-history-folder > div { padding-inline-start: 0; }

/* Compact plugin discovery uses the shared controls and theme tokens. */
.plugin-section.ui-disclosure-panel { border: 0; background: transparent; }
.plugin-section > .ui-disclosure-toggle, .plugin-section > .ui-disclosure-header > .ui-disclosure-toggle { background: transparent; padding: var(--space-2) 0; color: var(--text); }
.plugin-section-title { font-weight: 600; }
.plugin-count { margin-inline-start: auto; padding: 0 var(--space-2); border-radius: var(--radius-sm); background: var(--bg-hover); color: var(--text-muted); }
.plugin-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: var(--space-3); align-items: center; padding: var(--space-3) 0; min-width: 0; }
.plugin-row:hover { background: var(--bg-hover); }
.plugin-info { min-width: 0; }
.plugin-symbol { display: inline-flex; align-items: center; justify-content: center; color: var(--accent); }
.plugin-name.btn { max-width: 100%; padding: 0; min-height: 0; justify-content: flex-start; font-weight: 600; text-align: left; overflow: hidden; text-overflow: ellipsis; }
.plugin-description { margin: var(--space-1) 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: var(--font-caption); }
.plugin-metadata { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0; color: var(--text-muted); font-size: var(--font-caption); }
.plugin-status { margin: var(--space-1) 0 0; color: var(--text); font-size: var(--font-caption); font-weight: 600; }
.plugin-row-actions { display: flex; gap: var(--space-2); align-items: center; }
.plugin-details { padding: var(--space-4); background: var(--bg); border-radius: var(--radius-sm); overflow-wrap: anywhere; }
.plugin-empty { padding: var(--space-2) 0; }
.phone-layout .plugin-row { grid-template-columns: 24px minmax(0, 1fr); }
.phone-layout .plugin-row-actions { grid-column: 2; justify-content: flex-end; }

.plugin-update-count { color: var(--warn); }

.tui-statusline .tui-monitor-status { flex: none; margin-left: auto; min-width: 0; }
.tui-statusline .tui-monitor-status ~ .tui-goal-status { margin-left: 0; }
.tui-monitor-status .tui-monitor-label { font: inherit; padding: 2px 4px; color: var(--accent); }
.tui-monitor-menu { white-space: normal; overflow-y: auto; }
.tui-monitors { padding: var(--space-3); overflow-wrap: anywhere; }
.tui-monitors p { margin: var(--space-2) 0; }
.tui-monitor-entry { margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--border); }

.ui-disclosure-header { display: flex; align-items: center; gap: var(--space-2); }
.ui-disclosure-header > .ui-disclosure-toggle { flex: 1; min-width: 0; width: auto; }
.ui-disclosure-header > .btn { flex: none; }

/* Host inspection uses the same statusline flyout as goals and monitors. */
.tui-statusline .tui-host-status { flex: none; }
.tui-host-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); flex: none; }
.tui-host-actions .tui-goal-status, .tui-host-actions .tui-monitor-status { margin-left: 0; }
.host-panel-configured { height: max(0px, min(620px, calc(var(--dropdown-available-height, 640px) - 10px))); box-sizing: border-box; }
.host-summary { min-height: 5em; }
.host-summary p { margin: var(--space-2) 0; }
.host-resource-details { padding: var(--space-3); background: var(--bg); border-radius: var(--radius-md); }
.host-resource-details strong { font-size: var(--font-caption); color: var(--text-muted); }
.host-resource > summary { padding: var(--space-2) 0; overflow-wrap: anywhere; }
.tui-host-menu { white-space: normal; overflow: hidden; }
.tui-host-menu .host-panel { border: 0; max-height: none; padding: var(--space-3); }
.phone-layout .app-drawer-status { border-top: 1px solid var(--border); margin-top: var(--space-3); padding-top: var(--space-3); }
.phone-layout .app-drawer-status .statusbar { border: 0; padding: 0; background: transparent; }
.phone-layout .app-drawer-status .spacer { display: none; }
.phone-layout .app-drawer-status .editor-footer { flex-wrap: wrap; }

.release-notes { overflow-wrap: anywhere; }

.phone-layout .tui-host-status .ui-dropdown-trigger { padding-inline: var(--space-2); }

/* Shared declarative plugin documents, including the authoring playground. */
.plugin-panel-document { display: grid; gap: var(--space-4); min-width: 0; padding: var(--space-4); }
.plugin-panel-document :is(p, h3, ul) { margin: 0; overflow-wrap: anywhere; }
.plugin-panel-text { white-space: pre-wrap; }
.plugin-panel-table { min-width: 0; overflow-x: auto; }
.plugin-panel-table table { width: 100%; border-collapse: collapse; }
.plugin-panel-table :is(th, td) { padding: var(--space-2); border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.plugin-panel-code { margin: 0; padding: var(--space-3); overflow: auto; background: var(--bg-panel); font-family: var(--mono); }
.plugin-panel-document hr { width: 100%; margin: 0; border: 0; border-top: 1px solid var(--border); }
.plugin-panel-content { overflow: auto; }
.plugin-panel-host { width: 100%; min-width: 0; }
.plugin-panel-feedback { min-height: var(--control-height); padding: var(--space-2) var(--space-3); justify-content: flex-end; }
.plugin-panel-host > .ui-notice { margin: var(--space-3); }

.editor-diagnostic { position:absolute; height:3px; border-bottom:2px dotted var(--warn); transform:translate(var(--editor-scroll-x, 0px), var(--editor-scroll-y, 0px)); }
.editor-diagnostic-error { border-color:var(--offline); }

.editor-completion-popup.ui-dropdown-menu.recent-menu,
.editor-hover-popup.ui-dropdown-menu.recent-menu {
  position: fixed;
  min-width: 0;
  max-width: calc(100vw - 16px);
  box-sizing: border-box;
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--font-control);
}
.editor-completion-popup { display: flex; flex-direction: column; overflow: hidden; }
.editor-completion-list { min-height: 0; overflow: auto; }
.editor-completion-option.recent-item { flex: none; flex-direction: column; align-items: stretch; gap: 0; cursor: pointer; }
.editor-completion-option > span, .editor-completion-option > small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-completion-option > small { color: var(--text-muted); font-size: var(--font-caption); }
.editor-completion-option[aria-selected="true"] { background: var(--bg-hover); box-shadow: inset 2px 0 var(--accent); }
.editor-completion-hint { flex: none; padding: var(--space-1) var(--space-2); border-top: 1px solid var(--border); color: var(--text-muted); font-size: var(--font-caption); }
.editor-hover-popup { overflow: auto; padding: var(--space-3); overflow-wrap: anywhere; }
.editor-hover-popup pre { white-space: pre-wrap; }
.editor-hover-popup > :first-child { margin-top: 0; }
.editor-hover-popup > :last-child { margin-bottom: 0; }
