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

.settings-console-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(236px, 0.58fr) minmax(0, 1.42fr);
  grid-template-areas:
    "basic-config xhs-feishu"
    "models models";
  overflow: hidden;
}

.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-headline {
  align-items: center;
}

.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: 16px;
  border: 1px solid rgba(173, 192, 245, 0.75);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(245, 248, 255, 0.72));
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 28px rgba(109, 124, 255, 0.08);
}

.settings-panel {
  min-height: 0;
  padding: 8px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(157, 180, 255, 0.45);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.5));
  box-shadow: 0 10px 22px rgba(109, 124, 255, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
}

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

.settings-panel-modern {
  background:
    radial-gradient(circle at top right, rgba(94, 203, 255, 0.18), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(248, 250, 255, 0.62));
}

.settings-panel-secondary {
  background:
    radial-gradient(circle at top left, rgba(139, 125, 255, 0.18), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(248, 246, 255, 0.66));
}

.settings-panel-models {
  background:
    radial-gradient(circle at top center, rgba(109, 124, 255, 0.18), transparent 36%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(247, 249, 255, 0.66));
}

.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-models {
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.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: linear-gradient(135deg, rgba(109, 124, 255, 0.14), rgba(94, 203, 255, 0.16));
  color: #5166d6;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  box-shadow: inset 0 0 0 1px rgba(125, 143, 255, 0.16);
}

.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-basic-config-card {
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
}

.settings-section-headline-basic {
  align-items: flex-start;
  justify-content: flex-start;
}

.settings-basic-config-form {
  min-height: 0;
  display: grid;
  align-content: center;
  gap: 10px;
}

.settings-basic-config-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 146px;
  align-items: end;
  gap: 10px;
}

.settings-basic-config-row-directory {
  align-items: start;
}

.settings-basic-directory-card {
  gap: 6px;
}

.settings-basic-directory-actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: unset;
  grid-template-columns: repeat(2, 70px);
  align-self: end;
  justify-self: start;
  width: 146px;
}

.settings-basic-directory-actions button,
.settings-inline-save-button {
  height: 38px;
  min-height: 38px;
  padding-block: 0;
  padding-inline: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  white-space: nowrap;
}

.settings-inline-save-button {
  min-width: 72px;
  justify-self: start;
}

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

.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: 38px;
  padding: 9px 12px;
  border-color: rgba(170, 187, 228, 0.82);
  background: rgba(252, 253, 255, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.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 rgba(109, 124, 255, 0.16);
  outline-offset: 0;
  border-color: rgba(109, 124, 255, 0.42);
  box-shadow: 0 0 0 4px rgba(94, 203, 255, 0.12);
}

.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(188px, auto);
  align-content: start;
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 143, 255, 0.34) transparent;
}

.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(125, 143, 255, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.model-config-grid-four::-webkit-scrollbar-thumb:hover {
  background: rgba(125, 143, 255, 0.44);
}

.model-config-card {
  display: grid;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 12px;
  border-radius: 18px;
  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: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

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

.model-config-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  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: 3px;
}

.settings-field-grid-xhs-feishu .settings-input-label input {
  min-height: 34px;
  padding: 7px 10px;
}

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

.settings-panel-xhs-feishu .settings-primary-button {
  min-width: 72px;
}

.settings-panel .status-chip {
  min-height: 24px;
  padding: 0 9px;
  background: rgba(248, 250, 255, 0.88);
  color: #536587;
  box-shadow: inset 0 0 0 1px rgba(181, 195, 234, 0.88);
}

.settings-panel .status-chip.positive {
  background: rgba(16, 185, 129, 0.14);
  color: #0f7f59;
  box-shadow: none;
}

.settings-panel .status-chip.warning {
  background: rgba(245, 158, 11, 0.16);
  color: #b46f0a;
  box-shadow: none;
}

.settings-actions {
  gap: 8px;
  flex-wrap: wrap;
}

.settings-actions button {
  min-height: 38px;
}

.settings-page-shell .settings-primary-button {
  min-width: 100px;
  min-height: 38px;
  height: 38px;
  padding: 0 14px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  white-space: nowrap;
  background: linear-gradient(135deg, #3b82f6, #1e40af);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.24);
}

.settings-page-shell .settings-primary-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #4c8dff, #2148bd);
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.28);
}

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

.settings-page-shell .settings-inline-save-button,
.settings-page-shell .settings-panel-xhs-feishu .settings-primary-button {
  min-width: 72px;
  padding-inline: 12px;
}

.settings-page-shell .settings-basic-directory-actions button {
  width: 100%;
  min-width: 0;
  padding-inline: 6px;
}

.settings-page-shell .settings-actions button:not(.settings-primary-button):not(.secondary),
.settings-page-shell .workspace-directory-inline-actions button:not(.settings-primary-button):not(.secondary) {
  background: rgba(255, 255, 255, 0.94);
  color: #2b426d;
  box-shadow: inset 0 0 0 1px rgba(179, 194, 228, 0.9);
}

.settings-panel .workspace-directory-card {
  min-height: 0;
  gap: 8px;
}

.settings-panel .workspace-directory-panel {
  min-height: 0;
  height: 100%;
  padding: 12px 14px;
  border-radius: 18px;
  border-color: rgba(173, 192, 245, 0.72);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(245, 248, 255, 0.88) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 8px 18px rgba(109, 124, 255, 0.06);
}

.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-section-card {
  grid-template-rows: auto minmax(0, 1fr);
}

.settings-panel-basic-config .workspace-directory-card {
  gap: 6px;
}

.settings-panel-basic-config .settings-input-label input,
.settings-panel-basic-config .workspace-directory-panel {
  width: 100%;
  min-height: 38px;
  height: auto;
  padding: 9px 12px;
  border-radius: 18px;
  border: 1px solid rgba(173, 192, 245, 0.72);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(245, 248, 255, 0.88) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 8px 18px rgba(109, 124, 255, 0.06);
}

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

.settings-basic-directory-panel .workspace-directory-path {
  display: block;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: normal;
}

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

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

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

.workspace-directory-draft-row,
.workspace-directory-inline-actions,
.workspace-directory-actions {
  gap: 6px;
}

@media (max-width: 1180px) {
  .settings-console-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: minmax(164px, auto) minmax(0, 1fr);
    grid-template-areas:
      "basic-config xhs-feishu"
      "models models";
  }

  .model-config-grid-four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(188px, 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;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    grid-template-areas:
      "basic-config"
      "xhs-feishu"
      "models";
    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);
  }

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

  .settings-inline-save-button,
  .settings-basic-directory-actions {
    justify-self: stretch;
  }

  .settings-basic-directory-actions {
    grid-auto-flow: row;
    grid-auto-columns: unset;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 720px) {
  .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-panel .status-chip {
    align-self: flex-start;
  }

  .settings-actions button,
  .workspace-directory-actions button {
    width: 100%;
  }

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