/* Arena Bot
   Palet: batu tulis gelap sebagai dasar, kapur hangat untuk teks,
   satu aksen amber untuk uang dan aksi. Hijau/merah hanya untuk PnL. */

@font-face {
  font-family: "Plex Sans";
  src: url("/static/fonts/plexsans-400.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Plex Sans";
  src: url("/static/fonts/plexsans-600.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("/static/fonts/plexmono-400.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

:root {
  --ink: #161511;
  --ink-2: #1e1d18;
  --ink-3: #272620;
  --line: #3a382f;
  --line-soft: #2e2d26;
  --paper: #efece3;
  --paper-dim: #a9a396;
  --paper-faint: #7d786d;
  --amber: #e5a13c;
  --amber-dim: #6b4c1a;
  --up: #6fbf73;
  --down: #e0705f;
  --radius: 3px;
  --gap: 18px;
  --sans: "Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: "Plex Mono", ui-monospace, monospace;
}

[data-theme="light"] {
  --ink: #f4f1e8;
  --ink-2: #eae6da;
  --ink-3: #e0dbcd;
  --line: #c8c2b1;
  --line-soft: #d8d2c2;
  --paper: #191813;
  --paper-dim: #55524a;
  --paper-faint: #77736a;
  --amber: #a8641a;
  --amber-dim: #e0c79b;
  --up: #2f7d3a;
  --down: #a83a2a;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
ul, ol, dl { margin: 0; padding: 0; list-style: none; }

.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;
}

.skip {
  position: absolute; left: 12px; top: -40px;
  background: var(--amber); color: #191813;
  padding: 8px 12px; border-radius: var(--radius);
  font-weight: 600; z-index: 10; transition: top .15s;
}
.skip:focus { top: 12px; }

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* --- topbar --- */
.topbar {
  display: flex; flex-wrap: wrap; gap: 16px;
  align-items: center; justify-content: space-between;
  padding: 20px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: var(--ink-2);
}

.brand { display: flex; gap: 14px; align-items: flex-start; }

.brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; flex: 0 0 auto;
  background: var(--amber); color: #191813;
  font-family: var(--mono); font-size: 20px; font-weight: 500;
  border-radius: var(--radius);
}

.brand h1 { font-size: 19px; }

.brand-sub {
  font-size: 13px; color: var(--paper-dim);
  max-width: 46ch; margin-top: 2px;
}

.topbar-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.status-chip {
  font-family: var(--mono); font-size: 12px;
  padding: 5px 10px; border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--paper-dim);
}
.status-chip.is-live { border-color: var(--amber); color: var(--amber); }
.status-chip.is-down { border-color: var(--down); color: var(--down); }

/* --- buttons --- */
.btn {
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  padding: 8px 13px; min-height: 36px;
  background: var(--ink-3); color: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; transition: background .12s, border-color .12s;
}
.btn:hover:not(:disabled) { background: var(--line-soft); border-color: var(--paper-faint); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: var(--amber); color: #191813;
  border-color: var(--amber); font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: #f0b052; border-color: #f0b052; }

.btn-danger { color: var(--down); border-color: var(--down); background: transparent; }
.btn-danger:hover:not(:disabled) { background: rgba(224, 112, 95, .12); border-color: var(--down); }

.btn-quiet { background: transparent; color: var(--paper-dim); }
.btn-quiet:hover:not(:disabled) { color: var(--paper); }

.btn-small { font-size: 12px; padding: 6px 10px; min-height: 30px; }

.btn-icon { padding: 8px 10px; font-size: 15px; line-height: 1; }

/* --- layout --- */
main {
  padding: clamp(20px, 4vw, 36px) clamp(16px, 4vw, 40px) 64px;
  max-width: 1360px; margin: 0 auto;
}

.ledger {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink-2);
  margin-bottom: clamp(24px, 4vw, 40px);
}

.ledger-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.ledger-row > div {
  padding: 14px 18px;
  border-right: 1px solid var(--line-soft);
}
.ledger-row > div:last-child { border-right: 0; }

.ledger dt {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--paper-faint); margin-bottom: 4px;
}
.ledger dd { font-size: 16px; font-weight: 600; }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: clamp(20px, 3vw, 34px);
  align-items: start;
}

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

/* --- section heads --- */
.section-head { margin-bottom: 14px; }
.section-head h2 { font-size: 16px; }
.section-note { font-size: 13px; color: var(--paper-dim); margin-top: 3px; }
.create-head { margin-top: clamp(30px, 5vw, 48px); }

/* --- seats --- */
.seat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: var(--gap);
}

.seat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink-2);
  padding: 16px;
  display: flex; flex-direction: column; gap: 13px;
}

.seat.is-paused { opacity: .62; }

.seat-head { display: flex; align-items: flex-start; gap: 10px; }

.bib {
  font-family: var(--mono); font-size: 11px;
  color: var(--amber); background: var(--amber-dim);
  border-radius: 2px; padding: 2px 6px; margin-top: 3px;
  flex: 0 0 auto;
}

.seat-id { flex: 1 1 auto; min-width: 0; }
.seat-id h3 { font-size: 15px; }
.seat-kind { font-size: 12px; color: var(--paper-dim); margin-top: 1px; }

.seat-state {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: .06em; padding: 2px 6px; border-radius: 2px;
  border: 1px solid var(--line); color: var(--paper-faint);
  flex: 0 0 auto;
}
.seat-state[data-status="running"] { color: var(--up); border-color: var(--up); }
.seat-state[data-status="halted"] { color: var(--down); border-color: var(--down); }
.seat-state[data-status="bust"] { color: var(--down); border-color: var(--down); }

.seat-figures { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.figure-main { display: flex; align-items: baseline; gap: 6px; }
.figure-main .num { font-size: 24px; font-weight: 500; }
.figure-unit { font-size: 11px; color: var(--paper-faint); text-transform: uppercase; letter-spacing: .05em; }
.figure-delta { font-family: var(--mono); font-size: 12px; }
.figure-delta.up { color: var(--up); }
.figure-delta.down { color: var(--down); }
.figure-delta.flat { color: var(--paper-faint); }

.spark { width: 100%; height: 48px; display: block; }
.spark-line { fill: none; stroke: var(--paper-faint); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark-line.up { stroke: var(--up); }
.spark-line.down { stroke: var(--down); }
.spark-fill { fill: var(--paper-faint); opacity: .1; }
.spark-fill.up { fill: var(--up); }
.spark-fill.down { fill: var(--down); }

.seat-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line-soft); padding-top: 10px; gap: 8px;
}
.seat-stats dt { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--paper-faint); }
.seat-stats dd { font-size: 13px; }

.seat-position { font-size: 12px; color: var(--paper-dim); min-height: 18px; }
.seat-position.has-pos { color: var(--amber); }

.seat-actions { display: flex; gap: 8px; margin-top: auto; }

/* --- form --- */
.create-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--ink-2); padding: 18px;
  align-items: start;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 12px; color: var(--paper-dim); }

.field input, .field select {
  font-family: var(--sans); font-size: 14px;
  padding: 9px 10px; min-height: 38px;
  background: var(--ink-3); color: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius);
  width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--amber); }
.field input::placeholder { color: var(--paper-faint); }

.hint { font-size: 11px; color: var(--paper-faint); min-height: 15px; }

.field-action { justify-content: flex-end; }
.field-action .btn { width: 100%; }

.form-msg { grid-column: 1 / -1; font-size: 13px; min-height: 18px; }
.form-msg.error { color: var(--down); }
.form-msg.ok { color: var(--up); }

/* --- rail --- */
.rail { display: flex; flex-direction: column; gap: var(--gap); }

.panel {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--ink-2); padding: 16px;
}
.panel-quiet { background: transparent; }
.panel h2 { font-size: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.panel-note { font-size: 12px; color: var(--paper-dim); margin-top: 4px; }
.panel-foot { font-size: 11px; color: var(--paper-faint); margin-top: 10px; font-family: var(--mono); }

.llm-list { margin-top: 12px; display: flex; flex-direction: column; gap: 7px; }
.llm-list li {
  display: flex; justify-content: space-between; gap: 8px;
  font-family: var(--mono); font-size: 11px;
  padding-bottom: 7px; border-bottom: 1px solid var(--line-soft);
}
.llm-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.llm-list .model { color: var(--paper-dim); overflow: hidden; text-overflow: ellipsis; }
.llm-list .ready { color: var(--up); }
.llm-list .cool { color: var(--down); }

.feed {
  margin-top: 12px; display: flex; flex-direction: column;
  gap: 9px; max-height: 380px; overflow-y: auto;
}
.feed li {
  font-size: 12px; line-height: 1.45;
  padding-bottom: 9px; border-bottom: 1px solid var(--line-soft);
}
.feed li:last-child { border-bottom: 0; padding-bottom: 0; }
.feed time { font-family: var(--mono); font-size: 10px; color: var(--paper-faint); display: block; }
.feed .lvl-trade { color: var(--amber); }
.feed .lvl-error { color: var(--down); }
.feed .lvl-llm { color: var(--paper-dim); }
.feed .lvl-warn { color: var(--down); }

.token-actions { display: flex; gap: 8px; margin-top: 10px; }

.empty-state {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 22px 18px; color: var(--paper-dim); font-size: 13px;
  text-align: center;
}

@media (max-width: 620px) {
  .topbar { padding: 16px; }
  .brand-sub { display: none; }
  .ledger-row > div { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .ledger-row > div:last-child { border-bottom: 0; }
  .seat-grid { grid-template-columns: minmax(0, 1fr); }
  .create-form { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
