:root {
  --bg: #11110f;
  --surface: #1b1a17;
  --fg: #ece8df;
  --muted: #9a9488;
  --subtle: #6e6a62;
  --primary: #5f8a86;
  --primary-fg: #0e1413;
  --border: #2c2a26;
  --danger: #c45c4a;
  --warn: #c4a15a;
  --ok: #7a9a6e;
  --sans: "Figtree", "Segoe UI", system-ui, sans-serif;
  --display: "Instrument Serif", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(var(--border) 0.6px, transparent 0.6px);
  background-size: 7px 7px;
  opacity: 0.35;
  z-index: 0;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header */
.site-header {
  position: relative;
  z-index: 2;
  border-bottom: 1px solid var(--border);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 4rem;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  color: var(--fg);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  font-family: var(--display);
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}
.brand-tag {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtle);
}
.nav {
  display: flex;
  align-items: center;
  gap: 1.35rem;
}
.nav a {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--fg); }
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 0.4rem;
  height: 2.25rem;
  padding: 0 0.7rem;
  font: 600 0.75rem var(--sans);
}

/* Footer */
.site-footer {
  position: relative;
  z-index: 1;
  margin-top: 4rem;
  border-top: 1px solid var(--border);
  padding: 1.5rem 0 2.5rem;
  color: var(--subtle);
  font-size: 0.8125rem;
}
.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  justify-content: space-between;
}
.site-footer a { color: var(--muted); }

/* Type */
.kicker {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--primary);
}
h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1.08;
}
h1 em {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-style: italic;
}
h2 {
  margin: 0 0 0.75rem;
  font-family: var(--display);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 400;
  letter-spacing: -0.02em;
}
h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  font-weight: 600;
}
.lede {
  max-width: 38rem;
  margin: 1.15rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}
.section { padding: 4rem 0 0; }
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.75rem;
  padding: 0 1.15rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  font: 600 0.875rem/1 var(--sans);
  cursor: pointer;
  text-decoration: none;
  background: var(--surface);
  color: var(--fg);
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-fg); }
.btn.secondary { border-color: var(--border); }
.btn.ghost {
  height: 2.25rem;
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

/* Hero */
.hero { padding: 3.5rem 0 1rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.6rem; }

/* Cards / grids */
.grid-2, .grid-3, .grid-4 {
  display: grid;
  gap: 1rem;
}
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 980px) {
  .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
}

.card {
  display: flex;
  flex-direction: column;
  padding: 1.2rem 1.2rem 1.3rem;
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}
a.card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.card p { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.92rem; }
.card .meta {
  margin-top: auto;
  padding-top: 1rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtle);
}

/* Workbench */
.panel {
  display: flex;
  flex-direction: column;
  padding: 1.15rem;
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  background: var(--surface);
  min-height: 22rem;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.panel-head label,
.panel-head h2 {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.desk { display: grid; gap: 1.1rem; }
@media (min-width: 960px) {
  .desk { grid-template-columns: 1fr 1fr; }
}

textarea,
input[type="text"],
input[type="email"],
input[type="password"],
select {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.6;
}
textarea { flex: 1; min-height: 16rem; resize: vertical; }
textarea:focus, input:focus, select:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent);
  outline-offset: 0;
}

.count { font-family: var(--mono); font-size: 0.7rem; color: var(--subtle); }
.status { min-height: 1.25rem; margin: 0.85rem 0 0; font-size: 0.8125rem; color: var(--muted); }
.status.error { color: var(--danger); }

/* Tabs */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}
.chip {
  height: 2.25rem;
  padding: 0 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font: 500 0.75rem/1 var(--sans);
  cursor: pointer;
}
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-fg);
}

/* Scrub preview */
.preview {
  flex: 1;
  min-height: 16rem;
  overflow: auto;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg);
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.preview.empty { color: var(--subtle); text-align: center; padding-top: 4rem; white-space: normal; }
mark.pii {
  color: var(--primary-fg);
  border-radius: 0.2rem;
  padding: 0 0.15rem;
}
mark.pii.email, mark.pii.phone { background: #c4a15a; }
mark.pii.iban, mark.pii.ahv, mark.pii.card { background: #c45c4a; color: #1a0c0a; }
mark.pii.key, mark.pii.jwt { background: #c45c4a; color: #1a0c0a; }
mark.pii.ip { background: #5f8a86; }

.badge-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; }
.badge {
  font: 500 0.7rem/1 var(--mono);
  padding: 0.35rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge.hot { border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); color: #e8b4ab; }

/* Token table */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.stat {
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: var(--bg);
}
.stat b {
  display: block;
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 500;
}
.stat span { font-size: 0.72rem; color: var(--subtle); letter-spacing: 0.06em; text-transform: uppercase; }

table.prices {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
table.prices th,
table.prices td {
  text-align: left;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--border);
}
table.prices th { color: var(--subtle); font-weight: 600; font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; }
table.prices td.num { font-family: var(--mono); font-size: 0.78rem; }
.bar {
  height: 0.45rem;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 0.35rem;
}
.bar > i {
  display: block;
  height: 100%;
  background: var(--primary);
  width: 0;
}

/* Chunks */
.chunk-list { display: grid; gap: 0.7rem; }
.chunk {
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: var(--bg);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.55;
  white-space: pre-wrap;
}
.chunk header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.45rem;
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtle);
}
.overlap { color: var(--primary); }

/* Forms */
.form label {
  display: block;
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.form .field { margin-bottom: 1rem; }
.note { color: var(--subtle); font-size: 0.85rem; }
code {
  font-family: var(--mono);
  font-size: 0.82em;
  color: var(--fg);
}

/* Labs list extras */
.live { color: var(--primary); }

@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }
  .nav {
    display: none;
    position: absolute;
    top: 4rem;
    right: 1.25rem;
    left: 1.25rem;
    flex-direction: column;
    align-items: stretch;
    padding: 0.8rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.9rem;
  }
  .nav.open { display: flex; }
  .stat-row { grid-template-columns: 1fr; }
  .brand-tag { display: none; }
}
