/* Owner: d-shell */

/* Global scale: every shell measurement below uses rem so this also zooms. */
:root,
:root[data-theme] {
  --ui-scale: 1;
  /* Secondary copy keeps at least 4.5: 1 on panel and element surfaces. */
  --text-muted: color-mix(in srgb, var(--text) 68%, var(--bg));
  --scroll-thumb: color-mix(in srgb, var(--text) 18%, transparent);
  --scroll-thumb-hover: color-mix(in srgb, var(--text) 34%, transparent);
}

:root[data-theme="sand-light"] {
  --primary: #0A0A0C;
  --secondary: #0A0A0C;
  --accent: #5A5A62;
  --text: #0A0A0C;
  --text-muted: #5A5A62;
  --bg: #FFFFFF;
  --bg-panel: #FFFFFF;
  --bg-element: #F5F5F5;
  --border: #E5E5E7;
  --border-active: #D4D4D7;
  --border-subtle: #ECECEF;
  --md-heading: #0A0A0C;
  --md-link: #0A0A0C;
  --md-code: #0A0A0C;
  --md-quote: #5A5A62;
  --diff-add: #16A34A;
  --diff-del: #DC2626;
  --success: #16A34A;
  --warning: var(--text-muted);
  --error: #DC2626;
  --info: var(--accent, #D4D4D7);
  --shadow: none;
  --font: "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

:root[data-theme="sand-dark"] {
  --primary: #F5F5F5;
  --secondary: #F5F5F5;
  --accent: #D4D4D7;
  --text: #F5F5F5;
  --text-muted: #9A9AA3;
  --bg: #0E0E10;
  --bg-panel: #0E0E10;
  --bg-element: #1F1F23;
  --border: #26262B;
  --border-active: #3A3A42;
  --border-subtle: #202024;
  --md-heading: #F5F5F5;
  --md-link: #F5F5F5;
  --md-code: #D4D4D7;
  --md-quote: #9A9AA3;
  --diff-add: #22C55E;
  --diff-del: #EF4444;
  --success: #22C55E;
  --warning: var(--text-muted);
  --error: #EF4444;
  --info: #56B6C2;
  --shadow: none;
  --font: "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

:root[data-theme] {
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* The root font-size that follows the Font size setting lives with the rem
   token scale in app.css, so the whole shell has one rem source. */

/* Zoom scales the whole shell, then the compensated box keeps the layout
   inside the real viewport so nothing is clipped at the top or right edge. */
#app.app {
  zoom: var(--ui-scale);
  width: calc(100vw / var(--ui-scale));
  height: calc(100vh / var(--ui-scale));
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track,
*::-webkit-scrollbar-corner {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border: 0;
  border-radius: 8px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}

*::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

body {
  font-size: var(--text-body);
  line-height: var(--leading-body);
}

/* Rail ------------------------------------------------------------------ */
.rail {
  align-items: stretch;
  gap: 4px;
  padding: 12px 8px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
}

.rail-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.rail-group-bottom {
  margin-top: auto;
}

.rail-item {
  position: relative;
  display: flex;
  flex: 0 0 2.25rem;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 2.25rem;
  min-height: 2.25rem;
  padding: 0;
  color: var(--text-muted);
  background: transparent;
  border-radius: 8px;
  transition: color 120ms ease, background 120ms ease;
}

.rail-item:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.rail-item.active {
  color: var(--text);
  background: color-mix(in srgb, var(--primary) 12%, var(--bg-panel));
}

.rail-item.active::before {
  position: absolute;
  top: 0.5rem;
  bottom: 0.5rem;
  left: -0.375rem;
  width: 2px;
  background: var(--primary);
  border-radius: 8px;
  content: "";
  display: none;
}

.rail-item svg {
  width: 1.125rem;
  height: 1.125rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-label {
  position: absolute;
  top: 50%;
  left: calc(100% + 0.5rem);
  z-index: 80;
  padding: 4px 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  background: var(--bg-element);
  border: 1px solid var(--border);
  border-radius: 8px;
  
  opacity: 0;
  transform: translate(-0.25rem, -50%);
  transition: opacity 100ms ease, transform 100ms ease;
}

.rail-item:hover .rail-label,
.rail-item:focus-visible .rail-label {
  opacity: 1;
  transform: translate(0, -50%);
}

/* Sidebar --------------------------------------------------------------- */
.sidebar {
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--bg-panel);
}

.sb-header {
  flex: 0 0 var(--titlebar-h);
  gap: var(--space-2);
  height: var(--titlebar-h);
  padding: 0 var(--space-3) 0 var(--space-4);
}

.sb-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}

.sb-actions {
  gap: 4px;
}

.sb-header .icon-btn {
  flex-basis: 1.75rem;
  width: 1.75rem;
  height: 1.75rem;
}

.sb-header .icon-btn svg {
  width: 1rem;
  height: 1rem;
}

.sb-search {
  flex: 0 0 auto;
  margin: var(--space-3) var(--space-2) var(--space-1);
}

.sb-search .input {
  height: var(--space-8);
  min-height: var(--space-8);
  padding-left: var(--space-8);
  font-size: var(--text-body);
  background: var(--bg-element);
}

.sb-search svg {
  top: 50%;
  left: var(--space-4);
  transform: translateY(-50%);
  width: 0.875rem;
  height: 0.875rem;
}

.sb-section {
  flex: 0 0 auto;
  padding: var(--space-4) var(--space-2) 0;
}

.sb-section + .sb-section {
  padding-top: var(--space-5);
}

.sb-label {
  min-height: 1.25rem;
  padding: 0 12px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0;
  
}

.sb-row {
  gap: var(--space-3);
  height: auto;
  min-height: var(--space-8);
  padding: 0 var(--space-3);
  color: var(--text-2);
  font-size: var(--text-body);
  font-weight: 500;
  line-height: 1.35;
  border-radius: var(--radius-xl);
  transition: color 100ms ease, background 100ms ease;
}

.sb-row:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.sb-row.active {
  color: var(--text);
  font-weight: 600;
  background: color-mix(in srgb, var(--primary) 12%, var(--bg-panel));
  
}

.sb-row-icon {
  flex-basis: 1rem;
  width: 1rem;
  height: 1rem;
}

.sb-row-icon svg {
  width: 1rem;
  height: 1rem;
}

.sb-row-text {
  min-width: 0;
  line-height: 1.3;
}

.sb-row-chat {
  height: auto;
  min-height: var(--space-8);
}

.sb-row-chat .sb-row-text {
  display: block;
  flex: 1 1 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.sb-row-project + .sb-empty-action {
  margin-left: 4px;
}

.sb-row-time {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  transition: color 100ms ease;
}

/* The chat's status dot owns the right edge, so the date stops claiming it. */
.sb-row-chat .sb-row-time {
  margin-left: 0;
}

.sb-row:hover .sb-row-time {
  color: var(--text-2);
}

/* One crisp dot per chat, in the requested order of urgency. No blur: the
   running dot keeps the solid accent colour at full strength and pulses a
   separate ring, so it never fades into a grey idle-looking dot. */
.sb-status-dot {
  position: relative;
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-radius: 999px;
  background: var(--status-unread);
  transition: background 120ms ease;
}

.sb-status-dot.is-running {
  background: var(--status-running);
  animation: sb-status-breathe 2s ease-in-out infinite;
}

.sb-status-dot.is-running::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  border: 1px solid color-mix(in srgb, var(--status-running) 40%, transparent);
  animation: sb-status-ring 2s ease-in-out infinite;
}

.sb-status-dot.is-needs {
  background: var(--status-needs);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--status-needs) 24%, transparent);
}

.sb-status-dot.is-unread {
  background: var(--status-unread);
}

.sb-status-dot.is-failed {
  background: var(--status-failed);
}

/* Gentle: the accent dot stays lit and only its halo breathes. */
@keyframes sb-status-breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.86; }
}

@keyframes sb-status-ring {
  0%, 100% { opacity: 0.35; transform: scale(0.88); }
  50% { opacity: 0.95; transform: scale(1.3); }
}

@media (prefers-reduced-motion: reduce) {
  .sb-status-dot.is-running,
  .sb-status-dot.is-running::after {
    animation: none;
  }
  .sb-status-dot.is-running::after {
    opacity: 0.6;
    transform: none;
  }
}

.sb-row-end {
  flex: 0 0 1.5rem;
  justify-content: flex-end;
  width: 1.5rem;
  margin-left: 0;
}

.sb-row-end .icon-btn {
  flex-basis: 1.5rem;
  width: 1.5rem;
  height: 1.5rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 100ms ease;
}

.sb-row:hover .sb-row-end .icon-btn,
.sb-row:focus-within .sb-row-end .icon-btn {
  pointer-events: auto;
  opacity: 1;
}

.sb-row-running .sb-row-end .icon-btn {
  /* Running is shown by the status dot; the row keeps its icons for hover. */
  pointer-events: none;
  opacity: 0;
}

.sb-row-running .spinner {
  width: 0.75rem;
  height: 0.75rem;
  border-top-color: var(--text-2);
}

/* Sidebar resize ---------------------------------------------------------
   A 6px strip on the right edge, quiet until the pointer or keyboard reaches
   it. The sidebar itself never scrolls (the chat list does), so an absolutely
   positioned handle stays put through every render. */
html body .sidebar {
  position: relative;
}

.sb-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  width: 6px;
  cursor: col-resize;
  touch-action: none;
}

.sb-resize-handle::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: transparent;
  transition: background 120ms ease;
}

.sb-resize-handle:hover::after,
.sb-resize-handle.dragging::after,
.sb-resize-handle:focus-visible::after {
  background: var(--border-active);
}

.sb-resize-handle:focus-visible {
  outline: none;
}

body.sb-resizing {
  cursor: col-resize;
  user-select: none;
}

.sb-empty {
  padding: 8px 12px 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
}

.sb-about-popup {
  font-size: 15px;
}

/* Settings -------------------------------------------------------------- */
.settings-view {
  padding: 0;
  scroll-behavior: smooth;
  container-type: inline-size;
}

.settings-page {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.settings-title {
  margin: 0 0 24px;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
}

.settings-intro {
  max-width: 40rem;
  margin: -12px 0 32px;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.55;
}

.group {
  margin: 0 0 32px;
}

.group-title {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}

.group-card {
  background: var(--bg-panel);
  border-color: var(--border-subtle);
  border-radius: 8px;
  
}

.group-card > .row + .row,
.group-card > .account-card + .account-card {
  border-top-color: var(--border-subtle);
}

.row {
  gap: 20px;
  min-height: 3.25rem;
  padding: 16px 16px;
}

.row-main {
  line-height: 1.55;
}

.row-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
}

.row-help {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
}

.row-control {
  gap: 12px;
}

.row-control .input,
.row-control .select {
  width: 13rem;
}

.row-path {
  align-items: flex-start;
}

.row-path > .row-main {
  flex: 1 1 12rem;
  min-width: 160px;
}

.row-path > .row-path-control {
  display: flex;
  flex: 1 1 20rem;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
  max-width: min(32rem, 58%);
}

.row-path-control .select {
  width: 100%;
}

.path-value {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.path-value-text {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: baseline;
  overflow: hidden;
  color: var(--text-muted);
  font: 500 12px/1.5 var(--mono);
  white-space: nowrap;
}

/* Show the head and tail of a path so a long one truncates in the middle
   instead of running past the card. The full path stays in the title. */
.path-value-head {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.path-value-tail {
  flex: 0 0 auto;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-copy-btn {
  display: inline-flex;
  flex: 0 0 1.75rem;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
}

.row-copy-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
  border-color: var(--border-subtle);
}

.row-copy-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

/* Settings rows: the text column keeps its own line and the control moves
   below it when the settings pane itself is narrow. The pane, not the window,
   is the measure: the rail, sidebar and settings nav all take width here. */
.settings-content {
  container-type: inline-size;
  container-name: settings-content;
}

.settings-row {
  align-items: flex-start;
}

.settings-row > .row-main {
  display: flex;
  flex-direction: column;
  flex: 1 0 12rem;
  gap: 4px;
  min-width: 0;
}

.settings-row > .row-main > .row-help {
  display: block;
  margin-top: 0;
  overflow: visible;
  white-space: normal;
  overflow-wrap: anywhere;
  -webkit-line-clamp: unset;
  line-clamp: unset;
}

.settings-row .row-title {
  overflow-wrap: normal;
  word-break: normal;
}

.settings-row .row-control {
  flex: 0 1 auto;
  flex-wrap: wrap;
  min-width: 0;
  max-width: min(100%, 24rem);
}

.settings-row .row-control > * {
  min-width: 0;
  max-width: 100%;
}

.settings-row .row-control .pill {
  display: inline-block;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.group,
.group-card {
  min-width: 0;
  max-width: 100%;
}

/* Settings › Connections › Connect a client ------------------------------ */
.connect-client-card {
  padding: 16px 18px 18px;
}

.connect-intro {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.connect-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.connect-tab {
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

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

.connect-tab[aria-selected="true"] {
  border-color: var(--border);
  background: var(--bg-element);
  color: var(--text);
}

.connect-tab:focus-visible,
.connect-copy:focus-visible {
  outline: 2px solid var(--focus-ring, var(--primary));
  outline-offset: 2px;
}

.connect-panel {
  padding-top: 14px;
}

.connect-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.connect-agent-name {
  font-weight: 600;
  color: var(--text);
}

.connect-head .connect-action {
  margin-left: auto;
}

/* The dark theme leaves a pill as bare text; the connection state must read
   as a state at a glance in both themes. */
.connect-head .pill {
  padding: 2px 9px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--bg-element);
  color: var(--text-muted);
  font-size: 12px;
}

.connect-head .pill-ok {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 14%, var(--bg-element));
  border-color: color-mix(in srgb, var(--success) 34%, var(--border-subtle));
}

.connect-cap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-s);
  background: var(--bg-element);
}

.connect-cap-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.connect-cap-dollar {
  color: var(--text-muted);
  font: 12px/1 var(--mono);
}

.connect-cap-input {
  width: 6.5rem;
  padding: 4px 6px;
  font: 12px/1.4 var(--mono);
}

.connect-cap-note {
  color: var(--text-muted);
  font-size: 11.5px;
}

.connect-status {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.connect-label {
  margin: 16px 0 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.connect-command-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--bg-code, var(--bg-elev));
}

.connect-command {
  flex: 1 1 14rem;
  min-width: 0;
  overflow-x: auto;
  color: var(--text);
  font: 12.5px/1.5 var(--mono);
  white-space: pre;
}

.connect-copy {
  flex: 0 0 auto;
}

.connect-copy-note {
  min-width: 3.5rem;
  color: var(--text-muted);
  font-size: 11.5px;
}

.connect-changes {
  margin: 0 0 0 18px;
  padding: 0;
  color: var(--text-2, var(--text-muted));
  font-size: 12.5px;
  line-height: 1.6;
}

.connect-changes li + li {
  margin-top: 4px;
}

.connect-safety {
  margin: 14px 0 0;
  color: var(--text-faint, var(--text-muted));
  font-size: 11.5px;
  line-height: 1.5;
}

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

.computer-permission-note {
  padding: 12px 16px 12px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.computer-permission-instructions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 16px 12px;
  padding: 12px 16px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
  background: var(--bg-element);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.computer-permission-instructions strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.computer-permission-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  padding: 0 16px 16px;
}

.computer-permission-actions a {
  color: var(--text);
  text-decoration: none;
}

.appearance-theme-panel {
  padding: 16px;
}

.appearance-theme-grid {
  gap: 12px;
}

.appearance-theme-card {
  padding: 8px;
  border-radius: 8px;
}

.appearance-theme-name {
  font-size: 13px;
}

.appearance-scale {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 12.5rem;
}

.appearance-scale-slider {
  width: 8.5rem;
  height: 1.25rem;
  accent-color: var(--text-muted);
}

.appearance-scale-value {
  flex: 0 0 2.75rem;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.appearance-scale-reset {
  min-height: 1.75rem;
  padding: 0 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.settings-search-empty {
  margin: 0 auto;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.55;
  text-align: center;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.settings-view .btn {
  min-height: 1.875rem;
  font-size: 13px;
}

.settings-view .input,
.settings-view .select,
.settings-view .textarea {
  min-height: 2rem;
  font-size: 15px;
}

.settings-view .empty {
  font-size: 15px;
}

@media (max-width: 900px) {
  .settings-view {
    padding: 0;
  }

  .row-path {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .row-path > .row-main {
    flex: none;
    min-width: 0;
    width: 100%;
  }

  .row-path > .row-path-control {
    flex: none;
    max-width: none;
    width: 100%;
  }
}

@media (max-width: 720px) {
  .row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .row-control,
  .row-control .input,
  .row-control .select {
    width: 100%;
  }

  .appearance-scale {
    min-width: 0;
  }

  .appearance-scale-slider {
    flex: 1;
    width: auto;
  }
}


/* VU1: quieter navigation chrome, more air, hover-only emphasis. */
:root[data-theme] .rail-item.active {
  color: var(--text);
  background: var(--bg-hover);
}

:root[data-theme] .rail-item.active::before {
  display: none;
}

.sb-header {
  gap: var(--space-2);
  padding: 0 var(--space-3) 0 var(--space-4);
}

.sb-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.sb-search {
  margin: var(--space-3) var(--space-2) var(--space-1);
}

.sb-search .input {
  height: var(--space-8);
  min-height: var(--space-8);
  color: var(--text);
  font-size: var(--text-body);
  background: transparent;
  border-color: transparent;
}

.sb-search .input:hover {
  background: var(--bg-hover);
}

.sb-search .input:focus {
  background: var(--bg-element);
  border-color: var(--border-subtle);
}

.sb-section {
  padding: var(--space-4) var(--space-2) 0;
}

.sb-section + .sb-section {
  padding-top: var(--space-5);
}

.sb-label {
  min-height: 22px;
  padding: 0 12px;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  
}

.sb-row {
  gap: var(--space-3);
  height: auto;
  min-height: var(--space-8);
  padding: 0 var(--space-3);
  color: var(--text-2);
  font-size: var(--text-body);
  font-weight: 500;
  line-height: 1.4;
  background: transparent;
  border: 0;
  border-radius: var(--radius-s);
  transition: color 120ms ease, background-color 120ms ease;
}

.sb-row:hover {
  color: var(--text);
  background: var(--bg-hover);
}

:root[data-theme] .sidebar .sb-row.active {
  color: var(--text);
  font-weight: 600;
  background: var(--bg-active);
  
}

.sb-row-chat {
  min-height: var(--space-8);
}

.sb-row-icon,
.sb-row-icon svg {
  color: var(--text-muted);
}

.sb-row-time {
  color: var(--text-faint);
  font-size: 12px;
  opacity: 1;
  transition: opacity 120ms ease;
}

.sb-row:hover .sb-row-time,
.sb-row:focus-visible .sb-row-time {
  opacity: 1;
}

.sb-empty {
  padding: 8px 12px 8px;
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
}

.sb-empty.sb-empty-card {
  padding: 8px 12px 8px;
  background: transparent;
  border: 0;
}

.sb-empty-title {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
}

.sb-empty-copy {
  margin-top: 4px;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 400;
}

.sb-skeleton {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 8px;
}

.sb-skeleton .skeleton-label {
  width: 64px;
  height: 10px;
  margin: 2px 4px;
  opacity: 0.7;
}

.sb-skeleton .skeleton-row {
  width: 100%;
  height: 24px;
}

.sb-skeleton .skeleton-row.short {
  width: 70%;
}

.sb-empty-action {
  min-height: 28px;
  margin-top: 4px;
  padding: 0 4px;
  color: var(--text-muted);
  font-size: 13px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-s);
}

.sb-empty-action:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.sb-empty-action.primary {
  color: var(--text-2);
  background: transparent;
  border: 0;
}

.sb-empty-action.primary:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.sb-row-end .icon-btn {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--text-faint);
}
@media (prefers-reduced-motion: reduce) {
  .sb-row,
  .sb-row-time,
  .rail-item {
    transition: none;
  }
}

@container (max-width: 40rem) {
  .row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .row-control,
  .row-control .input,
  .row-control .select {
    width: 100%;
  }

  .settings-row .row-control {
    max-width: 100%;
  }

  .settings-row {
    flex-direction: column;
    align-items: stretch;
  }

  .settings-row > .row-main {
    flex: none;
    width: 100%;
  }

  .row-path {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .row-path > .row-main {
    flex: none;
    width: 100%;
    min-width: 0;
  }

  .row-path > .row-path-control {
    flex: none;
    width: 100%;
    max-width: none;
  }

  .appearance-scale {
    min-width: 0;
  }

  .appearance-scale-slider {
    flex: 1;
    width: auto;
  }
}

/* Bound intrinsic control and card widths only in squeezed windows. */
@media (max-width: 900px) {
  .settings-page,
  .settings-page :is(.row, .row-control, .account-primary, .account-head,
    .provider-card, .provider-connect-copy, .shortcut-control, .shortcut-search) {
    min-width: 0;
    max-width: 100%;
  }
  .settings-page { overflow-wrap: anywhere; }
  .settings-page :is(.row-control, .account-actions, .account-status,
    .account-share-row, .provider-card-meta, .provider-connect-top,
    .shortcut-toolbar, .shortcut-control, .shortcut-keys) { flex-wrap: wrap; }
  .settings-page :is(.input, .select, .textarea, .btn) {
    min-width: 0;
    max-width: 100%;
  }
  .settings-page .btn { white-space: normal; overflow-wrap: anywhere; }
  .settings-page .row-title { white-space: normal; }
  .settings-page .row-control > * { min-width: 0; max-width: 100%; }
  .settings-page .provider-grid { grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); }
  .settings-page .account-share-label { grid-template-columns: minmax(0, 1fr); max-width: 100%; }
  .settings-page .account-field-label { white-space: normal; }
  .settings-page :is(.provider-card-name, .provider-connect-title,
    .account-primary > .row-title, .account-meta .row-title) {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .settings-page .shortcut-row { flex-wrap: wrap; }
}

@media (max-width: 719px) {
  .settings-page :is(.settings-row, .shortcut-row, .row-path) {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .settings-page :is(.row-control, .shortcut-control) { width: 100%; max-width: 100%; }
}

/* SH1: top window row, sidebar product header, and docked side pane. */
html body .titlebar {
  display: flex;
  align-items: center;
  gap: var(--titlebar-group-gap, 10px);
  min-width: 0;
  border-bottom: 1px solid var(--border-subtle);
}

html body .titlebar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

html body .titlebar-nav .icon-btn,
html body .titlebar-actions .icon-btn {
  width: 28px;
  height: 28px;
  flex-basis: 28px;
}

.chat-title-button {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 28px;
  padding: 0;
  color: inherit;
  background: transparent;
  border-radius: var(--radius-s);
}

.chat-title-button::after {
  content: '';
  width: 6px;
  height: 6px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-2px) rotate(45deg);
}

.chat-title-button:hover,
.chat-title-button[aria-expanded="true"] {
  color: var(--text);
  background: var(--bg-hover);
}

.sb-row-chat { position: relative; }
.sb-row-chat button.sb-row-text {
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: start;
  background: transparent;
}

.sb-row-chat button.sb-row-text::after {
  content: '';
  position: absolute;
  inset: 0;
}

html body .sb-header {
  flex: 0 0 var(--titlebar-h);
  height: var(--titlebar-h);
  padding: 0 var(--space-3) 0 var(--space-4);
  background: transparent;
}

html body .sb-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

html body .sb-section:first-of-type {
  padding-top: var(--space-4);
}

html body .sb-section:first-of-type .sb-row {
  width: 100%;
  min-height: var(--space-8);
  font-weight: 500;
}

html body .sb-section:first-of-type .sb-row.active {
  font-weight: 600;
}

html body .sb-collapse {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  min-height: 24px;
  padding: 0 8px;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: left;
  background: transparent;
  border-radius: var(--radius-s);
}

html body .sb-collapse:hover {
  color: var(--text-2);
  background: var(--bg-hover);
}

html body .sb-collapse svg {
  width: 12px;
  height: 12px;
  transition: transform 120ms ease;
}

html body .sb-collapse[aria-expanded="false"] svg {
  transform: rotate(-90deg);
}

/* Row actions float over the right end of the row instead of reserving their
   own width. The name keeps the full row, and a short fade makes the moment
   the icons appear readable without a hard edge. */
html body .sb-row-actions {
  position: absolute;
  top: 50%;
  right: var(--space-2);
  z-index: 1;
  display: inline-flex;
  flex: 0 0 auto;
  width: auto;
  align-items: center;
  gap: 1px;
  margin-left: 0;
  padding-left: 12px;
  background: linear-gradient(90deg, transparent 0, var(--bg-hover) 12px);
  border-radius: var(--radius-s);
  transform: translateY(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 90ms ease;
}

/* Dates yield to actions; each control keeps its own space in the flex row. */
html body .sb-row-chat:hover .sb-row-time,
html body .sb-row-chat:focus-within .sb-row-time {
  display: none;
}

html body .sb-row-actions .icon-btn {
  position: relative;
  width: 24px;
  height: 24px;
  flex-basis: 24px;
  pointer-events: none;
  opacity: 0;
}

html body .sb-row.active .sb-row-actions {
  background: linear-gradient(90deg, transparent 0, color-mix(in srgb, var(--primary) 12%, var(--bg-panel)) 12px);
}

html body .sb-row:hover .sb-row-actions,
html body .sb-row:focus-within .sb-row-actions,
html body .sb-row-actions:focus-within,
html body .sb-row-actions:has(.icon-btn[aria-expanded="true"]) {
  opacity: 1;
  pointer-events: auto;
}

html body .sb-row:hover .sb-row-actions .icon-btn,
html body .sb-row:focus-within .sb-row-actions .icon-btn,
html body .sb-row-actions .icon-btn[aria-expanded="true"] {
  pointer-events: auto;
  opacity: 1;
}

@media (hover: none) {
  html body .sb-row-chat .sb-row-actions,
  html body .sb-row-chat .sb-row-actions .icon-btn {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Recents header: the sort/filter control stays quiet until the section is
   hovered or reached from the keyboard. */
html body .sb-section-head {
  display: flex;
  align-items: center;
  gap: 4px;
}

html body .sb-section-head .sb-collapse {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

html body .sb-section-head .icon-btn {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 100ms ease, color 100ms ease;
}

html body .sb-section-head:hover .icon-btn,
html body .sb-section-head:focus-within .icon-btn,
html body .sb-section-head .icon-btn:focus-visible {
  opacity: 1;
}

html body .sb-section-head .icon-btn:hover {
  color: var(--text);
}

html body .sb-subhead {
  padding: 8px 12px 2px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
}

html body .sb-choice-label {
  flex: 1 1 auto;
  min-width: 0;
}

html body .sb-more-form {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
}

html body .sb-more-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 28px;
  min-height: 28px;
  font-size: 13px;
}

html body .sb-more-save {
  flex: 0 0 auto;
}

/* Sidebar errors use the same quiet toast surface as other failures. */
html body .toast.error {
  color: var(--error-fg);
  border-color: color-mix(in srgb, var(--error) 50%, var(--border));
}

html body .panel {
  /* Each open pane keeps --pane-min-h (the same number as MIN_PANE_HEIGHT in
     panel-layout.js). With more panes than fit, the dock scrolls. */
  --pane-min-h: 190px;
  width: min(var(--panel-w), calc(100vw - 360px));
  min-width: 280px;
  max-width: 1400px;
  overflow-x: auto;
  overflow-y: auto;
  scrollbar-width: thin;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-subtle);
}

/* An overlay still reserves its lane, so composer controls never sit under it. */
.app.panel-overlay .thread-view {
  box-sizing: border-box;
  padding-right: var(--panel-w);
  min-width: 0;
}

/* Below 1100px the pane floats over the chat instead of taking a column, so it
   must not subtract its lane a second time from the transcript or composer. */
@media (max-width: 1099px) {
  .app.panel-overlay .thread-view { padding-right: 0; }
}

html body .panel-chrome {
  gap: 4px;
  padding-left: 10px;
}

html body .panel-tab {
  height: 34px;
  padding: 0 7px;
  font-size: 12px;
}

html body .panel-card {
  padding: 12px 13px 20px;
}

html body .panel-resizer {
  display: block;
}

html body .panel.is-bottom-docked .panel-resizer { display: none; }

html body .panel.is-bottom-docked:has(.panel-pane.is-minimized:only-child) {
  align-self: end;
  height: 34px;
}

/* Side panel panes: each panel has its own header, panes split vertically. */
.panel-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 34px;
  overflow: hidden;
}

.panel-pane:not(.is-minimized) {
  min-height: var(--pane-min-h, 190px);
}

.panel-pane.is-minimized {
  flex: 0 0 auto;
}

/* A split of the dock's tree: its children sit in a row or stack in a column,
   and dividers sit between them. */
.panel-group {
  display: flex;
  min-width: 0;
  min-height: 0;
}

.panel-group.is-row {
  flex-direction: row;
}

.panel-group.is-col {
  flex-direction: column;
}

/* The conversation and its writing box share one readable, fluid column. */
#threadView {
  --chat-gutter: clamp(12px, 2.5vw, 24px);
}

#app .thread {
  padding-inline: var(--chat-gutter);
}

#threadView:not(:has(.home)) > .thread {
  padding-inline: 0;
  scrollbar-gutter: stable;
}

#app .thread-inner {
  max-width: var(--thread-w);
}

#app .composer-wrap {
  max-width: calc(var(--thread-w) + var(--chat-gutter) * 2);
  padding-inline: var(--chat-gutter);
}

#threadView:not(:has(.home)) > .thread > .thread-inner {
  max-width: calc(var(--message-max-width) + var(--space-8) * 2);
  width: min(calc(var(--message-max-width) + var(--space-8) * 2), calc(100% - var(--chat-gutter) * 2));
}

/* The transcript spans both columns and reserves its own scrollbar gutter.
   The composer shares the first column and can let its menus overflow. */
#threadView:not(:has(.home)) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: minmax(0, 1fr);
}

#threadView:not(:has(.home)) > * {
  grid-column: 1 / -1;
}

#threadView:not(:has(.home)) > .thread {
  grid-row: 1;
}

#app #threadView:not(:has(.home)) > .composer-wrap {
  grid-column: 1;
  max-width: none;
  padding-inline: 0;
}

/* The input follows the transcript's pinned message column so the editor and
   the reading column keep one measure at every width. */
#threadView:not(:has(.home)) > .composer-wrap > * {
  width: min(calc(var(--message-max-width) + var(--space-8) * 2), calc(100% - var(--chat-gutter) * 2));
  margin-inline: auto;
}

#threadView:not(:has(.home))::after {
  content: "";
  grid-area: 1 / 2;
  block-size: 0;
  overflow: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}

#app .thread-inner .msg-agent {
  max-width: min(100%, var(--message-max-width));
}

.panel-split {
  position: relative;
  z-index: 3;
  flex: 0 0 1px;
  background: var(--border-subtle);
  touch-action: none;
}

.panel-split.is-col {
  cursor: row-resize;
}

.panel-split.is-row {
  cursor: col-resize;
}

.panel-split::before {
  position: absolute;
  content: "";
}

.panel-split.is-col::before {
  top: -4px;
  right: 0;
  bottom: -4px;
  left: 0;
}

.panel-split.is-row::before {
  top: 0;
  right: -4px;
  bottom: 0;
  left: -4px;
}

/* A minimized pane in a row keeps only a narrow rail with its buttons. */
.panel-pane.is-rail .pane-head {
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
}

.panel-pane.is-rail .pane-tabs,
.panel-pane.is-rail .pane-title-label {
  display: none;
}

.panel-pane.is-rail .pane-actions {
  flex-direction: column;
}

html body .panel-chrome.pane-head {
  cursor: grab;
  user-select: none;
}

html body .panel-chrome.pane-head .icon-btn,
html body .panel-chrome.pane-head .panel-tab {
  cursor: pointer;
}

body.is-panel-dragging,
body.is-panel-dragging * {
  cursor: grabbing !important;
  user-select: none !important;
}

/* Where a dragged panel will land: the half of the pane it would take, or the
   whole pane for a tab. */
.panel-drop-hint {
  position: fixed;
  z-index: 60;
  box-sizing: border-box;
  pointer-events: none;
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  border: 2px solid var(--primary);
  border-radius: var(--radius-s);
  transition: left 80ms ease, top 80ms ease, width 80ms ease, height 80ms ease;
}

.panel-drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 61;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  padding: 5px 10px;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  background: var(--bg-element);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-s);
}

.panel-split:hover,
.panel-split.is-dragging {
  background: color-mix(in srgb, var(--text) 24%, transparent);
}

.panel-split:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

html body .panel-chrome.pane-head {
  min-height: 34px;
  padding: 0 4px 0 10px;
}

.pane-title {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}

.pane-title-btn {
  height: 28px;
  padding: 0;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.pane-title-btn:hover {
  color: var(--text);
}

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

.pane-title svg {
  flex: 0 0 14px;
  stroke: currentColor;
  fill: none;
}

.pane-head .pane-tabs {
  overflow-x: auto;
  scrollbar-width: thin;
}

.pane-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 2px;
}

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

html body .panel-empty {
  padding: 10px 2px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

html body .summary-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

html body .summary-entry {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  color: var(--text-2);
  font-size: 12px;
  text-align: left;
  background: transparent;
  border-radius: var(--radius-s);
}

html body .summary-entry:hover {
  color: var(--text);
  background: var(--bg-hover);
}

html body .summary-entry svg {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  margin-top: 1px;
  color: var(--text-muted);
}

html body .summary-entry .summary-copy {
  min-width: 0;
}

html body .summary-entry .summary-sub {
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 12px;
  overflow-wrap: anywhere;
}

html body .browser-panel,
html body .preview-panel,
html body .terminal-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100%;
}

html body .browser-toolbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 3px;
  min-width: 0;
}

html body .browser-toolbar .input {
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

html body .browser-note,
html body .preview-note {
  padding: 8px 9px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
  background: var(--bg-hover);
  border-radius: var(--radius-s);
}

html body .browser-frame-wrap,
html body .preview-frame-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 320px;
  overflow: hidden;
  background: var(--bg-element);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

html body .browser-frame,
html body .preview-frame {
  width: 100%;
  height: 100%;
  min-height: 320px;
  background: #fff;
  border: 0;
}

html body .browser-empty,
html body .preview-empty {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 220px;
  padding: 24px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

html body .browser-empty svg,
html body .preview-empty svg {
  width: 24px;
  height: 24px;
  color: var(--text-faint);
}

html body .browser-actions,
html body .preview-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

html body .browser-bookmarks {
  flex: 0 0 auto;
  max-height: 180px;
  overflow-y: auto;
}

html body .browser-bookmark {
  display: block;
  width: 100%;
  padding: 5px 7px;
  overflow: hidden;
  color: var(--text-2);
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: transparent;
  border-radius: var(--radius-s);
}

html body .browser-bookmark:hover {
  color: var(--text);
  background: var(--bg-hover);
}

html body .import-sheet {
  display: flex;
  flex-direction: column;
  gap: 13px;
  min-width: min(440px, 80vw);
}

html body .import-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px;
  background: var(--bg-element);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

html body .import-option input {
  margin-top: 2px;
}

html body .import-option-copy {
  min-width: 0;
}

html body .import-option-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

html body .import-option-help {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

html body .import-safety {
  padding: 10px;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.55;
  background: color-mix(in srgb, var(--primary) 7%, var(--bg-element));
  border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--border-subtle));
  border-radius: var(--radius);
}

html body .import-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

html body .tools-popup {
  width: min(520px, calc(100vw - 28px));
  max-height: min(680px, calc(100vh - 70px));
  overflow-y: auto;
  padding: 8px;
}

html body .tools-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 7px 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

html body .tools-group {
  padding: 7px;
  border-top: 1px solid var(--border-subtle);
}

html body .tools-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

html body .tools-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-height: 30px;
  padding: 6px 7px;
  color: var(--text-2);
  font-size: 12px;
  border-radius: var(--radius-s);
}

html body .tools-row:hover {
  color: var(--text);
  background: var(--bg-hover);
}

html body .tools-row-main {
  flex: 1 1 220px;
  min-width: 0;
}

html body .tools-row-icon,
html body .tools-row-trailing {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  padding-top: 1px;
}

html body .tools-row-title {
  color: var(--text);
  line-height: 1.35;
}

html body .tools-row-sub {
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: break-word;
}

html body .tools-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 7px 0 0;
}

html body .terminal-placeholder {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 240px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

html body .terminal-placeholder svg {
  width: 24px;
  height: 24px;
  color: var(--text-faint);
}

html body .terminal-panel {
  height: 100%;
  min-height: 0;
  gap: 0;
  overflow: hidden;
}

html body .terminal-toolbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--border-subtle);
}

html body .terminal-toolbar-title {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}

html body .terminal-toolbar-title svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  color: var(--text-muted);
}

html body .terminal-toolbar-title > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html body .terminal-summary {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  color: var(--text-faint);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html body .terminal-toolbar-btn {
  flex: 0 0 auto;
  padding: 3px 7px;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-s);
  cursor: pointer;
}

html body .terminal-toolbar-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

html body .terminal-scroll {
  min-height: 0;
  flex: 1 1 auto;
  margin: 8px -6px 0 0;
  padding-right: 6px;
  overflow: auto;
}

html body .terminal-command-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

html body .terminal-command {
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-panel);
}

html body .terminal-command-head {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  padding: 8px 9px;
  border-bottom: 1px solid var(--border-subtle);
}

html body .terminal-command-line {
  min-width: 0;
  flex: 1 1 auto;
  max-width: 100%;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html body .terminal-status {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

html body .terminal-status::before {
  width: 6px;
  height: 6px;
  background: var(--text-faint);
  border-radius: 8px;
  content: "";
}

html body .terminal-status.is-running::before {
  background: var(--info);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--info) 16%, transparent);
}

html body .terminal-status.is-done::before {
  background: var(--success);
}

html body .terminal-status.is-failed::before {
  background: var(--error);
}

html body .terminal-status.is-stopped::before {
  background: var(--warning);
}

html body .terminal-stop {
  flex: 0 0 auto;
  padding: 3px 8px;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-s);
  cursor: pointer;
}

html body .terminal-stop:hover:not(:disabled) {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 12%, var(--bg-hover));
}

html body .terminal-stop:disabled {
  color: var(--text-faint);
  background: transparent;
  border-color: var(--border-subtle);
  cursor: default;
}

html body .terminal-meta {
  padding: 5px 9px 0;
  color: var(--text-faint);
  font-size: 12px;
  overflow-wrap: anywhere;
}

html body .terminal-output {
  max-height: 220px;
  margin: 0;
  padding: 7px 9px 9px;
  overflow: auto;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

html body .terminal-stdout {
  color: inherit;
}

html body .terminal-stderr {
  color: var(--error);
}

html body .terminal-empty {
  display: flex;
  min-height: 240px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 20px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

html body .terminal-empty svg {
  width: 22px;
  height: 22px;
  color: var(--text-faint);
}

html body .automation-history {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

html body .automation-run {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  color: var(--text-muted);
  font-size: 12px;
}

/* The title bar spans the window. The rail and sidebar start below it. */
html[data-desktop="1"][data-platform="darwin"] body .rail {
  padding-top: 0.625rem;
}

html[data-desktop="1"][data-platform="darwin"] body .rail::before {
  display: none;
}

html[data-desktop="1"][data-platform="darwin"] body .sb-header {
  flex-basis: 44px;
  height: 44px;
  padding-left: 14px;
}

@media (max-width: 760px) {
  html body .titlebar {
    gap: 4px;
    padding-right: 6px;
  }

  html body .titlebar-text-btn {
    padding: 0 5px;
    font-size: 12px;
  }

  html body .panel {
    width: min(var(--panel-w), calc(100vw - 290px));
    min-width: min(260px, calc(100vw - 290px));
  }
}

@media (max-width: 560px) {
  /* The row scrolls sideways below 760px, so the text buttons stay on it. */
  html body .titlebar-text-btn {
    padding: 0 4px;
  }
}

/* A row of panes already saved for a wider window can still be wider than the
   floating dock: scroll across instead of cutting the extra panes off. */
html body .app.panel-overlay .panel {
  overflow-x: auto;
}

/* The service catalog keeps the compact Settings row measure, including when
   the surrounding settings container switches ordinary rows to a column. */
.connect-services-page .connect-service-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1.3fr) max-content minmax(0, 1fr);
  box-sizing: border-box;
  height: auto;
  min-height: 52px;
  padding: 6px 12px;
  gap: 10px;
  align-items: center;
}

.connect-service-row > .row-main {
  gap: 2px;
}

.connect-service-row .row-title {
  font-size: 13px;
  line-height: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connect-service-row > .row-main > .row-help {
  font-size: 11px;
  line-height: 14px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: normal;
}

.connect-service-logo {
  display: inline-block;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.connect-service-logo-mark {
  background: var(--text-2);
  -webkit-mask: var(--service-icon) center / contain no-repeat;
  mask: var(--service-icon) center / contain no-repeat;
}

.connect-service-monogram {
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.connect-service-row .connect-service-state {
  padding: 2px 5px;
  font-size: 11px;
  line-height: 16px;
  white-space: nowrap;
}

.connect-service-row > .row-control {
  display: block;
  width: 100%;
  max-width: none;
  min-width: 0;
}

.connect-service-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  width: 100%;
}

.connect-service-tool {
  max-width: 110px;
  padding: 1px 5px;
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connect-services-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.connect-services-filter-row .connect-services-filter { flex: 1; min-width: 0; }
.connect-services-filter-row > .btn { flex: none; }

.connect-service-command {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.connect-service-command code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  line-height: 16px;
}

.connect-service-row .connect-service-command .btn {
  flex: none;
  min-height: 22px;
  padding: 1px 6px;
  font-size: 11px;
  line-height: 18px;
  white-space: nowrap;
}

.connect-service-row .connect-service-actions > .btn {
  min-height: 22px;
  padding: 1px 8px;
  font-size: 11px;
  line-height: 18px;
  white-space: nowrap;
}

.connect-service-links {
  display: flex;
  gap: 6px;
  font-size: 11px;
  line-height: 14px;
  white-space: nowrap;
}

.connect-service-icon-button {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  text-decoration: none;
}

.connect-service-copy-status {
  min-width: 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 14px;
  white-space: nowrap;
}

.connect-service-connect-status {
  min-width: 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 14px;
  overflow-wrap: anywhere;
}


/* Save feedback occupies its own row, including at large interface sizes. */
.appearance-save-status {
  min-height: 1.5em;
  margin-bottom: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.sb-search-results { display:flex; flex-direction:column; gap:4px; padding:4px 10px 12px; }
.sb-search-status { padding:16px 14px; color:var(--text-muted); font-size:12px; }
.sb-search-result { width:100%; min-width:0; display:flex; align-items:center; gap:10px; padding:9px 10px; border:0; border-radius:10px; background:transparent; color:var(--text-1); text-align:left; cursor:pointer; }
.sb-search-result:hover, .sb-search-result:focus-visible { background:var(--bg-hover); outline:none; }
.sb-search-result-copy { min-width:0; flex:1; display:flex; flex-direction:column; gap:2px; }
.sb-search-result-title, .sb-search-result-subtitle { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sb-search-result-title { font-size:13px; }
.sb-search-result-subtitle { color:var(--text-muted); font-size:11px; }
.sb-search-result-tag { flex:none; margin-left:auto; padding:3px 7px; border:1px solid var(--border); border-radius:999px; color:var(--text-muted); font-size:10px; font-weight:600; letter-spacing:.02em; }
@media (max-width: 640px) {
  .sb-search-result { min-height:46px; padding:10px 8px; }
  .sb-search-result-tag { font-size:11px; }

}
