.settings-page-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  height: 100%;
  padding: 0;
  overflow: hidden;
}

.settings-page-shell {
  --settings-control-height: 36px;
  --settings-control-radius: 6px;
  --settings-card-radius: 10px;
  --settings-control-padding-x: 12px;
  --settings-control-border: #d4d9e2;
  --settings-control-border-strong: #b0b8c8;
  --settings-control-background: #f8fafc;
  --settings-focus-outline: rgba(79, 110, 247, 0.22);
  --settings-focus-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
  --settings-button-height: 32px;
  --settings-button-radius: 6px;
}

.settings-console-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.settings-tabs-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.settings-tabs-toolbar {
  flex: 0 0 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-tabs-row {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.settings-tabs-row::-webkit-scrollbar {
  display: none;
}

.settings-tabs {
  width: max-content;
  max-width: none;
}

.settings-config-source-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: var(--settings-control-height);
  padding: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(229, 239, 235, 0.94), rgba(216, 231, 224, 0.9));
  box-shadow: inset 0 0 0 1px rgba(170, 191, 182, 0.18);
}

.settings-config-source-option {
  min-width: 94px;
  min-height: calc(var(--settings-control-height) - 8px);
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #557062;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: none;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.settings-config-source-option.active {
  background: #ffffff;
  color: #176046;
  box-shadow: 0 8px 18px rgba(36, 84, 64, 0.12), inset 0 0 0 1px rgba(168, 189, 179, 0.22);
}

.settings-panel-basic-config {
  grid-area: basic-config;
}

.settings-panel-connection {
  grid-area: connection;
}

.settings-panel-diagnostics {
  grid-area: diagnostics;
}

.settings-panel-xhs-feishu {
  grid-area: xhs-feishu;
}

.settings-panel-xhs-feishu .settings-section-card-compact {
  grid-template-rows: auto auto auto;
  align-content: start;
  gap: 7px;
  padding: 8px;
}

.settings-panel-xhs-feishu .settings-section-kicker {
  min-height: 22px;
  padding-inline: 9px;
}

.settings-panel-models {
  grid-area: models;
}

.settings-runtime-hint {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #e8ecf1;
  background: #f8fafc;
}

.settings-panel {
  flex: 1 1 auto;
  min-height: 0;
  padding: 8px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e8ecf1;
  background: #ffffff;
}

.settings-panel-body {
  min-height: 0;
  height: 100%;
  padding: 0;
}

.settings-panel-modern {
  background: #ffffff;
}

.settings-panel-secondary {
  background: #ffffff;
}

.settings-panel-models {
  background: #ffffff;
}

.settings-section-card {
  display: grid;
  min-height: 0;
  height: 100%;
  gap: 10px;
  padding: 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.settings-section-card-compact {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.settings-section-card-compact-body-actions {
  grid-template-rows: minmax(0, 1fr) auto;
}

.settings-section-card-models {
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.settings-tabs-layout .settings-section-card-models {
  grid-template-rows: minmax(0, 1fr);
}

.settings-section-headline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.settings-section-headline > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.settings-section-headline-minimal {
  justify-content: flex-start;
  gap: 0;
}

.settings-section-headline h4 {
  margin: 2px 0 0;
  color: #1a2e52;
  font-size: 16px;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.settings-section-headline p {
  margin-top: 4px;
  color: #64779a;
  font-size: 11px;
  line-height: 1.5;
}

.settings-section-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4f6ef7;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.settings-field-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.settings-inline-key-row {
  display: grid;
  grid-template-columns: minmax(0, 520px) auto;
  align-items: end;
  gap: 10px;
}

.settings-inline-key-row .settings-input-label {
  display: grid;
}

.settings-input-label {
  min-width: 0;
  gap: 6px;
}

.settings-input-label-text {
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #60729b;
}

.settings-input-label input,
.settings-input-label textarea,
.settings-input-label select {
  min-height: var(--settings-control-height);
  height: var(--settings-control-height);
  padding: 0 var(--settings-control-padding-x);
  border: 1px solid var(--settings-control-border);
  border-radius: var(--settings-control-radius);
  background: var(--settings-control-background);
  color: #163152;
  font-size: 13px;
  line-height: 1.35;
}

.settings-truncated-input {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-input-label input:focus-visible,
.settings-input-label textarea:focus-visible,
.settings-input-label select:focus-visible {
  outline: 2px solid var(--settings-focus-outline);
  outline-offset: 0;
  border-color: var(--settings-control-border-strong);
  box-shadow: var(--settings-focus-shadow);
}

.settings-secret-input-row {
  position: relative;
  min-width: 0;
}

.settings-secret-input-row input {
  width: 100%;
  min-width: 0;
}

.settings-secret-input-row.has-reveal input {
  padding-right: calc(var(--settings-control-height) + 8px);
}

.settings-secret-value-input {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-secret-reveal-button {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 4px;
  margin: auto 0;
  width: calc(var(--settings-control-height) - 8px);
  height: calc(var(--settings-control-height) - 8px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  padding: 0;
  z-index: 1;
  background: transparent;
  color: #60729b;
  box-shadow: none;
  cursor: pointer;
}

.settings-secret-reveal-button:hover:not(:disabled) {
  color: #1f3f6d;
  background: rgba(31, 63, 109, 0.08);
}

.settings-secret-reveal-button:focus-visible,
.settings-secret-reveal-button:active {
  outline: none;
}

.settings-secret-reveal-button:disabled {
  cursor: default;
  opacity: 0.58;
}

.settings-secret-reveal-button svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.settings-readonly-config-field {
  min-width: 0;
}

.settings-readonly-config-value {
  min-height: var(--settings-control-height);
  height: var(--settings-control-height);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 var(--settings-control-padding-x);
  border: 1px solid var(--settings-control-border);
  border-radius: var(--settings-control-radius);
  background: rgba(246, 249, 255, 0.82);
  color: #405679;
  font-size: 13px;
  line-height: var(--settings-control-height);
}

.settings-readonly-config-text {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-readonly-config-copy-feedback {
  flex: 0 0 auto;
  min-width: 42px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
}

.settings-readonly-config-value[role="button"] {
  cursor: copy;
}

.settings-readonly-config-value[aria-disabled="true"] {
  cursor: default;
}

.settings-readonly-config-value[role="button"]:hover:not([aria-disabled="true"]) {
  border-color: var(--settings-control-border-strong);
  color: #1f3f6d;
  background: rgba(255, 255, 255, 0.92);
}

.settings-readonly-config-value:focus-visible {
  outline: 2px solid var(--settings-focus-outline);
  outline-offset: 0;
  border-color: var(--settings-control-border-strong);
  box-shadow: var(--settings-focus-shadow);
}

.model-config-grid {
  display: grid;
  min-height: 0;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.model-config-grid-four {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(214px, auto);
  align-content: start;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.46) transparent;
}

.model-config-grid-single {
  min-height: 0;
  height: 100%;
  grid-template-columns: minmax(0, 560px);
  align-content: start;
}

.model-config-grid-four::-webkit-scrollbar {
  width: 8px;
}

.model-config-grid-four::-webkit-scrollbar-track {
  background: transparent;
}

.model-config-grid-four::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.model-config-grid-four::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.62);
}

.model-config-card {
  display: grid;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
  border-radius: var(--settings-card-radius);
  border: 1px solid rgba(178, 194, 255, 0.62);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(247, 249, 255, 0.84));
  box-shadow: 0 10px 22px rgba(109, 124, 255, 0.08);
  overflow: hidden;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.settings-actions-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
  margin-top: 2px;
}

.settings-action-button {
  min-width: 72px;
  min-height: var(--settings-button-height);
  height: var(--settings-button-height);
  padding: 0 14px;
  border-radius: var(--settings-button-radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e2e8f0;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.settings-action-button:hover:not(:disabled) {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.settings-action-button:focus-visible {
  outline: 2px solid var(--settings-focus-outline);
  outline-offset: 0;
  box-shadow: var(--settings-focus-shadow);
}

.settings-action-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
}

.settings-action-button-primary {
  border-color: transparent;
  background: #4f6ef7;
  color: #ffffff;
  box-shadow: none;
}

.settings-action-button-primary:hover:not(:disabled) {
  background: #3d5bd9;
  border-color: transparent;
}

.settings-action-button-primary:focus-visible {
  outline-color: rgba(37, 99, 235, 0.22);
}

.settings-action-button-secondary {
  border-color: #e2e8f0;
  background: #f1f5f9;
  color: #475569;
}

.settings-action-button-secondary:hover:not(:disabled) {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.model-config-card:hover {
  border-color: rgba(109, 124, 255, 0.36);
  box-shadow: 0 14px 26px rgba(109, 124, 255, 0.12);
}

.settings-panel-models .model-config-grid-single .model-config-card {
  padding: 0;
  border: 0 !important;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;
}

.settings-panel-models .model-config-grid-single .model-config-card:hover {
  border-color: transparent !important;
  box-shadow: none !important;
}

.model-config-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
}

.model-config-card-head > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.model-config-card-head strong {
  display: block;
  color: #1a2e52;
  font-size: 14px;
  line-height: 1.4;
}

.model-config-card-head p {
  margin-top: 0;
  color: #62759a;
  font-size: 11px;
  line-height: 1.5;
}

.model-config-card-body {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 1px;
}

.model-config-card-body .settings-field-grid {
  min-height: 100%;
  align-content: start;
}

.model-config-card-body-digital-human {
  overflow: visible;
  padding-right: 0;
}

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

.settings-field-grid-xhs-feishu {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  align-content: start;
}

.settings-field-grid-xhs-feishu .settings-input-label {
  gap: 6px;
}

.settings-field-grid-xhs-feishu .settings-input-label input {
  min-height: var(--settings-control-height);
  height: var(--settings-control-height);
  padding: 0 var(--settings-control-padding-x);
}

.settings-xhs-feishu-form {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
}

.settings-xhs-feishu-actions {
  justify-content: flex-end;
  margin-top: 0;
}

.settings-panel .workspace-directory-panel {
  min-height: 0;
  height: 100%;
  padding: 0 var(--settings-control-padding-x);
  border-radius: var(--settings-control-radius);
  border: 1px solid var(--settings-control-border);
  background: var(--settings-control-background);
}

.settings-panel-connection .settings-section-card,
.settings-panel-diagnostics .settings-section-card {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.settings-panel-basic-config .settings-input-label input,
.settings-panel-basic-config .workspace-directory-panel {
  width: 100%;
  min-height: var(--settings-control-height);
  height: var(--settings-control-height);
  padding: 0 var(--settings-control-padding-x);
  border-radius: var(--settings-control-radius);
  border: 1px solid var(--settings-control-border);
  background: var(--settings-control-background);
}

.settings-panel-basic-config .workspace-directory-panel {
  display: flex;
  align-items: center;
}

.settings-readonly-field {
  display: flex;
  align-items: center;
}

.workspace-directory-eyebrow {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: #6c7da0;
}

.workspace-directory-path {
  color: #173056;
  font-size: 12px;
  line-height: 1.45;
  word-break: normal;
}

.workspace-directory-hint {
  color: #66789a;
  font-size: 11px;
  line-height: 1.5;
}

.model-config-grid-runtime .settings-runtime-actions-panel {
  min-height: 0;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
}

.model-config-grid-runtime .settings-runtime-actions {
  width: 100%;
  justify-content: flex-end;
}

@media (max-width: 1180px) {
  .model-config-grid-four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(214px, auto);
  }
}

@media (max-width: 960px) {
  .settings-page-shell {
    height: auto;
    min-height: 100%;
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }

  .settings-page-shell::before,
  .settings-page-shell::after {
    display: none;
  }

  .settings-page-stack {
    height: auto;
    overflow: visible;
  }

  .settings-console-grid {
    flex: 0 0 auto;
    height: auto;
    overflow: visible;
  }

  .settings-tabs-layout {
    height: auto;
    overflow: visible;
  }

  .settings-field-grid,
  .model-config-grid,
  .model-config-grid-four {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(0, auto);
  }

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

  .model-config-grid-runtime .settings-runtime-actions-panel {
    height: auto;
    align-items: stretch;
  }

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

@media (max-width: 720px) {
  .settings-tabs-toolbar {
    align-items: stretch;
    gap: 8px;
  }

  .settings-config-source-toggle {
    align-self: flex-start;
  }

  .settings-config-source-option {
    padding-inline: 9px;
  }

  .plugin-page-topbar,
  .settings-page-topbar {
    padding: 0;
    align-items: stretch;
  }

  .plugin-page,
  .settings-panel {
    padding: 10px;
  }

  .plugin-flat-grid {
    grid-template-columns: 1fr;
  }

  .plugin-flat-card,
  .settings-section-card,
  .model-config-card {
    min-height: 0;
    padding: 14px;
  }

  .settings-section-headline,
  .model-config-card-head {
    flex-direction: column;
  }

  .settings-actions-row .settings-action-button {
    width: 100%;
  }
}

/* --- Bento config cards (basic tab) --- */
.settings-config-cards {
  display: grid;
  gap: 10px;
}

.settings-config-card {
  border: 1px solid #e8ecf1;
  border-radius: 10px;
  background: #fff;
  padding: 16px 18px;
  display: grid;
  gap: 10px;
}

.settings-card-body {
  max-width: 560px;
}

.settings-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* --- Feishu Mobile config grid --- */
.settings-field-grid-feishu-mobile {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

/* --- Secret reveal spinner --- */
.settings-secret-reveal-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(96, 114, 155, 0.24);
  border-top-color: #60729b;
  animation: settings-secret-spin 0.7s linear infinite;
}

@keyframes settings-secret-spin {
  to { transform: rotate(360deg); }
}

/* --- Reveal error in toolbar --- */
.settings-reveal-error {
  font-size: 12px;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
  border-radius: 8px;
  padding: 4px 10px;
  margin-right: 8px;
  white-space: nowrap;
}
