:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #f7f8fb;
  --panel-2: #eef2f7;
  --text: #142033;
  --muted: #5d6b82;
  --line: #d9e0eb;
  --brand: #174ea6;
  --brand-2: #0b66c3;
  --accent: #0f9d8f;
  --shadow: 0 20px 50px rgba(18, 32, 51, 0.08);
  --radius: 22px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10141c;
  --panel: #161d29;
  --panel-2: #202938;
  --text: #edf3ff;
  --muted: #a9b7cb;
  --line: #314057;
  --brand: #8ab4ff;
  --brand-2: #7cc7ff;
  --accent: #5ee0c6;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.30);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 3rem);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand:hover { text-decoration: none; }

.brand-logo {
  display: block;
  width: min(320px, 46vw);
  height: auto;
}

.nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav a {
  color: var(--muted);
  font-weight: 600;
  font-size: .95rem;
}

.theme-toggle {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: .55rem .85rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 650;
}

main { padding: clamp(1.2rem, 4vw, 3rem); }

.hero {
  display: grid;
  gap: clamp(1rem, 4vw, 3rem);
  align-items: center;
  min-height: 72vh;
  max-width: 1180px;
  margin: 0 auto;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .78rem;
  color: var(--accent);
  font-weight: 800;
}

h1, h2, h3 { line-height: 1.08; letter-spacing: -0.04em; }
h1 { font-size: clamp(2.4rem, 7vw, 5.8rem); margin: .2rem 0 1rem; }
h2 { font-size: clamp(1.4rem, 3vw, 2.25rem); }
h3 { font-size: 1.25rem; }

.lead {
  font-size: clamp(1.08rem, 2vw, 1.35rem);
  color: var(--muted);
  max-width: 760px;
}

.actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.actions.stacked {
  align-items: stretch;
  flex-direction: column;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: .75rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-weight: 750;
  cursor: pointer;
  text-decoration: none;
}

.button:hover { text-decoration: none; transform: translateY(-1px); }
.button.primary { background: var(--brand); color: white; border-color: var(--brand); }
.button.ghost { background: transparent; }

.file-button input { display: none; }

.hero-card, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.2rem, 3vw, 2rem);
  box-shadow: var(--shadow);
}

.metric-list {
  display: grid;
  gap: 1rem;
  margin: 1.5rem 0 0;
}

.metric-list div {
  padding: 1rem;
  border-radius: 16px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.metric-list dt { color: var(--muted); font-size: .85rem; font-weight: 700; }
.metric-list dd { margin: .2rem 0 0; font-size: 1.08rem; font-weight: 800; }

.grid {
  display: grid;
  max-width: 1180px;
  margin: 4rem auto;
  gap: 1rem;
}

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

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 2rem;
  max-width: 1180px;
  margin: 4rem auto;
  align-items: start;
}

.narrow {
  max-width: 920px;
  margin: 0 auto;
}

.steps {
  display: grid;
  gap: 1rem;
  margin: 2rem 0;
}

.steps article {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  grid-auto-flow: column;
  align-items: center;
}

.steps span {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 16px;
  background: var(--brand);
  color: white;
  font-weight: 900;
}

.steps h2 { margin: 0; }
.steps p { margin: .35rem 0 0; color: var(--muted); }

.checklist { padding-left: 1.2rem; }
.checklist li { margin: .4rem 0; }

pre {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
  overflow-x: auto;
}

code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 2rem clamp(1rem, 4vw, 3rem);
  border-top: 1px solid var(--line);
  color: var(--muted);
}

/* Tool page */

.tool-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 1rem;
  align-items: start;
}

.tool-panel, .visual-panel, .table-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.tool-panel { position: sticky; top: 5.5rem; }

.status {
  margin: 1rem 0;
  color: var(--muted);
  font-weight: 650;
}

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

.stats-grid div {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: .8rem;
}

.stats-grid span { display: block; color: var(--muted); font-size: .8rem; }
.stats-grid strong { font-size: 1.25rem; }

.filters {
  margin-top: 1rem;
  display: grid;
  gap: .8rem;
}

.filters label {
  display: grid;
  gap: .35rem;
  font-weight: 750;
  color: var(--muted);
}

.filters input[type="search"] {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  padding: .7rem .8rem;
}

.visual-panel { min-height: 620px; }
.canvas-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

#graphCanvas {
  width: 100%;
  height: min(66vh, 720px);
  display: block;
  border-radius: 18px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.table-panel {
  grid-column: 2;
}

.table-wrap { overflow-x: auto; max-height: 420px; overflow-y: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}

th, td {
  padding: .75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: var(--panel);
}

td:nth-child(3), td:nth-child(4) { text-align: right; }

@media (max-width: 920px) {
  .hero, .split, .tool-layout {
    grid-template-columns: 1fr;
  }
  .grid.three, .grid.two {
    grid-template-columns: 1fr;
  }
  .tool-panel {
    position: static;
  }
  .table-panel {
    grid-column: auto;
  }
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .nav {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  main { padding: 1rem; }
  .actions { align-items: stretch; flex-direction: column; }
  .button { width: 100%; }
  .stats-grid { grid-template-columns: 1fr; }
}

/* Tool page refinements */
:root {
  --surface: var(--panel);
  --surface-2: var(--panel-2);
  --canvas: #ffffff;
  --ok: #0f766e;
  --danger: #dc2626;
}
html[data-theme="dark"] {
  --surface: var(--panel);
  --surface-2: var(--panel-2);
  --canvas: #0d1420;
  --ok: #6be2c4;
  --danger: #ff8c8c;
}
.tool-main {
  display: grid;
  gap: clamp(1.5rem, 4vw, 3rem);
  max-width: 1240px;
  margin: 0 auto;
}
.tool-intro { padding-top: .5rem; }
.subtitle {
  max-width: 70rem;
  color: var(--muted);
  font-size: clamp(1rem, 1.7vw, 1.2rem);
}
.section {
  display: grid;
  gap: 1rem;
}
.section-heading.row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}
.panel,
.note,
.code {
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem;
}
.note { color: var(--muted); }
.note strong { color: var(--text); }
.dataset-empty { border-style: dashed; }
.dataset-ready { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.dataset-loading { border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.dataset-error { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.actions.compact { margin-top: 0; justify-content: flex-end; }
.actions.in-panel { margin-top: 0; }
.controls {
  display: grid;
  grid-template-columns: 2fr repeat(4, minmax(120px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
label {
  display: grid;
  gap: .4rem;
  color: var(--muted);
  font-size: .93rem;
}
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 14px;
  padding: .82rem;
  font: inherit;
}
input:disabled,
select:disabled { opacity: .55; cursor: not-allowed; }
.explorer.disabled .panel { opacity: .84; }
canvas {
  display: block;
  width: 100%;
  height: 620px;
  border-radius: 18px;
  background: var(--canvas);
  border: 1px solid var(--line);
}
.hint,
.muted { color: var(--muted); }
.details { line-height: 1.65; overflow-wrap: anywhere; }
.details h3 { margin-bottom: .75rem; }
.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 999px;
  padding: .22rem .58rem;
  margin: .15rem .25rem .15rem 0;
  color: var(--muted);
  font-size: .78rem;
}
.ranked {
  margin: 0;
  padding-left: 1.5rem;
  color: var(--muted);
}
.ranked li { margin: .45rem 0; }
.ranked strong { color: var(--text); }
.chips {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.chip {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 999px;
  padding: .45rem .7rem;
  font-size: .84rem;
}
.table-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .75rem;
}
.table-wrap {
  overflow: auto;
  max-height: 650px;
  border: 1px solid var(--line);
  border-radius: 18px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}
th, td {
  padding: .75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  z-index: 2;
}
tbody tr[data-id] { cursor: pointer; }
tbody tr[data-id]:hover { background: color-mix(in srgb, var(--brand) 8%, transparent); }
.code {
  margin: 0;
  overflow: auto;
  background: var(--panel-2);
}
@media (max-width: 1100px) {
  .controls,
  .section-heading.row,
  .tool-main .grid.two,
  .tool-main .grid.three,
  .tool-main .split {
    grid-template-columns: 1fr;
  }
  .section-heading.row {
    align-items: start;
    flex-direction: column;
  }
  .actions.compact { justify-content: flex-start; }
  canvas { height: 500px; }
}
@media (max-width: 720px) {
  .button,
  button,
  .actions { width: 100%; }
  .actions.compact { justify-content: stretch; }
  canvas { height: 420px; }
  .table-head { align-items: stretch; flex-direction: column; }
}


.hero-brand {
  min-height: auto;
  padding-top: clamp(1rem, 2vw, 2rem);
  padding-bottom: clamp(1rem, 2vw, 2rem);
}

.hero-visual {
  display: grid;
  gap: 1rem;
  align-self: stretch;
}

.hero-visual img,
.artwork-showcase img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 18px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.caption {
  margin: 0;
  color: var(--muted);
  font-size: .92rem;
}

.brand-card {
  display: grid;
  gap: 1rem;
}

.brand-card-mark,
.intro-mark {
  width: 112px;
  height: auto;
  display: block;
}

.page-intro.brand-intro {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 1.25rem;
  align-items: center;
  margin-bottom: 2rem;
}

.artwork-showcase {
  display: grid;
  gap: 1rem;
}

@media (max-width: 920px) {
  .page-intro.brand-intro {
    grid-template-columns: 1fr;
  }
  .intro-mark {
    width: 96px;
  }
}
