.settings-panel {
  width: min(820px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border-visible);
  border-radius: 14px;
  padding: 28px 24px 24px;
  overscroll-behavior: contain;
  box-shadow:
    0 4px 24px var(--shadow-color),
    0 24px 64px var(--shadow-color-strong),
    inset 0 1px 0 var(--inset-highlight);
  animation: command-bar-enter 350ms var(--ease-out-expo) both;
}
.command-bar-overlay.closing .settings-panel {
  animation: command-bar-exit 200ms var(--ease-in-out) both;
}
.settings-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 22px;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}

/* Compact global upsell */
.settings-compact-upsell {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--accent-primary) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-primary) 18%, transparent);
}
.settings-compact-upsell-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.settings-compact-upsell-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.settings-compact-upsell-actions .premium-btn {
  font-size: 11px;
  padding: 4px 12px;
  height: auto;
}

/* Sidebar + Content layout */
.settings-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 0;
}
.settings-sidebar {
  width: 170px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-subtle);
  padding: 8px 8px 8px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
  text-align: left;
}
.settings-nav-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.settings-nav-item:focus-visible {
  outline: 1px solid var(--accent-primary);
  outline-offset: -1px;
}
.settings-nav-item.active {
  background: color-mix(in srgb, var(--accent-primary) 12%, transparent);
  color: var(--accent-primary);
  font-weight: 500;
}
.settings-nav-item svg {
  flex-shrink: 0;
}
.settings-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 0 0 0 20px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.settings-category-panel {
  /* wrapper for each category's content */
}

/* Mobile: stack sidebar above content */
@media (max-width: 700px) {
  .settings-panel {
    width: min(440px, calc(100vw - 32px));
  }
  .settings-layout {
    flex-direction: column;
  }
  .settings-sidebar {
    flex-direction: row;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 0 8px 0;
    margin-bottom: 12px;
    overflow-x: auto;
    gap: 2px;
  }
  .settings-nav-item {
    flex-shrink: 0;
    width: auto;
    padding: 6px 10px;
    font-size: 11px;
  }
  .settings-nav-item span {
    display: none;
  }
  .settings-content {
    padding-left: 0;
  }
}

.settings-callout {
  margin-bottom: 20px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--accent-primary) 14%, transparent);
  background: color-mix(in srgb, var(--accent-primary) 6%, transparent);
}
.settings-callout-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.settings-callout-copy {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0;
}
.settings-premium-callout {
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--accent-primary) 16%, transparent), transparent 40%),
    color-mix(in srgb, var(--accent-primary) 6%, transparent);
  border-color: color-mix(in srgb, var(--accent-primary) 22%, transparent);
}
.settings-premium-callout-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.settings-field {
  margin-bottom: 18px;
}
.settings-health {
  margin-bottom: 20px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-visible);
  background: var(--surface-glass);
}
.settings-health-issues {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.settings-health-issue {
  font-size: 12px;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
}
.settings-health-issue.warning {
  border-color: color-mix(in srgb, var(--accent-primary) 28%, transparent);
  background: color-mix(in srgb, var(--accent-primary) 6%, transparent);
}
.settings-health-issue.error {
  border-color: color-mix(in srgb, var(--status-error) 32%, transparent);
  background: color-mix(in srgb, var(--status-error) 6%, transparent);
}
.settings-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.settings-secondary-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-visible);
  background: var(--surface-glass);
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
}
.settings-secondary-btn:hover:not(:disabled) {
  background: var(--bg-tertiary);
}
.settings-secondary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.settings-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.settings-label-optional {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}
.settings-input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  margin: 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-visible);
  background: var(--surface-glass);
  color: var(--text-primary);
  font-family: "JetBrains Mono", "SF Mono", "Fira Code", monospace;
  font-size: 12px;
  line-height: 1;
  box-sizing: border-box;
  text-rendering: auto;
}
.settings-select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.settings-textarea {
  width: 100%;
  padding: 8px 10px;
  margin: 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-visible);
  background: var(--surface-glass);
  color: var(--text-primary);
  font-family: "JetBrains Mono", "SF Mono", "Fira Code", monospace;
  font-size: 12px;
  min-height: 120px;
  resize: vertical;
  box-sizing: border-box;
  line-height: 1.5;
}
.settings-feedback-textarea {
  margin-top: 8px;
  min-height: 96px;
}
.settings-input:focus,
.settings-textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-primary) 18%, transparent);
}
.settings-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}
.settings-hint code {
  font-size: 11px;
  background: var(--bg-tertiary);
  padding: 1px 5px;
  border-radius: 3px;
}
.settings-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--text-muted) 40%, transparent);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--duration-fast);
}
.toggle-switch:hover {
  background: color-mix(in srgb, var(--text-muted) 60%, transparent);
}
.toggle-switch.on {
  background: var(--accent-primary);
}
.toggle-switch.on:hover {
  background: var(--button-primary-hover-bg);
}
.toggle-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 7px;
  background: var(--bg-primary);
  transition: transform var(--duration-fast);
  box-shadow: 0 1px 3px var(--shadow-color);
}
.toggle-switch.on .toggle-switch-thumb {
  transform: translateX(16px);
}
.settings-status {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.settings-status.success {
  color: var(--status-success);
}
.settings-status.error {
  color: var(--status-error);
}
.settings-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  flex-shrink: 0;
}
.settings-save {
  height: 34px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-primary);
  color: var(--button-primary-fg);
  cursor: pointer;
  transition: background var(--duration-fast);
}
.settings-save:hover {
  background: var(--button-primary-hover-bg);
}
.settings-close {
  height: 34px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-visible);
  font-size: 12px;
  background: var(--surface-glass);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast);
}
.settings-close:hover {
  background: var(--surface-hover);
}
.settings-refresh-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-visible);
  border-radius: var(--radius-md);
  background: var(--surface-glass);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration-fast);
  flex-shrink: 0;
}
.settings-refresh-btn:hover {
  background: var(--surface-hover);
}
.settings-refresh-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.settings-input-disabled {
  display: flex;
  align-items: center;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: 12px;
  opacity: 0.7;
  cursor: not-allowed;
}

/* --- Premium section --- */
.premium-section {
  display: flex;
  flex-direction: column;
}
.premium-description {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0 0 12px;
}
.premium-activate-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.premium-email-input {
  flex: 1;
}
.premium-btn {
  height: 34px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--duration-fast), transform var(--duration-fast);
  white-space: nowrap;
}
.premium-btn:active {
  transform: scale(0.97);
}
.premium-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.premium-btn-activate {
  background: var(--surface-glass);
  border: 1px solid var(--border-visible);
  color: var(--text-primary);
}
.premium-btn-activate:hover {
  background: var(--surface-hover);
}
.premium-btn-upgrade {
  background: var(--accent-primary);
  border: none;
  color: var(--button-primary-fg);
}
.premium-btn-upgrade:hover {
  background: var(--button-primary-hover-bg);
}
.premium-btn-manage {
  background: var(--surface-glass);
  border: 1px solid var(--border-visible);
  color: var(--text-primary);
  align-self: flex-start;
}
.premium-btn-manage:hover {
  background: var(--surface-hover);
}
.premium-active-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--button-primary-fg);
  background: var(--status-success);
  padding: 2px 10px;
  border-radius: 4px;
  margin-bottom: 10px;
}
.premium-detail {
  font-size: 11px;
  color: var(--text-muted);
  margin: 6px 0;
}
.premium-actions-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.premium-btn-reset {
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
}
.premium-btn-reset:hover {
  background: var(--surface-hover);
}

/* Welcome banner */
.welcome-banner {
  margin-bottom: 20px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--accent-primary) 22%, transparent);
  background: color-mix(in srgb, var(--accent-primary) 8%, transparent);
}
.welcome-banner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.welcome-banner-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-primary);
}
.welcome-banner-dismiss {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.welcome-banner-dismiss:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.welcome-banner-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0 0 8px;
}
.welcome-banner-steps {
  margin: 8px 0 0 16px;
  padding: 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.7;
}
.welcome-banner-steps li.done {
  color: var(--text-muted);
  text-decoration: line-through;
}
.welcome-banner-steps kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 11px;
  font-family: "JetBrains Mono", "SF Mono", monospace;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
}
.welcome-banner-actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.welcome-banner-note {
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 360px;
}

/* Agent Credential Vault */
.vault-premium-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent-primary);
  background: color-mix(in srgb, var(--accent-primary) 15%, transparent);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 8px;
  vertical-align: middle;
}
.vault-entries {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.vault-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.vault-entry-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.vault-entry-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vault-entry-detail {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vault-entry-remove {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.vault-entry-remove:hover {
  background: color-mix(in srgb, var(--status-error) 12%, transparent);
  color: var(--status-error);
}
.vault-add-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-tertiary);
  border: 1px dashed var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  width: 100%;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
.vault-add-btn:hover {
  background: var(--border-visible);
  border-color: var(--border-visible);
}
.vault-add-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--surface-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.vault-add-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}
