:root {
  --bg: #f7f7f5; --surface: #ffffff; --text: #1d1d1f; --muted: #6b6b70; --line: #e4e4e0;
  --accent: #2f5bd3; --accent-text: #ffffff; --danger: #c43a31; --ok: #1f8a4c; --warn: #b7791f;
  --code: #f0f0ec; --radius: 10px;
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214; --surface: #1b1b1f; --text: #ececee; --muted: #9a9aa2; --line: #2c2c32;
    --accent: #6d8ff0; --accent-text: #0d0d10; --danger: #ef6b62; --ok: #4cc283; --warn: #e2a84b; --code: #24242a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.7rem; margin: 1.2rem 0 .8rem; }
h2 { font-size: 1.15rem; margin: 0 0 .7rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: grid; gap: .8rem; }
.muted { color: var(--muted); }
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top .row { justify-content: space-between; min-height: 58px; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
nav form { margin: 0; }
footer { padding: 2rem 16px; font-size: .85rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; overflow-x: auto; }
.highlight { border-color: var(--accent); }
.narrow { max-width: 440px; margin: 2rem auto; }
.grid2, .grid3, .grid4 { display: grid; gap: 1rem; margin-bottom: 1rem; }
.grid2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.grid4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
.grid2 > .card, .grid3 > .card, .grid4 > .card { margin-bottom: 0; }
.banner { background: var(--accent); color: var(--accent-text); text-align: center; padding: .5rem 16px; font-weight: 600; }
.banner.warn { background: var(--warn); color: #fff; }
.notice { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); padding: .7rem .9rem; border-radius: 8px; margin: 1rem 0; }
.notice .secret, .alert .secret { margin-top: .5rem; color: var(--text); }
.alert { margin: 1rem 0; }
.grow { flex: 1 1 220px; }
.small { font-size: .85rem; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; }
td.row { flex-wrap: nowrap; }
td.row form { margin: 0; }
.hero { padding: 2.5rem 0 1.5rem; max-width: 720px; }
.hero h1 { font-size: 2.2rem; line-height: 1.2; }
.lead { font-size: 1.1rem; color: var(--muted); }
.stat b { display: block; font-size: 1.5rem; margin-top: .2rem; }
.meter { height: 6px; background: var(--code); border-radius: 3px; margin-top: .6rem; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); }
.bar { display: grid; grid-template-columns: 48px 1fr 40px; gap: .5rem; align-items: center; font-size: .85rem; margin: .3rem 0; }
.bar i { display: block; height: 10px; background: var(--accent); border-radius: 3px; min-width: 2px; }
.bar b { text-align: right; }
label { display: grid; gap: .3rem; font-weight: 500; }
input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; min-width: 0; }
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input.num { width: 6.5rem; }
input.num.tiny { width: 4rem; }
.notice code.key { white-space: pre-wrap; display: block; max-height: 40vh; overflow-y: auto; }
.btn { display: inline-block; font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent); border-radius: 8px; padding: .55rem 1rem; cursor: pointer; }
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.small { padding: .35rem .7rem; font-size: .88rem; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
.alert { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); padding: .6rem .8rem; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; }
tr.revoked td { opacity: .5; }
code, pre { font-family: ui-monospace, Consolas, monospace; font-size: .88rem; background: var(--code); border-radius: 6px; }
code { padding: .1rem .35rem; }
pre { padding: .8rem; overflow-x: auto; white-space: pre; }
code.key { padding: .5rem .7rem; word-break: break-all; }
pre.result { white-space: pre-wrap; min-height: 220px; max-height: 60vh; overflow-y: auto; }
.preview { max-width: 100%; max-height: 360px; border-radius: 8px; border: 1px solid var(--line); }
.pill { display: inline-block; padding: .1rem .5rem; border-radius: 99px; font-size: .8rem; font-weight: 600; }
.pill.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.pill.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.pill.bad { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.docs { max-width: 820px; }
.docs h2 { margin-top: 2rem; }
[x-cloak] { display: none; }

/* Smooth loading progress indicator */
body.loading-progress::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #4cc283);
  z-index: 9999;
  animation: pulseProgress 1s infinite linear;
}
@keyframes pulseProgress {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(0%); }
  100% { transform: translateX(100%); }
}

/* Playground Drop Zone */
.drop-zone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  vertical-align: middle;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
