:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #eef2f4;
  --text: #17201d;
  --muted: #66726d;
  --border: #d8dfdc;
  --border-strong: #b8c4bf;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #eef4ff;
  --amber: #c2410c;
  --rose: #b42318;
  --shadow: 0 16px 40px rgba(23, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(224, 242, 239, 0.72), rgba(246, 247, 249, 0) 340px),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  width: min(1400px, 100%);
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  text-decoration: none;
}

.brand-description {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.brand-mark {
  position: relative;
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark::before,
.brand-mark::after,
.brand-mark span {
  position: absolute;
  content: "";
  border-radius: 999px;
  background: var(--accent);
}

.brand-mark::before {
  width: 22px;
  height: 2px;
}

.brand-mark::after {
  width: 2px;
  height: 22px;
}

.brand-mark span {
  width: 10px;
  height: 10px;
  border: 2px solid var(--amber);
  background: var(--surface);
}

.eyebrow {
  display: block;
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 2px;
  font-size: clamp(1.65rem, 4vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.95rem;
  white-space: nowrap;
}

.status-strip span {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  padding: 6px 10px;
}

.page-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 20px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  padding: 4px;
}

.page-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 7px 14px;
  font-weight: 800;
  text-decoration: none;
}

.page-tab[aria-current="page"] {
  background: var(--accent);
  color: #ffffff;
}

.page-tab:focus-visible {
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
  outline: none;
}

.page-panel[hidden] {
  display: none;
}

.tool-band {
  position: sticky;
  top: 56px;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  align-items: end;
  gap: 14px;
  margin-top: 24px;
  border-block: 1px solid var(--border);
  background: rgba(247, 249, 252, 0.94);
  padding: 14px 0;
  backdrop-filter: blur(16px);
}

.search-field {
  display: grid;
  gap: 5px;
}

.field-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.search-control {
  position: relative;
  display: block;
}

.search-field input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px 10px 42px;
  outline: none;
}

.search-field input:focus,
.select-field input:focus,
.select-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 15px;
  width: 15px;
  height: 15px;
  border: 2px solid var(--muted);
  border-radius: 999px;
  transform: translateY(-55%);
}

.search-icon::after {
  position: absolute;
  right: -6px;
  bottom: -5px;
  width: 7px;
  height: 2px;
  background: var(--muted);
  content: "";
  transform: rotate(45deg);
}

.select-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.select-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.select-field input,
.select-field select {
  min-width: 126px;
  min-height: 46px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 34px 9px 12px;
  outline: none;
}

.content-band {
  padding-top: 30px;
}

.model-band {
  display: grid;
  gap: 18px;
  border-bottom: 1px solid var(--border);
  padding: 26px 0;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.section-heading__copy {
  display: grid;
  gap: 6px;
}

.section-heading h2 {
  margin-top: 3px;
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  line-height: 1.2;
}

.section-heading p {
  color: var(--muted);
  text-align: right;
}

.section-heading .section-description {
  max-width: 540px;
  text-align: left;
}

.result-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.filter-reset {
  min-height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-strong);
  padding: 6px 10px;
  font-size: 0.84rem;
  font-weight: 800;
}

.filter-reset:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.filter-reset:focus-visible {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
  outline: none;
}

.health-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 6px 12px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.health-pill[data-state="secure"] {
  border-color: rgba(15, 118, 110, 0.26);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.health-pill[data-state="open"],
.health-pill[data-state="error"] {
  border-color: rgba(180, 83, 9, 0.28);
  background: #fff4df;
  color: var(--amber);
}

.model-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.summary-card {
  display: grid;
  gap: 7px;
  min-height: 128px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 16px;
}

.summary-card__label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.summary-card strong {
  display: block;
  color: var(--text);
  font-size: clamp(1.05rem, 2vw, 1.34rem);
  line-height: 1.25;
}

.summary-card__hint {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.summary-card--endpoint {
  align-content: start;
}

.summary-card code {
  display: block;
  overflow-wrap: anywhere;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
  padding: 7px 8px;
  color: var(--accent-strong);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
}

.model-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(360px, 1.28fr);
  gap: 16px;
  align-items: end;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  padding: 16px;
}

.model-toolbar h3 {
  font-size: 1.05rem;
}

.model-toolbar p,
.config-section__head p,
.provider-row__head p {
  color: var(--muted);
  font-size: 0.9rem;
}

.model-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 220px) minmax(150px, 190px) auto;
  gap: 12px;
  align-items: end;
}

.admin-save-note {
  display: grid;
  min-height: 46px;
  align-content: center;
  gap: 2px;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 8px;
  background: var(--accent-soft);
  padding: 8px 12px;
  color: var(--accent-strong);
  font-size: 0.84rem;
}

.admin-save-note strong {
  color: var(--accent-strong);
  font-size: 0.92rem;
}

.admin-save-note span {
  color: var(--muted);
}

.text-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.text-field small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
}

.text-field input,
.text-field select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 12px;
  outline: none;
}

.text-field input:focus,
.text-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.text-field--key {
  min-width: min(100%, 230px);
}

.text-field--wide {
  min-width: min(100%, 270px);
}

.model-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.config-section {
  display: grid;
  gap: 12px;
}

.config-section__head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.config-section__head h3 {
  margin-top: 3px;
  font-size: 1.14rem;
  line-height: 1.25;
}

.config-section__head p {
  max-width: 420px;
  text-align: right;
}

.provider-list {
  display: grid;
  gap: 10px;
}

.provider-row {
  display: grid;
  gap: 12px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  padding: 14px;
}

.provider-row[data-provider-state="active"] {
  border-left-color: var(--accent);
}

.provider-row[data-provider-state="saved"] {
  border-left-color: var(--amber);
}

.provider-row[data-provider-state="empty"] {
  border-left-color: var(--border-strong);
}

.provider-row__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.provider-row__title {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.toggle-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.provider-row .toggle-field input[type="checkbox"] {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.provider-name {
  min-width: 0;
  overflow-wrap: normal;
  word-break: keep-all;
}

.provider-state {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 4px 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  white-space: nowrap;
}

.provider-state--active {
  border-color: rgba(15, 118, 110, 0.28);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.provider-state--saved {
  border-color: rgba(180, 83, 9, 0.28);
  background: #fff4df;
  color: var(--amber);
}

.provider-row__fields {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 10px;
  align-items: end;
}

.model-multi-field {
  display: grid;
  grid-column: 1 / -1;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  padding: 10px;
}

.model-multi-field legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.model-choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.model-choice {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 6px 9px;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 750;
}

.model-choice input[type="checkbox"] {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.model-choice span {
  overflow-wrap: anywhere;
}

.provider-row__fields > .inline-button {
  justify-self: end;
}

.inline-button {
  min-height: 46px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 12px;
  font-weight: 800;
  white-space: nowrap;
}

.inline-button:hover {
  border-color: var(--rose);
  color: var(--rose);
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  align-items: stretch;
  gap: 18px;
}

.project-card {
  display: grid;
  min-height: 218px;
  align-content: space-between;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  text-decoration: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.project-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.project-card:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
  outline: none;
}

.project-card__media {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
  margin: -6px -6px 0;
}

.project-card__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-card__media picture {
  display: block;
  width: 100%;
  height: 100%;
}

.project-card__top {
  display: grid;
  gap: 12px;
}

.project-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.pill--stage {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.project-card h3 {
  font-size: 1.15rem;
  line-height: 1.25;
}

.project-card p {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.project-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  color: var(--muted);
  font-size: 0.86rem;
}

.open-indicator {
  display: inline-flex;
  min-width: 54px;
  height: 28px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 8px;
  background: var(--text);
  color: var(--surface);
  padding: 0 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

.empty-state {
  display: grid;
  min-height: 360px;
  place-items: center;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  padding: 44px 22px;
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-state h3 {
  margin-top: 18px;
  font-size: 1.2rem;
}

.empty-state p {
  margin-top: 6px;
  max-width: 420px;
  color: var(--muted);
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

.action-button {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--surface);
  padding: 9px 14px;
  font-weight: 800;
}

.action-button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.action-button:focus-visible {
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
  outline: none;
}

.action-button--secondary {
  background: var(--surface);
  color: var(--accent-strong);
}

.action-button--secondary:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.action-status {
  min-height: 24px;
  font-size: 0.9rem;
  font-weight: 700;
}

.empty-visual {
  display: grid;
  grid-template-columns: repeat(3, 34px);
  gap: 10px;
}

.empty-visual span {
  display: block;
  height: 50px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
}

.empty-visual span:nth-child(2) {
  height: 74px;
  background: var(--accent-soft);
}

.empty-visual span:nth-child(3) {
  height: 58px;
  background: #fff4df;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 24px, 1180px);
    padding-top: 18px;
  }

  .topbar,
  .section-heading,
  .config-section__head {
    align-items: stretch;
    flex-direction: column;
  }

  .status-strip {
    flex-wrap: wrap;
  }

  .brand-description {
    margin-top: 6px;
    font-size: 0.88rem;
  }

  .page-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .tool-band {
    position: static;
    grid-template-columns: 1fr;
    margin-top: 20px;
    background: transparent;
    backdrop-filter: none;
  }

  .model-summary,
  .model-toolbar,
  .model-controls,
  .provider-row__fields {
    grid-template-columns: 1fr;
  }

  .config-section__head p {
    max-width: none;
    text-align: left;
  }

  .provider-row__head {
    align-items: flex-start;
    flex-direction: column;
  }

  .provider-row__fields > .inline-button {
    justify-self: stretch;
    width: 100%;
  }

  .model-actions {
    justify-content: stretch;
  }

  .model-actions .action-button {
    flex: 1 1 140px;
  }

  .select-group {
    justify-content: stretch;
  }

  .select-field {
    flex: 1 1 150px;
  }

  .select-field input,
  .select-field select {
    width: 100%;
  }

  .section-heading p {
    text-align: left;
  }

  .result-tools {
    justify-content: space-between;
  }

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

@media (max-width: 420px) {
  .brand {
    align-items: flex-start;
  }

  .brand-description {
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .status-strip {
    gap: 8px;
    font-size: 0.86rem;
  }

  .status-strip span {
    padding: 5px 8px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

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