/* Kairos console.
   Type: Outfit for the display voice (one statement per screen), DM Sans for the interface,
   a licensed code face for literal code and addresses only. Three surfaces, one accent, one
   blue and one red reserved for data. No gradients, no glass, no rules between sections —
   hierarchy comes from tone steps, weight and space. */

@font-face { font-family: "Outfit"; src: url("./fonts/outfit-regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Outfit"; src: url("./fonts/outfit-bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("./fonts/text-regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("./fonts/text-medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("./fonts/text-bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Kairos Code"; src: url("./fonts/code-regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }

:root {
  /* materials */
  --ground: #07090a;
  --surface: #0c1013;
  --surface-2: #12171b;
  --surface-3: #1a2025;
  --edge: rgba(255, 255, 255, 0.055);
  --edge-strong: rgba(255, 255, 255, 0.1);
  --highlight: rgba(255, 255, 255, 0.045);

  /* ink */
  --ink: #f4f7f6;
  --ink-2: #ccd5d4;
  --muted: #9ba6a8;

  /* data */
  --accent: #c9f24d;
  --accent-ink: #0b1000;
  --up: #c9f24d;
  --down: #ff7a5c;
  --data: #7fa6ff;

  /* type */
  --display-font: "Outfit", ui-sans-serif, -apple-system, "SF Pro Display", Helvetica, sans-serif;
  --text-font: "DM Sans", ui-sans-serif, -apple-system, "SF Pro Text", Helvetica, sans-serif;
  --code-font: "Kairos Code"; /* taste-skill-ignore: literal code and contract addresses only */

  --display: clamp(3rem, 7.2vw, 5.4rem);
  --figure: clamp(2.6rem, 7.2vw, 5.4rem);
  --title: 1.375rem;
  --lead: 1.1875rem;
  --body: 1rem;
  --small: 1rem;
  --micro: 0.8125rem;

  --rail: 252px;
  --gutter: clamp(20px, 3vw, 46px);
  --radius: 6px;
  --radius-sm: 4px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--text-font);
  font-size: var(--body);
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -0.015em; line-height: 1.15; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; }
code, pre { font-family: var(--code-font); }

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

.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100%; }

.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 30px;
  padding: 24px 20px;
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { display: flex; align-items: center; gap: 9px; font-family: var(--display-font); font-weight: 700; font-size: 1.25rem; letter-spacing: -0.02em; }
.brand-mark svg { display: block; }
.brand-sub { margin-top: 8px; font-size: var(--micro); color: var(--muted); line-height: 1.45; }

.rail-nav { position: relative; display: grid; gap: 1px; }
.rail-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: var(--body);
  transition: background 0.16s ease, color 0.16s ease;
}
.rail-nav a svg { opacity: 0.75; }
.rail-nav a:hover { background: var(--surface-2); color: var(--ink-2); }
.rail-nav a.active { background: var(--surface-3); color: var(--ink); }
.rail-nav a.active svg { opacity: 1; color: var(--accent); }
.rail-indicator {
  position: absolute;
  left: -20px;
  width: 2px;
  height: 0;
  background: var(--accent);
  opacity: 0;
}

.rail-foot { margin-top: auto; display: grid; gap: 12px; }
.mini { margin: 0; display: grid; gap: 1px; }
.mini > div {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  background: var(--surface-2); padding: 9px 12px; border-radius: var(--radius-sm);
}
.mini dt { font-size: var(--micro); color: var(--muted); }
.mini dd { margin: 0; font-size: var(--micro); font-weight: 500; }

/* ------------------------------------------------------------------ stage */

.stage { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding: 24px var(--gutter) 18px;
  background: var(--ground);
}
.topbar-title h1 { font-family: var(--display-font); font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.topbar-title p { margin-top: 5px; color: var(--muted); font-size: var(--micro); max-width: 58ch; }
.topbar-chips { display: flex; align-items: stretch; gap: 1px; }
.chip {
  background: var(--surface-2); padding: 9px 14px; border-radius: var(--radius-sm);
}
.chip span { display: block; font-size: var(--micro); color: var(--muted); margin-bottom: 3px; }
.chip b { font-size: var(--small); font-weight: 500; letter-spacing: -0.005em; }

.view { padding: 10px var(--gutter) 0; flex: 1; }

/* ------------------------------------------------------------------ blocks */

.block { background: var(--surface); padding: 22px; border-radius: var(--radius); }
.block + .block, .grid + .block, .block + .grid, .grid + .grid, .figure + .block, .figure + .grid { margin-top: 10px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.block-head h2 { font-size: var(--title); font-weight: 500; letter-spacing: -0.02em; }
.hint, .note { font-size: var(--small); color: var(--muted); }
.note { display: block; margin-top: 10px; max-width: 74ch; }
.muted { color: var(--muted); }

.grid { display: grid; gap: 10px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.hero { grid-template-columns: minmax(0, 1.05fr) minmax(330px, 0.95fr); align-items: start; }

/* the one statement, and the numbers */

.hero-head { background: transparent; padding: 6px 0 4px; }
.hero-line {
  font-family: var(--display-font);
  font-weight: 700;
  font-size: var(--display);
  letter-spacing: -0.045em;
  line-height: 0.95;
}

.figure {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 28px;
  background: var(--surface); padding: 26px; border-radius: var(--radius);
}
.figure-value {
  font-family: var(--display-font);
  font-weight: 700;
  font-size: var(--figure);
  letter-spacing: -0.045em;
  line-height: 1;
}
.unit { margin-left: 0.32em; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.figure-value .unit, .stat b .unit { font-family: var(--text-font); font-size: 0.4em; }
.figure-label { display: block; margin-top: 12px; font-size: var(--micro); color: var(--muted); }
.figure-side { max-width: 42ch; text-align: right; font-size: var(--micro); color: var(--muted); }

.stat { background: var(--surface); padding: 18px; border-radius: var(--radius); }
.stat b {
  display: block; font-size: 1.5rem; font-weight: 500; letter-spacing: -0.025em; line-height: 1.1;
}
.stat span { display: block; margin-top: 9px; font-size: var(--micro); color: var(--muted); letter-spacing: 0.01em; }
.stat .sub { margin-top: 5px; font-size: var(--small); color: var(--ink-2); }

.delta { font-size: var(--small); font-weight: 500; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }

/* clock */

.clock { background: var(--surface); padding: 24px; border-radius: var(--radius); display: flex; flex-direction: column; }
.clock-time { font-family: var(--display-font); font-weight: 700; font-size: var(--figure); letter-spacing: -0.045em; line-height: 1; }
.clock-sub { margin-top: 8px; font-size: var(--micro); color: var(--muted); }
.segments { display: flex; gap: 3px; margin: 22px 0 20px; height: 6px; }
.segments i { flex: 1; background: var(--surface-3); border-radius: 2px; }
.segments i.on { background: var(--accent); }

/* rows and tables */

.rows { display: grid; gap: 1px; }
.row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
  background: var(--surface-2); padding: 14px 16px; border-radius: var(--radius-sm);
  transition: background 0.16s ease;
}
.row.selectable { cursor: pointer; }
.row.selectable:hover { background: var(--surface-3); }
.row.selected { background: var(--accent); color: var(--accent-ink); }
.row.selected .muted, .row.selected .row-sub { color: rgba(11, 16, 0, 0.68); }
.row-title { font-weight: 500; }
.row-sub { font-size: var(--small); color: var(--muted); margin-top: 2px; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: var(--micro);
  padding: 11px 14px; background: var(--surface-2); white-space: nowrap;
}
.table th:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.table th:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.table td { padding: 13px 14px; font-size: var(--body); }
.table td.num, .table th.num { text-align: right; }
.table tbody tr { transition: background 0.14s ease; }
.table tbody tr:hover td { background: var(--surface-2); }
.table td .unit { font-size: 0.9em; }

/* pagination */

.pager { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 16px; }
.pager-info { font-size: var(--micro); color: var(--muted); }
.pager-controls { display: flex; gap: 3px; }
.pager-controls button {
  appearance: none; border: 0; background: var(--surface-2); color: var(--muted);
  padding: 7px 12px; border-radius: var(--radius-sm); font-size: var(--small); cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.pager-controls button:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
.pager-controls button.active { background: var(--accent); color: var(--accent-ink); font-weight: 500; }
.pager-controls button:disabled { opacity: 0.35; cursor: not-allowed; }

/* forms */

.field { margin-bottom: 18px; }
.field label { display: block; font-size: var(--micro); color: var(--muted); margin-bottom: 7px; }
input:not([type]), input[type="text"], input[type="range"], select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--edge-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
  padding: 12px 14px;
  transition: background 0.16s ease;
}
input:not([type]):focus, input[type="text"]:focus, select:focus {
  outline: 0;
  background: var(--surface-3);
  border-color: var(--accent);
}
input[type="range"] { padding: 10px 0; background: transparent; border: 0; accent-color: var(--accent); }
input:read-only { color: var(--muted); }
select { padding: 11px 12px; }
.range-meta { display: flex; justify-content: space-between; font-size: var(--small); color: var(--muted); margin-top: 6px; }
output { display: block; font-family: var(--display-font); font-weight: 700; font-size: 1.5rem; letter-spacing: -0.02em; }
.two-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  appearance: none;
  border: 0;
  background: var(--surface-2);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: var(--small);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border: 0; font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: #d8ff63; }
.btn.block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.actions.bar { background: var(--surface-2); padding: 14px; margin: 0; align-items: center; border-radius: var(--radius-sm); }
.inline { display: flex; align-items: center; gap: 10px; margin-right: auto; font-size: var(--micro); color: var(--muted); }
.inline select { width: auto; min-width: 150px; }

.swap { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 10px; align-items: end; }
.swap .field { margin-bottom: 0; }

.bar { height: 4px; background: var(--surface-3); margin-top: 9px; border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--data); }

.facts { margin: 0; display: grid; gap: 1px; }
.facts > div { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; background: var(--surface-2); padding: 11px 14px; border-radius: var(--radius-sm); }
.facts dt { font-size: var(--small); color: var(--muted); }
.facts dd { margin: 0; font-size: var(--small); font-weight: 500; }

.empty { background: var(--surface-2); padding: 22px; color: var(--muted); font-size: var(--body); border-radius: var(--radius-sm); }

/* loading states: tone blocks that pulse, never a spinner over the whole app */

.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--radius-sm); }
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  opacity: 0.5;
  animation: pulse 1.5s ease-in-out infinite;
}
.skeleton.line { height: 12px; margin: 8px 0; }
.skeleton.big { height: 38px; width: 60%; }
.skeleton.row { height: 44px; }
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 0.6; } }

/* charts */

.chart { width: 100%; height: auto; display: block; margin: 4px 0 18px; }
.chart .grid { stroke: var(--surface-3); stroke-width: 1; }
.chart .area { fill: rgba(201, 242, 77, 0.14); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .axis { fill: var(--muted); font-size: 12px; }
.chart .up { fill: var(--up); }
.chart .down { fill: var(--down); }
.chart .vol { fill: rgba(201, 242, 77, 0.22); }
.chart .vol.down { fill: rgba(255, 122, 92, 0.22); }
.chart .last { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .marker { fill: var(--ink); font-size: 12px; font-weight: 500; }
.chart .pill { fill: var(--surface-3); }
.chart .crosshair { stroke: var(--edge-strong); stroke-width: 1; }
.spark { width: 96px; height: 28px; display: block; }
.table tr.clickable { cursor: pointer; }
.chart-range { display: flex; gap: 3px; }
.chart-range button {
  appearance: none; border: 0; background: var(--surface-2); color: var(--muted);
  padding: 6px 11px; font-size: var(--small); cursor: pointer; border-radius: var(--radius-sm);
  transition: background 0.16s ease, color 0.16s ease;
}
.chart-range button:hover { background: var(--surface-3); color: var(--ink); }
.chart-range button.active { background: var(--accent); color: var(--accent-ink); font-weight: 500; }

/* transaction toasts */

.toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 60; display: grid; gap: 8px; max-width: 340px;
  /* the container must not swallow clicks aimed at the page underneath: verified blocking by a
     browser test, where a confirmation toast covered the swap button */
  pointer-events: none;
}
.toast { pointer-events: auto; }
.toast {
  background: var(--surface-2); border-radius: var(--radius); padding: 14px 16px;
  border-left: 2px solid var(--muted);
}
.toast.pending { border-left-color: var(--data); }
.toast.ok { border-left-color: var(--accent); }
.toast.failed { border-left-color: var(--down); }
.toast b { display: block; font-size: var(--small); font-weight: 500; margin-bottom: 4px; }
.toast span { font-size: var(--micro); color: var(--muted); }

/* footer */

.foot {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 24px;
  padding: 34px var(--gutter) 40px; margin-top: 12px; background: var(--surface); border-radius: var(--radius);
  margin-left: var(--gutter); margin-right: var(--gutter);
}
.foot-brand { max-width: 46ch; }
.foot-brand b { font-family: var(--display-font); font-size: 1rem; font-weight: 700; letter-spacing: -0.02em; }
.foot-brand p { margin-top: 9px; font-size: var(--small); color: var(--muted); }
.foot-meta { display: flex; flex-wrap: wrap; gap: 20px; font-size: var(--micro); color: var(--muted); }

/* motion primitives (GSAP drives these; without JS the page stays readable) */

.fade-up { opacity: 0; transform: translateY(14px); }

@media (prefers-reduced-motion: reduce) {
  .fade-up { opacity: 1; transform: none; }
  .skeleton::after { animation: none; opacity: 0.4; }
}

@media (max-width: 1100px) {
  .grid.hero { grid-template-columns: 1fr; }
  .clock-time { font-size: 2rem; }
}
@media (max-width: 900px) {
  /* wide tables scroll inside their card instead of pushing the page sideways */
  .block { overflow-x: auto; }
  .table { min-width: 660px; }
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 14px; }
  .rail-nav { display: flex; gap: 2px; overflow-x: auto; width: 100%; }
  .rail-nav a span { display: none; }
  .topbar-title p { display: none; }
  .rail-indicator { display: none; }
  .rail-foot { margin: 0; width: 100%; grid-auto-flow: column; align-items: center; }
  .topbar { position: static; flex-wrap: wrap; align-items: flex-start; }
  .topbar-chips { display: none; }
  .foot { grid-template-columns: 1fr; }
  .swap { grid-template-columns: 1fr; }
  .two-inputs { grid-template-columns: 1fr; }
  .figure { flex-direction: column; align-items: flex-start; }
  .figure-side { text-align: left; }
}

/* a text-only action: the footer already carries three metadata lines, so this must not read as a
   fourth button — no fill, no border, accent on hover only. */
.link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
}
.link:hover { text-decoration: underline; }
.link[hidden] { display: none; }

/* keyboard focus: visible on every control, without a permanent outline on mouse users */
.btn:focus-visible, .link:focus-visible, .tab:focus-visible, .row:focus-visible,
input:focus-visible, select:focus-visible, [data-open]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.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;
}
