.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

/* ----- Card ----- */

.row {
  border: 1px solid var(--divider);
  border-radius: 8px;
  background: color-mix(in srgb, var(--sidebar-bg) 78%, transparent);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.rowEditing {
  border-color: color-mix(in srgb, var(--accent-primary) 55%, var(--divider));
}

.rowDangerous {
  border-color: color-mix(in srgb, var(--status-stopped) 35%, var(--divider));
}

@media (prefers-reduced-motion: reduce) {
  .row {
    transition: none;
  }
}

/* ----- Display mode ----- */

.displayHeader {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.displayName {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.displayPreview {
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: pre-wrap;
  word-break: break-word;
}

.displayMeta {
  font-size: 11px;
  color: var(--text-dim);
}

/* ----- Editing mode ----- */

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

.nameInput {
  flex: 1;
  background-color: var(--chat-input-bg);
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  min-width: 0;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.nameInput:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-primary) 50%, transparent);
}

.nameInputError {
  composes: nameInput;
  border-color: var(--status-stopped);
}

.promptInput {
  width: 100%;
  background-color: var(--chat-input-bg);
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  color: var(--text-primary);
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  outline: none;
  resize: vertical;
  min-height: 56px;
  box-sizing: border-box;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.promptInput:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-primary) 50%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .nameInput,
  .promptInput {
    transition: none;
  }
}

.textareaWrapper {
  position: relative;
}

.controlsRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.autoSendLabel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

.autoSendLabel input[type="checkbox"] {
  accent-color: var(--accent-primary);
}

/* ----- Toolbar override controls (tri-state) ----- */

.overridesGroup {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px dashed var(--divider);
}

.overridesLabel {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.overrideRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.overrideName {
  font-size: 12px;
  color: var(--text-muted);
}

.segmentedControl {
  display: inline-flex;
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--chat-input-bg);
}

/* Hide native radios visually but keep them in the tab order so the browser
   handles roving-tabindex + Left/Right/Up/Down arrow navigation natively. */
.segmentedRadioInput {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
  white-space: nowrap;
}

.segmentedButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease, color 0.12s ease;
}

/* Inter-segment dividers only. Every label is immediately preceded by its
   own radio input, so an adjacent-sibling rule would also border the first
   segment (which already has the container's left edge) — target labels
   after the first instead. The `label` element selector isn't hashed by
   CSS modules; the scoping comes from `.segmentedControl`. */
.segmentedControl > label:not(:first-of-type) {
  border-left: 1px solid var(--divider);
}

.segmentedButton:hover {
  color: var(--text-primary);
  background: var(--hover-bg);
}

/* Radio focus ring lands on the associated label (the visible "button"). */
.segmentedRadioInput:focus-visible + .segmentedButton,
.segmentedRadioInput:focus-visible + .segmentedButtonActive {
  outline: 2px solid color-mix(in srgb, var(--accent-primary) 60%, transparent);
  outline-offset: -2px;
}

/* Disabled radio → make its label look and behave inert. */
.segmentedRadioInput:disabled + .segmentedButton,
.segmentedRadioInput:disabled + .segmentedButtonActive {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

.segmentedButtonActive {
  composes: segmentedButton;
  background: color-mix(in srgb, var(--accent-primary) 18%, transparent);
  color: var(--accent-primary);
}

.segmentedButtonActive:hover {
  background: color-mix(in srgb, var(--accent-primary) 24%, transparent);
  color: var(--accent-primary);
}

@media (prefers-reduced-motion: reduce) {
  .segmentedButton {
    transition: none;
  }
}

.overrideSummaryChip {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
  background: color-mix(in srgb, var(--accent-primary) 14%, transparent);
  color: var(--accent-primary);
  text-transform: none;
  letter-spacing: 0;
}

.actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ----- Footer (segmented action bar) ----- */

.footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  margin-top: 2px;
  border-top: 1px solid var(--divider);
}

.footerSpacer {
  margin-left: auto;
}

.errorText {
  color: var(--status-stopped);
  font-size: 11px;
}

/* ----- Icon buttons (chevrons, edit pencil) ----- */

.iconButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  transition: background 0.12s ease, color 0.12s ease;
}

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

.iconButton:disabled {
  opacity: 0.35;
  cursor: default;
}

@media (prefers-reduced-motion: reduce) {
  .iconButton {
    transition: none;
  }
}

/* ----- Button variants ----- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
  color: var(--text-primary);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease,
    box-shadow 0.12s ease, opacity 0.12s ease;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-primary) 60%, transparent);
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }
}

.btnPrimary {
  composes: btn;
  background: var(--accent-primary);
  color: var(--on-accent);
  border-color: var(--accent-primary);
}

.btnPrimary:hover:not(:disabled) {
  filter: brightness(0.92);
}

.btnGhost {
  composes: btn;
  border-color: var(--divider);
  color: var(--text-muted);
}

.btnGhost:hover:not(:disabled) {
  background: var(--hover-bg);
  color: var(--text-primary);
  border-color: var(--text-dim);
}

.btnDestructiveText {
  composes: btn;
  color: var(--accent-error);
}

.btnDestructiveText:hover:not(:disabled) {
  background: var(--accent-error-hover);
}

.btnDestructiveFill {
  composes: btn;
  background: var(--accent-error);
  color: var(--on-accent);
  border-color: var(--accent-error);
}

.btnDestructiveFill:hover:not(:disabled) {
  filter: brightness(0.92);
}

/* ----- Confirm-delete panel (inset, bleeds to card edges) ----- */

.confirmPanel {
  margin: 4px -14px -12px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--status-stopped) 6%, transparent);
  border-top: 1px solid color-mix(in srgb, var(--status-stopped) 25%, var(--divider));
  /* Match the card's inner corner radius (8px outer - 1px border) so the
     destructive bleed looks flush with the card without `overflow: hidden`
     on `.row`, which would clip the slash autocomplete picker. */
  border-bottom-left-radius: 7px;
  border-bottom-right-radius: 7px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.confirmCopy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

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

.confirmActions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* ----- Empty state + Add button ----- */

.empty {
  padding: 16px;
  border: 1px dashed var(--divider);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  margin-bottom: 16px;
}

.addButton {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px dashed var(--divider);
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
}

.addButton:hover {
  border-color: var(--text-dim);
  color: var(--text-primary);
}

/* ----- Inherited globals list ----- */

.inheritedHeading {
  margin: 24px 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.inheritedRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--divider);
  border-radius: 6px;
  background: color-mix(in srgb, var(--sidebar-bg) 60%, transparent);
}

.inheritedRow + .inheritedRow {
  margin-top: 6px;
}

.inheritedName {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  flex-shrink: 0;
}

.inheritedPrompt {
  flex: 1;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.overriddenBadge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--accent-bg);
  color: var(--accent-primary);
  flex-shrink: 0;
}
