:root {
  color-scheme: light;
  --bg: #f6f6f4; --surface: #fcfcfb; --surface-2: #efefec; --line: #dddcd7;
  --text: #0b0b0b; --text-2: #52514e; --text-3: #7a7974;
  --accent: #0b0b0b; --accent-ink: #ffffff;
  --series-1: #2a78d6; --series-2: #eb6834;
  --good: #1b7f4c;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --line: #34332f;
    --text: #ffffff; --text-2: #c3c2b7; --text-3: #8f8e86;
    --accent: #ffffff; --accent-ink: #0b0b0b;
    --series-1: #3987e5; --series-2: #d95926; --good: #46b37a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --line: #34332f;
  --text: #ffffff; --text-2: #c3c2b7; --text-3: #8f8e86;
  --accent: #ffffff; --accent-ink: #0b0b0b;
  --series-1: #3987e5; --series-2: #d95926; --good: #46b37a;
}
/* disorderly's wordmark typeface (Chakra Petch Bold, SIL Open Font License, see fonts/OFL.txt), self-hosted. */
@font-face { font-family: 'Chakra Petch'; src: url('fonts/ChakraPetch-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans); }
body { overflow-x: hidden; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }

/* Header */
header.top { border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
header.top .wrap { display: flex; align-items: center; gap: 8px 16px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 650; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.brand .mark { width: 18px; height: 18px; display: grid; grid-template-columns: 1fr 1fr; }
.brand .mark i:nth-child(1) { background: #00b5e2; } .brand .mark i:nth-child(2) { background: #e4007c; }
.brand .mark i:nth-child(3) { background: #ffd100; } .brand .mark i:nth-child(4) { background: #111; }
.brand .by { font-weight: 400; font-size: 13px; color: var(--text-3); margin-left: -2px; }
/* The disorderly lockup exactly as on disorderly.ai (mark + Chakra Petch wordmark, green "order" with its glow),
   on disorderly's own dark background so it reads the same in light and dark themes. */
.disorderly { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 6px; border-radius: 6px; background: #101820; border: 1px solid rgba(0,255,163,.14); text-decoration: none; }
.disorderly img { width: 20px; height: 20px; display: block; }
.disorderly .dz-name { font-family: 'Chakra Petch', system-ui, sans-serif; font-weight: 700; font-size: 15px; letter-spacing: -.02em; color: #dfe9f0; text-transform: lowercase; line-height: 1; }
.disorderly .ord { color: #00ffa3; text-shadow: 0 0 16px rgba(0,255,163,.55); }
.disorderly:hover { border-color: rgba(0,255,163,.45); }
nav.tabs { display: flex; gap: 4px; overflow-x: auto; max-width: 100%; }
nav.tabs button { border: 0; background: none; padding: 8px 12px; border-radius: 8px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
nav.tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
.tab-count { font: 600 11px var(--mono); color: var(--text-2); }
.status { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.live { background: var(--good); } .dot.demo { background: var(--series-2); }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 9px; cursor: pointer; }

/* Layout pieces */
/* One spacing step (16px) under the nav, between tiles and between sections. main.wrap beats .wrap's padding. */
main.wrap { padding-top: 16px; padding-bottom: 64px; }
.notice { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; color: var(--text-2); }
.notice strong { color: var(--text); }
.notice code { font-family: var(--mono); font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.tile .k { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.tile .v { font: 600 22px/1.25 var(--mono); margin-top: 4px; overflow-wrap: anywhere; }
.tile .s { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.tile .s a { color: var(--text-2); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; min-width: 0; }
.panel h2 { font-size: 15px; margin: 0; font-weight: 600; }
.panel .sub { color: var(--text-2); font-size: 13px; margin: 2px 0 10px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.two > .panel { margin-bottom: 16px; }
.row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.muted { color: var(--text-2); font-size: 12px; }
.hidden { display: none !important; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 16px; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { padding: 4px 10px; font-size: 13px; }
button.link { border: 0; background: none; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }

/* Chart */
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chart-box { position: relative; height: 300px; margin-top: 8px; }
.chart-box canvas { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: pan-y; }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,.12); display: none; white-space: nowrap; z-index: 2; }
.tip b { font-family: var(--mono); }
.zoom-box { position: absolute; border: 1px solid var(--text-2); background: color-mix(in srgb, var(--series-1) 10%, transparent); pointer-events: none; }
.chart-tools { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--text-2); margin-top: 6px; flex-wrap: wrap; }

/* Filters, grid and table */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 12px; }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-2); }
.filters input, .filters select { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; min-width: 0; }
.filters input[type="number"] { width: 110px; }
.filters .check { flex-direction: row; align-items: center; gap: 6px; font-size: 14px; color: var(--text); padding-bottom: 8px; }
.filters .grow { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 12px; cursor: pointer; color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.count { font-size: 13px; color: var(--text-2); margin-bottom: 10px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.card .art { aspect-ratio: 1; background: var(--surface-2); }
.card .art svg, .lookup-art svg { width: 100%; height: 100%; display: block; }
/* The body fills the card so the action buttons can sit at the bottom: cards in a row share a height, so the
   buttons line up whatever the price or chips above them look like. */
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card .price, .card .per { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.id { font: 600 14px var(--mono); }
.score { font: 600 15px var(--mono); }
.price { font: 600 15px var(--mono); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.chip { font-size: 11px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; color: var(--text-2); }
.badge { font-size: 11px; border-radius: 999px; padding: 1px 7px; color: #fff; background: var(--series-2); font-weight: 600; white-space: nowrap; }
.badge.ink { background: var(--text); color: var(--bg); }
.card .actions { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-top: auto; padding-top: 8px; }
.card a.buy { text-align: center; border: 1px solid var(--line); border-radius: 8px; padding: 6px; text-decoration: none; font-size: 13px; }
.card a.buy:hover { background: var(--surface-2); }
.add { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 13px; }
.add[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.more { display: flex; justify-content: center; margin-top: 16px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th { color: var(--text-2); font-weight: 500; position: sticky; top: 0; background: var(--surface); }
th:first-child, td:first-child, td.l, th.l { text-align: left; }
td { font-family: var(--mono); }
td.sans { font-family: var(--sans); }
.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--series-1) 22%, transparent); } to { background: transparent; } }

/* Lookup */
.lookup { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 16px; align-items: start; }
.lookup-art { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.facts { display: grid; gap: 0; }
.facts .row { padding: 8px 0; border-bottom: 1px solid var(--line); }
.facts .row span:last-child { font-family: var(--mono); text-align: right; }
.big { font: 650 40px/1.1 var(--mono); }
.hist-box { position: relative; height: 140px; margin-top: 8px; }
.hist-box canvas { width: 100%; height: 100%; display: block; }

/* Builder */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.builder .side { display: grid; gap: 16px; position: sticky; top: 72px; }
.builder .side .panel { margin: 0; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); margin-bottom: 10px; }
.field input, .field select, .inline input { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 14px; color: var(--text); min-width: 0; }
.inline { display: flex; gap: 8px; } .inline > * { flex: 1; min-width: 0; }
.modes { display: grid; gap: 6px; margin-bottom: 10px; }
.modes label { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.msg { font-size: 13px; color: var(--text-2); margin-top: 8px; min-height: 1em; }
.msg.err { color: var(--series-2); }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.slots { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.slot { aspect-ratio: 1; border-radius: 4px; background: var(--surface-2); position: relative; overflow: hidden; border: 0; padding: 0; cursor: pointer; }
.slot .art, .slot svg { width: 100%; height: 100%; display: block; }
.slot.empty { cursor: default; border: 1px dashed var(--line); background: transparent; }
.slot .k { position: absolute; left: 2px; top: 2px; font: 600 9px/1 var(--mono); padding: 2px 3px; border-radius: 3px; background: var(--surface); color: var(--text); }
.slot:not(.empty):hover::after { content: "\00d7"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.45); color: #fff; font-size: 20px; }
.legend-k { display: inline-flex; gap: 12px; font-size: 12px; color: var(--text-2); }
.legend-k b { font: 600 10px var(--mono); border: 1px solid var(--line); border-radius: 3px; padding: 0 3px; color: var(--text); }
.mix { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-2); margin-top: 12px; }
.mix b { font-family: var(--mono); color: var(--text); }
.stale td { color: var(--series-2); }

/* Supply */
.empty-state { padding: 28px 16px; text-align: center; color: var(--text-2); }
.empty-state strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
tr.expand td { background: var(--surface-2); white-space: normal; }
.mini { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 3px; padding: 6px 0; }
.mini .art { aspect-ratio: 1; display: block; background: var(--surface); border-radius: 3px; overflow: hidden; }
.mini .art svg { width: 100%; height: 100%; display: block; }
.bar { display: inline-block; height: 8px; border-radius: 4px; background: var(--series-1); vertical-align: middle; min-width: 2px; }
.ok { color: var(--good); }
.warn { color: var(--series-2); }

details.about { margin-top: 10px; font-size: 13px; color: var(--text-2); }
details.about summary { cursor: pointer; color: var(--text); }
details.about p { margin: 8px 0 0; max-width: 90ch; }
footer { color: var(--text-3); font-size: 12px; padding: 24px 0; border-top: 1px solid var(--line); }
footer a { color: var(--text-2); }

@media (max-width: 960px) { .builder { grid-template-columns: 1fr; } .builder .side { position: static; order: -1; } .two { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .lookup { grid-template-columns: 1fr; } }
@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .filters input[type="number"] { width: 92px; }
  .status .label { display: none; }
  .tile .v { font-size: 18px; }
  .chart-box { height: 240px; }
  .slots { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}
