:root {
  color-scheme: light;
  --ink: #171b18;
  --ink-soft: #39433d;
  --paper: #f4f5f0;
  --surface: #ffffff;
  --surface-muted: #eceee7;
  --muted: #626d66;
  --quiet: #8b948e;
  --border: #d7dbd0;
  --border-strong: #bdc5b9;
  --accent: #175f45;
  --accent-dark: #104532;
  --accent-soft: #dfece5;
  --ok: #217847;
  --warn: #a45d17;
  --bad: #b23c2f;
  --content: 1180px;
  --radius: 7px;
  --sans: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--accent-dark);
  text-underline-offset: 3px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(23, 95, 69, 0.28);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
}

.top-nav,
#app,
.site-footer {
  width: min(var(--content), calc(100% - 48px));
  margin: 0 auto;
}

.top-nav {
  min-height: 64px;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font-family: var(--mono);
  font-size: 0.67rem;
  font-weight: 750;
}

.nav-links,
.session-actions {
  display: flex;
  align-items: center;
}

.nav-links {
  justify-content: flex-start;
  gap: 22px;
}

.session-actions {
  justify-content: flex-end;
  gap: 10px;
}

.nav-links a,
.text-link,
.login-link {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 620;
  text-decoration: none;
  white-space: nowrap;
}

.nav-links a:hover,
.text-link:hover {
  color: var(--ink);
}

.login-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.account-label {
  max-width: 200px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 1rem;
}

.icon-button:hover {
  border-color: var(--border-strong);
  background: var(--surface-muted);
}

#app {
  padding: 42px 0 72px;
}

.public-gate {
  min-height: min(460px, calc(100dvh - 150px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  align-items: center;
  gap: 80px;
  border-bottom: 1px solid var(--border);
}

.public-copy h1,
.dashboard-head h1 {
  margin: 14px 0 0;
  font-size: clamp(2.65rem, 6vw, 4.4rem);
  font-weight: 720;
  line-height: 1;
  letter-spacing: 0;
}

.public-copy p {
  margin: 18px 0 0;
  color: var(--ink-soft);
  font-size: 1.08rem;
}

.live-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.live-state i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}

.login-panel {
  display: grid;
  gap: 16px;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 36px rgba(31, 47, 38, 0.08);
}

.login-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
}

.login-modes button {
  min-height: 34px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-weight: 650;
}

.login-modes button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(31, 47, 38, 0.12);
}

.login-fields {
  display: grid;
  gap: 16px;
}

.login-fields[hidden] {
  display: none;
}

.public-catalog {
  margin-top: 40px;
}

.login-heading,
.section-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.login-heading {
  margin-bottom: 2px;
}

.login-heading h2,
.section-bar h2,
.readme-heading h2 {
  margin: 3px 0 0;
  font-size: 1.18rem;
  font-weight: 700;
  line-height: 1.25;
}

.section-label {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.67rem;
  font-weight: 750;
}

.lock-mark {
  color: var(--accent);
  font-size: 0.7rem;
}

.login-panel label {
  display: grid;
  gap: 6px;
}

.login-panel label > span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 620;
}

.login-panel input,
.search-field input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

.login-panel input {
  min-height: 44px;
  padding: 0 12px;
}

.primary-button {
  min-height: 44px;
  margin-top: 4px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 680;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.form-message {
  margin: 0;
  padding: 9px 11px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink-soft);
  font-size: 0.76rem;
}

.form-message.is-error {
  border-left-color: var(--bad);
  background: #f7e8e5;
  color: #812e25;
}

.dashboard-head {
  min-height: 136px;
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(600px, 1.8fr);
  align-items: center;
  gap: 48px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--border);
}

.dashboard-head h1 {
  font-size: 2.25rem;
}

.ingest-bay {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(0, 1.28fr);
  gap: 28px;
  align-items: stretch;
  margin: 0 0 40px;
}

.ingest-copy h2 {
  margin: 6px 0 10px;
  font-size: 1.55rem;
  font-weight: 720;
}

.ingest-copy p {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.ingest-probe {
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 650;
}

.ingest-mouth {
  min-height: 168px;
  display: grid;
  place-items: center;
  padding: 28px 24px 32px;
  border-radius: 999px 999px 42px 42px;
  background:
    radial-gradient(120% 90% at 50% 118%, rgba(0, 0, 0, 0.38), transparent 52%),
    linear-gradient(180deg, #1b7a58 0%, var(--accent-dark) 72%);
  color: #f4fff8;
  text-align: center;
  cursor: pointer;
  box-shadow: inset 0 -18px 28px rgba(0, 0, 0, 0.22);
}

.ingest-mouth b {
  font-size: 1.28rem;
  font-weight: 760;
}

.ingest-mouth span {
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.82rem;
}

.ingest-mouth.is-open,
.ingest-mouth:hover {
  filter: brightness(1.06);
}

.ingest-queue {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.ingest-queue li {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.8rem;
}

.ingest-queue b {
  color: var(--accent-dark);
}

@media (max-width: 760px) {
  .ingest-bay {
    grid-template-columns: 1fr;
  }

  .ingest-mouth {
    min-height: 140px;
    border-radius: 28px;
  }
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.metric {
  min-height: 68px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 16px;
  border-left: 1px solid var(--border);
}

.metric:first-child {
  border-left: 0;
}

.metric strong {
  font-family: var(--mono);
  font-size: 1.2rem;
  line-height: 1.1;
}

.metric span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.67rem;
}

.dashboard-section {
  margin-bottom: 52px;
  scroll-margin-top: 86px;
}

.section-bar {
  min-height: 52px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-strong);
}

.section-count {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.workbench-tools {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 8px;
  border: 1px solid var(--border);
  border-top: 0;
  background: var(--surface-muted);
}

.segments {
  display: flex;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
}

.segments button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.73rem;
  font-weight: 650;
  white-space: nowrap;
}

.segments button:hover {
  background: var(--surface);
  color: var(--ink);
}

.segments button[aria-pressed="true"] {
  background: var(--accent);
  color: #ffffff;
}

.search-field {
  width: 250px;
  flex: 0 0 auto;
}

.search-field input {
  min-height: 36px;
  padding: 0 11px;
  font-size: 0.75rem;
}

.workbench-list {
  border: 1px solid var(--border);
  border-top: 0;
  background: var(--surface);
}

.workbench-row {
  min-height: 88px;
  display: grid;
  grid-template-columns: 42px minmax(240px, 1.35fr) minmax(280px, 1.2fr) 62px;
  align-items: center;
  gap: 18px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}

.workbench-row:last-child {
  border-bottom: 0;
}

.workbench-row:hover {
  background: #f8f9f6;
}

.workbench-row[hidden] {
  display: none;
}

.app-mark {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #b9cabf;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 750;
}

.workbench-name {
  min-width: 0;
}

.workbench-name > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workbench-name h3 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 0.87rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workbench-name p {
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.status::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status-available {
  color: var(--ok);
}

.status-degraded {
  color: var(--warn);
}

.status-unavailable {
  color: var(--bad);
}

.capability-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.capability-list span {
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-muted);
  color: var(--ink-soft);
  font-size: 0.64rem;
  white-space: nowrap;
}

.open-link {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-decoration: none;
}

.open-link b {
  font-size: 0.9rem;
  font-weight: 500;
}

.empty-state {
  margin: 0;
  padding: 32px;
  border: 1px solid var(--border);
  border-top: 0;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.data-grid,
.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
}

.data-item,
.status-grid > div {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 15px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.data-item strong,
.status-grid > div > span:first-child {
  overflow: hidden;
  font-size: 0.76rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-item code {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.62rem;
}

.agent-row {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 16px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.agent-row > div {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.agent-row span {
  color: var(--muted);
  font-size: 0.7rem;
}

.agent-row code {
  overflow: hidden;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-row nav {
  display: flex;
  gap: 16px;
}

.agent-row a {
  font-size: 0.72rem;
  font-weight: 650;
}

.agent-hint {
  margin: 12px 0 0;
  color: var(--muted, #687481);
  font-size: 0.82rem;
  line-height: 1.45;
}

.agent-hint code {
  font-size: 0.78rem;
}

.readme {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 48px;
  padding: 42px 0 12px;
  border-top: 1px solid var(--border-strong);
  scroll-margin-top: 84px;
}

.readme-list {
  border-top: 1px solid var(--border);
}

.readme details {
  border-bottom: 1px solid var(--border);
}

.readme summary {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 650;
  list-style: none;
}

.readme summary::-webkit-details-marker {
  display: none;
}

.readme summary::after {
  color: var(--quiet);
  content: "+";
  font-family: var(--mono);
}

.readme details[open] summary::after {
  content: "-";
}

.readme p {
  max-width: 700px;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.76rem;
}

.doc-links {
  display: flex;
  gap: 16px;
  margin-bottom: 18px;
}

.doc-links a {
  font-size: 0.72rem;
  font-weight: 650;
}

.site-footer {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  color: var(--quiet);
  font-family: var(--mono);
  font-size: 0.65rem;
}

noscript {
  display: block;
  padding: 16px;
  background: #f7e8e5;
  color: #812e25;
  text-align: center;
}

.clipboard-assistant {
  width: min(460px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 18px 60px rgb(18 31 25 / 18%);
}

.clipboard-assistant::backdrop { background: rgb(18 31 25 / 28%); }
.clipboard-assistant form { padding: 24px; }
.clipboard-assistant h2 { margin: 5px 0 10px; font-size: 1.25rem; }
.clipboard-assistant p { margin: 0; color: var(--muted); line-height: 1.6; }
.clipboard-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.secondary-button { border: 1px solid var(--border); background: white; }
.clipboard-actions button { min-height: 42px; padding: 0 16px; border-radius: 6px; cursor: pointer; }

@media (max-width: 980px) {
  .top-nav {
    grid-template-columns: auto 1fr auto;
  }

  .nav-links {
    gap: 14px;
  }

  .public-gate {
    grid-template-columns: minmax(0, 1fr) 350px;
    gap: 44px;
  }

  .dashboard-head {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 24px 0;
  }

  .workbench-row {
    grid-template-columns: 42px minmax(220px, 1fr) minmax(180px, 0.8fr) 54px;
    gap: 14px;
  }

  .capability-list span:nth-child(n + 3) {
    display: none;
  }
}

@media (max-width: 760px) {
  .top-nav,
  #app,
  .site-footer {
    width: min(100% - 28px, var(--content));
  }

  .top-nav {
    min-height: 58px;
    grid-template-columns: 1fr auto;
  }

  .brand {
    font-size: 0.9rem;
  }

  .nav-links {
    display: none;
  }

  .text-link,
  .account-label {
    display: none;
  }

  #app {
    padding-top: 26px;
  }

  .public-gate {
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 34px;
    padding: 42px 0 52px;
  }

  .public-copy h1 {
    font-size: 2.7rem;
  }

  .login-panel {
    padding: 20px;
  }

  .dashboard-head {
    margin-bottom: 30px;
  }

  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric {
    min-height: 58px;
    border-bottom: 1px solid var(--border);
  }

  .metric:nth-child(4) {
    border-left: 0;
  }

  .workbench-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .search-field {
    width: 100%;
  }

  .workbench-row {
    grid-template-columns: 38px minmax(0, 1fr) 36px;
    min-height: 76px;
    padding: 11px;
  }

  .app-mark {
    width: 34px;
    height: 34px;
  }

  .capability-list {
    display: none;
  }

  .open-link span {
    display: none;
  }

  .data-grid,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .agent-row {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .agent-row > div {
    width: 100%;
  }

  .readme {
    grid-template-columns: 1fr;
    gap: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
