/* Design tokens are centralized so the mockup remains easy to retheme and extend. */
:root {
  color-scheme: light;
  /* Keep the shell bound to the visible viewport instead of Safari's unstable legacy 100vh. */
  --app-viewport-height: 100vh;
  --bg-canvas: #efeff2;
  --bg-panel: #ffffff;
  --bg-panel-strong: #f6f6f8;
  --bg-subtle: #f1f2f5;
  --bg-muted: #e6e8ed;
  --bg-emphasis: #171717;
  --surface-1: #ffffff;
  --surface-2: #f6f7fb;
  --line-soft: #dddddf;
  --line-strong: #cbccd2;
  --border-strong: #b8bfcd;
  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --icon-color: color-mix(in srgb, var(--text-secondary) 68%, var(--text-muted));
  --icon-color-hover: var(--text-primary);
  --icon-button-hover-bg: color-mix(in srgb, var(--bg-subtle) 82%, transparent);
  --icon-button-active-bg: color-mix(in srgb, var(--bg-muted) 76%, transparent);
  --accent: #4f7cff;
  --accent-soft: rgba(79, 124, 255, 0.12);
  --accent-strong: #3158d6;
  --success: #12b76a;
  --warning: #f79009;
  --terminal-surface: #f5f6fa;
  --terminal-line: #27272a;
  --terminal-line-muted: #5f6470;
  --terminal-line-warning: #b45309;
  --terminal-line-accent: #3158d6;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow-soft: none;
  --shadow-card: none;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 2.5rem;
  --font-ui: "SF Pro Display", "SF Pro Text", "Helvetica Neue", "Segoe UI", sans-serif;
  --font-mono: "SF Mono", "IBM Plex Mono", "JetBrains Mono", monospace;
  --duration-fast: 160ms;
  --duration-slow: 320ms;
  --header-height: 72px;
  --footer-height: 0px;
  --sidebar-width: 320px;
  --inspector-width: 320px;
  --terminal-height: 280px;
  --shell-resize-handle-size: 10px;
}

@supports (height: 100dvh) {
  :root {
    /* Prefer dynamic viewport units when the browser supports them. */
    --app-viewport-height: 100dvh;
  }
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg-canvas: #0d0d0f;
  --bg-panel: #181818;
  --bg-panel-strong: #202020;
  --bg-subtle: #262626;
  --bg-muted: #303030;
  --bg-emphasis: #111111;
  --surface-1: #171a22;
  --surface-2: #1e2330;
  --line-soft: #2f2f31;
  --line-strong: #3c3c40;
  --border-strong: #4d5568;
  --text-primary: #f4f4f5;
  --text-secondary: #d7dbe6;
  --text-muted: #b2b8c7;
  --icon-color: color-mix(in srgb, var(--text-muted) 76%, #6f7687 24%);
  --icon-color-hover: color-mix(in srgb, #ffffff 92%, var(--accent-strong) 8%);
  --icon-button-hover-bg: color-mix(in srgb, var(--surface-2) 74%, transparent);
  --icon-button-active-bg: color-mix(in srgb, var(--surface-2) 88%, transparent);
  --accent: #6d90ff;
  --accent-soft: rgba(109, 144, 255, 0.16);
  --accent-strong: #8eabff;
  --success: #32d583;
  --warning: #fdb022;
  --terminal-surface: #121214;
  --terminal-line: rgba(220, 232, 255, 0.88);
  --terminal-line-muted: rgba(179, 191, 214, 0.84);
  --terminal-line-warning: #ffbf85;
  --terminal-line-accent: #9fc1ff;
  --shadow-soft: none;
  --shadow-card: none;
}

/* Basic reset keeps the static mockup visually stable across browsers. */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
}

body {
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-ui);
  overflow: hidden;
  transition:
    background-color var(--duration-slow) ease,
    color var(--duration-fast) ease;
}

button,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  height: var(--app-viewport-height);
  min-height: var(--app-viewport-height);
  display: grid;
  grid-template-rows: var(--header-height) minmax(0, 1fr) var(--footer-height);
  background: var(--bg-canvas);
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  height: var(--header-height);
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg-panel) 94%, transparent);
  border-bottom: 1px solid var(--line-soft);
}

.topbar__left,
.topbar__center,
.topbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.topbar__center {
  justify-content: space-between;
  min-width: 0;
}

.topbar__right {
  justify-content: flex-end;
  gap: 0.6rem;
  white-space: nowrap;
}

.topbar__mobile-context,
.icon-button--mobile-settings,
.composer__options-toggle,
.mobile-shell-backdrop {
  display: none;
}

.topbar__mobile-context {
  min-width: 0;
}

.topbar__mobile-context strong,
.topbar__mobile-context span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__mobile-context strong {
  color: var(--text-primary);
  font-size: 0.96rem;
  line-height: 1.16;
}

.topbar__mobile-context span {
  margin-top: 0.1rem;
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.1;
}

.mobile-shell-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  border: 0;
  background: rgba(9, 11, 17, 0.48);
  backdrop-filter: blur(5px);
}

.icon-button,
.ghost-button,
.small-button,
.primary-button,
.project-card,
.thread-row,
.segmented-control__item {
  border: 1px solid transparent;
  transition:
    transform var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    background-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease;
}

.ghost-button,
.small-button {
  background: var(--bg-subtle);
  border-color: var(--line-soft);
  color: var(--text-primary);
}

.icon-button--plain,
.ghost-button--toolbar {
  background: transparent;
}

.icon-button:hover,
.ghost-button:hover,
.small-button:hover,
.project-card:hover,
.thread-row:hover,
.segmented-control__item:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  gap: 3px;
  padding: 0;
  /* Icon-only controls stay chrome-light so the glyph state, not a button frame, carries the affordance. */
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  box-shadow: none;
}

/* Shared SVG icon sizing keeps the static shell and dynamic renderers on one visual contract. */
.app-icon {
  width: 16px;
  height: 16px;
  display: block;
  flex: 0 0 auto;
  color: inherit;
}

.app-icon--sm {
  width: 16px;
  height: 16px;
}

.app-icon--md {
  width: 19px;
  height: 19px;
}

.app-icon--lg {
  width: 24px;
  height: 24px;
}

.app-icon--interactive {
  color: var(--icon-color);
  transition: color var(--duration-fast) ease;
}

.icon-button--sidebar-toggle {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: transparent;
  border-color: transparent;
}

.topbar .icon-button {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.topbar .icon-button:hover {
  background: var(--icon-button-hover-bg);
  color: var(--text-primary);
}

.icon-button:hover,
.icon-button:focus-visible {
  background: var(--icon-button-hover-bg);
  border-color: transparent;
}

.icon-button:active,
.thread-rail-header-actions .icon-button.is-active {
  background: var(--icon-button-active-bg);
  border-color: transparent;
}

.icon-button:hover .app-icon--interactive,
.icon-button:focus-visible .app-icon--interactive,
.sidebar-nav__item:hover .app-icon--interactive,
.sidebar-nav__item:focus-visible .app-icon--interactive,
.sidebar-settings:hover .app-icon--interactive,
.sidebar-settings:focus-visible .app-icon--interactive,
.settings-back:hover .app-icon--interactive,
.settings-back:focus-visible .app-icon--interactive,
.settings-nav__item:hover .app-icon--interactive,
.settings-nav__item:focus-visible .app-icon--interactive,
.runtime-toggle__item:hover .app-icon--interactive,
.runtime-toggle__item:focus-visible .app-icon--interactive,
.send-button:hover .app-icon--interactive,
.send-button:focus-visible .app-icon--interactive {
  color: var(--icon-color-hover);
}

.settings-nav__item.is-active .app-icon--interactive,
.runtime-toggle__item--active .app-icon--interactive {
  color: var(--text-primary);
}

.topbar .icon-button:focus-visible {
  outline: 3px solid rgba(42, 109, 246, 0.18);
  outline-offset: 2px;
}

.topbar-symbol {
  width: auto;
  height: auto;
  background: transparent;
  border-radius: 0;
  font-size: 0.8rem;
  line-height: 1;
  letter-spacing: 0;
  color: var(--text-muted);
}

.toolbar-select {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: color-mix(in srgb, var(--bg-subtle) 76%, transparent);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 0.2rem 0.5rem 0.2rem 0.62rem;
  color: var(--text-secondary);
}

.toolbar-select span {
  font-size: 0.78rem;
}

.toolbar-select select {
  min-width: 0;
  min-height: 2rem;
  padding: 0.26rem 1.7rem 0.26rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--line-soft) 88%, transparent);
  border-radius: 999px;
  /* Native select menus keep their own popup chrome, so the control itself needs a strong dark surface. */
  background-color: color-mix(in srgb, var(--bg-panel) 94%, var(--bg-subtle));
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 0.9rem) calc(50% - 0.06rem),
    calc(100% - 0.65rem) calc(50% - 0.06rem);
  background-repeat: no-repeat;
  background-size: 0.32rem 0.32rem;
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

[data-theme="dark"] .toolbar-select select {
  color-scheme: dark;
  background-color: color-mix(in srgb, var(--bg-panel) 90%, black 10%);
  border-color: color-mix(in srgb, var(--line-soft) 84%, var(--text-muted));
}

.toolbar-select select option {
  background-color: var(--bg-panel);
  color: var(--text-primary);
}

[data-theme="dark"] .toolbar-select select option {
  background-color: color-mix(in srgb, var(--bg-panel) 92%, black 8%);
  color: var(--text-primary);
}

.toolbar-select--composer {
  min-width: 154px;
}

.toolbar-select.is-disabled {
  opacity: 0.52;
  border-color: color-mix(in srgb, var(--line-soft) 82%, transparent);
  background: color-mix(in srgb, var(--bg-subtle) 92%, transparent);
}

.toolbar-select select:disabled {
  cursor: not-allowed;
  color: var(--text-muted);
}

.composer__mode.is-hidden {
  display: none;
}

.status-pill,
.info-chip,
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border-radius: 8px;
  white-space: nowrap;
}

.status-pill,
.info-chip {
  padding: 0.45rem 0.7rem;
  background: var(--bg-subtle);
  border: 1px solid var(--line-soft);
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.badge {
  padding: 0.4rem 0.65rem;
  background: var(--bg-subtle);
  border: 1px solid var(--line-soft);
  color: var(--text-secondary);
  font-size: 0.78rem;
}

.badge--live {
  background: color-mix(in srgb, var(--success) 18%, var(--bg-subtle));
  color: var(--text-primary);
}

.badge--muted {
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.status-pill--warning {
  border-color: color-mix(in srgb, var(--warning) 42%, var(--line-soft));
  color: color-mix(in srgb, var(--warning) 72%, var(--text-primary));
}

.header-status-pill {
  background: color-mix(in srgb, var(--bg-subtle) 88%, transparent);
}

.status-pill__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-pill__dot--green {
  background: var(--success);
  box-shadow: 0 0 0 6px rgba(30, 155, 99, 0.12);
}

.ghost-button,
.small-button,
.primary-button {
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
}

.small-button {
  padding: 0.45rem 0.75rem;
  font-size: 0.86rem;
}

.small-button--danger {
  border-color: color-mix(in srgb, #ff7f7f 40%, var(--line-soft));
  background: color-mix(in srgb, #ff7f7f 10%, var(--bg-subtle));
}

.primary-button {
  background: var(--accent);
  color: white;
  border-color: color-mix(in srgb, var(--accent) 70%, black);
  box-shadow: none;
}

.primary-button:hover {
  transform: translateY(-1px);
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns:
    var(--sidebar-width)
    var(--shell-resize-handle-size)
    minmax(0, 1fr)
    var(--shell-resize-handle-size)
    var(--inspector-width);
  gap: 0;
  padding: 0;
  height: calc(var(--app-viewport-height) - var(--header-height) - var(--footer-height));
  min-height: 0;
  overflow: hidden;
  background: var(--bg-canvas);
}

.workspace:has(.sidebar.is-hidden) {
  grid-template-columns: minmax(0, 1fr) var(--shell-resize-handle-size) var(--inspector-width);
}

.workspace:has(.inspector.is-hidden) {
  grid-template-columns: var(--sidebar-width) var(--shell-resize-handle-size) minmax(0, 1fr);
}

.workspace:has(.sidebar.is-hidden):has(.inspector.is-hidden) {
  grid-template-columns: minmax(0, 1fr);
}

.workspace:has(#view-settings.is-active) {
  grid-template-columns: minmax(0, 1fr);
}

.workspace:has(#view-settings.is-active) .sidebar,
.workspace:has(#view-settings.is-active) .inspector,
.workspace:has(#view-settings.is-active) .shell-resize-handle {
  display: none;
}

.sidebar,
.content-area,
.inspector,
.shell-resize-handle {
  min-height: 0;
}

.sidebar {
  grid-column: 1;
}

#sidebar-resize-handle {
  grid-column: 2;
}

.content-area {
  grid-column: 3;
}

#inspector-resize-handle {
  grid-column: 4;
}

.inspector {
  grid-column: 5;
}

.workspace:has(.sidebar.is-hidden) #sidebar-resize-handle,
.workspace:has(.inspector.is-hidden) #inspector-resize-handle,
.workspace:has(.sidebar.is-hidden):has(.inspector.is-hidden) .shell-resize-handle {
  display: none;
}

.workspace:has(.sidebar.is-hidden) .content-area {
  grid-column: 1;
}

.workspace:has(.sidebar.is-hidden) #inspector-resize-handle {
  grid-column: 2;
}

.workspace:has(.sidebar.is-hidden) .inspector {
  grid-column: 3;
}

.workspace:has(.inspector.is-hidden) .content-area {
  grid-column: 3;
}

.workspace:has(.sidebar.is-hidden):has(.inspector.is-hidden) .content-area,
.workspace:has(#view-settings.is-active) .content-area {
  grid-column: 1;
}

.sidebar.is-hidden {
  display: none;
}

/* Resize handles stay intentionally subtle so the shell looks calm until the pointer hovers near a draggable edge. */
.shell-resize-handle {
  position: relative;
  display: block;
  touch-action: none;
  user-select: none;
  background: transparent;
}

.shell-resize-handle::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  background: color-mix(in srgb, var(--line-strong) 62%, transparent);
  opacity: 0.34;
  transition: opacity var(--duration-fast) ease, background-color var(--duration-fast) ease;
}

.shell-resize-handle:hover::before,
.app-shell.is-shell-resizing .shell-resize-handle::before {
  opacity: 0.76;
  background: color-mix(in srgb, var(--accent) 48%, var(--line-strong));
}

.shell-resize-handle--sidebar,
.shell-resize-handle--inspector {
  cursor: col-resize;
}

.shell-resize-handle--sidebar::before,
.shell-resize-handle--inspector::before {
  width: 2px;
  height: calc(100% - 1.4rem);
  border-radius: 999px;
}

.shell-resize-handle--terminal {
  flex: 0 0 var(--shell-resize-handle-size);
  cursor: row-resize;
}

.shell-resize-handle--terminal::before {
  width: calc(100% - 2rem);
  height: 2px;
  border-radius: 999px;
}

.app-shell.is-shell-resizing,
body.is-shell-resizing {
  cursor: col-resize;
}

.app-shell.is-shell-resizing .shell-resize-handle--terminal,
body.is-shell-resizing .shell-resize-handle--terminal {
  cursor: row-resize;
}

.sidebar,
.welcome-card,
.picker-modal,
.dialog-card {
  background: var(--bg-panel);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-soft);
}

.dialog-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.dialog-layer.is-hidden {
  display: none;
}

.dialog-layer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 12, 17, 0.72);
  backdrop-filter: blur(10px);
}

.dialog-card {
  position: relative;
  z-index: 1;
  width: min(100%, 32rem);
  border-radius: 18px;
  padding: 1.15rem;
  background: color-mix(in srgb, var(--bg-panel) 92%, #0f1520);
  display: grid;
  gap: 1rem;
}

.dialog-card__header,
.dialog-card__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.dialog-card__header strong {
  color: var(--text-primary);
  font-size: 1.02rem;
}

.dialog-card__message,
.dialog-form {
  display: grid;
  gap: 0.85rem;
}

.dialog-card__message p,
.dialog-form p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.55;
}

.dialog-card__detail {
  white-space: pre-wrap;
  border-radius: 14px;
  border: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg-muted) 82%, transparent);
  padding: 0.9rem 1rem;
  color: var(--text-primary);
  line-height: 1.55;
}

.dialog-card__error {
  border-radius: 12px;
  border: 1px solid rgba(255, 122, 122, 0.25);
  background: rgba(120, 18, 18, 0.18);
  color: #ffb8b8;
  padding: 0.8rem 0.9rem;
  font-size: 0.92rem;
}

.dialog-form__field {
  display: grid;
  gap: 0.4rem;
}

.dialog-form__field span {
  color: var(--text-primary);
  font-size: 0.92rem;
  font-weight: 600;
}

.dialog-form__field small {
  color: var(--text-muted);
  line-height: 1.45;
}

.dialog-form__input {
  width: 100%;
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--line-soft) 70%, transparent);
  background: color-mix(in srgb, var(--bg-base) 78%, var(--bg-muted));
  color: var(--text-primary);
  padding: 0.75rem 0.9rem;
}

.dialog-form__input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent-strong) 72%, white);
  box-shadow: 0 0 0 3px rgba(99, 146, 255, 0.18);
}

.dialog-button {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  padding: 0 1rem;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent-strong) 88%, white), var(--accent-strong));
  color: white;
  font-weight: 600;
  cursor: pointer;
}

.dialog-button--ghost {
  background: transparent;
  border: 1px solid var(--line-soft);
  color: var(--text-secondary);
}

.dialog-button--danger {
  background: linear-gradient(135deg, #f16b6b, #c93d3d);
}

.sidebar {
  border-radius: 0;
  padding: 0.95rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  overflow: hidden;
  border-top: 0;
  border-left: 0;
  border-bottom: 0;
  background: color-mix(in srgb, var(--bg-panel) 88%, var(--bg-muted));
}

.sidebar-panel {
  flex: 0 0 auto;
  background: transparent;
  border: 0;
  border-radius: 0;
  min-height: 0;
  padding: 0.3rem 0;
}

.sidebar-panel--threads {
  /* The thread rail owns the remaining sidebar height so only the project list scrolls on desktop. */
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-panel--compact {
  /* The settings entry stays pinned below the scrollable thread rail instead of drifting with long lists. */
  flex: 0 0 auto;
  margin-top: 0;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line-soft);
}

.sidebar-panel__header,
.inspector-panel__header,
.picker-modal__header,
.run-card__header,
.composer__footer,
.picker-modal__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.sidebar-panel__header,
.inspector-panel__header {
  margin-bottom: 0.9rem;
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.sidebar-panel__header--plain {
  margin-bottom: 0.6rem;
}

.sidebar-panel__header--tools {
  margin-bottom: 0.55rem;
}

.thread-rail-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}

.thread-rail-tools {
  flex: 0 0 auto;
  display: grid;
  gap: 0.7rem;
  margin: 0 0 0.75rem;
  padding: 0.7rem 0 0.8rem;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

#thread-list-container {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.thread-rail-tools__meta,
.thread-rail-tools__controls {
  display: grid;
  gap: 0.55rem;
}

.thread-rail-tools__meta {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  color: var(--text-muted);
  font-size: 0.76rem;
}

.thread-rail-field {
  display: grid;
  gap: 0.3rem;
}

.thread-rail-field span {
  color: var(--text-muted);
  font-size: 0.74rem;
}

.thread-rail-field input,
.thread-rail-field select {
  min-height: 2rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
}

.thread-rail-field input::placeholder {
  color: var(--text-muted);
}

.sidebar-divider {
  height: 1px;
  margin: 0.2rem 0 0.9rem;
  background: var(--line-soft);
}

.sidebar-nav,
.thread-group {
  display: grid;
  gap: 0.25rem;
}

.sidebar-nav__item,
.thread-row {
  width: 100%;
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
}

.sidebar-nav__item {
  padding: 0 0.35rem;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}

.thread-group + .thread-group {
  margin-top: 0.7rem;
}

.thread-group__header-row {
  display: flex;
  align-items: flex-start;
  gap: 0.3rem;
}

.thread-group__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
  min-height: 32px;
  padding: 0.15rem 0.2rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

.thread-group {
  position: relative;
  min-width: 0;
}

.thread-group__header-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  flex: 0 0 auto;
  margin: 0;
  padding-top: 0.1rem;
}

.thread-group__header--active .thread-group__title {
  color: var(--text-primary);
}

.thread-group__title {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1 1 auto;
}

.thread-group__title-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-group__header-summary {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  min-width: 0;
}

.thread-group__chevron {
  width: 0.5rem;
  height: 0.5rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  flex: 0 0 auto;
  transform: rotate(-45deg) translateY(-0.02rem);
  transition: transform 140ms ease;
}

.thread-group__chevron--expanded {
  transform: rotate(45deg) translateY(-0.08rem);
}

.thread-group__count {
  color: var(--text-muted);
  font-size: 0.74rem;
  line-height: 1;
  min-width: 1.5rem;
  text-align: center;
}

.thread-group__menu {
  position: absolute;
  top: 2.2rem;
  right: 0;
  z-index: 4;
  display: grid;
  gap: 0.2rem;
  min-width: 12rem;
  padding: 0.35rem;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--bg-panel);
  box-shadow: var(--shadow-soft);
}

.thread-group__menu-item {
  min-height: 2.2rem;
  padding: 0.4rem 0.65rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  text-align: left;
}

.thread-group__menu-item:hover {
  background: color-mix(in srgb, var(--bg-subtle) 88%, transparent);
}

.thread-group__menu-item--danger {
  color: color-mix(in srgb, #ff6a6a 82%, var(--text-primary));
}

.thread-group__menu-item--danger:hover {
  background: color-mix(in srgb, rgba(255, 106, 106, 0.18) 88%, transparent);
}

.project-card,
.thread-row,
.picker-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.55rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.project-card + .project-card,
.picker-item + .picker-item {
  margin-top: 0.75rem;
}

.project-card--active,
.thread-row--active,
.picker-item--selected {
  background: color-mix(in srgb, var(--bg-subtle) 86%, var(--accent) 14%);
  border-color: color-mix(in srgb, var(--accent) 22%, var(--line-soft));
}

.thread-row-shell {
  display: flex;
  align-items: center;
  gap: 0.18rem;
  min-width: 0;
}

.thread-row-shell + .thread-row-shell {
  margin-top: 0.08rem;
}

.thread-group__header + .thread-row-shell,
.thread-group__menu + .thread-row-shell,
.thread-group__header-row + .thread-row-shell,
.thread-group__header-row + .thread-group__empty {
  margin-top: 0.22rem;
}

.thread-row-shell--active {
  background: color-mix(in srgb, var(--bg-subtle) 94%, #ffffff 6%);
  border-radius: 6px;
}

.thread-row {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  padding: 0 0.4rem;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  flex: 1 1 auto;
  min-width: 0;
}

.thread-row__title {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-row__main,
.thread-row__meta,
.thread-row__markers {
  display: inline-flex;
  align-items: center;
}

.thread-row__main {
  gap: 0.38rem;
  min-width: 0;
  flex: 1 1 auto;
}

.thread-row__meta {
  gap: 0.35rem;
  margin-left: auto;
  min-width: 0;
  flex: 0 1 auto;
}

.thread-row__markers {
  gap: 0.24rem;
  min-width: 1rem;
}

.thread-row__unread {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 140ms ease, transform 140ms ease, background-color 140ms ease;
}

.thread-row__unread--visible {
  background: #4b8dff;
  opacity: 1;
  transform: scale(1);
}

.thread-row__activity {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.6px solid color-mix(in srgb, var(--text-muted) 32%, transparent);
  border-top-color: var(--text-primary);
  border-right-color: color-mix(in srgb, var(--accent) 78%, var(--text-primary));
  animation: thread-activity-spin 0.9s linear infinite;
}

.thread-row__badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, var(--bg-subtle));
  color: var(--text-secondary);
  font-size: 0.7rem;
  line-height: 1;
}

.thread-row--active {
  background: color-mix(in srgb, var(--bg-subtle) 94%, #ffffff 6%);
  box-shadow: none;
}

.thread-row--active .thread-row__title {
  color: var(--text-primary);
}

.thread-row__action {
  opacity: 0.68;
  flex: 0 0 auto;
}

.thread-row-shell:hover .thread-row__action,
.thread-row-shell--active .thread-row__action,
.thread-row__action:focus-visible {
  opacity: 1;
}

@media (hover: hover) and (pointer: fine) {
  /* Fine-pointer layouts keep secondary sidebar actions quiet until the user intentionally engages the row. */
  .thread-group__header-actions .icon-button,
  .thread-row__action {
    opacity: 0;
    pointer-events: none;
    transition: opacity 140ms ease;
  }

  .thread-group:hover .thread-group__header-actions .icon-button,
  .thread-group:focus-within .thread-group__header-actions .icon-button,
  .thread-group--menu-open .thread-group__header-actions .icon-button,
  .thread-row-shell:hover .thread-row__action,
  .thread-row-shell:focus-within .thread-row__action,
  .thread-row-shell--active .thread-row__action {
    opacity: 1;
    pointer-events: auto;
  }
}

.project-card__title,
.thread-row__title,
.picker-item__title {
  font-weight: 700;
}

.thread-group__empty {
  display: grid;
  gap: 0.55rem;
  padding: 0.6rem 0.4rem 0.15rem 1.55rem;
}

.thread-group__empty-copy {
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.project-card__meta,
.picker-item__meta,
.message__header time,
.meta-list dt,
.stack-item span {
  color: var(--text-muted);
  font-size: 0.84rem;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-subtle);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 0.2rem;
}

.segmented-control__item {
  border-radius: 8px;
  border: 0;
  background: transparent;
  padding: 0.65rem 0.4rem;
  color: var(--text-secondary);
}

.segmented-control__item.is-active {
  background: var(--bg-panel);
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
}

.content-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
  background: var(--bg-canvas);
}

.stage {
  display: none;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.stage.is-active {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.conversation-shell {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-canvas);
}

.conversation-header {
  display: none;
}

.conversation-header__title {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
}

.conversation-header__title h1 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.1;
}

.conversation-header__title span {
  color: var(--text-muted);
  font-size: 0.94rem;
  font-weight: 600;
}

.conversation-header__actions {
  margin-left: auto;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
}

.icon-button--tiny {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}

/* Icon-driven surfaces now rely on the shared SVG sprite instead of CSS-drawn glyphs. */
.thread-group__title .app-icon,
.composer__mode .app-icon {
  color: currentColor;
}

.thread-group__header:hover,
.thread-group__header:focus-visible {
  background: color-mix(in srgb, var(--bg-subtle) 90%, transparent);
  border-color: color-mix(in srgb, var(--line-soft) 88%, transparent);
}

.sidebar-settings {
  width: 100%;
  min-height: 32px;
  padding: 0 0.35rem;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-align: left;
}

.settings-view {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 100%;
  background: var(--bg-canvas);
}

.settings-sidebar {
  padding: 1.15rem 0.75rem;
  border-right: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg-panel) 88%, var(--bg-muted));
}

.settings-back {
  width: 100%;
  min-height: 38px;
  margin-bottom: 1rem;
  padding: 0 0.4rem;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-align: left;
}

.settings-nav {
  display: grid;
  gap: 0.12rem;
}

.settings-nav__item {
  width: 100%;
  min-height: 40px;
  padding: 0 0.5rem;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-align: left;
}

.settings-nav__item.is-active {
  background: color-mix(in srgb, var(--accent) 9%, var(--bg-subtle));
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line-soft));
  color: var(--text-primary);
  font-weight: 600;
}

.settings-content {
  overflow: auto;
  padding: 2.6rem 2rem 3rem;
  background: var(--bg-canvas);
}

.settings-content__inner {
  width: min(820px, 100%);
  margin: 0 auto;
}

.settings-content__inner h1 {
  margin: 0 0 2rem;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.settings-content__summary {
  margin: -1.15rem 0 1rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.settings-feedback {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  margin-bottom: 1rem;
  padding: 0 0.95rem;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg-subtle) 82%, transparent);
  color: var(--text-secondary);
}

.settings-feedback.is-hidden {
  display: none;
}

.settings-feedback--saved {
  color: var(--accent-strong);
}

.settings-feedback--action {
  color: var(--success);
}

.settings-panels {
  display: grid;
}

.settings-section {
  display: block;
}

.settings-card {
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg-panel) 96%, transparent);
  overflow: hidden;
}

/* The integration setup card keeps guided onboarding visible inside the normal settings flow instead of pushing users into a hidden admin path. */
.settings-setup-card {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line-soft));
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg-panel) 88%, var(--accent) 8%);
  display: grid;
  gap: 0.95rem;
}

.settings-setup-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.settings-setup-card__header p,
.settings-setup-copy p {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  line-height: 1.45;
}

.settings-setup-copy h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-primary);
}

.settings-setup-steps,
.settings-setup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.settings-step-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 0.75rem;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-subtle) 76%, transparent);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.settings-step-chip--active {
  border-color: color-mix(in srgb, var(--accent) 36%, var(--line-soft));
  color: var(--text-primary);
}

.settings-step-chip--done {
  color: var(--success);
}

.settings-setup-preview {
  display: grid;
  gap: 0.55rem;
}

.settings-setup-preview__item {
  display: grid;
  gap: 0.15rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-subtle) 74%, transparent);
}

.settings-setup-preview__item strong {
  color: var(--text-primary);
}

.settings-setup-preview__item span {
  color: var(--text-muted);
  font-size: 0.84rem;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 1.5rem;
  padding: 1rem 1rem 1.05rem;
  border-top: 1px solid var(--line-soft);
}

.settings-row:first-child {
  border-top: 0;
}

.settings-row--stacked {
  grid-template-columns: minmax(0, 1fr);
}

.settings-row strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.98rem;
  color: var(--text-primary);
}

.settings-row p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.45;
}

.provider-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.9rem;
}

.provider-card {
  display: grid;
  gap: 0.9rem;
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg-subtle) 82%, transparent);
}

.provider-card__header,
.provider-card__identity,
.provider-card__meta,
.provider-card__actions {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.provider-card__header {
  justify-content: space-between;
}

.provider-card__identity {
  min-width: 0;
}

.provider-card__identity strong {
  margin-bottom: 0.2rem;
}

.provider-card__identity p,
.provider-card__hint {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.45;
}

.provider-card__meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  flex-wrap: wrap;
  width: 100%;
}

.provider-card__meta > * {
  /* Keep provider form controls inside their card instead of forcing the grid wider. */
  min-width: 0;
}

.provider-card__capabilities {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.provider-card__capabilities span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 0.7rem;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-panel) 76%, transparent);
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.provider-card__actions {
  flex-wrap: wrap;
}

.settings-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.settings-meta-details {
  margin-top: 0.75rem;
}

.settings-meta-details summary {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 30px;
  padding: 0 0.7rem;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-subtle) 72%, transparent);
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.settings-meta-details summary::-webkit-details-marker {
  display: none;
}

.settings-meta-details[open] summary {
  background: color-mix(in srgb, var(--bg-subtle) 62%, var(--accent) 10%);
  color: var(--text-primary);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line-soft));
}

.settings-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  min-height: 28px;
  padding: 0 0.6rem;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-subtle) 72%, transparent);
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1;
}

.settings-chip strong {
  margin: 0;
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.settings-select select {
  min-width: 290px;
  min-height: 36px;
  padding: 0 0.85rem;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg-panel) 94%, var(--bg-subtle));
  color: var(--text-primary);
}

.settings-input input {
  min-width: 290px;
  min-height: 36px;
  padding: 0 0.85rem;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg-panel) 94%, var(--bg-subtle));
  color: var(--text-primary);
}

.settings-inline-action,
.settings-pill-group {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
}

.settings-action-button {
  min-height: 36px;
  padding: 0 0.95rem;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg-panel) 92%, var(--bg-subtle));
  color: var(--text-primary);
}

/* Compact table actions keep row-specific OAuth controls readable without stretching the full settings grid. */
.settings-action-button--small {
  min-height: 30px;
  padding: 0 0.7rem;
  border-radius: 10px;
  font-size: 0.78rem;
}

.settings-switch {
  width: 40px;
  height: 24px;
  border: 1px solid color-mix(in srgb, var(--line-strong) 85%, transparent);
  border-radius: 999px;
  padding: 2px;
  background: color-mix(in srgb, var(--bg-muted) 84%, var(--bg-panel));
}

.settings-switch span {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-panel);
  transition: transform var(--duration-fast) ease;
}

.settings-switch.is-on {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 88%, white 12%);
}

.settings-switch.is-on span {
  transform: translateX(16px);
}

.settings-pill {
  min-height: 34px;
  padding: 0 0.9rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
}

.settings-pill--active {
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-subtle));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--text-primary);
}

.settings-status {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 0.9rem;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--line-soft);
  white-space: nowrap;
}

.settings-note {
  display: grid;
  gap: 0.35rem;
  width: min(100%, 620px);
  padding: 0.8rem 0.9rem;
  border-radius: 14px;
  border: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg-subtle) 72%, transparent);
  color: var(--text-secondary);
  line-height: 1.45;
  white-space: normal;
}

.settings-note strong,
.settings-note p {
  margin: 0;
}

.settings-note--error {
  border-color: color-mix(in srgb, #d46f6f 38%, var(--line-soft));
  background: color-mix(in srgb, #d46f6f 12%, var(--bg-panel));
  color: var(--text-primary);
}

.settings-disabled-hint {
  margin-top: 0.7rem;
  color: var(--warning);
  font-size: 0.83rem;
  line-height: 1.5;
}

.settings-status--ok {
  color: var(--success);
}

.settings-status--muted {
  color: var(--text-muted);
}

.settings-code {
  /* Long host-login commands must wrap inside cards so adjacent providers do not overlap. */
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--line-soft);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.settings-table,
.settings-list,
.settings-grid {
  display: grid;
  gap: 0.75rem;
}

.settings-table {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  overflow: hidden;
}

.settings-table__row {
  display: grid;
  grid-template-columns: repeat(var(--settings-table-columns, 4), minmax(0, 1fr));
  gap: 1rem;
  padding: 0.8rem 0.9rem;
  border-top: 1px solid var(--line-soft);
  background: transparent;
  color: var(--text-secondary);
}

.settings-table__row:first-child {
  border-top: 0;
}

.settings-table__row--head {
  background: color-mix(in srgb, var(--bg-subtle) 82%, transparent);
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.settings-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 42px;
  padding: 0 0.9rem;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg-subtle) 68%, transparent);
}

.settings-list__item span {
  color: var(--text-muted);
}

.settings-list__value {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  flex-wrap: wrap;
  text-align: right;
}

.settings-grid {
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
}

.settings-surface {
  min-height: 150px;
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: color-mix(in srgb, var(--bg-subtle) 76%, transparent);
  display: grid;
  align-content: start;
  gap: 0.75rem;
}

.settings-surface--active {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line-soft));
  background: color-mix(in srgb, var(--bg-subtle) 72%, var(--accent) 8%);
}

.settings-surface strong {
  font-size: 0.96rem;
}

.settings-surface p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.45;
}

.settings-surface .settings-note {
  width: 100%;
}

@media (max-width: 1180px) {
  .settings-view {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-table__row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .settings-view {
    grid-template-columns: 1fr;
  }

  .settings-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .settings-content {
    padding: 1.5rem 1rem 2rem;
  }

  .settings-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-select select {
    min-width: 100%;
  }
}

.skills-view__inner {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 2.5rem 2rem 3rem;
}

.skills-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.skills-header h1 {
  margin: 0.2rem 0 0.45rem;
  color: var(--text-primary);
  font-size: 1.65rem;
}

.skills-header p,
.skill-card p,
.skills-empty-state p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.skills-header__eyebrow {
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.skills-summary,
.skills-toolbar,
.skills-diagnostics,
.skills-restart-note,
.skills-feedback {
  margin-bottom: 1rem;
}

.skills-summary,
.skills-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.skills-summary span,
.skill-card__meta span,
.skill-card__status,
.skills-feedback {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 0.65rem;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-subtle) 72%, transparent);
  color: var(--text-muted);
  font-size: 0.78rem;
}

.skills-summary strong {
  margin-right: 0.3rem;
  color: var(--text-primary);
}

.skills-toolbar label {
  display: grid;
  gap: 0.35rem;
  min-width: min(100%, 240px);
  color: var(--text-muted);
  font-size: 0.78rem;
}

.skills-toolbar input,
.skills-toolbar select {
  min-height: 38px;
  padding: 0 0.8rem;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-panel) 94%, var(--bg-subtle));
  color: var(--text-primary);
}

.skills-feedback--error {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--line-soft));
  color: var(--danger);
}

.skills-diagnostics,
.skills-restart-note,
.skills-empty-state {
  padding: 0.9rem 1rem;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-subtle) 72%, transparent);
  display: grid;
  gap: 0.4rem;
}

.skills-diagnostics span,
.skills-restart-note span {
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.skill-card {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-panel) 94%, transparent);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
}

.skill-card--disabled {
  opacity: 0.72;
}

.skill-card__main {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.skill-card__copy {
  min-width: 0;
  display: grid;
  gap: 0.45rem;
}

.skill-card__title-row,
.skill-card__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.skill-card__title-row strong,
.skill-card__name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.skill-card__name {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.skill-card__status--enabled {
  color: var(--success);
}

.skill-card__status--disabled {
  color: var(--warning);
}

.skill-card__icon {
  flex: 0 0 42px;
  width: 42px;
  aspect-ratio: 1;
  border: 1px solid color-mix(in srgb, var(--skill-brand-color, var(--accent)) 26%, var(--line-soft));
  border-radius: 8px;
  background: color-mix(in srgb, var(--skill-brand-color, var(--accent)) 12%, var(--bg-subtle));
  display: inline-grid;
  place-items: center;
  color: var(--text-primary);
  font-weight: 800;
  overflow: hidden;
}

.skill-card__icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.skill-toggle {
  width: 42px;
  height: 26px;
  padding: 2px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--bg-subtle);
}

.skill-toggle span {
  display: block;
  width: 20px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--duration-fast) ease, background var(--duration-fast) ease;
}

.skill-toggle.is-on {
  background: color-mix(in srgb, var(--accent) 24%, var(--bg-subtle));
}

.skill-toggle.is-on span {
  background: var(--accent);
  transform: translateX(16px);
}

@media (max-width: 760px) {
  .skills-view__inner {
    padding: 1.5rem 1rem 2rem;
  }

  .skills-header,
  .skill-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .skills-grid {
    grid-template-columns: 1fr;
  }

  .skill-toggle {
    justify-self: start;
  }
}

.welcome-card h2,
.welcome-card h2,
.picker-modal h2 {
  margin: 0.35rem 0 0.65rem;
  font-size: clamp(1.6rem, 2.8vw, 2.35rem);
  line-height: 1.05;
}

.welcome-card p,
.approval-card p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.6;
}

.conversation-stream {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.15rem 0 1.7rem;
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg-canvas) 96%, var(--bg-subtle)), var(--bg-canvas));
}

.conversation-stream,
#thread-list-container,
.terminal--dock .xterm-viewport {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--text-muted) 36%, transparent) transparent;
}

.conversation-stream::-webkit-scrollbar,
#thread-list-container::-webkit-scrollbar,
.terminal--dock .xterm-viewport::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.conversation-stream::-webkit-scrollbar-track,
#thread-list-container::-webkit-scrollbar-track,
.terminal--dock .xterm-viewport::-webkit-scrollbar-track {
  background: transparent;
}

.conversation-stream::-webkit-scrollbar-thumb,
#thread-list-container::-webkit-scrollbar-thumb,
.terminal--dock .xterm-viewport::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 30%, var(--bg-subtle));
  background-clip: padding-box;
}

.conversation-stream::-webkit-scrollbar-thumb:hover,
#thread-list-container::-webkit-scrollbar-thumb:hover,
.terminal--dock .xterm-viewport::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--text-secondary) 42%, var(--bg-subtle));
  background-clip: padding-box;
}

.prompt-preview,
.response-block,
.timeline-note,
.conversation-divider,
.composer--dock {
  width: min(920px, calc(100% - 3rem));
  margin: 0 auto;
}

.prompt-preview {
  display: flex;
  justify-content: flex-end;
  padding: 0.2rem 0 0.9rem;
}

.timeline-card__body {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.timeline-card__bubble {
  width: min(72%, 680px);
  padding: 0.95rem 1.05rem 1rem;
  border: 1px solid color-mix(in srgb, var(--line-soft) 72%, transparent);
  border-radius: 20px;
  background: color-mix(in srgb, var(--bg-panel) 78%, #111 22%);
}

.prompt-preview__attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.attachment--inline {
  background: color-mix(in srgb, var(--bg-panel) 72%, var(--bg-subtle));
}

.conversation-divider {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.conversation-divider::before,
.conversation-divider::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--line-soft);
}

.response-block {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.3rem 0 1.15rem;
}

/* The conversation stream should read like a markdown document with clear user bubbles, not like dashboard cards. */
.timeline-card {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  padding: 0.4rem 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  border: 0;
}

.timeline-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.timeline-note {
  padding: 0.8rem 0;
}

.timeline-card--user .timeline-card__body,
.timeline-card--assistant .timeline-card__body {
  color: var(--text-primary);
}

.timeline-files {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.45rem;
}

.timeline-card--assistant {
  padding-left: 0;
  padding-right: 0;
}

.timeline-card--assistant .timeline-card__content {
  width: min(860px, 100%);
}

/* User prompts stay as the only bubble shape so they remain easy to scan against the flat assistant transcript. */
.conversation-turn--user .timeline-card__body {
  font-size: 0.99rem;
  line-height: 1.62;
  color: color-mix(in srgb, var(--text-primary) 96%, white 4%);
}

.conversation-turn--user {
  align-items: flex-end;
}

.conversation-turn--user .conversation-turn__bubble {
  margin-left: auto;
}

.conversation-turn--user .timeline-files {
  justify-content: flex-end;
}

/* Assistant output should feel like rendered markdown, not like a boxed panel or timeline event. */
.conversation-turn--assistant {
  align-items: flex-start;
}

.conversation-turn--assistant .timeline-card__content {
  display: block;
}

.conversation-turn__body {
  min-width: 0;
}

.conversation-turn__body--with-provider {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: start;
  column-gap: 0.55rem;
}

.conversation-turn__markdown {
  min-width: 0;
}

.conversation-turn__provider,
.conversation-progress__provider {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  opacity: 0.72;
  flex: 0 0 auto;
}

.conversation-turn__provider-icon,
.conversation-progress__provider-icon {
  width: 14px;
  height: 14px;
}

.conversation-turn__provider {
  margin-top: 0.22rem;
}

.conversation-progress {
  width: min(920px, calc(100% - 3rem));
  margin: 0 auto;
  padding: 0.35rem 0 1rem;
  color: var(--text-secondary);
}

.conversation-progress__content {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.42rem;
  min-height: 32px;
  line-height: 1.45;
}

.conversation-progress__pulse {
  width: 0.55rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent);
  animation: conversation-progress-pulse 1.45s ease-in-out infinite;
}

.conversation-progress__message {
  color: var(--text-primary);
  font-weight: 650;
}

.conversation-progress__detail {
  flex: 1 1 100%;
  min-width: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.conversation-progress__dots {
  display: inline-flex;
  align-items: center;
  gap: 0.16rem;
  width: 1.3rem;
}

.conversation-progress__dots span {
  width: 0.22rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: currentColor;
  animation: conversation-progress-dot 1.2s ease-in-out infinite;
}

.conversation-progress__dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.conversation-progress__dots span:nth-child(3) {
  animation-delay: 0.32s;
}

.conversation-progress--failed .conversation-progress__pulse {
  background: var(--danger);
  animation: none;
}

.conversation-progress--stopping .conversation-progress__pulse,
.conversation-progress--stopped .conversation-progress__pulse {
  background: var(--warning);
}

.conversation-progress--stopped .conversation-progress__pulse {
  animation: none;
}

@keyframes conversation-progress-pulse {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.86);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes conversation-progress-dot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-0.18rem);
  }
}

.message-markdown {
  display: grid;
  gap: 0.95rem;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message-markdown__paragraph {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.01rem;
  line-height: 1.82;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message-markdown__list {
  margin: 0;
  padding-left: 1.35rem;
  color: var(--text-primary);
  display: grid;
  gap: 0.46rem;
}

.message-markdown__list li {
  line-height: 1.72;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message-markdown__code-inline {
  padding: 0.08rem 0.38rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-subtle) 72%, transparent);
  border: 1px solid color-mix(in srgb, var(--line-soft) 85%, transparent);
  font-family: var(--font-mono);
  font-size: 0.9em;
  white-space: break-spaces;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message-markdown__code-block {
  margin: 0;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-subtle) 72%, #000 12%);
  border: 1px solid color-mix(in srgb, var(--line-soft) 85%, transparent);
  overflow: auto;
}

.message-markdown__code-block code {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text-primary);
}

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

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

.message-markdown a {
  color: var(--accent);
  text-decoration: none;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-decoration-skip-ink: auto;
}

.message-markdown a:hover {
  text-decoration: underline;
}

.change-surface {
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg-panel) 10%, transparent);
  border: 1px solid var(--line-soft);
  overflow: hidden;
}

.change-surface__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
  background: color-mix(in srgb, var(--bg-subtle) 44%, transparent);
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-secondary);
}

.terminal-drawer {
  padding: 0 1.2rem 1.2rem;
  display: grid;
  gap: 0.85rem;
}

.terminal-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.terminal {
  border-radius: 14px;
  background: var(--terminal-surface);
  border: 1px solid var(--line-soft);
  padding: 1rem 1.05rem;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.38;
}

.terminal--dock {
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 0;
  border: 0;
  background: var(--terminal-surface);
  padding: 0.8rem 1rem 0.4rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
}

.terminal__line {
  color: var(--terminal-line);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 0;
  margin: 0;
  line-height: 1.35;
}

.terminal__line--muted {
  color: var(--terminal-line-muted);
}

.terminal__line--warning {
  color: var(--terminal-line-warning);
}

.terminal__line--accent {
  color: var(--terminal-line-accent);
}

.composer {
  background: var(--bg-panel);
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  padding: 0.82rem 0.9rem 0.72rem;
  display: flex;
  flex-direction: column;
  gap: 0.62rem;
  backdrop-filter: blur(16px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.24);
}

.slash-command-popup {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  padding: 0.3rem;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: color-mix(in srgb, var(--bg-subtle) 90%, transparent);
}

.slash-command-popup.is-hidden {
  display: none;
}

.slash-command-popup__item {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: transparent;
  padding: 0.52rem 0.58rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem 0.7rem;
  align-items: center;
  text-align: left;
  color: var(--text-primary);
}

.slash-command-popup__item:hover,
.slash-command-popup__item.is-active,
.slash-command-popup__item:focus-visible {
  background: color-mix(in srgb, var(--bg-subtle) 84%, #ffffff 7%);
  outline: none;
}

.slash-command-popup__item.is-disabled {
  opacity: 0.62;
}

.slash-command-popup__command {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-primary);
}

.slash-command-popup__label {
  margin-left: 0.45rem;
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.slash-command-popup__desc {
  grid-column: 1 / 2;
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.slash-command-popup__reason {
  grid-column: 2 / 3;
  color: var(--text-muted);
  font-size: 0.74rem;
  align-self: start;
}

.timeline-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.35rem;
}

.timeline-card--upload {
  padding-left: 1rem;
}

.timeline-upload__meta {
  margin-top: 0.15rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.timeline-card--user,
.timeline-card--assistant {
  padding-left: 0;
}

.timeline-upload__preview {
  margin-top: 0.45rem;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg-subtle) 88%, transparent);
}

.timeline-upload__preview img {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: contain;
}

.composer--dock {
  margin-bottom: 0.9rem;
  background: color-mix(in srgb, var(--bg-panel) 90%, transparent);
}

.composer__dockbar,
.welcome-card__actions,
.approval-card__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.composer__dock-left,
.composer__dock-right,
.composer__statusbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.composer-provider-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.14rem;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-subtle) 86%, transparent);
}

.composer-provider-switcher__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  transition: background 120ms ease, color 120ms ease, transform 120ms ease;
}

.composer-provider-switcher__button:hover,
.composer-provider-switcher__button:focus-visible {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-panel));
  color: var(--text-primary);
}

.composer-provider-switcher__button.is-active {
  background: var(--bg-panel);
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 26%, transparent);
}

.composer__statusbar {
  color: var(--text-muted);
  font-size: 0.78rem;
  padding-top: 0.05rem;
  justify-content: flex-start;
}

.composer__status-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.7rem;
}

.composer__status-hints.is-hidden {
  display: none;
}

.composer__status-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 34px;
  padding: 0.45rem 0.8rem;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--warning) 30%, var(--line-soft));
  background: color-mix(in srgb, var(--warning) 10%, var(--bg-subtle));
  color: var(--text-secondary);
  font-size: 0.78rem;
  line-height: 1.4;
}

.composer__status-hint strong {
  color: var(--text-primary);
}

.composer__attachment-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0;
}

/* Empty prompt attachment strips should collapse fully so the textarea keeps the compact idle height. */
.composer__attachment-strip:empty {
  display: none;
}

.composer__drop-hint {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-height: 28px;
  padding: 0.2rem 0.72rem;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--line-soft));
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-subtle));
  color: var(--text-primary);
  font-size: 0.76rem;
  line-height: 1.2;
}

.composer__drop-hint.is-hidden {
  display: none;
}

.composer-upload-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--bg-subtle) 92%, transparent);
}

.composer-upload-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.42rem 0.7rem;
  border: 0;
  background: transparent;
  color: var(--text-primary);
}

.composer-upload-chip__label {
  font-weight: 600;
  font-size: 0.8rem;
}

.composer-upload-chip__meta {
  color: var(--text-muted);
  font-size: 0.74rem;
}

.composer-upload-remove {
  min-width: 30px;
  min-height: 30px;
  padding: 0 0.55rem 0 0.45rem;
  border: 0;
  border-left: 1px solid var(--line-soft);
  background: transparent;
  color: var(--text-primary);
  font-size: 1rem;
  line-height: 1;
}

.composer-upload-pill:hover {
  transform: translateY(-1px);
}

/* Shared focus treatment keeps chip actions keyboard-visible without drawing extra outlines on the outer composer. */
.composer-upload-chip:focus-visible,
.composer-upload-remove:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 36%, transparent);
  outline-offset: -2px;
}

.runtime-toggle,
.runtime-toggle__item,
.composer__mode {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.runtime-toggle {
  padding: 0.12rem;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-subtle) 88%, transparent);
}

.runtime-toggle__item {
  min-height: 24px;
  padding: 0 0.55rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.runtime-toggle__item--active {
  background: var(--bg-panel);
  color: var(--text-primary);
}

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

.composer__mode--external {
  color: var(--accent);
}

.composer__mode--active {
  color: var(--text-primary);
}

@keyframes thread-activity-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.toolbar-select--branch select {
  min-width: 210px;
}

.send-button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0;
  background: #f3f4f6;
  color: #1c1c1f;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 1px 2px rgba(0, 0, 0, 0.22);
}

.send-button:hover {
  transform: translateY(-1px);
  background: #ffffff;
}

/* The primary composer control flips into a stop affordance while a run is active without moving the user's muscle memory. */
.send-button--stop {
  background: color-mix(in srgb, var(--warning) 72%, #ffffff);
  color: #1f1304;
}

.send-button--stop:hover {
  background: color-mix(in srgb, var(--warning) 84%, #ffffff);
}

.send-button--stopping {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.58),
    0 0 0 1px color-mix(in srgb, var(--warning) 38%, transparent),
    0 1px 2px rgba(0, 0, 0, 0.2);
}

/* The send button uses a slightly smaller icon so the circular control keeps its visual balance. */
.send-button .app-icon {
  width: 14px;
  height: 14px;
}

.change-surface__files {
  display: grid;
}

.change-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1.2rem;
  border-top: 1px solid var(--line-soft);
}

.terminal-console {
  flex: 0 0 var(--terminal-height);
  min-height: 220px;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-panel);
  min-width: 0;
}

.terminal-console.is-hidden {
  display: none;
}

.terminal-console__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.72rem 1rem 0.64rem;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg-panel) 88%, var(--bg-subtle));
}

.terminal-console__title {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}

.terminal-console__title span {
  color: var(--text-muted);
}

.terminal-console__header-meta {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.terminal-console__cwd {
  max-width: min(48vw, 640px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.terminal-console__surface {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--terminal-surface);
}

.terminal-console__empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
  background: linear-gradient(180deg, color-mix(in srgb, var(--terminal-surface) 98%, transparent), color-mix(in srgb, var(--bg-panel) 18%, var(--terminal-surface)));
  pointer-events: none;
}

.terminal-console__empty-state.is-hidden {
  display: none;
}

.terminal--dock {
  position: absolute;
  inset: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--terminal-surface);
  outline: none;
}

.terminal--dock:focus-visible {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 48%, transparent);
}

.terminal--dock .xterm {
  height: 100%;
  padding: 0.45rem 0.55rem;
}

.terminal--dock .xterm-viewport {
  overflow-y: auto !important;
  background: transparent !important;
}

.terminal--dock .xterm-screen,
.terminal--dock .xterm-helpers {
  height: 100%;
}

.terminal--dock .xterm .xterm-rows,
.terminal--dock .xterm .xterm-rows > div {
  line-height: 1.05 !important;
}

.terminal--dock .xterm .xterm-cursor-layer,
.terminal--dock .xterm .xterm-selection-layer {
  z-index: 2;
}

.terminal--connected {
  cursor: text;
}

.composer__input--dock {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.35rem 0.45rem 0.25rem;
  border: 1px solid transparent;
  border-radius: 16px;
  transition:
    border-color var(--duration-fast) ease,
    background var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease,
    transform var(--duration-fast) ease;
}

.composer--dock.is-drop-active .composer__input--dock {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line-soft));
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-panel));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent),
    0 10px 24px color-mix(in srgb, var(--accent) 12%, transparent);
  transform: translateY(-1px);
}

.composer__input--dock textarea {
  width: 100%;
  border: 0;
  /* iOS Safari can repaint focused transparent textareas as a white layer until the first input event. */
  -webkit-appearance: none;
  appearance: none;
  background: color-mix(in srgb, var(--bg-panel) 92%, transparent);
  background-clip: padding-box;
  border-radius: 14px;
  padding: 0.42rem 0.15rem 0.44rem;
  resize: none;
  min-height: 44px;
  max-height: min(26vh, 220px);
  overflow-y: hidden;
  color: var(--text-primary);
  -webkit-text-fill-color: var(--text-primary);
  caret-color: var(--text-primary);
  opacity: 1;
  box-shadow: none;
  font-size: 0.94rem;
  line-height: 1.45;
  transform: translateZ(0);
}

.composer__input--dock textarea::placeholder {
  color: var(--text-muted);
  -webkit-text-fill-color: var(--text-muted);
  opacity: 1;
}

.composer__input--dock textarea:focus,
.composer__input--dock textarea:active {
  background: color-mix(in srgb, var(--bg-panel) 96%, transparent);
}

.composer__input textarea:focus-visible,
.toolbar-select select:focus-visible,
.ghost-button:focus-visible,
.small-button:focus-visible,
.primary-button:focus-visible,
.segmented-control__item:focus-visible {
  outline: 3px solid rgba(42, 109, 246, 0.24);
  outline-offset: 2px;
}

.welcome-screen,
.picker-screen {
  min-height: 760px;
  display: grid;
  place-items: center;
  border-radius: 0;
  background:
    radial-gradient(circle at top center, rgba(91, 124, 250, 0.18), transparent 36%),
    linear-gradient(180deg, color-mix(in srgb, var(--bg-canvas) 76%, white), color-mix(in srgb, var(--bg-canvas) 90%, black));
  border: 1px solid var(--line-soft);
}

.welcome-card,
.picker-modal {
  width: min(100%, 740px);
  border-radius: 12px;
  padding: clamp(1.5rem, 4vw, 3rem);
}

.welcome-card {
  text-align: center;
}

.welcome-card__badge {
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, white), var(--accent-strong));
  color: white;
  font-weight: 700;
  box-shadow: 0 22px 48px rgba(41, 94, 219, 0.28);
}

.welcome-card__actions {
  justify-content: center;
  margin-top: 1.5rem;
}

.picker-list {
  margin: 1.3rem 0;
}

.picker-item {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.8rem;
  align-items: center;
}

.picker-item input {
  margin: 0;
}

.inspector {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border-left: 1px solid var(--line-soft);
  background: var(--bg-panel);
  width: auto;
  min-width: 0;
}

.inspector.is-hidden {
  display: none;
}

.inspector-panel {
  border-radius: 0;
  padding: 1rem;
  border-top: 0;
  border-right: 0;
  border-left: 0;
  border-bottom: 0;
  box-shadow: none;
  background: transparent;
}

.inspector-panel + .inspector-panel {
  border-top: 1px solid var(--line-soft);
}

.badge {
  padding: 0.3rem 0.55rem;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.74rem;
  font-weight: 700;
}

.meta-list,
.stack-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.meta-list div {
  display: grid;
  gap: 0.2rem;
}

.meta-list dd {
  margin: 0;
  font-weight: 600;
}

.stack-item,
.approval-card {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  padding: 0.85rem 0;
}

.stack-item {
  display: grid;
  gap: 0.3rem;
}

.stack-item--overview {
  gap: 0.55rem;
  padding-top: 0.2rem;
}

.stack-item__overview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
}

.stack-item__overview-copy {
  display: grid;
  gap: 0.22rem;
  min-width: 0;
}

.stack-item__path {
  display: block;
  margin: 0;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg-subtle) 72%, transparent);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.stack-item--artifact {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.stack-item--summary,
.stack-item--placeholder {
  cursor: default;
}

.stack-item__meta {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 0.72rem;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg-subtle) 76%, transparent);
  color: var(--text-secondary);
  font-size: 0.77rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill--accent {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line-soft));
  color: var(--accent-strong);
}

.status-pill--success {
  border-color: color-mix(in srgb, var(--success) 34%, var(--line-soft));
  color: var(--success);
}

.status-pill--warning {
  border-color: color-mix(in srgb, var(--warning) 34%, var(--line-soft));
  color: var(--warning);
}

.status-pill--danger {
  border-color: color-mix(in srgb, #dc2626 34%, var(--line-soft));
  color: #dc2626;
}

.stack-item__list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text-secondary);
  display: grid;
  gap: 0.35rem;
}

.stack-item__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.25rem;
}

.stack-item--preview {
  gap: 0.75rem;
}

.stack-item__preview {
  margin: 0;
  max-height: 24rem;
  overflow: auto;
  padding: 0.9rem 1rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(116, 162, 255, 0.2);
  background: rgba(6, 10, 18, 0.9);
  color: rgba(233, 239, 255, 0.92);
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.stack-item__image-preview {
  overflow: hidden;
  border-radius: 1rem;
  border: 1px solid rgba(116, 162, 255, 0.18);
  background: rgba(6, 10, 18, 0.9);
}

.stack-item__image-preview img {
  display: block;
  width: 100%;
  max-height: 20rem;
  object-fit: contain;
}

.approval-card {
  display: grid;
  gap: var(--space-4);
}

@media (max-width: 1240px) {
  /* Medium-width layouts still need three grid tracks so the inspector stays docked on the right instead of auto-flowing into a second row. */
  .workspace {
    grid-template-columns:
      var(--sidebar-width)
      var(--shell-resize-handle-size)
      minmax(0, 1fr)
      var(--shell-resize-handle-size)
      var(--inspector-width);
    padding: 0;
  }

  /* Hidden-panel variants reuse the narrower medium rail widths so the grid does not leave stale desktop-sized tracks behind. */
  .workspace:has(.sidebar.is-hidden) {
    grid-template-columns: minmax(0, 1fr) var(--shell-resize-handle-size) var(--inspector-width);
  }

  .workspace:has(.inspector.is-hidden) {
    grid-template-columns: var(--sidebar-width) var(--shell-resize-handle-size) minmax(0, 1fr);
  }

  .workspace:has(.sidebar.is-hidden):has(.inspector.is-hidden) {
    grid-template-columns: minmax(0, 1fr);
  }

  /* The shell keeps slightly narrower default rails on medium widths while still allowing drag-resize within the new limits. */
  .app-shell {
    --sidebar-width: 280px;
    --inspector-width: 280px;
  }
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr;
    height: auto;
    padding: 0.85rem 1rem;
  }

  .topbar__center,
  .topbar__right {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .inspector,
  .shell-resize-handle {
    display: none;
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 0;
  }

  .sidebar,
  .welcome-card,
  .picker-modal {
    border-radius: 0;
  }

  .conversation-header,
  .conversation-header__title,
  .composer__dockbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0ms !important;
    scroll-behavior: auto !important;
  }
}

.app-shell[data-view-mode="auth"] {
  overflow: auto;
}

.app-shell[data-view-mode="auth"] .topbar,
.app-shell[data-view-mode="auth"] .sidebar,
.app-shell[data-view-mode="auth"] .inspector,
.app-shell[data-view-mode="auth"] .terminal-console {
  display: none;
}

.app-shell[data-view-mode="auth"] .workspace {
  /* WebKit can keep stale implicit grid tracks here, so auth mode switches to a simple single-column flow. */
  display: block;
  padding: 0;
  height: calc(var(--app-viewport-height) - var(--header-height) - var(--footer-height));
}

.app-shell[data-view-mode="auth"] .shell-resize-handle {
  display: none;
}

.app-shell[data-view-mode="auth"] .sidebar,
.app-shell[data-view-mode="auth"] .inspector {
  display: none;
}

.app-shell[data-view-mode="auth"] .content-area {
  width: 100%;
  min-height: calc(var(--app-viewport-height) - var(--header-height));
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 16%, transparent), transparent 28%),
    radial-gradient(circle at bottom right, color-mix(in srgb, #4ad7b5 10%, transparent), transparent 34%),
    linear-gradient(180deg, color-mix(in srgb, var(--bg-emphasis) 94%, #0a0c11), color-mix(in srgb, var(--bg-emphasis) 100%, black));
}

.app-shell[data-view-mode="auth"] .content-area:has(.auth-card--picker) {
  overflow: auto;
  background: var(--bg-canvas);
}

.auth-stage {
  display: grid;
  width: 100%;
  min-height: calc(var(--app-viewport-height) - var(--header-height));
  place-items: center;
  padding: clamp(2rem, 5vw, 4rem);
}

.auth-stage--centered {
  align-items: center;
}

.auth-card {
  width: min(100%, 34rem);
  padding: clamp(1.75rem, 3vw, 2.5rem);
  border: 1px solid color-mix(in srgb, var(--border-strong) 65%, transparent);
  border-radius: 1.5rem;
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--accent) 18%, transparent), transparent 42%),
    linear-gradient(180deg, color-mix(in srgb, var(--surface-2) 96%, black 4%), color-mix(in srgb, var(--surface-1) 94%, black 6%));
  box-shadow: 0 1.2rem 3.2rem rgba(0, 0, 0, 0.3);
}

.auth-card--loading,
.auth-card--hero {
  width: min(100%, 40rem);
}

.auth-card--wizard,
.auth-card--picker {
  width: min(100%, 72rem);
}

.auth-card--provider-auth {
  width: min(100%, 78rem);
}

.auth-stage--provider {
  align-items: start;
  padding-block: clamp(1.5rem, 3vw, 2.5rem);
}

.provider-auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  margin-top: 0.75rem;
}

.provider-auth-copy {
  display: grid;
  gap: 0.85rem;
  align-content: start;
}

.provider-auth-copy__header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.8rem;
  align-items: start;
}

.provider-auth-copy__header p {
  margin: 0.25rem 0 0;
  color: var(--text-secondary);
}

.provider-auth-terminal-card {
  display: grid;
  border: 1px solid color-mix(in srgb, var(--line-soft) 78%, transparent);
  border-radius: 1.1rem;
  background: color-mix(in srgb, var(--surface-2) 94%, transparent);
  overflow: hidden;
}

.provider-auth-terminal-card--debug {
  min-height: 14rem;
}

.provider-auth-terminal-card__header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line-soft) 74%, transparent);
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.provider-auth-terminal-card__surface {
  position: relative;
  min-height: 0;
  display: grid;
  gap: 0.75rem;
  padding: 0.9rem 1rem 1rem;
}

.terminal--provider-auth {
  height: 100%;
  min-height: 8rem;
  max-height: 11rem;
  padding: 0.75rem 0.85rem;
}

.terminal-console__empty-state--inline {
  position: absolute;
  inset: 0;
}

.provider-auth-browser-link {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  width: fit-content;
  padding: 0.65rem 0.8rem;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  border-radius: 0.95rem;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

.provider-auth-browser-link span {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.provider-auth-browser-link__action {
  color: var(--text-primary);
  font-weight: 600;
  text-decoration: none;
}

.provider-auth-browser-link__action:hover {
  text-decoration: underline;
}

.provider-auth-code-card {
  display: grid;
  gap: 0.8rem;
  padding: 0.95rem 1rem;
  border: 1px solid color-mix(in srgb, var(--line-soft) 78%, transparent);
  border-radius: 1rem;
  background: color-mix(in srgb, var(--surface-1) 88%, transparent);
}

.provider-auth-code-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.provider-auth-code-card__header span {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.provider-auth-code-card__field {
  gap: 0.5rem;
}

.provider-auth-code-card__input {
  min-height: 5.5rem;
}

.provider-auth-code-card__actions {
  margin-top: 0;
}

.provider-auth-debug__meta {
  margin-top: 0;
}

.provider-auth-debug__code {
  display: block;
  margin: 0;
}

.provider-auth-debug__diagnostics {
  display: grid;
  gap: 0.4rem;
  padding: 0.75rem 0.85rem;
  border-radius: 0.95rem;
  background: color-mix(in srgb, var(--surface-3) 92%, transparent);
  color: var(--text-secondary);
}

.provider-auth-debug__diagnostics.is-danger {
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.provider-auth-debug__diagnostics pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
}

.auth-card--picker {
  /* Keep the header and footer stable while long project/folder lists can scroll on their own. */
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 0;
  max-height: calc(var(--app-viewport-height) - var(--header-height) - clamp(4rem, 7vw, 7rem));
  padding-bottom: clamp(1.2rem, 2vw, 1.75rem);
  overflow: hidden;
  box-shadow: 0 1rem 2.4rem rgba(0, 0, 0, 0.18);
}

.auth-stage:has(.auth-card--picker) {
  align-items: start;
  padding-block: clamp(1.25rem, 3vw, 2rem);
}

.auth-card--picker {
  border-color: color-mix(in srgb, var(--line-soft) 88%, transparent);
  background: var(--bg-panel);
}

.app-shell[data-theme="light"] .auth-card--picker {
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.app-shell[data-theme="light"] .auth-card--picker .auth-card__badge {
  border-color: color-mix(in srgb, var(--accent) 18%, var(--line-soft));
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-panel));
}

.auth-card--picker .auth-actions {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid color-mix(in srgb, var(--line-soft) 76%, transparent);
}

.auth-card--wide {
  width: min(100%, 56rem);
}

.auth-card__badge,
.wizard-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: fit-content;
  margin-bottom: 1rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-card__identity {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.auth-card__identity .auth-card__badge {
  margin-bottom: 0;
}

.auth-card__version {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
}

.auth-card h1,
.auth-card h2,
.wizard-sidebar h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.8rem, 3vw, 2.75rem);
  line-height: 1.05;
  color: var(--text-primary);
}

.auth-card p,
.wizard-sidebar p,
.wizard-copy p {
  margin: 0;
  color: var(--text-secondary);
}

.auth-form,
.wizard-fields {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.auth-field {
  display: grid;
  gap: 0.45rem;
}

.auth-field span,
.auth-field strong {
  color: var(--text-primary);
}

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

.auth-field input,
.auth-field select,
.auth-field textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 2.85rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid color-mix(in srgb, var(--border-strong) 72%, transparent);
  border-radius: 0.9rem;
  background: color-mix(in srgb, var(--surface-1) 96%, black 4%);
  color: var(--text-primary);
}

.auth-field input::placeholder,
.auth-field select::placeholder,
.auth-field textarea::placeholder {
  color: var(--text-muted);
}

.auth-field input:focus,
.auth-field select:focus,
.auth-field textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 68%, transparent);
  outline-offset: 2px;
  border-color: color-mix(in srgb, var(--accent) 48%, var(--border-strong));
}

.auth-field textarea {
  resize: vertical;
  font: inherit;
}

.auth-field--choice,
.auth-field--checkbox {
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0.85rem;
  padding: 1rem;
  border: 1px solid color-mix(in srgb, var(--border-strong) 62%, transparent);
  border-radius: 1rem;
  background: color-mix(in srgb, var(--surface-1) 82%, transparent);
}

.auth-field--choice small {
  display: block;
  margin-top: 0.35rem;
  color: var(--text-muted);
}

.auth-field--summary {
  padding: 1rem 1.05rem;
  border: 1px solid color-mix(in srgb, var(--border-strong) 62%, transparent);
  border-radius: 1rem;
  background: color-mix(in srgb, var(--surface-1) 88%, transparent);
}

.auth-field--summary strong {
  overflow-wrap: anywhere;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.auth-actions--compact {
  margin-top: 1rem;
}

.auth-actions--split {
  justify-content: space-between;
}

.auth-callout {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 1rem;
  border: 1px solid transparent;
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--surface-1) 88%, transparent);
}

.auth-callout--warning {
  border-color: color-mix(in srgb, #d6b76c 44%, transparent);
  background: color-mix(in srgb, #d6b76c 10%, var(--surface-1));
}

.auth-callout--danger {
  border-color: color-mix(in srgb, #ff7b7b 44%, transparent);
  background: color-mix(in srgb, #ff7b7b 10%, var(--surface-1));
}

.auth-callout--success {
  border-color: color-mix(in srgb, #53d2a4 44%, transparent);
  background: color-mix(in srgb, #53d2a4 12%, var(--surface-1));
}

.backup-code-list {
  display: grid;
  gap: 0.65rem;
}

.backup-code-list code,
.two-factor-setup__details code {
  display: block;
  width: 100%;
  padding: 0.8rem 0.95rem;
  border: 1px solid color-mix(in srgb, var(--border-strong) 72%, transparent);
  border-radius: 0.9rem;
  background: color-mix(in srgb, var(--surface-1) 90%, black 10%);
  color: var(--text-primary);
  font-size: 0.94rem;
  overflow-wrap: anywhere;
}

.wizard-layout {
  display: grid;
  grid-template-columns: minmax(16rem, 20rem) 1fr;
  gap: 1.5rem;
}

.wizard-sidebar {
  padding: 0.5rem 0.25rem 0.5rem 0;
}

.wizard-sidebar h1,
.wizard-steps li.is-active,
.wizard-steps li.is-complete {
  color: var(--text-primary);
}

.wizard-steps {
  display: grid;
  gap: 0.65rem;
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
}

.wizard-steps li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text-muted);
}

.wizard-steps li::before {
  content: "";
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border-strong) 70%, transparent);
}

.wizard-steps li.is-active,
.wizard-steps li.is-complete {
  color: var(--text-primary);
}

.wizard-steps li.is-active::before,
.wizard-steps li.is-complete::before {
  background: var(--accent);
}

.wizard-provider-grid,
.wizard-provider-methods {
  display: grid;
  gap: 0.8rem;
}

.provider-choice strong {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.picker-list {
  display: grid;
  gap: 0.8rem;
  margin-top: 1.5rem;
}

.picker-scroll {
  display: grid;
  gap: 1.4rem;
  min-height: 0;
  margin-top: 1.35rem;
  padding-right: 0.2rem;
  overflow: auto;
}

.picker-section {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.1rem;
}

.picker-section--flat {
  margin-top: 0;
}

.picker-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--text-secondary);
}

.picker-section__header strong {
  color: var(--text-primary);
}

.picker-flat-list {
  display: grid;
  gap: 0;
  border-top: 1px solid color-mix(in srgb, var(--line-soft) 76%, transparent);
}

.picker-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.9rem;
  align-items: start;
  padding: 0.95rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line-soft) 76%, transparent);
  background: transparent;
  color: var(--text-primary);
  text-align: left;
}

.picker-row--candidate {
  grid-template-columns: minmax(0, 1fr) auto;
}

.picker-row input {
  margin-top: 0.18rem;
}

.picker-row--selected {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.app-shell[data-theme="light"] .picker-row--selected {
  background: color-mix(in srgb, var(--accent) 9%, white);
}

.picker-row__main {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.picker-row__title {
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.3;
}

.picker-row__meta {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.picker-row__aside {
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.4;
  white-space: nowrap;
}

.ghost-button--small {
  min-height: 2.25rem;
  padding: 0 0.85rem;
  border-radius: 0.8rem;
  font-size: 0.9rem;
}

.empty-state {
  display: grid;
  gap: 0.4rem;
  padding: 1rem;
  border-radius: 1rem;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--surface-1) 82%, transparent);
}

.empty-state strong {
  color: var(--text-primary);
}

.empty-state--conversation {
  min-height: 16rem;
  place-content: center;
}

.empty-state__actions {
  margin-top: 0.35rem;
}

.two-factor-setup {
  display: grid;
  grid-template-columns: minmax(14rem, 16rem) 1fr;
  gap: 1rem;
  align-items: start;
}

.two-factor-setup__qr {
  display: grid;
  place-items: center;
  padding: 1rem;
  border: 1px solid color-mix(in srgb, var(--border-strong) 62%, transparent);
  border-radius: 1rem;
  background: color-mix(in srgb, var(--surface-1) 84%, transparent);
}

.two-factor-setup__qr img {
  width: 100%;
  max-width: 14rem;
  height: auto;
  border-radius: 0.75rem;
  background: white;
  padding: 0.5rem;
}

.two-factor-setup__details {
  display: grid;
  gap: 0.85rem;
}

.loading-dots {
  display: inline-flex;
  gap: 0.45rem;
  margin-top: 1.5rem;
}

.loading-dots span {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  background: var(--accent);
  animation: loading-pulse 1.2s infinite ease-in-out;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

.thread-group--empty {
  padding: 0.5rem 0;
}

.settings-table__row--empty {
  opacity: 0.7;
}

@keyframes loading-pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: scale(0.92);
  }

  40% {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 900px) {
  .wizard-layout {
    grid-template-columns: 1fr;
  }

  .two-factor-setup {
    grid-template-columns: 1fr;
  }

  .auth-card--wizard,
  .auth-card--picker,
  .auth-card--wide {
    width: min(100%, 42rem);
  }

  .auth-card--picker {
    max-height: none;
  }

  .picker-scroll {
    overflow: visible;
    padding-right: 0;
  }

  .picker-row,
  .picker-row--candidate {
    grid-template-columns: minmax(0, 1fr);
  }

  .picker-row__aside {
    white-space: normal;
  }
}

@media (max-width: 980px) {
  :root {
    /* Include the top safe area so Safari on iPadOS does not let browser chrome overlap the header. */
    --header-height: calc(64px + env(safe-area-inset-top));
  }

  .app-shell[data-view-mode="auth"] {
    --header-height: 0px;
  }

  .app-shell {
    grid-template-rows: var(--header-height) minmax(0, 1fr);
    overflow: hidden;
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    height: var(--header-height);
    padding: env(safe-area-inset-top) 0.7rem 0;
    gap: 0.55rem;
  }

  .topbar__center {
    display: none;
  }

  .topbar__mobile-context {
    display: block;
  }

  .topbar__left,
  .topbar__right {
    min-width: 0;
    gap: 0.38rem;
  }

  .topbar__right {
    justify-content: flex-end;
    flex-wrap: nowrap;
  }

  .topbar .icon-button {
    width: 38px;
    height: 38px;
    border-radius: 11px;
  }

  .topbar #theme-toggle,
  .topbar #locale-toggle {
    display: none;
  }

  .icon-button--mobile-settings {
    display: grid;
  }

  .workspace,
  .workspace:has(.sidebar.is-hidden),
  .workspace:has(.inspector.is-hidden),
  .workspace:has(.sidebar.is-hidden):has(.inspector.is-hidden) {
    grid-template-columns: minmax(0, 1fr);
    height: calc(var(--app-viewport-height) - var(--header-height));
    overflow: hidden;
  }

  .content-area,
  .stage.is-active,
  .conversation-shell {
    min-width: 0;
    min-height: 0;
  }

  /* Mobile Safari should never widen the full conversation surface because one child prefers a larger intrinsic width. */
  .content-area,
  .stage.is-active,
  .conversation-shell,
  .conversation-stream {
    overflow-x: clip;
  }

  .sidebar {
    position: fixed;
    z-index: 55;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(92vw, 360px);
    display: flex !important;
    padding: max(0.9rem, env(safe-area-inset-top)) 0.75rem max(1rem, env(safe-area-inset-bottom));
    border-right: 1px solid var(--line-soft);
    transform: translateX(-104%);
    transition: transform var(--duration-fast) ease;
    overflow: auto;
    overscroll-behavior: contain;
  }

  .app-shell.is-mobile-nav-open .sidebar {
    transform: translateX(0);
  }

  .inspector {
    position: fixed;
    z-index: 56;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: auto;
    max-height: min(74vh, 720px);
    display: flex !important;
    border-left: 0;
    border-top: 1px solid var(--line-soft);
    border-radius: 18px 18px 0 0;
    transform: translateY(106%);
    transition: transform var(--duration-fast) ease;
    overflow: auto;
    overscroll-behavior: contain;
  }

  .app-shell.is-mobile-inspector-open .inspector {
    transform: translateY(0);
  }

  .app-shell.is-mobile-nav-open .mobile-shell-backdrop,
  .app-shell.is-mobile-inspector-open .mobile-shell-backdrop {
    display: block;
    z-index: 54;
  }

  .conversation-stream {
    padding: 0.85rem 0 1rem;
    gap: 0.2rem;
  }

  .prompt-preview,
  .response-block,
  .timeline-note,
  .conversation-divider,
  .composer--dock {
    width: min(100%, calc(100% - 1rem));
    max-width: 100%;
  }

  .timeline-card__bubble {
    width: min(92%, 680px);
    max-width: 100%;
    padding: 0.75rem 0.85rem;
    border-radius: 17px;
  }

  /* Chat cards keep their own internal wrapping so the stream itself never gains a horizontal scrollbar on iOS. */
  .conversation-progress,
  .timeline-card__content,
  .conversation-turn__bubble,
  .message-markdown__code-block {
    max-width: 100%;
    box-sizing: border-box;
  }

  .message-markdown__paragraph {
    font-size: 0.98rem;
    line-height: 1.72;
  }

  .composer--dock {
    position: relative;
    margin-bottom: max(0.55rem, env(safe-area-inset-bottom));
    border-radius: 18px;
    padding: 0.55rem;
    gap: 0.45rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  }

  .composer__input--dock textarea {
    min-height: 44px;
    max-height: min(28vh, 210px);
    padding: 0.34rem 0.1rem 0.36rem;
    font-size: 1rem;
    line-height: 1.36;
  }

  .composer__dockbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .composer__dock-left {
    flex: 1 1 auto;
    min-width: 0;
  }

  .composer-provider-switcher {
    width: 100%;
    justify-content: space-between;
  }

  .composer-provider-switcher__button {
    flex: 1 1 0;
  }

  .composer__dock-left .toolbar-select,
  .composer__statusbar,
  .composer__status-hints {
    display: none;
  }

  .composer__options-toggle {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
  }

  .app-shell.is-mobile-composer-options-open .composer--dock {
    max-height: min(74vh, 620px);
    overflow: auto;
  }

  .app-shell.is-mobile-composer-options-open .composer__dockbar,
  .app-shell.is-mobile-composer-options-open .composer__dock-left,
  .app-shell.is-mobile-composer-options-open .composer__statusbar,
  .app-shell.is-mobile-composer-options-open .composer__status-hints {
    display: flex;
  }

  .app-shell.is-mobile-composer-options-open .composer__dock-left .toolbar-select {
    display: inline-flex;
  }

  .app-shell.is-mobile-composer-options-open .composer__statusbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-shell.is-mobile-composer-options-open .runtime-toggle,
  .app-shell.is-mobile-composer-options-open .toolbar-select--branch {
    width: 100%;
  }

  .app-shell.is-mobile-composer-options-open .toolbar-select select,
  .app-shell.is-mobile-composer-options-open .toolbar-select--branch select {
    min-width: 0;
    width: 100%;
  }

  .terminal-console {
    flex-basis: clamp(240px, 36vh, 420px);
    min-height: 240px;
    max-height: 58vh;
  }

  .app-shell.is-mobile-terminal-fullscreen .terminal-console {
    position: fixed;
    z-index: 70;
    inset: 0;
    display: flex !important;
    min-height: var(--app-viewport-height);
    max-height: none;
    background: var(--bg-panel);
  }

  .app-shell.is-mobile-terminal-fullscreen .terminal-console__header {
    flex: 0 0 auto;
    min-height: 56px;
    padding: max(0.7rem, env(safe-area-inset-top)) 0.75rem 0.65rem;
  }

  .app-shell.is-mobile-terminal-fullscreen .terminal-console__surface {
    flex: 1 1 auto;
  }

  .terminal-console__header-meta {
    display: none;
  }

  .app-shell.is-mobile-terminal-fullscreen .terminal-console__header-meta {
    display: flex;
  }

  .settings-view {
    height: calc(var(--app-viewport-height) - var(--header-height));
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .settings-sidebar {
    flex: 0 0 auto;
    padding: 0.65rem;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .settings-back {
    min-height: 36px;
    margin-bottom: 0.55rem;
  }

  .settings-nav {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    padding-bottom: 0.15rem;
    scrollbar-width: none;
  }

  .settings-nav::-webkit-scrollbar {
    display: none;
  }

  .settings-nav__item {
    flex: 0 0 auto;
    width: auto;
    min-height: 36px;
    padding: 0 0.75rem;
  }

  .settings-nav__item .settings-nav__icon {
    display: none;
  }

  .settings-content {
    flex: 1 1 auto;
    min-height: 0;
    padding: 1rem 0.8rem 1.4rem;
  }

  .settings-content__inner h1 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
  }

  .settings-card {
    border-radius: 14px;
  }

  .settings-row,
  .settings-table__row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.8rem;
  }

  .settings-select select,
  .settings-input input,
  .settings-action-button {
    width: 100%;
    min-width: 0;
  }

  .settings-inline-action,
  .settings-pill-group,
  .settings-list__item,
  .settings-list__value {
    align-items: stretch;
    flex-direction: column;
    text-align: left;
  }

  .app-shell[data-view-mode="auth"] .workspace,
  .app-shell[data-view-mode="auth"] .content-area,
  .app-shell[data-view-mode="auth"] .auth-stage {
    min-height: var(--app-viewport-height);
    height: var(--app-viewport-height);
  }

  .app-shell[data-view-mode="auth"] .content-area {
    min-height: var(--app-viewport-height);
  }

  .auth-stage:has(.auth-card--picker) {
    padding: 0;
    align-items: stretch;
  }

  .auth-card--picker {
    width: 100%;
    height: var(--app-viewport-height);
    max-height: var(--app-viewport-height);
    border-radius: 0;
    border: 0;
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    padding: max(1rem, env(safe-area-inset-top)) 0.85rem max(1rem, env(safe-area-inset-bottom));
  }

  .auth-card--picker .picker-scroll {
    min-height: 0;
    overflow: auto;
    padding-right: 0;
    overscroll-behavior: contain;
  }

  .auth-card--picker .auth-actions {
    margin-top: 0.7rem;
    padding-top: 0.7rem;
  }
}

@media (max-width: 420px) {
  .topbar {
    padding-inline: 0.55rem;
  }

  .topbar .icon-button {
    width: 36px;
    height: 36px;
  }

  .topbar__right {
    gap: 0.25rem;
  }

  .thread-row__badge {
    display: none;
  }

  .composer--dock {
    width: 100%;
    margin-bottom: 0;
    border-right: 0;
    border-left: 0;
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
  }
}
