:root {
  --bg: #f3f4f1;
  --paper: #ffffff;
  --ink: #111716;
  --ink-2: #3a4040;
  --mute: #69726e;
  --faint: #9aa29e;
  --line: #e1e5df;
  --line-2: #eef0ec;
  --em: #0c5c44;
  --em-2: #1f8a66;
  --em-soft: #e5f1eb;
  --warn: #9a6512;
  --warn-soft: #faf0dc;
  --bad: #a93b28;
  --bad-soft: #f8e5e1;
  --radius: 18px;
  --dock: 320px;
  --top: 68px;
  --gutter: clamp(16px, 3vw, 32px);
  --shadow: 0 1px 2px rgba(17, 23, 22, 0.04), 0 8px 24px rgba(17, 23, 22, 0.05);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 500 15px/1.55 "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: var(--em); text-decoration-color: rgba(12, 92, 68, 0.3); text-underline-offset: 3px; }
code, .mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.88em; }
code { background: var(--line-2); padding: 1px 6px; border-radius: 6px; color: var(--ink-2); }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; color: var(--ink); }
h1, .h1 { font-size: clamp(30px, 4.2vw, 52px); line-height: 1.04; font-weight: 800; }
h2 { font-size: 21px; font-weight: 800; }
h3 { font-size: 17px; font-weight: 800; margin-bottom: 14px; }
.muted { color: var(--mute); }
.eyebrow { margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--em); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.note { margin: 12px 0 0; font-size: 13px; color: var(--mute); }
[hidden] { display: none !important; }

/* ------------------------------------------------------------- top bar */

.top {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--top);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding-inline: var(--gutter);
  background: rgba(243, 244, 241, 0.86);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand img { width: 34px; height: 34px; }
.brand span { font-size: 20px; font-weight: 800; letter-spacing: -0.03em; }
.tabs { display: flex; gap: 4px; justify-self: center; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 4px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; padding: 8px 16px; border-radius: 999px; text-decoration: none; color: var(--mute); font-weight: 700; font-size: 14px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--ink); color: #fff; }
.top-right { display: flex; align-items: center; gap: 10px; }

.chip { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); font-size: 12.5px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.chip b { font-family: "IBM Plex Mono", monospace; font-weight: 500; }
.chip-soft { background: var(--line-2); border-color: transparent; color: var(--mute); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--em-2); box-shadow: 0 0 0 0 rgba(31, 138, 102, 0.45); animation: pulse 2.2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(31, 138, 102, 0); } 100% { box-shadow: 0 0 0 0 rgba(31, 138, 102, 0); } }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent; font: 700 14px/1 "Manrope", sans-serif; text-decoration: none; cursor: pointer; transition: transform 0.12s, background 0.15s, box-shadow 0.15s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-em { background: var(--em); color: #fff; box-shadow: 0 6px 16px rgba(12, 92, 68, 0.22); }
.btn-em:hover:not(:disabled) { background: #0a4d39; color: #fff; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover:not(:disabled) { background: #26302d; color: #fff; }
.btn-ghost { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--ink-2); }
.mini { border: 0; background: var(--line-2); color: var(--ink-2); font: 700 12px/1 "Manrope", sans-serif; padding: 8px 10px; border-radius: 999px; cursor: pointer; }

/* ------------------------------------------------------------- shell */

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--dock);
  gap: var(--gutter);
  padding: var(--gutter);
  max-width: 1480px;
  margin: 0 auto;
  align-items: start;
}
main { min-width: 0; display: grid; gap: var(--gutter); }
.view { display: grid; gap: var(--gutter); min-width: 0; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(18px, 2.4vw, 28px); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.card-head p { margin: 6px 0 0; font-size: 14px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gutter); align-items: start; }
.view-head p { margin: 10px 0 0; max-width: 60ch; }

/* ------------------------------------------------------------- markets */

.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: center; padding: 0; overflow: hidden; min-height: 400px; }
.hero-copy { padding: clamp(24px, 4vw, 48px); }
.hero-copy h1 { margin-bottom: 14px; }
.lede { font-size: 17px; color: var(--ink-2); margin: 0 0 22px; max-width: 46ch; }
.status { display: flex; align-items: center; gap: 8px; margin: 20px 0 0; font-size: 13px; color: var(--mute); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.status.live .dot { background: var(--em-2); }
.hero-art { position: relative; width: 100%; height: 100%; min-height: 360px; background: radial-gradient(60% 60% at 55% 50%, #ffffff, #f6f7f4 70%); }
.hero-art.knot-fallback { background: url(/img/hero-960.jpg) right center / cover no-repeat; }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin: 0; }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; min-width: 0; }
.kpi dt { font-size: 12px; font-weight: 700; color: var(--mute); }
.kpi dd { margin: 4px 0 2px; font: 500 22px/1.2 "IBM Plex Mono", monospace; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi span { font-size: 12px; color: var(--faint); }

.table-wrap { overflow-x: auto; margin: 0 calc(clamp(18px, 2.4vw, 28px) * -1); padding: 0 clamp(18px, 2.4vw, 28px); }
table { border-collapse: collapse; width: 100%; }
.markets { min-width: 780px; }
.markets .go { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 999px; background: var(--em-soft); color: var(--em); font-weight: 800; font-size: 13px; text-decoration: none; }
.markets .go:hover { background: var(--em); color: #fff; }
.markets th { text-align: left; font-size: 12px; font-weight: 700; color: var(--mute); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.markets td { padding: 14px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; white-space: nowrap; }
.markets tr:last-child td { border-bottom: 0; }
.markets .num { font-family: "IBM Plex Mono", monospace; }
.asset { display: flex; align-items: center; gap: 12px; }
.asset i { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font: 800 12px/1 "Manrope", sans-serif; font-style: normal; color: #fff; background: var(--ink-2); flex: none; }
.asset i.tb { background: var(--em); }
.asset b { display: block; font-weight: 800; }
.asset small { color: var(--mute); font-size: 12.5px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; letter-spacing: 0.02em; background: var(--em-soft); color: var(--em); }
.pill.settling { background: var(--warn-soft); color: var(--warn); }
.pill.stale, .pill.paused, .pill.invalid { background: var(--bad-soft); color: var(--bad); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.powerbar { display: inline-block; width: 90px; height: 6px; border-radius: 6px; background: var(--line-2); vertical-align: middle; margin-right: 8px; overflow: hidden; }
.powerbar i { display: block; height: 100%; background: var(--em-2); }

/* ------------------------------------------------------------- borrow */

.picker { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.picker button { border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 10px 8px; cursor: pointer; text-align: left; font: inherit; min-width: 0; }
.picker button b { display: block; font-weight: 800; }
.picker button small { display: block; color: var(--mute); font-size: 11.5px; font-family: "IBM Plex Mono", monospace; overflow: hidden; text-overflow: ellipsis; }
.picker button[aria-checked="true"] { border-color: var(--em); box-shadow: inset 0 0 0 1px var(--em); background: var(--em-soft); }
.field { margin-bottom: 14px; }
.field label { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.input { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; background: #fbfbfa; }
.input:focus-within { border-color: var(--em); box-shadow: 0 0 0 3px rgba(12, 92, 68, 0.12); }
.input input { flex: 1; min-width: 0; border: 0; background: transparent; font: 500 20px/1 "IBM Plex Mono", monospace; padding: 14px 0; color: var(--ink); outline: none; }
.input span { font-size: 13px; color: var(--mute); font-family: "IBM Plex Mono", monospace; white-space: nowrap; }
input[type="range"] { width: 100%; accent-color: var(--em); margin: 12px 0 0; }
.lines { margin: 14px 0 0; display: grid; gap: 0; }
.lines div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-2); }
.lines dt { color: var(--mute); font-size: 13.5px; }
.lines dd { margin: 0; font-family: "IBM Plex Mono", monospace; font-size: 14px; text-align: right; }
.lines.tight div { padding: 8px 0; }
.actions { margin-top: 18px; }
.plate { padding: 0; overflow: hidden; margin: 0; }
.plate img { width: 100%; height: auto; }
.plate figcaption { padding: 18px 22px 22px; font-size: 14px; color: var(--ink-2); }

/* ------------------------------------------------------------- lend */

.curve { width: 100%; height: auto; display: block; }
.curve .axis { stroke: var(--line); stroke-width: 1; }
.curve .borrow { fill: none; stroke: var(--ink-2); stroke-width: 3; }
.curve .supply { fill: none; stroke: var(--em-2); stroke-width: 3; }
.curve .kink { stroke: var(--faint); stroke-dasharray: 4 5; }
.curve text { font: 600 12px "IBM Plex Mono", monospace; fill: var(--mute); }
.curve .marker { stroke: var(--em); stroke-width: 1.5; }
.curve .dotb { fill: var(--ink-2); }
.curve .dots { fill: var(--em-2); }

/* ------------------------------------------------------------- oracle */

.plate-wide { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); padding: 0; overflow: hidden; align-items: center; }
.plate-copy { padding: clamp(22px, 3.4vw, 40px); }
.plate-copy .h1 { margin-bottom: 12px; }
.plate-wide img { width: 100%; height: 100%; object-fit: cover; object-position: left center; }
.clock { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
.clock div { background: var(--line-2); border-radius: 12px; padding: 10px 12px; }
.clock span { display: block; font-size: 12px; color: var(--mute); font-weight: 700; }
.clock b { font: 500 17px/1.3 "IBM Plex Mono", monospace; }
.rules { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.rule { background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--em-2); border-radius: 14px; padding: 14px 16px; }
.rule.warn { border-left-color: #d69a2b; }
.rule.bad { border-left-color: var(--bad); }
.rule b { font-size: 13px; letter-spacing: 0.04em; }
.rule p { margin: 6px 0 0; font-size: 13.5px; color: var(--ink-2); }
.oracles { display: grid; gap: 10px; }
.orow { display: grid; grid-template-columns: 150px minmax(0, 1fr) 120px 120px; gap: 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line-2); }
.orow:first-child { border-top: 0; }
.timeline { position: relative; height: 10px; border-radius: 10px; background: linear-gradient(90deg, var(--em-soft) 0 1.4%, #eef3ef 1.4% 75%, var(--warn-soft) 75% 100%); }
.timeline i { position: absolute; top: -4px; width: 4px; height: 18px; border-radius: 3px; background: var(--ink); transform: translateX(-2px); }
.timeline-legend { display: flex; justify-content: space-between; font: 500 11px "IBM Plex Mono", monospace; color: var(--faint); margin-top: 6px; }
.orow .num { font-family: "IBM Plex Mono", monospace; font-size: 14px; }
.orow small { display: block; color: var(--mute); font-size: 12px; }

/* ------------------------------------------------------------- docs */

.docs { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: var(--gutter); align-items: start; }
.toc { position: sticky; top: calc(var(--top) + var(--gutter)); display: grid; gap: 2px; }
.toc a { padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--mute); font-weight: 700; font-size: 14px; }
.toc a:hover { background: var(--paper); color: var(--ink); }
.toc a.on { background: var(--paper); color: var(--em); box-shadow: inset 3px 0 0 var(--em); }
.doc section { padding: 8px 0 22px; scroll-margin-top: calc(var(--top) + 24px); }
.doc section + section { border-top: 1px solid var(--line-2); padding-top: 26px; }
.doc p, .doc li { font-size: 15.5px; color: var(--ink-2); max-width: 72ch; }
.doc .h1 { margin-bottom: 14px; }
.steps { padding-left: 20px; }
.steps li { margin: 6px 0; }
.formula { background: #f6f7f4; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; font: 500 13px/1.8 "IBM Plex Mono", monospace; color: var(--ink); overflow-x: auto; white-space: pre; }
.spec { width: 100%; font-size: 14.5px; }
.spec td, .spec th { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line-2); vertical-align: top; text-align: left; }
.spec th { font-size: 12px; color: var(--mute); font-weight: 700; }
.spec td:first-child { font-weight: 800; white-space: nowrap; color: var(--ink); }
.spec.wide { min-width: 640px; }
.spec a { font-family: "IBM Plex Mono", monospace; font-size: 13px; overflow-wrap: anywhere; }

/* ------------------------------------------------------------- dock */

.dock { position: sticky; top: calc(var(--top) + var(--gutter)); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.dock-handle { display: none; }
.dock-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dock-head b { font-size: 18px; font-weight: 800; margin-right: auto; }
.gauge { width: 100%; height: auto; display: block; }
.g-track { fill: none; stroke: var(--line-2); stroke-width: 16; stroke-linecap: round; }
.g-fill { fill: none; stroke: var(--em-2); stroke-width: 16; stroke-linecap: round; stroke-dasharray: 0 100; transition: stroke-dasharray 0.4s, stroke 0.3s; }
.g-needle { stroke: var(--ink); stroke-width: 3; stroke-linecap: round; transform-origin: 110px 115px; transition: transform 0.4s; }
.g-hub { fill: var(--ink); }
.hf { text-align: center; margin: -6px 0 14px; }
.hf b { display: block; font: 500 34px/1.1 "IBM Plex Mono", monospace; }
.hf span { font-size: 12px; color: var(--mute); font-weight: 700; }
.bar { position: relative; height: 10px; border-radius: 10px; background: var(--line-2); overflow: visible; }
.bar i { display: block; height: 100%; border-radius: 10px; background: var(--em-2); width: 0; transition: width 0.3s, background 0.3s; }
.bar em, .bar strong { position: absolute; top: -4px; width: 2px; height: 18px; background: var(--ink-2); }
.bar strong { background: var(--bad); }
.bar-legend { display: flex; justify-content: space-between; font: 500 11.5px "IBM Plex Mono", monospace; color: var(--mute); margin: 6px 0 4px; }

/* ------------------------------------------------------------- footer, toast */

.foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 22px var(--gutter) 40px; max-width: 1480px; margin: 0 auto; color: var(--mute); font-size: 13.5px; }
.foot a { margin-left: auto; font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px; font-size: 14px; font-weight: 700; max-width: min(92vw, 520px); }

/* ------------------------------------------------------------- responsive */

@media (max-width: 1180px) {
  :root { --dock: 290px; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding-bottom: 120px; }
  .grid-2, .hero, .plate-wide { grid-template-columns: minmax(0, 1fr); }
  .hero-art { min-height: 280px; order: -1; }
  .docs { grid-template-columns: minmax(0, 1fr); }
  .toc { position: static; display: flex; overflow-x: auto; gap: 4px; scrollbar-width: none; }
  .toc a { flex: none; background: var(--paper); border: 1px solid var(--line); }
  .orow { grid-template-columns: minmax(0, 1fr) auto; }
  .orow .timeline-cell { grid-column: 1 / -1; order: 3; }

  /* The dock becomes a sheet pinned to the bottom, always showing the health factor. */
  .dock { position: fixed; left: 12px; right: 12px; bottom: 12px; top: auto; z-index: 40; padding: 0; max-height: 78vh; overflow: auto; }
  .dock-handle { display: flex; width: 100%; justify-content: space-between; align-items: center; min-height: 56px; padding: 0 18px; border: 0; background: transparent; font: 700 14px "Manrope", sans-serif; color: var(--ink); cursor: pointer; }
  .dock-handle b { font: 500 18px "IBM Plex Mono", monospace; }
  .dock-body { display: none; padding: 0 18px 18px; }
  .dock.open .dock-body { display: block; }
}

@media (max-width: 720px) {
  .top { grid-template-columns: auto auto; grid-template-rows: var(--top) auto; height: auto; row-gap: 0; padding-bottom: 10px; }
  .tabs { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; }
  .brand span { font-size: 18px; }
  .hide-sm { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rules { grid-template-columns: minmax(0, 1fr); }
  .picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .clock { grid-template-columns: minmax(0, 1fr); }
  .foot a { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .pulse { animation: none; }
  .g-fill, .g-needle, .bar i { transition: none; }
}
