:root {
  --bg: #161617;
  --surface: #1d1d1f;
  --surface-2: #2a2a2d;
  --text: #f5f5f7;
  --muted: #86868b;
  --accent: #2997ff;
  --warn: #ffb340;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  line-height: 1.5;
}

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

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 1280px; margin: 0 auto; padding: 18px 24px;
}
.brand { color: var(--text); font-weight: 800; font-size: 18px; }
.brand:hover { text-decoration: none; }
.top nav { display: flex; gap: 4px; }
.nav {
  background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.nav:hover { color: var(--text); }
.nav.on { color: var(--text); background: var(--surface); }

.banner {
  max-width: 1280px; margin: 0 auto 8px; padding: 10px 24px;
  color: var(--muted); font-size: 14px;
}

/* ---------- layout ---------- */
.grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px;
  max-width: 1280px; margin: 0 auto; padding: 8px 24px 64px;
}
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; gap: 24px; padding: 8px 16px 48px; }
  .top { padding: 16px; }
  .banner { padding: 8px 16px; }
}

section { margin-bottom: 28px; }

.label { color: var(--muted); font-size: 13px; font-weight: 600; margin: 0 0 10px; }
.hint { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.muted { color: var(--muted); }

/* ---------- form ---------- */
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row { grid-template-columns: 1fr; } }
.narrow { max-width: 280px; margin-top: 8px; }

input, select, textarea {
  display: block; width: 100%; margin-top: 6px;
  background: var(--surface); color: var(--text);
  border: 1px solid transparent; border-radius: 10px;
  padding: 10px 12px; font: inherit; font-weight: 400;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(41, 151, 255, 0.25);
}
::placeholder { color: #5f5f64; }

.check { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.check input { width: auto; margin: 0; accent-color: var(--accent); }
#rca-fields { margin-top: 12px; }

/* segmented controls */
.seg {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin: 0 8px 10px 0;
  background: var(--surface); border-radius: 999px;
}
.seg button {
  background: none; border: 0; color: var(--muted); font: inherit; font-weight: 700; font-size: 14px;
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--text); color: var(--bg); }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip { margin: 0; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
  display: inline-block; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); color: var(--muted); font-size: 14px; font-weight: 600;
}
.chip:hover span { color: var(--text); }
.chip input:checked + span { background: var(--accent); color: #fff; }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px rgba(41, 151, 255, 0.4); }

/* ---------- preview ---------- */
.preview { position: sticky; top: 16px; align-self: start; }
.subject { font-size: 20px; font-weight: 800; margin: 0 0 24px; line-height: 1.3; }
.out {
  white-space: pre-wrap; word-wrap: break-word;
  background: var(--surface); border-radius: var(--radius); padding: 20px;
  min-height: 240px; max-height: 60vh; overflow: auto; font-size: 15px;
}
.missing { color: var(--warn); font-size: 13px; margin: 12px 0 0; padding-left: 18px; }
.missing:empty { display: none; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn {
  background: var(--surface-2); color: var(--text); border: 0; border-radius: 999px;
  padding: 10px 18px; font: inherit; font-weight: 700; cursor: pointer;
}
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: none; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }
.toast { color: var(--muted); font-size: 14px; min-height: 1.5em; margin: 10px 0 0; }

/* ---------- clients ---------- */
.clients { max-width: 760px; margin: 0 auto; padding: 8px 24px 64px; }
.clients h1 { font-size: 40px; font-weight: 800; margin: 8px 0 4px; }
.client-row { display: grid; grid-template-columns: 1fr 220px auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.client-row input, .client-row select { margin: 0; }
@media (max-width: 600px) {
  .clients { padding: 8px 16px 48px; }
  .client-row { grid-template-columns: 1fr; padding-bottom: 12px; }
}

/* ---------- landing ---------- */
.home { max-width: 1080px; margin: 0 auto; padding: 48px 24px 80px; }
.home h1 { font-size: clamp(36px, 6vw, 56px); font-weight: 800; line-height: 1.1; margin: 0 0 16px; }
.home .lead { font-size: 20px; color: var(--muted); max-width: 640px; margin: 0 0 32px; }
.home .cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; margin-top: 56px; }
.home h2 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 12px; }
.home ul { list-style: none; padding: 0; margin: 0; }
.home li { font-weight: 600; margin-bottom: 8px; }
@media (max-width: 760px) {
  .home { padding: 32px 16px 56px; }
  .home .cols { grid-template-columns: 1fr; gap: 24px; }
}

[hidden] { display: none !important; }
