:root {
  --ink: #171717;
  --paper: #f4f0e8;
  --paper-strong: #fffaf0;
  --line: #d9d1c2;
  --muted: #726b60;
  --teal: #0f766e;
  --blue: #2563eb;
  --amber: #d97706;
  --red: #b42318;
  --green-soft: #dff3df;
  --shadow: 0 18px 50px rgba(45, 38, 28, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23, 23, 23, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 23, 23, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  border: 1px solid var(--ink);
  color: var(--paper-strong);
  background: var(--ink);
  border-radius: 6px;
  min-height: 42px;
  padding: 0 16px;
}

button:hover {
  background: var(--teal);
  border-color: var(--teal);
}

.app {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 0 22px;
  border-bottom: 3px solid var(--ink);
}

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

h1,
h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(34px, 5vw, 68px);
  line-height: 0.94;
}

h2 {
  font-size: 23px;
}

.status {
  min-width: 150px;
  text-align: right;
  color: var(--muted);
  font-weight: 700;
}

.controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 18px 0;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-strong);
  color: var(--ink);
  padding: 0 10px;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(15, 118, 110, 0.25);
  outline-offset: 2px;
}

.chain-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  background: var(--green-soft);
  border: 1px solid #b6ddb4;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.chain-band code {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 18px;
  font-weight: 800;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  margin-top: 20px;
}

.chart-wrap,
.side-panel,
.table-section {
  background: rgba(255, 250, 240, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.section-head span,
.section-head a {
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
}

.canvas-box {
  position: relative;
  aspect-ratio: 16 / 9;
  min-height: 360px;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.tooltip {
  position: absolute;
  z-index: 4;
  max-width: 260px;
  pointer-events: none;
  background: var(--ink);
  color: var(--paper-strong);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  box-shadow: var(--shadow);
}

.cards {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.model-card {
  border: 1px solid var(--line);
  border-left: 7px solid var(--teal);
  border-radius: 8px;
  background: var(--paper-strong);
  padding: 13px;
}

.model-card:nth-child(2) {
  border-left-color: var(--blue);
}

.model-card:nth-child(3) {
  border-left-color: var(--amber);
}

.model-card h3 {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.metric {
  min-width: 0;
}

.metric b {
  display: block;
  font-size: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.table-section {
  margin-top: 20px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td code {
  font-weight: 800;
  overflow-wrap: anywhere;
}

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

@media (max-width: 1000px) {
  .controls,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .chain-band {
    align-items: start;
    flex-direction: column;
  }

  .status {
    text-align: left;
  }
}
