:root {
  color-scheme: dark;
  --bg: #0c0e10;
  --surface: #14171a;
  --surface-2: #1a1e22;
  --line: #2a3036;
  --line-strong: #3b444d;
  --text: #f3f5f7;
  --muted: #98a1aa;
  --signal: #c9ff4a;
  --danger: #ff8585;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at 85% -10%, #243019 0, transparent 30%), var(--bg);
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 72px;
}

.topbar,
.topbar > div,
.topbar nav,
.dialog-heading,
.section-heading,
.capability-heading,
.dialog-actions {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  padding-bottom: 38px;
  border-bottom: 1px solid var(--line);
}

.topbar > div,
.topbar nav { gap: 20px; }

.topbar a,
.text-button {
  padding: 8px;
  border: 0;
  color: var(--muted);
  background: none;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.topbar a:hover,
.text-button:hover { color: var(--text); }

.brand-mark {
  color: var(--signal);
  font: 700 18px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .04em;
}

.topbar-caption,
.count { color: var(--muted); }

.hero-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 40px;
  align-items: end;
  padding: 68px 0 42px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--signal);
  font: 600 12px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 900px;
  margin-bottom: 24px;
  font-size: clamp(42px, 7vw, 82px);
  line-height: .96;
  letter-spacing: -.055em;
}

h2 {
  margin-bottom: 8px;
  font-size: 32px;
  letter-spacing: -.035em;
}

.lede {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.button {
  padding: 13px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: 650 15px/1 inherit;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}

.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .5; cursor: wait; transform: none; }
.primary { border-color: var(--signal); color: #10130b; background: var(--signal); }
.secondary { color: var(--text); background: transparent; }
.secondary:hover { border-color: var(--line-strong); }

.metric-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 18px;
  align-items: center;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgb(20 23 26 / 78%);
}

.metric-strip div { display: flex; flex-direction: column; gap: 6px; }
.metric-strip span { color: var(--muted); font-size: 13px; }
.metric-strip strong { font: 14px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; }
.metric-strip i { color: var(--signal); font-style: normal; }

.projects-section { padding-top: 64px; }
.section-heading { justify-content: space-between; align-items: end; margin-bottom: 20px; }
.project-list { display: grid; gap: 12px; }

.project-card {
  display: grid;
  grid-template-columns: minmax(190px, .85fr) minmax(360px, 1.6fr) auto;
  gap: 24px;
  align-items: center;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.project-card h3 { margin: 10px 0 7px; font-size: 20px; }
.project-card p { margin: 0 0 8px; color: var(--muted); line-height: 1.45; }
.project-identity > small { color: #747d86; }

.status {
  display: inline-flex;
  width: max-content;
  padding: 5px 9px;
  border-radius: 999px;
  color: #cfffab;
  background: #20301c;
  font-size: 12px;
}

.status.incomplete { color: #ffdc8a; background: #352d1c; }
.route-stack { display: flex; flex-wrap: wrap; gap: 8px; }

.route-chip {
  display: inline-grid;
  gap: 3px;
  min-width: 148px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: #101316;
  font-size: 11px;
}

.route-chip b { color: var(--text); font-size: 12px; }
.empty-chip { min-width: 0; }
.card-actions { display: flex; gap: 9px; }

.empty-state {
  padding: 42px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}

dialog {
  width: min(980px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 28px 90px #000b;
}

dialog::backdrop { background: #050607cc; backdrop-filter: blur(5px); }
.dialog-card { padding: 28px; }
.dialog-heading { justify-content: space-between; gap: 20px; }

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  font-size: 25px;
  cursor: pointer;
}

.form-grid,
.credential-grid,
.route-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.project-basics { margin-top: 18px; }

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  color: #dfe3e6;
  font-size: 14px;
}

input,
select {
  width: 100%;
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  color: var(--text);
  background: #0f1214;
  font: inherit;
}

input:focus,
select:focus {
  border-color: var(--signal);
  box-shadow: 0 0 0 3px #c9ff4a1a;
}

input:disabled,
select:disabled { opacity: .55; }
small { color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
.credential-status.saved { color: #bce98c; }

details {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

summary {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  cursor: pointer;
  list-style-position: outside;
}

summary span { color: var(--text); font-weight: 650; }
.credential-grid { margin-top: 18px; grid-template-columns: repeat(3, 1fr); }

.capability-fieldset {
  margin: 28px 0 0;
  padding: 0;
  border: 0;
}

.capability-fieldset legend { font-size: 18px; font-weight: 700; }
.field-help { margin: 6px 0 15px; color: var(--muted); font-size: 14px; }
.capability-list { display: grid; gap: 10px; }

.capability-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #101316;
  transition: border-color .16s ease, background .16s ease;
}

.capability-card.enabled { border-color: #465434; background: #141912; }
.capability-heading { justify-content: space-between; gap: 16px; }

.capability-toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 11px;
  align-items: start;
  cursor: pointer;
}

.capability-toggle input { width: 18px; margin: 3px 0 0; accent-color: var(--signal); }
.capability-toggle strong,
.capability-toggle small { display: block; }
.capability-toggle small { margin-top: 4px; }

.capability-heading code {
  max-width: 45%;
  color: #77818b;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.route-controls {
  grid-template-columns: minmax(180px, .72fr) minmax(260px, 1.28fr);
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #293021;
}

.route-controls[hidden] { display: none; }
.model-field { position: relative; }
.limits { grid-template-columns: 1fr 1fr 1fr; margin-top: 16px; }
.dialog-actions { justify-content: flex-end; gap: 10px; margin-top: 24px; }
.form-error { min-height: 1.3em; margin: 16px 0 0; color: var(--danger); }
.result-card { text-align: center; }

.result-card pre {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: #dfffb5;
  background: #0b0d0f;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.result-close { margin-top: 14px; }
.login-view { min-height: calc(100vh - 100px); display: grid; place-items: center; }
.login-view[hidden] { display: none; }

.brand-lockup {
  position: absolute;
  top: 32px;
  left: 40px;
  display: flex;
  gap: 15px;
  color: var(--muted);
}

.login-card {
  width: min(430px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 24px 80px #0007;
}

.login-card h1 { margin-bottom: 16px; font-size: 46px; }
.login-card label { margin-top: 16px; }
.login-card .button { width: 100%; margin-top: 20px; }

@media (max-width: 820px) {
  .app-shell { width: min(100% - 24px, 1180px); padding-top: 18px; }
  .topbar { padding-bottom: 20px; }
  .topbar-caption,
  .topbar a { display: none; }
  .hero-row { grid-template-columns: 1fr; align-items: start; padding: 44px 0 28px; gap: 24px; }
  .hero-row .button { width: 100%; }
  h1 { font-size: 44px; }
  .metric-strip { grid-template-columns: 1fr; padding: 18px; gap: 10px; }
  .metric-strip i { justify-self: start; transform: rotate(90deg); }
  .project-card { grid-template-columns: 1fr; gap: 18px; }
  .card-actions .button { width: 100%; }
  .credential-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  dialog { width: calc(100% - 16px); max-height: calc(100dvh - 16px); border-radius: 18px; }
  .dialog-card { padding: 18px; }
  .dialog-heading { align-items: flex-start; }
  .dialog-heading h2 { max-width: 270px; font-size: 26px; overflow-wrap: anywhere; }
  .form-grid,
  .route-controls,
  .limits { grid-template-columns: 1fr; }
  .capability-heading { align-items: flex-start; }
  .capability-heading code { max-width: 38%; text-align: right; }
  summary { align-items: flex-start; }
  summary small { max-width: 50%; text-align: right; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .button { width: 100%; }
  .brand-lockup { top: 24px; left: 24px; }
  .login-view { padding-top: 80px; place-items: start center; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
