/* Standalone: no shared stylesheet, so this file carries its own tokens. */
:root {
  --bg: #faf9f8;
  --surface: #ffffff;
  --surface2: #f3f1ef;
  --border: #e6e2de;
  --border-strong: #d6d0ca;
  --text: #1c1a18;
  --text2: #55504b;
  --text3: #8b837c;
  --accent: #a4522b;
  --accent-soft: #f6ece6;
  --warn: #8a5a10;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17151300; --surface: #201d1b; --surface2: #2a2624;
    --border: #332e2b; --border-strong: #453f3b;
    --text: #f2efec; --text2: #b8b0a9; --text3: #857d76;
    --accent: #d98b5f; --accent-soft: #2e211a; --warn: #d9a441;
  }
  body { background: #171513; }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 1.4rem 1.6rem 3rem;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

.head h1 { font-size: 1.25rem; font-weight: 600; margin: 0 0 0.2rem; letter-spacing: -0.01em; }
.lede { margin: 0 0 0.7rem; color: var(--text2); font-size: 0.85rem; max-width: 60ch; }
.note {
  margin: 0 0 1rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.76rem;
  color: var(--text2);
  max-width: 90ch;
}
.note strong { color: var(--text); }

.config, .controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.55rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  margin-bottom: 0.6rem;
}
.config label, .controls label {
  display: flex; flex-direction: column; gap: 0.15rem;
  font-size: 0.66rem; color: var(--text3);
}
input, textarea, select {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.32rem 0.45rem;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text);
}
textarea { resize: vertical; }
.controls label.wide { flex: 1 1 20rem; }
.config label.narrow input { width: 5rem; }
.buttons { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-left: auto; }

button {
  font-family: var(--sans);
  font-size: 0.75rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--surface2); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

.strategy-note {
  margin: 0 0 0.7rem;
  font-size: 0.74rem;
  color: var(--text2);
  max-width: 90ch;
}
.strategy-note .trade { display: block; margin-top: 0.15rem; color: var(--text3); font-size: 0.7rem; }

.step {
  display: flex; flex-direction: column; gap: 0.15rem;
  padding: 0.55rem 0.8rem;
  border-radius: 6px;
  background: var(--accent-soft);
  font-size: 0.76rem;
  color: var(--text2);
  min-height: 3rem;
  margin-bottom: 0.7rem;
}
.step strong { color: var(--text); font-size: 0.8rem; }
.step .mono, #step-detail.mono { font-family: var(--mono); font-size: 0.7rem; white-space: pre; overflow-x: auto; }

.cost {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  margin-bottom: 0.8rem;
}
.cost.empty-cost { color: var(--text3); font-size: 0.75rem; }
.stat {
  display: flex; flex-direction: column;
  padding: 0.25rem 0.55rem;
  border-radius: 5px;
  background: var(--surface2);
  min-width: 6.5rem;
}
.stat.is-warn { background: var(--accent-soft); }
.stat-label { font-size: 0.62rem; color: var(--text3); text-transform: uppercase; letter-spacing: 0.04em; }
.stat strong { font-family: var(--mono); font-size: 0.85rem; }

/* KV bytes per write. The shape is the point: it climbs until a seal. */
.spark {
  display: flex; align-items: flex-end; gap: 1px;
  height: 42px; flex: 1 1 12rem; min-width: 8rem;
  padding: 0.2rem 0.3rem;
  border-radius: 5px;
  background: var(--surface2);
}
.spark span { flex: 1; background: var(--accent); border-radius: 1px 1px 0 0; min-height: 2px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 0.7rem;
  align-items: start;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.7rem 0.8rem 0.85rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.panel.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.panel header { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.35rem; }
.panel h2 { font-size: 0.82rem; font-weight: 600; margin: 0; }

.badge {
  padding: 0.08rem 0.38rem; border-radius: 4px;
  font-size: 0.58rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
}
.badge.browser { background: #e8f0fe; color: #1a56db; }
.badge.worker  { background: #fdece4; color: #a4522b; }
.badge.do      { background: #f3ecfd; color: #6d28d9; }
.badge.kv      { background: #e9f0e9; color: #35663f; }

.key { margin: 0.2rem 0; font-size: 0.68rem; color: var(--text3); overflow-wrap: anywhere; }
.key code, .sub code { font-family: var(--mono); font-size: 0.66rem; color: var(--text2); }
.sub { margin: 0.45rem 0 0.15rem; font-size: 0.66rem; color: var(--text3); line-height: 1.4; }
.empty { margin: 0.25rem 0; font-size: 0.72rem; color: var(--text3); font-style: italic; }

pre {
  margin: 0.15rem 0 0;
  padding: 0.45rem 0.55rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 0.67rem;
  line-height: 1.45;
  color: var(--text2);
  max-height: 15rem;
  overflow: auto;
  white-space: pre;
}

.rows { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 0.65rem; }
.rows th {
  text-align: left; font-weight: 600; color: var(--text3);
  padding: 0.22rem 0.3rem; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.rows td {
  padding: 0.22rem 0.3rem; border-bottom: 1px solid var(--border);
  color: var(--text2); max-width: 11rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rows tr.pending td { color: var(--warn); }
.idx {
  font-size: 0.54rem; padding: 0 0.18rem; border-radius: 3px;
  background: var(--surface2); color: var(--text3); text-transform: uppercase;
}

.bar { height: 4px; border-radius: 2px; background: var(--surface2); overflow: hidden; margin: 0.3rem 0; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.3s ease; }

@media (prefers-reduced-motion: reduce) {
  .bar-fill, .panel { transition: none; }
}

/* The 2 MB per-key ceiling. Shown as bars because the shape is the message:
   it fills steadily and then simply stops working. */
.limit { margin: 0.35rem 0 0.45rem; display: flex; flex-direction: column; gap: 0.25rem; }
.limit-row { display: flex; align-items: center; gap: 0.4rem; font-size: 0.66rem; }
.limit-key { font-family: var(--mono); color: var(--text3); min-width: 5.5rem; }
.limit-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--surface2); overflow: hidden; }
.limit-bar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.limit-bar span.near { background: var(--warn); }
.limit-bar span.over { background: #c0392b; }
.limit-val { font-family: var(--mono); color: var(--text2); min-width: 8.5rem; text-align: right; }
.limit-note { margin: 0.15rem 0 0; font-size: 0.66rem; color: var(--text3); line-height: 1.4; }
.limit-note.is-over { color: #c0392b; font-weight: 600; }

.grow-wrap { display: flex; gap: 0.2rem; }
.grow-wrap input { width: 5.5rem; }
button.tiny { padding: 0.28rem 0.45rem; font-size: 0.68rem; }
