:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --line: #dfe5ec;
  --line-strong: #cbd5e1;
  --accent: #3156a3;
  --accent-soft: #eef3ff;
  --mark: #fff0a6;
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
  --radius: 12px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

button, input, select { font: inherit; }

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

.site-header {
  background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
  border-bottom: 1px solid var(--line);
}

.header-inner { padding: 34px 0 30px; }

.eyebrow {
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 7px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.15;
  letter-spacing: -0.035em;
}

.subtitle { margin-bottom: 0; color: var(--muted); font-size: 16px; }

.main-grid {
  display: grid;
  gap: 18px;
  padding-top: 24px;
  padding-bottom: 36px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.controls-panel { padding: 18px; }

.control-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(260px, 1fr) minmax(300px, 1.3fr);
  gap: 14px;
}

.field { display: grid; gap: 6px; }
.field > span { color: var(--muted); font-size: 12px; font-weight: 700; }

select, input[type="search"] {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
}

select:focus, input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(49, 86, 163, 0.12);
}

select:disabled { color: #98a2b3; background: #f2f4f7; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 28px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.check input { accent-color: var(--accent); }
.search-count { margin-left: auto; }
.status { color: #b54708; }

.metrics {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 10px;
}

.metric-card {
  min-width: 0;
  padding: 14px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.metric-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-value {
  display: block;
  overflow: hidden;
  font-size: 20px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.question-panel { overflow: hidden; }

.question-panel summary {
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 700;
  user-select: none;
}

.question-panel[open] summary { border-bottom: 1px solid var(--line); }

.question-text {
  max-height: 260px;
  padding: 18px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #344054;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.65;
}

.trace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.trace-panel {
  min-width: 0;
  overflow: hidden;
}

.trace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 72px;
  padding: 14px 16px;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--line);
}

.trace-kicker {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.trace-header h2 { margin: 1px 0 0; font-size: 18px; }

.trace-body {
  height: min(66vh, 780px);
  min-height: 480px;
  overflow: auto;
  padding: 18px;
  background: #fff;
  color: #222b3a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  line-height: 1.65;
  tab-size: 2;
  white-space: pre;
}

.trace-body.wrap {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

mark {
  padding: 0 1px;
  background: var(--mark);
  color: inherit;
  border-radius: 2px;
}

.ghost-button, .nav-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #344054;
  border-radius: 7px;
  cursor: pointer;
}

.ghost-button { padding: 6px 10px; font-size: 12px; }
.ghost-button:hover, .nav-button:hover { border-color: #98a2b3; background: #f8fafc; }

.sample-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.nav-button { padding: 10px 14px; }
.nav-button:first-child { justify-self: start; }
.nav-button:last-child { justify-self: end; }
.nav-button:disabled { opacity: 0.45; cursor: default; }
.sample-position { color: var(--muted); font-size: 13px; }

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  font-size: 12px;
}
.site-footer .shell { padding: 18px 0 24px; }

.error-box {
  margin: 24px auto;
  max-width: 780px;
  padding: 18px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  color: #9a3412;
}

@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(4, minmax(130px, 1fr)); }
}

@media (max-width: 900px) {
  .control-grid { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .trace-grid { grid-template-columns: 1fr; }
  .trace-body { height: 580px; min-height: 380px; }
}

@media (max-width: 620px) {
  .shell { width: min(100% - 24px, 1500px); }
  .control-grid, .metrics { grid-template-columns: 1fr; }
  .toolbar { align-items: flex-start; flex-wrap: wrap; }
  .search-count { margin-left: 0; width: 100%; }
  .sample-nav { grid-template-columns: 1fr 1fr; }
  .sample-position { grid-column: 1 / -1; grid-row: 1; text-align: center; }
}
