:root {
  --bg: #f5f8fc;
  --ink: #0f172a;
  --muted: #5b677a;
  --line: #e2e8f0;
  --brand: #145184;
  --brand-2: #1767aa;
  --panel: #ffffff;
  --dark: #0f172a;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Space Grotesk", Inter, ui-sans-serif, system-ui, sans-serif;
  --hero-gradient: linear-gradient(135deg, #f8fafc 0%, #eef6ff 55%, #e0ecfb 100%);
  --primary-gradient: linear-gradient(135deg, #1767aa 0%, #145184 100%);
  --accent-gradient: linear-gradient(120deg, #1767aa 0%, #4f46e5 100%);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
}

.topbar {
  align-items: center;
  background: var(--hero-gradient);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 1.5rem;
  justify-content: space-between;
  padding: clamp(2rem, 5vw, 3.5rem) clamp(1rem, 4vw, 3rem);
}

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

h1, h2, h3 { font-family: var(--display); letter-spacing: -0.01em; }

h1 {
  font-size: clamp(1.6rem, 3.5vw, 2.6rem);
  font-weight: 700;
  line-height: 1.1;
  margin-top: 0.5rem;
}

h2 { font-size: clamp(1.5rem, 3vw, 2.4rem); font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }

.eyebrow {
  color: var(--brand-2);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Gradient text accent for a hero keyword: <span class="grad">…</span> */
.grad {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lede {
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.6;
  margin-top: 1rem;
  max-width: 56rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

button {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  padding: 0.7rem 0.9rem;
}

button.primary {
  background: var(--primary-gradient);
  border-color: transparent;
  color: #ffffff;
}

.button-link {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  line-height: 1;
  min-height: 2.75rem;
  padding: 0.7rem 1.25rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.button-link:hover {
  border-color: var(--brand-2);
  color: var(--brand-2);
}

.button-link.primary {
  background: var(--primary-gradient);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.button-link.primary:hover {
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(20, 81, 132, 0.28);
  transform: translateY(-1px);
  filter: brightness(1.05);
}

/* Hero header: keep the text fluid and the two CTAs as an aligned,
   equal-width pair instead of ragged, mid-floating buttons. */
.public-hero {
  gap: 2rem;
}

.public-hero > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.public-hero .actions {
  align-items: center;
  align-self: center;
  flex-wrap: wrap;
}

main {
  margin: 0 auto;
  max-width: 1240px;
  padding: 1.5rem clamp(1rem, 4vw, 2rem) 3rem;
}

.metrics {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metrics article,
.panel,
.card,
.answer {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metrics article,
.card {
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.metrics article:hover,
.card:hover {
  border-color: #cfdbeb;
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.panel { box-shadow: var(--shadow-sm); }

.metrics article {
  padding: 1.2rem 1.25rem;
}

.metrics span {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: block;
  font-family: var(--display);
  font-size: 2.1rem;
  font-weight: 700;
}

.metrics p {
  color: var(--muted);
  margin-top: 0.25rem;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0;
}

.tabs button {
  border-radius: 9999px;
  color: var(--muted);
  padding: 0.5rem 1rem;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tabs button:hover {
  border-color: var(--brand-2);
  color: var(--brand-2);
}

.tabs button.active {
  background: var(--primary-gradient);
  border-color: transparent;
  color: #ffffff;
}

.panel {
  display: none;
  padding: clamp(1rem, 3vw, 1.5rem);
}

.panel.active { display: block; }

.section-head {
  align-items: start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.section-head > p {
  color: var(--muted);
  line-height: 1.6;
  max-width: 30rem;
}

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

.stack {
  display: grid;
  gap: 0.8rem;
}

.card {
  padding: 1rem;
}

/* Long unbroken tokens (storage paths, dotted table ids) must wrap inside the
   card instead of overflowing its border. */
.card h3,
.card p,
.card .meta { overflow-wrap: anywhere; }

.app-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.card p {
  color: var(--muted);
  line-height: 1.55;
  margin-top: 0.45rem;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: auto;
}

.meta {
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 800;
  margin-top: 0.65rem;
}

pre {
  background: #0f172a;
  border-radius: 6px;
  color: #dbeafe;
  overflow: auto;
  padding: 0.9rem;
}

.split {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.split h3 {
  margin-bottom: 0.75rem;
}

.chat-form {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.chat-form div {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: 1fr auto;
}

input {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.8rem;
  width: 100%;
}

.answer {
  color: var(--muted);
  line-height: 1.65;
  min-height: 5rem;
  padding: 1rem;
}

.guide {
  color: var(--muted);
  line-height: 1.8;
}

code {
  background: #eef6ff;
  border-radius: 4px;
  color: var(--brand);
  padding: 0.1rem 0.3rem;
}

footer {
  align-items: center;
  background: var(--dark);
  color: #cbd5e1;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 1rem clamp(1rem, 4vw, 3rem);
}

footer a {
  color: #ffffff;
  font-weight: 800;
}

@media (max-width: 860px) {
  .topbar,
  .section-head,
  footer {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .grid,
  .split {
    grid-template-columns: 1fr;
  }

  .chat-form div {
    grid-template-columns: 1fr;
  }

  .public-hero .actions {
    align-self: flex-start;
  }
}

/* ---------------------------------------------------- authoring / build forms */
.build-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.builder-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.2rem;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.builder-card:hover { border-color: #cfdbeb; box-shadow: var(--shadow-md); }
.builder-card h3 { font-size: 1rem; }
.builder-card label {
  color: var(--muted);
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  font-weight: 600;
  gap: 0.3rem;
}
.builder-card input,
.builder-card select,
.builder-card textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  padding: 0.55rem 0.65rem;
  width: 100%;
}
.builder-card textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; }
.builder-card .field-row { display: grid; gap: 0.6rem; grid-template-columns: 1fr 1fr; }
.builder-card .button-link { margin-top: 0.2rem; }
.builder-card .hint { color: var(--muted); font-size: 0.8rem; line-height: 1.5; }
.file-label { font-size: 0.78rem; }

/* ----------------------------------------------------------------- D3 graphs */
.graph-block { margin-bottom: 1.5rem; }
.graph-head { align-items: center; display: flex; gap: 1rem; justify-content: space-between; margin-bottom: 0.5rem; }
.graph-wrap { position: relative; }
.graph {
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 440px;
  width: 100%;
}
.graph-empty {
  color: var(--muted);
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}
.node-label { paint-order: stroke; stroke: #ffffff; stroke-width: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.legend-chip { align-items: center; color: var(--muted); display: inline-flex; font-size: 0.78rem; font-weight: 600; gap: 0.35rem; }
.legend-chip i { border-radius: 50%; display: inline-block; height: 0.7rem; width: 0.7rem; }
.graph-tooltip {
  background: var(--dark);
  border-radius: 6px;
  color: #ffffff;
  font-size: 0.78rem;
  line-height: 1.4;
  padding: 0.45rem 0.6rem;
  pointer-events: none;
  position: absolute;
  z-index: 50;
}

/* ----------------------------------------------------------------- monitoring */
.monitor-controls { align-items: center; display: flex; gap: 1rem; }
.auto-toggle { align-items: center; color: var(--muted); display: inline-flex; font-size: 0.85rem; font-weight: 600; gap: 0.35rem; }
.monitor-overall {
  align-items: center; border-radius: 8px; display: flex; font-weight: 700; gap: 0.5rem;
  margin-bottom: 1rem; padding: 0.75rem 1rem;
}
.monitor-overall .status-dot { border-radius: 50%; height: 0.7rem; width: 0.7rem; }
.monitor-overall.is-ready { background: #ecfdf5; color: #047857; }
.monitor-overall.is-ready .status-dot { background: #10b981; }
.monitor-overall.is-degraded { background: #fef2f2; color: #b91c1c; }
.monitor-overall.is-degraded .status-dot { background: #ef4444; }
.monitor-overall.is-static { background: #fffbeb; color: #92400e; }
.monitor-overall.is-static .status-dot { background: #f59e0b; }
.status-card h3 { align-items: center; display: flex; font-size: 0.95rem; gap: 0.4rem; }
.status-card .status-dot { border-radius: 50%; height: 0.6rem; width: 0.6rem; }
.status-card.is-ok .status-dot { background: #10b981; }
.status-card.is-fail .status-dot { background: #ef4444; }

/* --------------------------------------------------------------------- agents */
.agent-card { display: flex; flex-direction: column; gap: 0.6rem; }
.agent-providers { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.badge { background: #eef6ff; border-radius: 9999px; color: var(--brand); font-size: 0.72rem; font-weight: 800; padding: 0.15rem 0.6rem; }
.agent-uses { color: var(--muted); font-size: 0.85rem; line-height: 1.5; margin: 0; padding-left: 1.1rem; }
.agent-example { color: var(--ink); font-size: 0.85rem; }
.agent-install { font-size: 0.74rem; white-space: pre-wrap; }

/* ----------------------------------------------------------------- learn/glossary */
.app-card.is-soon { opacity: 0.82; }
.app-card.is-soon h3 { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; }
.app-card.is-soon .badge { background: #f1f5f9; color: var(--muted); }

.glossary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 0; }
.glossary-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.1rem;
}
.glossary-item dt {
  color: var(--ink);
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.glossary-item dd { color: var(--muted); line-height: 1.55; margin: 0; }
.glossary-item dd code,
.glossary-item dd strong { color: var(--ink); }
.glossary-item dd code {
  background: #eef6ff;
  border-radius: 5px;
  font-size: 0.85em;
  padding: 0.05rem 0.35rem;
}
@media (max-width: 860px) {
  .glossary { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------- glossary controls */
.glossary-controls {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: clamp(1.35rem, 3vw, 1.9rem);
}
.glossary-search-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.glossary-search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font: inherit;
  font-size: 1rem;
  padding: 0.9rem 1.1rem;
  color: var(--ink);
}
.glossary-search:focus {
  border-color: var(--brand-2);
  outline: none;
  box-shadow: 0 0 0 3px rgba(23, 103, 170, 0.15);
}
.glossary-cats { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }
.glossary-chip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9999px;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.55rem 1.15rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.glossary-chip:hover { border-color: var(--brand-2); color: var(--brand); }
.glossary-chip.is-active {
  background: var(--primary-gradient);
  border-color: transparent;
  color: #fff;
}
.glossary-empty { color: var(--muted); margin: 0.2rem 0 0; }
.glossary-empty-reset {
  background: none;
  border: none;
  color: var(--brand);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 0;
  text-decoration: underline;
}

/* ----------------------------------------------------------- column lineage drill-down */
.column-lineage {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  padding: clamp(0.9rem, 2.5vw, 1.3rem);
}
.col-lineage-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.col-lineage-table th {
  text-align: left;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
  padding: 0.4rem 0.6rem;
}
.col-lineage-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.45rem 0.6rem;
  vertical-align: top;
  color: var(--ink);
}
.col-lineage-table code {
  background: #eef6ff;
  border-radius: 5px;
  font-size: 0.82em;
  padding: 0.05rem 0.35rem;
}
