:root {
  color-scheme: light;
  --bg: #f5f3ed;
  --ink: #191a17;
  --muted: #6f726c;
  --line: #d9d3c6;
  --panel: #fffdf8;
  --green: #1e6654;
  --green-dark: #0e4035;
  --amber: #b88926;
  --red: #9e2b25;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--green-dark);
  color: white;
  cursor: pointer;
  font-weight: 760;
  min-height: 38px;
  padding: 0 14px;
}

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

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

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 820;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.1;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  display: grid;
  gap: 6px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.metric strong {
  overflow: hidden;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 34px rgba(35, 31, 22, 0.08);
  padding: 16px;
}

.panel-heading {
  display: grid;
  gap: 5px;
  margin-bottom: 14px;
}

.panel-heading p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.stack {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

label.inline {
  display: flex;
  align-items: center;
  color: var(--ink);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

.result {
  max-height: 240px;
  margin: 12px 0 0;
  overflow: auto;
  border-radius: 6px;
  background: #171a15;
  color: #e7efe7;
  padding: 10px;
  font-size: 12px;
  white-space: pre-wrap;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.source-links a {
  border: 1px solid #c6dbc8;
  border-radius: 999px;
  background: #eef8ef;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 760;
  text-decoration: none;
}

.matches {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.matches li,
.article-row,
.trace-row {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.matches li {
  display: grid;
  gap: 5px;
}

.matches span {
  color: var(--amber);
  font-size: 12px;
  font-weight: 820;
}

.matches p,
.article-row p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-top: 16px;
}

.tab {
  background: transparent;
  color: var(--muted);
}

.tab.active {
  background: var(--green-dark);
  color: white;
}

.tab-panel {
  display: none;
  margin-top: 8px;
}

.tab-panel.active {
  display: block;
}

.article-list,
.trace-list {
  display: grid;
  gap: 10px;
}

.article-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.article-row code {
  color: var(--muted);
  font-size: 12px;
}

.graph {
  width: 100%;
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf5;
}

.graph-edge {
  stroke: #c5bcae;
  stroke-width: 1;
}

.graph-node rect {
  fill: white;
  stroke: var(--line);
}

.graph-node.article rect {
  fill: #eaf4ef;
  stroke: #b8d4c4;
}

.graph-node.chunk rect {
  fill: #fff7e3;
  stroke: #e2cf94;
}

.graph-node text {
  fill: var(--ink);
  font-size: 12px;
}

.trace-row {
  display: grid;
  gap: 8px;
}

.trace-row div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.trace-row time {
  color: var(--muted);
  font-size: 12px;
}

.trace-row ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.empty {
  color: var(--muted);
  font-size: 13px;
}

.error {
  color: var(--red);
}

@media (max-width: 880px) {
  .metrics,
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar,
  .article-row,
  .trace-row div {
    align-items: stretch;
    flex-direction: column;
  }
}


.topbar-actions {
  display: flex;
  gap: 8px;
}

button.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

button.ghost:hover {
  background: white;
  color: var(--green-dark);
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(520px, 100%);
}

.login-panel {
  display: grid;
  gap: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 34px rgba(35, 31, 22, 0.08);
  padding: 28px;
}

.login-panel form {
  display: grid;
  gap: 14px;
}

.error-text {
  min-height: 18px;
  color: var(--red);
  font-size: 13px;
}
