/* Thermals Proxy. No framework; light and dark follow the system. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #16181d;
  --muted: #5d6573;
  --border: #e2e5ea;
  --accent: #e8542c;
  --accent-ink: #ffffff;
  --accent-soft: #fdebe5;
  --ok: #1f9d55;
  --warn: #d48806;
  --bad: #d64545;
  --off: #9aa1ad;
  --code-bg: #0f1218;
  --code-ink: #e6e8ee;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f13;
    --surface: #161a21;
    --surface-2: #1d222b;
    --text: #e8eaee;
    --muted: #9aa3b2;
    --border: #2a303b;
    --accent: #ff7a50;
    --accent-ink: #1a0d08;
    --accent-soft: #3a2018;
    --code-bg: #0a0c10;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: .2rem 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 5px; word-break: break-all; }
pre { background: var(--code-bg); color: var(--code-ink); padding: 1rem; border-radius: 10px; overflow-x: auto; margin: 0; }
pre code { background: none; padding: 0; color: inherit; word-break: normal; white-space: pre; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: .5rem 1rem; z-index: 10; }

/* top bar */
.topbar {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: .7rem clamp(1rem, 4vw, 2rem); background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--text); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.logo {
  width: 26px; height: 26px; border-radius: 8px; display: inline-block;
  background: linear-gradient(135deg, var(--accent), #f5a524);
}
.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a, .subnav a { color: var(--muted); padding: .4rem .7rem; border-radius: 8px; font-weight: 500; }
.nav a:hover, .subnav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"], .subnav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.me { display: flex; align-items: center; gap: .6rem; }
.me-name { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.avatar.initials { display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .85rem; }
.subnav { display: flex; gap: .25rem; flex-wrap: wrap; padding: .5rem clamp(1rem, 4vw, 2rem); border-bottom: 1px solid var(--border); background: var(--surface); }
.banner { background: var(--bad); color: #fff; padding: .6rem clamp(1rem, 4vw, 2rem); font-weight: 600; }

main { width: 100%; max-width: 1080px; margin: 0 auto; padding: 1.5rem clamp(1rem, 4vw, 2rem) 3rem; flex: 1; }
main.wide { max-width: 1400px; }
.footer { display: flex; gap: 1rem; justify-content: center; padding: 1.25rem; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--border); }

/* building blocks */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.card.highlight { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.25rem; }
.grid2 > .card, .grid3 > .card { margin-bottom: 0; }
.grid2 { margin-bottom: 1.25rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.section-title { margin-top: 1.5rem; }
.lede { font-size: 1.05rem; color: var(--muted); max-width: 46rem; margin-top: -.25rem; }
.hero { padding: 3rem 0 2rem; max-width: 46rem; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.hidden { display: none; }
.empty { color: var(--muted); }
.note { background: var(--surface-2); border-left: 3px solid var(--warn); padding: .6rem .8rem; border-radius: 6px; }
.note.bad { border-left-color: var(--bad); }
.hint { color: var(--muted); font-size: .88rem; margin-top: .75rem; }

.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 500; }
.flash.ok { background: color-mix(in srgb, var(--ok) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.stat-num { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
.stat-label { color: var(--muted); font-size: .85rem; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: .35rem; justify-content: center;
  font: inherit; font-weight: 600; font-size: .92rem; line-height: 1.2;
  padding: .55rem .95rem; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: .32rem .62rem; font-size: .82rem; border-radius: 7px; }
.btn.large { padding: .8rem 1.4rem; font-size: 1.05rem; }
.btn.copied { color: var(--ok); border-color: var(--ok); }
form.inline { display: inline-flex; gap: .4rem; align-items: center; margin: 0; }

/* forms */
.form { display: flex; flex-direction: column; gap: .9rem; }
.form label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; }
.form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem; }
.form label.check { flex-direction: row; align-items: flex-start; gap: .6rem; font-weight: 400; }
.form label.check input { margin-top: .3rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: .5rem .65rem; width: 100%; min-width: 0;
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88rem; }
input[type="checkbox"] { width: auto; }
.form .btn { align-self: flex-start; }
details summary { cursor: pointer; color: var(--muted); font-weight: 500; margin-bottom: .6rem; }
details[open] { display: flex; flex-direction: column; gap: .9rem; }
.code-input { font-family: ui-monospace, monospace; font-size: 1.3rem; letter-spacing: .12em; text-transform: uppercase; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-bottom: 1rem; }
.filters label { display: flex; flex-direction: column; gap: .2rem; font-size: .82rem; color: var(--muted); }
.filters input, .filters select { width: 10rem; padding: .4rem .55rem; }

/* lists, facts, steps */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .7rem; padding: .6rem 0; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.list li .muted { flex-basis: 100%; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem 1.25rem; margin: .5rem 0 1rem; }
.facts.big { grid-template-columns: 1fr; gap: .5rem; }
.facts.big div { display: grid; grid-template-columns: 9rem 1fr; gap: 1rem; }
.facts dt { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 0; font-weight: 500; }
.steps { padding-left: 1.25rem; margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.steps.big li { padding-left: .25rem; }
.plain { padding-left: 1.1rem; margin: 0; display: flex; flex-direction: column; gap: .45rem; }
.actions { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
td.actions { min-width: 14rem; }
.rename input { width: 11rem; padding: .3rem .5rem; }
.node-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.25rem; }
.node-grid .card { margin-bottom: 0; }
.node .actions select { width: auto; padding: .3rem .5rem; font-size: .85rem; }

/* status */
.live { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--off); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.dot-label { font-size: .85rem; color: var(--muted); }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); text-transform: lowercase; }
.badge.active, .badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.disabled, .badge.denied { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.revoked, .badge.error { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.meter { display: inline-block; width: 70px; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; vertical-align: middle; }
.meter-fill { display: block; height: 100%; background: var(--accent); width: 0; }
.w0 { width: 0; } .w5 { width: 5%; } .w10 { width: 10%; } .w15 { width: 15%; } .w20 { width: 20%; } .w25 { width: 25%; }
.w30 { width: 30%; } .w35 { width: 35%; } .w40 { width: 40%; } .w45 { width: 45%; } .w50 { width: 50%; } .w55 { width: 55%; }
.w60 { width: 60%; } .w65 { width: 65%; } .w70 { width: 70%; } .w75 { width: 75%; } .w80 { width: 80%; } .w85 { width: 85%; }
.w90 { width: 90%; } .w95 { width: 95%; } .w100 { width: 100%; background: var(--bad); }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
table.dense td, table.dense th { padding: .45rem .65rem; font-size: .88rem; }
td.detail { max-width: 32rem; word-break: break-word; }
.card .table-wrap { border: 0; }

/* snippets */
.tabs .tablist { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .6rem; }
.tab { font: inherit; font-size: .85rem; font-weight: 600; padding: .35rem .7rem; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; }
.tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tablist { display: none; }
.tabs.js .tablist { display: flex; }
.snippet { margin-bottom: .9rem; }
.tabs.js .snippet { display: none; margin-bottom: 0; }
.tabs.js .snippet.shown { display: block; }
.snippet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .35rem; font-weight: 600; font-size: .88rem; color: var(--muted); }
.secret-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; background: var(--surface-2); padding: .7rem .8rem; border-radius: 10px; margin-bottom: 1rem; }
.secret-row code { background: none; font-size: .9rem; flex: 1; }

@media (max-width: 700px) {
  .topbar { gap: .6rem; }
  .me { margin-left: auto; }
  .nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; margin: 0 -.25rem; }
  .nav a { white-space: nowrap; }
  .subnav { flex-wrap: nowrap; overflow-x: auto; }
  .subnav a { white-space: nowrap; }
  .me-name { display: none; }
  .facts.big div { grid-template-columns: 1fr; gap: 0; }
  td.actions { min-width: 0; }
}
