:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1d212a;
  --ink: #e6e8ee;
  --dim: #98a0b3;
  --line: #2a2f3a;
  --accent: #6ea8fe;
  --accent-2: #7ee0a8;
  --warn: #ffb454;
  --bad: #ff7a7a;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Inter, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --panel-2: #f1f3f7;
    --ink: #14171f;
    --dim: #5b6373;
    --line: #dde1e9;
    --accent: #1f5fd0;
    --accent-2: #12794a;
    --warn: #9a5b00;
    --bad: #c02222;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
}

header {
  padding: 2.5rem 1.5rem 1rem;
  text-align: center;
}
header h1 { margin: 0; font-size: 1.9rem; letter-spacing: -0.02em; }
header .sub { margin: .35rem 0 0; color: var(--dim); }

main {
  max-width: 68rem;
  margin: 0 auto;
  padding: 1rem 1.25rem 5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.5rem;
}

.hero { text-align: center; }
.hero .cta { display: flex; flex-direction: column; align-items: center; gap: .85rem; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: filter .12s ease, opacity .12s ease;
}
button:disabled { opacity: .55; cursor: progress; }
button:hover:not(:disabled) { filter: brightness(1.1); }

.big {
  background: var(--accent);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 600;
  padding: .85rem 2.2rem;
  box-shadow: 0 6px 18px -10px var(--accent);
}

.secondary {
  background: var(--panel-2);
  color: var(--ink);
  border-color: var(--line);
  padding: .45rem 1rem;
}
.secondary.small { font-size: .85rem; padding: .3rem .7rem; }

.link {
  color: var(--accent);
  text-decoration: none;
  font-size: .95rem;
  border-bottom: 1px dotted currentColor;
}
.link:hover { text-decoration: none; opacity: .8; }

form { display: flex; flex-direction: column; gap: .6rem; align-items: center; }
form label { color: var(--dim); font-size: .9rem; }
input[type=text] {
  font: inherit;
  padding: .7rem 1rem;
  width: min(22rem, 100%);
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
}
input[type=text]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; align-items: center; gap: 1rem; }

.who {
  margin-bottom: 1rem;
  font-size: 1.05rem;
}
.who strong { color: var(--accent-2); }

.status { min-height: 1.4rem; margin: 1rem 0 0; color: var(--dim); font-size: .95rem; }
.status.err { color: var(--bad); }
.status.ok { color: var(--accent-2); }

.hidden { display: none !important; }

/* live client-side call log — shows whether the final POST actually went out */
.calllog {
  margin-top: 1rem;
  max-height: 11rem;
  overflow-y: auto;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .6rem .8rem;
  font-family: var(--mono);
  font-size: .75rem;
  line-height: 1.6;
  color: var(--dim);
  white-space: pre;
}
.calllog div:last-child { color: var(--ink); }

/* ---- trace ---- */

.trace-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  padding: 0 .25rem;
}
.trace-head h2 { margin: 0; font-size: 1.3rem; }
.trace-tools { display: flex; align-items: center; gap: 1rem; }
.toggle { color: var(--dim); font-size: .85rem; user-select: none; cursor: pointer; }

#trace { display: flex; flex-direction: column; gap: .8rem; margin-top: 1rem; }

.step {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.step.msg { border-left: 3px solid var(--accent); }
.step.verify { border-left: 3px solid var(--accent-2); }
.step.result { border-left: 3px solid var(--warn); }

.step > summary {
  cursor: pointer;
  padding: .8rem 1rem;
  display: flex;
  align-items: center;
  gap: .7rem;
  flex-wrap: wrap;
  list-style: none;
}
.step > summary::-webkit-details-marker { display: none; }
.step > summary::before {
  content: "▸";
  color: var(--dim);
  font-size: .8rem;
  transition: transform .12s ease;
}
.step[open] > summary::before { transform: rotate(90deg); }

.num {
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--dim);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  min-width: 1.7rem;
  text-align: center;
  padding: .05rem .35rem;
}
.title { font-weight: 600; }

.pill {
  font-size: .7rem;
  font-family: var(--mono);
  padding: .1rem .5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--dim);
  white-space: nowrap;
}
.pill-recon { border-style: dashed; }
.pill-wire { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

.body { padding: 0 1rem 1rem; display: flex; flex-direction: column; gap: .85rem; }
.note { color: var(--dim); font-size: .92rem; margin: 0; }
.spec { font-family: var(--mono); font-size: .75rem; color: var(--dim); }

pre {
  margin: 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .75rem .9rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: .78rem;
  line-height: 1.45;
  white-space: pre;
}
pre.wrap { white-space: pre-wrap; word-break: break-all; }

.blocklabel {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--dim);
  margin-bottom: .3rem;
}

table.fields { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.fields td { padding: .35rem .5rem; border-top: 1px solid var(--line); vertical-align: top; }
table.fields tr:first-child td { border-top: none; }
table.fields td.k { font-family: var(--mono); color: var(--accent); white-space: nowrap; width: 1%; }
table.fields td.v { font-family: var(--mono); word-break: break-all; }
table.fields td.n { color: var(--dim); font-size: .8rem; }

.bytes { display: flex; flex-direction: column; gap: .4rem; }
.byteseg {
  display: grid;
  grid-template-columns: 5.5rem 10rem 1fr;
  gap: .5rem;
  align-items: start;
  font-size: .8rem;
  padding: .35rem .5rem;
  border-radius: 6px;
  background: var(--panel-2);
  border-left: 3px solid var(--seg, var(--accent));
}
.byteseg .off { font-family: var(--mono); color: var(--dim); }
.byteseg .nm { font-family: var(--mono); color: var(--seg, var(--accent)); word-break: break-all; }
.byteseg .val { font-family: var(--mono); word-break: break-all; }
.byteseg .segnote { color: var(--dim); font-size: .78rem; display: block; margin-top: .2rem; }
@media (max-width: 720px) {
  .byteseg { grid-template-columns: 1fr; }
}

ul.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
ul.checks li { display: flex; gap: .55rem; align-items: baseline; font-size: .87rem; }
ul.checks .mark { font-family: var(--mono); font-weight: 700; }
ul.checks li.ok .mark { color: var(--accent-2); }
ul.checks li.no .mark { color: var(--bad); }
ul.checks .detail { color: var(--dim); font-family: var(--mono); font-size: .78rem; }

.history { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.history li { display: flex; gap: .7rem; align-items: baseline; font-size: .88rem; }
.history button { background: none; border: none; color: var(--accent); padding: 0; font-size: .88rem; text-align: left; }
.history .ts { font-family: var(--mono); color: var(--dim); font-size: .78rem; }
.history .ok { color: var(--accent-2); }
.history .no { color: var(--bad); }

.hint { color: var(--dim); font-size: .85rem; margin: .2rem 0 0; }
.notes p { color: var(--dim); font-size: .92rem; }
.notes em { color: var(--ink); font-style: normal; font-weight: 600; }
h2 { font-size: 1.15rem; margin: 0 0 .3rem; }
