:root {
  color-scheme: light;
  --ink: #15201d;
  --muted: #68736f;
  --paper: #f5f2ea;
  --panel: #fffdf8;
  --line: #d7d3c8;
  --green: #146b4d;
  --green-dark: #0c4c36;
  --green-soft: #dcebe3;
  --gold: #d4a938;
  --danger: #a33a32;
  --shadow: 0 18px 54px rgba(40, 47, 43, 0.1);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 84% 5%, rgba(212, 169, 56, 0.12), transparent 24rem),
    linear-gradient(180deg, #f8f5ee 0%, var(--paper) 100%);
}

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

button,
select,
input[type="file"] + span {
  cursor: pointer;
}

.page-shell {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 86px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: white;
  background: var(--green-dark);
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.runtime-pill {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 9px 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(212, 169, 56, 0.14);
}

.runtime-pill.ready .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(20, 107, 77, 0.14);
}

.runtime-pill.error .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(163, 58, 50, 0.12);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.65fr);
  gap: 60px;
  align-items: end;
  padding: 72px 0 58px;
}

.eyebrow,
.step {
  color: var(--green);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 790px;
  margin-bottom: 22px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(45px, 6vw, 76px);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.hero-copy {
  max-width: 690px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.65;
}

.runtime-facts {
  margin: 0;
  border-top: 1px solid var(--ink);
}

.runtime-facts div {
  display: flex;
  justify-content: space-between;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.runtime-facts dt {
  color: var(--muted);
}

.runtime-facts dd {
  margin: 0;
  font-weight: 650;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 0.78fr) minmax(0, 1.55fr);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.data-panel,
.search-panel {
  padding: 32px;
}

.data-panel {
  background: #f0eee7;
  border-right: 1px solid var(--line);
}

.section-heading,
.section-heading > div,
.result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-heading {
  margin-bottom: 24px;
}

.section-heading > div {
  justify-content: flex-start;
  gap: 12px;
}

.section-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
  font-weight: 500;
}

.text-button {
  padding: 0;
  color: var(--green);
  background: none;
  border: 0;
  font-size: 13px;
  font-weight: 700;
}

.worker-label {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
}

.file-button {
  display: grid;
  place-items: center;
  min-height: 46px;
  margin-bottom: 18px;
  color: var(--green-dark);
  background: var(--green-soft);
  border: 1px dashed rgba(20, 107, 77, 0.45);
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

#dataset,
#analyzer-profile {
  min-height: 46px;
  padding: 0 12px;
}

.custom-source[hidden] {
  display: none;
}

.field-label,
.query-options label span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

textarea,
input,
select {
  width: 100%;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(20, 107, 77, 0.1);
}

textarea {
  min-height: 282px;
  padding: 14px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
}

.field-help {
  margin: 10px 0 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

code {
  color: var(--green-dark);
}

.primary-button {
  min-height: 48px;
  padding: 0 22px;
  color: #fff;
  background: var(--green-dark);
  border: 1px solid var(--green-dark);
  border-radius: 8px;
  font-weight: 750;
  transition: background 140ms ease, transform 140ms ease;
}

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

.primary-button:active {
  transform: translateY(1px);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button {
  min-height: 48px;
  padding: 0 18px;
  color: var(--danger);
  background: transparent;
  border: 1px solid rgba(163, 58, 50, 0.42);
  border-radius: 8px;
  font-weight: 750;
}

.secondary-button[hidden] {
  display: none;
}

.load-actions {
  display: flex;
  gap: 10px;
}

.load-progress {
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.progress-track {
  height: 5px;
  margin-bottom: 9px;
  overflow: hidden;
  background: rgba(20, 107, 77, 0.13);
  border-radius: 999px;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green);
  border-radius: inherit;
  transition: width 180ms ease;
}

.progress-track span.indeterminate {
  animation: progress-pulse 1.1s ease-in-out infinite alternate;
}

@keyframes progress-pulse {
  from {
    transform: translateX(-90%);
  }
  to {
    transform: translateX(210%);
  }
}

.load-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 18px 0 0;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.load-metrics div {
  min-width: 0;
  padding: 10px 11px;
  background: rgba(255, 253, 248, 0.78);
}

.load-metrics dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.load-metrics dd {
  margin: 0;
  overflow: hidden;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wide {
  width: 100%;
}

.version-label {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.query-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.query-row input {
  min-height: 52px;
  padding: 0 16px;
  font-size: 16px;
}

.query-options {
  display: grid;
  grid-template-columns: 1fr 1.35fr 0.62fr;
  gap: 12px;
  margin-top: 14px;
}

.query-options select,
.query-options input {
  min-height: 42px;
  padding: 0 10px;
}

.analyzer-preview {
  margin-top: 18px;
  padding: 14px 15px;
  background: #f3f1ea;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.preview-heading {
  display: flex;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.preview-heading h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-weight: 500;
}

.preview-heading span {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
}

.token-preview {
  display: grid;
  gap: 8px;
  min-height: 26px;
  color: var(--muted);
  font-size: 12px;
}

.token-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.token-row > strong {
  padding-top: 5px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.token-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.token-chip {
  padding: 4px 7px;
  color: var(--green-dark);
  background: #fff;
  border: 1px solid rgba(20, 107, 77, 0.24);
  border-radius: 999px;
  font-family: "SFMono-Regular", Consolas, monospace;
}

.token-chip.graph-token {
  background: #fff5cf;
  border-color: rgba(212, 169, 56, 0.56);
}

.token-remainder {
  padding: 5px 2px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 28px 0 20px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metrics div {
  padding: 0 18px;
  border-right: 1px solid var(--line);
}

.metrics div:first-child {
  padding-left: 0;
}

.metrics div:last-child {
  border-right: 0;
}

.metrics span,
.metrics small {
  display: block;
}

.metrics span {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 27px;
}

.metrics small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.message {
  display: none;
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.message.visible {
  display: block;
}

.message.info {
  color: var(--green-dark);
  background: var(--green-soft);
}

.message.error {
  color: var(--danger);
  background: #f8e7e4;
}

.result-heading {
  margin: 12px 0 14px;
}

.result-heading h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 500;
}

.result-heading span {
  color: var(--muted);
  font-size: 12px;
}

.results {
  display: grid;
  gap: 12px;
}

.result-card {
  padding: 18px 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
}

.score {
  color: var(--green-dark);
  font-weight: 750;
}

.result-card h4 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 500;
}

.result-body,
.highlight-fragment {
  margin: 0;
  color: #53605b;
  font-size: 14px;
  line-height: 1.65;
}

mark {
  padding: 0 2px;
  color: inherit;
  background: #f4d978;
  border-radius: 2px;
}

.empty-results {
  padding: 34px 20px;
  color: var(--muted);
  background: #f8f6f0;
  border: 1px dashed var(--line);
  border-radius: 10px;
  text-align: center;
}

footer {
  display: flex;
  justify-content: space-between;
  padding: 30px 0 40px;
  color: var(--muted);
  font-size: 12px;
}

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

@media (max-width: 920px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 36px;
  }

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

  .data-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 600px) {
  .page-shell {
    width: min(100% - 24px, 1240px);
  }

  .masthead {
    min-height: 74px;
  }

  .brand small {
    display: none;
  }

  .runtime-pill {
    padding: 8px 10px;
    font-size: 11px;
  }

  .hero {
    padding: 48px 0 38px;
  }

  h1 {
    font-size: 43px;
  }

  .hero-copy {
    font-size: 16px;
  }

  .data-panel,
  .search-panel {
    padding: 22px 18px;
  }

  .query-row,
  .query-options {
    grid-template-columns: 1fr;
  }

  .query-row .primary-button {
    width: 100%;
  }

  footer {
    gap: 8px;
    flex-direction: column;
  }
}
