/* Lowfloat Labs — Paper Agent. Graph paper, blueprint blue, pencil gray. */
:root {
  --paper: #FAFAF7;
  --sheet: #FFFFFF;
  --grid: rgba(31, 79, 216, 0.07);
  --grid-major: rgba(31, 79, 216, 0.12);
  --ink: #16181D;
  --blue: #1F4FD8;
  --blue-dark: #183FAE;
  --blue-tint: #E8EEFC;
  --pencil: #565B63;       /* 6.6:1 on paper */
  --pencil-light: #C8CCD2; /* rules / borders only */
  --red: #B3261E;          /* 6.1:1 on white */
  --up: #1F4FD8;
  --down: #B3261E;
  --radius: 10px;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation: none !important; transition: none !important; } }

a { color: var(--blue); }
a:hover { color: var(--blue-dark); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--pencil); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar { background: rgba(250, 250, 247, 0.96); border-bottom: 1.5px solid var(--ink); position: sticky; top: 0; z-index: 20; }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 17px; letter-spacing: -0.01em; }
.brand-labs { font-family: var(--mono); font-size: 11px; color: var(--pencil); text-transform: uppercase; letter-spacing: 0.08em; }
.nav { display: flex; align-items: center; gap: 18px; font-weight: 500; }
.nav a:not(.btn) { color: var(--ink); text-decoration: none; font-size: 15px; }
.nav a:not(.btn):hover { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 14px/1 var(--sans); padding: 10px 14px; border-radius: 8px; text-decoration: none; cursor: pointer; border: 1.5px solid var(--ink); }
.btn-primary { background: var(--blue); color: #fff !important; border-color: var(--blue); box-shadow: 2px 2px 0 var(--ink); }
.btn-primary:hover { background: var(--blue-dark); }
.btn-ghost { background: var(--sheet); color: var(--ink); }
.btn-ghost:hover { background: var(--blue-tint); }

/* ---------- CA strip ---------- */
.castrip { background: var(--ink); color: #F3F4F6; font-family: var(--mono); font-size: 13px; }
.castrip-in { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding-top: 9px; padding-bottom: 9px; }
.ca-ticker { font-weight: 600; color: #fff; }
.sep { color: #8B93A1; }
.ca-label { color: #C5CAD3; }
.ca-value { color: #fff; background: rgba(255,255,255,0.08); padding: 2px 8px; border-radius: 5px; overflow-wrap: anywhere; font-family: var(--mono); }
.ca-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.chip { display: inline-flex; align-items: center; gap: 5px; font: 500 12px/1 var(--mono); color: #fff; background: transparent; border: 1px solid #6B7380; border-radius: 6px; padding: 6px 9px; text-decoration: none; cursor: pointer; }
.chip svg { width: 13px; height: 13px; }
.chip:hover:not(:disabled):not(.is-disabled) { border-color: #fff; color: #fff; background: rgba(255,255,255,0.08); }
.chip:disabled, .chip.is-disabled { color: #A5ACB8; border-color: #4A505A; cursor: not-allowed; pointer-events: none; }

/* ---------- live row ---------- */
.liverow { border-bottom: 1px solid var(--pencil-light); background: rgba(255,255,255,0.7); font-family: var(--mono); font-size: 12.5px; color: var(--pencil); }
.liverow-in { display: flex; flex-wrap: wrap; gap: 6px 22px; padding-top: 8px; padding-bottom: 8px; }
.live-item { display: inline-flex; align-items: center; gap: 6px; }
.live-item strong { color: var(--ink); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 0 rgba(31,79,216,0.5); animation: pulse 2s infinite; }
.dot.is-warn { background: var(--red); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(31,79,216,0.45); } 70% { box-shadow: 0 0 0 7px rgba(31,79,216,0); } 100% { box-shadow: 0 0 0 0 rgba(31,79,216,0); } }

/* ---------- stamp ---------- */
.stamp { display: inline-block; font: 600 10.5px/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--red); border: 1.5px solid var(--red); border-radius: 4px; padding: 4px 6px; white-space: nowrap; background: rgba(255,255,255,0.6); }
.stamp-lg { font-size: 13px; padding: 7px 10px; border-width: 2px; transform: rotate(-2deg); box-shadow: inset 0 0 0 2px rgba(255,255,255,0.8), inset 0 0 0 3px rgba(179,38,30,0.35); }

/* ---------- hero ---------- */
.hero { padding-top: 40px; padding-bottom: 8px; }
.eyebrow { font: 500 12px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--blue); margin: 0 0 14px; }
h1 { font-size: clamp(30px, 4.6vw, 52px); line-height: 1.04; letter-spacing: -0.03em; margin: 0; max-width: 21ch; font-weight: 700; }
.hero-meta { display: flex; align-items: flex-start; gap: 20px; margin-top: 20px; flex-wrap: wrap; }
.hero-sub { margin: 0; max-width: 60ch; color: var(--pencil); font-size: 17px; flex: 1 1 320px; }
h2 { font-size: clamp(24px, 3vw, 32px); letter-spacing: -0.02em; margin: 0 0 8px; line-height: 1.1; }
h3 { margin: 0; }

/* ---------- app panel ---------- */
.app { margin-top: 28px; background: var(--sheet); border: 1.5px solid var(--ink); border-radius: 14px; box-shadow: 5px 5px 0 var(--blue); outline: none; }
.app-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; padding: 12px 18px; border-bottom: 1.5px dashed var(--pencil-light); }
.app-title { font: 600 12px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--blue); }
.app-note { font: 400 12px/1.4 var(--mono); color: var(--pencil); }
.error { margin: 14px 18px 0; padding: 10px 12px; border: 1.5px solid var(--red); border-radius: 8px; color: var(--red); font: 500 13px/1.4 var(--mono); background: #FFF6F5; }
.agents { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.agent-card { padding: 18px; border-right: 1.5px dashed var(--pencil-light); display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.agent-card:last-child { border-right: 0; }
.skeleton { min-height: 420px; }
.sk { height: 100%; min-height: 380px; border-radius: 10px; background: repeating-linear-gradient(-45deg, #F4F5F2, #F4F5F2 8px, #FAFAF7 8px, #FAFAF7 16px); }

.agent-top { display: flex; gap: 12px; align-items: flex-start; }
.char { width: 92px; height: 92px; flex: none; }
.char .eyes { animation: blink 5s infinite; transform-origin: center 50%; transform-box: fill-box; }
.char-plumb .eyes { animation-delay: 1.3s; }
.char-dipper .eyes { animation-delay: 2.6s; }
@keyframes blink { 0%, 95%, 100% { transform: scaleY(1); } 97% { transform: scaleY(0.1); } }
.char-glide { animation: float 4s ease-in-out infinite; }
.char-plumb { animation: sway 5s ease-in-out infinite; transform-origin: 50% 3%; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes sway { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }

.agent-id { min-width: 0; }
.agent-name { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.agent-style { font: 500 11px/1.2 var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--blue); margin-top: 3px; }
.agent-eq { font: 600 20px/1.2 var(--mono); margin-top: 8px; }
.agent-eq small { display: block; font: 400 11px/1.3 var(--mono); color: var(--pencil); text-transform: uppercase; letter-spacing: 0.06em; }

/* speech bubble */
.bubble { position: relative; background: var(--blue-tint); border: 1.5px solid var(--blue); border-radius: 12px; padding: 12px 13px 11px; font-size: 14.5px; line-height: 1.45; }
.bubble::before { content: ""; position: absolute; top: -10px; left: 34px; width: 16px; height: 16px; background: var(--blue-tint); border-left: 1.5px solid var(--blue); border-top: 1.5px solid var(--blue); transform: rotate(45deg); }
.bubble-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; }
.bubble-time { font: 400 11.5px/1 var(--mono); color: var(--pencil); }
.bubble p { margin: 0 0 9px; color: var(--ink); }
.bubble .stamp { font-size: 9.5px; }

.act { display: inline-block; font: 600 11px/1 var(--mono); letter-spacing: 0.05em; padding: 4px 6px; border-radius: 4px; border: 1.5px solid currentColor; }
.act-BUY { color: var(--blue); background: #fff; }
.act-SELL { color: var(--ink); background: #fff; }
.act-HOLD { color: var(--pencil); background: #fff; border-style: dashed; }
.tag { display: inline-block; font: 600 10px/1 var(--mono); letter-spacing: 0.08em; padding: 3px 5px; border-radius: 3px; vertical-align: 1px; }
.tag-live { background: var(--blue); color: #fff; }
.tag-replay { background: #EDEEF0; color: #3F444C; border: 1px solid #C8CCD2; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; font-family: var(--mono); font-size: 12.5px; margin: 0; }
.facts dt { color: var(--pencil); text-transform: uppercase; letter-spacing: 0.06em; font-size: 10.5px; }
.facts dd { margin: 1px 0 0; font-weight: 600; }
.up { color: var(--up); }
.down { color: var(--down); }

.spark { width: 100%; height: 56px; display: block; }
.spark-wrap { border: 1px solid var(--pencil-light); border-radius: 8px; padding: 6px 8px 4px; background: #fff; }
.spark-cap { display: flex; justify-content: space-between; font: 400 10.5px/1.3 var(--mono); color: var(--pencil); text-transform: uppercase; letter-spacing: 0.06em; }

.positions { font-family: var(--mono); font-size: 12.5px; }
.positions h4 { margin: 0 0 6px; font: 500 10.5px/1 var(--mono); color: var(--pencil); text-transform: uppercase; letter-spacing: 0.06em; }
.positions ul { list-style: none; margin: 0; padding: 0; }
.positions li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-top: 1px dotted var(--pencil-light); }
.positions .none { color: var(--pencil); }
.rules { font-size: 13px; color: var(--pencil); border-top: 1.5px dashed var(--pencil-light); padding-top: 10px; margin-top: auto; }
.rules summary { cursor: pointer; font: 500 12px/1.4 var(--mono); color: var(--blue); }
.rules p { margin: 6px 0 0; }
.rules b { color: var(--ink); font-weight: 600; }

/* ---------- sections ---------- */
.section { padding-top: 56px; }
.section-head { margin-bottom: 16px; }
.section-head p { max-width: 78ch; margin: 0; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-bottom: 12px; }
.filter-group { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 8px; overflow: hidden; background: #fff; }
.fbtn { font: 500 12.5px/1 var(--mono); background: transparent; border: 0; border-right: 1px solid var(--pencil-light); padding: 9px 11px; cursor: pointer; color: var(--ink); }
.fbtn:last-child { border-right: 0; }
.fbtn:hover { background: var(--blue-tint); }
.fbtn.is-on { background: var(--ink); color: #fff; }

/* log */
.log-wrap { background: #fff; border: 1.5px solid var(--ink); border-radius: 12px; overflow: hidden; }
.log { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12.5px; }
.log th { text-align: left; font-weight: 500; font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--pencil); padding: 10px 12px; border-bottom: 1.5px solid var(--ink); background: #F7F8F5; white-space: nowrap; }
.log td { padding: 11px 12px; border-bottom: 1px solid #E6E8EB; vertical-align: top; }
.log tr:last-child td { border-bottom: 0; }
.log .num { text-align: right; white-space: nowrap; }
.log .t { white-space: nowrap; color: var(--pencil); }
.log .who { white-space: nowrap; font-weight: 600; }
.log .reason { font-family: var(--sans); font-size: 14px; line-height: 1.45; min-width: 260px; }
.log tr.is-hold td { color: var(--pencil); }
.log tr.is-hold .reason { color: var(--pencil); }
.log tr.row-new { animation: flash 2.4s ease-out; }
@keyframes flash { from { background: var(--blue-tint); } to { background: transparent; } }
.log .stamp { font-size: 9px; padding: 3px 4px; }
.log-empty { padding: 18px; margin: 0; }
[data-more] { display: flex; margin: 0 auto; border: 0; border-top: 1.5px dashed var(--pencil-light); border-radius: 0; width: 100%; padding: 14px; }

/* steps */
.steps { list-style: none; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.step { background: #fff; border: 1.5px solid var(--ink); border-radius: 12px; padding: 18px; }
.step-n { font: 600 13px/1 var(--mono); color: var(--blue); display: inline-block; border: 1.5px solid var(--blue); border-radius: 50%; width: 34px; height: 34px; line-height: 31px; text-align: center; margin-bottom: 12px; }
.step h3 { font-size: 19px; margin-bottom: 6px; }
.step p { margin: 0; color: var(--pencil); font-size: 15px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); border: 1.5px solid var(--ink); border-radius: 12px; background: #fff; overflow: hidden; }
.stat { padding: 18px; border-right: 1.5px dashed var(--pencil-light); }
.stat:last-child { border-right: 0; }
.stat-v { font: 600 28px/1.1 var(--mono); letter-spacing: -0.02em; }
.stat-l { font: 500 11px/1.4 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--pencil); margin-top: 6px; }

/* status */
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.status-col { background: #fff; border: 1.5px solid var(--ink); border-radius: 12px; padding: 18px; }
.status-col h3 { margin-bottom: 10px; }
.pill { display: inline-block; font: 600 12px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; padding: 6px 9px; border-radius: 999px; }
.pill-live { background: var(--blue); color: #fff; }
.pill-planned { background: #fff; color: var(--ink); border: 1.5px dashed var(--ink); }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { position: relative; padding: 7px 0 7px 26px; border-top: 1px dotted var(--pencil-light); font-size: 15px; }
.checklist li:first-child { border-top: 0; }
.checklist li::before { content: ""; position: absolute; left: 2px; top: 12px; width: 13px; height: 13px; border: 1.5px solid var(--blue); border-radius: 3px; background: var(--blue) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.5 9.5 3.5' fill='none' stroke='white' stroke-width='1.8'/%3E%3C/svg%3E") center/11px no-repeat; }
.checklist.planned li { color: var(--pencil); }
.checklist.planned li::before { background: #fff; border-style: dashed; border-color: var(--pencil); }

/* footer */
.footer { margin-top: 64px; border-top: 1.5px solid var(--ink); background: #fff; padding: 22px 0 30px; font-size: 14px; }
.footer-in > * { margin: 0 0 6px; }
.footer a { color: var(--blue); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .agents { grid-template-columns: 1fr; }
  .agent-card { border-right: 0; border-bottom: 1.5px dashed var(--pencil-light); }
  .agent-card:last-child { border-bottom: 0; }
  .skeleton { min-height: 200px; }
  .sk { min-height: 180px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1.5px dashed var(--pencil-light); }
}
@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .nav { gap: 12px; }
  .nav a:not(.btn) { font-size: 14px; }
  .brand-labs { display: none; }
  .btn { padding: 9px 11px; font-size: 13px; }
  .ca-actions { margin-left: 0; width: 100%; }
  .live-item { flex-wrap: wrap; }
  .steps, .status-grid { grid-template-columns: 1fr; }
  .hero { padding-top: 28px; }

  /* log rows become cards */
  .log thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .log, .log tbody, .log tr, .log td { display: block; width: 100%; }
  .log tr { padding: 12px 14px; border-bottom: 1px solid #E6E8EB; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
  .log td { padding: 0; border: 0; width: auto; }
  .log .t { flex-basis: 100%; font-size: 11.5px; }
  .log .reason { flex-basis: 100%; min-width: 0; }
  .log td.stampcell { flex-basis: 100%; }
  .log .num { text-align: left; }
  .log .num::before { content: attr(data-label) " "; color: var(--pencil); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; }
  .log .num:empty, .log .num.is-empty { display: none; }
}
@media (max-width: 380px) {
  .nav a[data-link] { display: none; }
  .facts { grid-template-columns: 1fr 1fr; }
  .char { width: 76px; height: 76px; }
}
