/* =============================================================
   THE MESSY MIDDLE KIT — DESIGN SYSTEM
   Tokens lifted from rob-curtis.com (theme: Pine & Acid).
   Change the block below and the whole kit changes with it.
   ============================================================= */

:root {
  /* ---- straight from the site ---- */
  --cream: #f7f3e8;
  --paper: #fffcf4;
  --ink: #141310;
  --ink-2: #4e4a42;
  --ink-3: #6e685e;
  --line: rgba(20, 19, 16, .14);
  --line-2: rgba(20, 19, 16, .07);

  --green: #1c4034;
  --green-deep: #132c24;
  --on-green: #f4f0e4;
  --accent: #c8ff4d;
  --on-accent: #141310;

  --red: #d9553f;
  --mint: #9fe0c2;

  --r: 2px;
  --f-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --f-hand: "Caveat", cursive;

  /* ---- kit aliases, so the tool code stays readable ---- */
  --ink-soft: var(--ink-2);
  --muted: var(--ink-3);
  --wash: var(--cream);
  --line-strong: rgba(20, 19, 16, .28);
  --accent-deep: var(--green);
  --accent-wash: #eef7d8;
  --good: var(--green);
  --good-wash: #e7efe6;
  --warn: #8a6a12;
  --warn-wash: #f6f0d9;
  --bad: var(--red);
  --bad-wash: #fbeae6;

  --radius: var(--r);
  --radius-sm: var(--r);
  --shadow: none;
  --shadow-lift: 0 10px 30px rgba(20, 19, 16, .08);

  --font: var(--f-display);
  --maxw: 820px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--f-display);
  font-size: 17px;
  line-height: 1.55;
  letter-spacing: -.008em;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* ---------- Layout ---------- */

.k-wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(20px, 5vw, 40px); }
.k-wrap-wide { max-width: 1180px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 40px); }

.k-topbar {
  border-bottom: 1px solid var(--line-2);
  background: color-mix(in srgb, var(--cream) 88%, transparent);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 60;
}
.k-topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 40px);
  height: clamp(60px, 4.6vw, 74px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.k-logo {
  font-weight: 700;
  font-size: clamp(15px, 1.16vw, 18px);
  letter-spacing: -.045em;
  text-decoration: none;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.k-logo .dot {
  width: 13px; height: 13px;
  background: var(--accent);
  border: 1px solid var(--ink);
  display: inline-block;
}
.k-topnav { display: flex; gap: clamp(14px, 1.5vw, 26px); align-items: center; }
.k-topnav a {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -.01em;
  color: var(--ink-2);
  text-decoration: none;
  position: relative;
  padding-block: 6px;
  transition: color .18s;
}
.k-topnav a::after {
  content: ""; position: absolute; left: 0; right: 100%; bottom: 2px; height: 1.5px;
  background: var(--green); transition: right .28s cubic-bezier(.2, .8, .2, 1);
}
.k-topnav a:hover { color: var(--ink); }
.k-topnav a:hover::after { right: 0; }

.k-main { padding: clamp(38px, 5vw, 64px) 0 clamp(70px, 9vw, 120px); }

/* ---------- Type ---------- */

h1, h2, h3, h4 { margin: 0 0 14px; font-family: var(--f-display); font-weight: 700; }
h1 { font-size: clamp(34px, 5.2vw, 62px); line-height: .96; letter-spacing: -.04em; }
h2 { font-size: clamp(24px, 3.1vw, 36px); line-height: 1.04; letter-spacing: -.032em; margin-top: 4px; }
h3 { font-size: clamp(18px, 1.72vw, 22px); line-height: 1.16; letter-spacing: -.026em; font-weight: 600; }
h4 { font-size: 17px; line-height: 1.22; letter-spacing: -.02em; font-weight: 600; }
p { margin: 0 0 16px; }
a { color: var(--ink); }
em { font-family: var(--f-serif); font-style: italic; font-weight: 300; letter-spacing: -.02em; }

.k-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 14px;
}
.k-lede {
  font-family: var(--f-serif);
  font-weight: 300;
  font-size: clamp(19px, 1.62vw, 25px);
  line-height: 1.42;
  letter-spacing: -.012em;
  color: var(--ink-2);
}
.k-small { font-size: 15px; line-height: 1.5; color: var(--ink-2); }
.k-hint { font-size: 14px; color: var(--ink-3); margin-top: -6px; }
.k-hand {
  font-family: var(--f-hand);
  font-weight: 600;
  font-size: clamp(19px, 1.7vw, 26px);
  line-height: 1.1;
  color: var(--green);
  transform: rotate(-2deg);
  display: inline-block;
}

.k-eyebrow-rule { display: flex; align-items: center; gap: 14px; }
.k-eyebrow-rule::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.k-hero { margin-bottom: clamp(30px, 4vw, 52px); }
.k-hero h1 { margin-bottom: 18px; }
.k-hero .k-lede { max-width: 46ch; }

.k-endcap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  flex-wrap: wrap;
  background: var(--ink);
  color: var(--cream);
  border-radius: var(--r);
  padding: clamp(26px, 3vw, 42px);
  margin-top: clamp(26px, 3vw, 44px);
}
.k-endcap h2 { margin: 0 0 8px; color: var(--cream); }
.k-endcap .k-small { color: rgba(247, 243, 232, .72); }

/* ---------- Cards & panels ---------- */

.k-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: clamp(20px, 2.4vw, 34px);
  margin-bottom: 18px;
}
.k-card-flat { border-color: var(--line-2); }
.k-panel {
  background: var(--green);
  color: var(--on-green);
  border: 1px solid var(--green);
  border-radius: var(--r);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.k-panel a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.k-panel strong { color: var(--accent); }
.k-panel .k-hand { color: var(--accent); }
.k-divider { height: 1px; background: var(--line); border: 0; margin: 28px 0; }

/* ---------- Steps ---------- */

.k-step {
  display: flex; align-items: baseline; gap: 10px;
  font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 18px;
}
.k-progress {
  height: 3px;
  background: var(--line);
  overflow: hidden;
  margin-bottom: 26px;
}
.k-progress span {
  display: block; height: 100%;
  background: var(--green);
  width: 0%;
  transition: width .35s cubic-bezier(.2, .8, .2, 1);
}

/* ---------- Forms ---------- */

label { display: block; font-weight: 600; font-size: 15px; letter-spacing: -.014em; margin-bottom: 7px; }

input[type="text"], input[type="email"], input[type="number"], textarea, select {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  letter-spacing: -.01em;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: 13px 15px;
  transition: border-color .18s, box-shadow .18s;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(200, 255, 77, .55);
}
.k-field { margin-bottom: 20px; }
.k-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 620px) { .k-field-row { grid-template-columns: 1fr; } }

/* ---------- Buttons ---------- */

.k-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1;
  padding: 15px 26px;
  border-radius: 100px;
  border: 1.5px solid transparent;
  background: var(--green);
  color: var(--on-green);
  cursor: pointer;
  text-decoration: none;
  transition: transform .18s cubic-bezier(.2, .8, .2, 1), background .2s, color .2s, border-color .2s;
}
.k-btn:hover { transform: translateY(-2px); background: var(--green-deep); }
.k-btn:active { transform: translateY(0); }
.k-btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.k-btn-accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.k-btn-accent:hover { background: var(--accent); border-color: var(--ink); color: var(--on-accent); }
.k-btn-ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.k-btn-ghost:hover { background: var(--ink); color: var(--cream); border-color: var(--ink); }
.k-btn-sm { font-size: 14px; padding: 11px 20px; }
.k-btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }

/* ---------- Scale (scorecard / quiz answers) ---------- */

.k-q { padding: 22px 0; border-bottom: 1px solid var(--line-2); }
.k-q:last-child { border-bottom: 0; }
.k-q-text { font-weight: 600; letter-spacing: -.018em; margin-bottom: 4px; }
.k-q-help { font-size: 14px; color: var(--ink-3); margin-bottom: 14px; }

.k-scale { display: flex; gap: 8px; flex-wrap: wrap; }
.k-scale label {
  flex: 1 1 0;
  min-width: 92px;
  margin: 0;
  cursor: pointer;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -.008em;
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 6px;
  background: var(--paper);
  transition: background .15s, border-color .15s, color .15s;
}
.k-scale input { position: absolute; opacity: 0; width: 0; height: 0; }
.k-scale label:hover { border-color: var(--ink); }
.k-scale label.is-on {
  background: var(--accent);
  border-color: var(--ink);
  color: var(--on-accent);
  font-weight: 700;
}

.k-choice { display: grid; gap: 10px; }
.k-choice label {
  margin: 0;
  cursor: pointer;
  font-weight: 500;
  font-size: 16px;
  letter-spacing: -.014em;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 15px 17px;
  background: var(--paper);
  transition: background .15s, border-color .15s;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.k-choice label:hover { border-color: var(--ink); }
.k-choice label.is-on { background: var(--accent); border-color: var(--ink); font-weight: 600; }
.k-choice input { margin-top: 3px; accent-color: var(--green); flex: 0 0 auto; }

/* ---------- Results ---------- */

.k-result { display: none; }
.k-result.is-visible { display: block; }

.k-score-hero {
  text-align: center;
  padding: clamp(30px, 4vw, 46px) 24px;
  background: var(--green);
  color: var(--on-green);
  border: 1px solid var(--green);
  border-radius: var(--r);
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}
.k-score-hero::after {
  content: ""; position: absolute; right: -6%; top: -30%; width: 34%; aspect-ratio: 1;
  border: 1.5px solid rgba(244, 240, 228, .18); border-radius: 50%;
}
.k-score-hero h2 { color: var(--accent); }
.k-score-hero .k-small { color: rgba(244, 240, 228, .72); }
.k-score-num {
  font-size: clamp(64px, 11vw, 104px);
  font-weight: 700;
  letter-spacing: -.055em;
  line-height: .86;
  display: block;
  color: var(--accent);
}
.k-score-den { font-size: .3em; color: rgba(244, 240, 228, .6); font-weight: 600; letter-spacing: -.02em; }
.k-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: 6px 13px;
  border-radius: 100px;
  margin-bottom: 16px;
  background: rgba(244, 240, 228, .12);
  color: var(--on-green);
}
.k-badge-good { background: var(--accent); color: var(--on-accent); }
.k-badge-warn { background: rgba(244, 240, 228, .14); color: var(--on-green); }
.k-badge-bad { background: var(--red); color: #fff; }
.k-badge-neutral { background: var(--accent); color: var(--on-accent); }

.k-bars { display: grid; gap: 18px; }
.k-bar-label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 15px; font-weight: 600; letter-spacing: -.018em; margin-bottom: 7px; gap: 12px;
}
.k-bar-label span:last-child { font-variant-numeric: tabular-nums; color: var(--ink-3); font-weight: 600; }
.k-bar-track { height: 8px; background: var(--line-2); overflow: hidden; }
.k-bar-fill { height: 100%; background: var(--green); }
.k-bar-fill.is-good { background: var(--accent); }
.k-bar-fill.is-warn { background: var(--green); }
.k-bar-fill.is-bad { background: var(--red); }
.k-bar-note { font-size: 13.5px; color: var(--ink-3); margin-top: 6px; }

.k-actions { counter-reset: act; list-style: none; padding: 0; margin: 0; }
.k-actions li {
  counter-increment: act;
  position: relative;
  padding: 17px 0 17px 46px;
  border-top: 1px solid var(--line-2);
}
.k-actions li:first-child { border-top: 0; padding-top: 6px; }
.k-actions li::before {
  content: counter(act);
  position: absolute;
  left: 0; top: 16px;
  width: 28px; height: 28px;
  background: var(--accent);
  border: 1px solid var(--ink);
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.k-actions li:first-child::before { top: 5px; }
.k-actions strong { display: block; margin-bottom: 4px; letter-spacing: -.018em; }
.k-actions .k-ref { font-size: 13px; color: var(--ink-3); }

.k-output {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  border-radius: var(--r);
  padding: 20px 22px;
  margin-bottom: 16px;
  white-space: pre-wrap;
  font-size: 15.5px;
  line-height: 1.6;
}
.k-output h4 {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.k-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  background: transparent;
  color: var(--green);
  border: 1px solid var(--green);
  padding: 5px 11px;
  border-radius: 100px;
  margin: 0 6px 6px 0;
}
.k-tag-gap { background: var(--red); color: #fff; border-color: var(--red); }
.k-tag-ok { background: var(--accent); color: var(--on-accent); border-color: var(--ink); }

/* ---------- Gate ---------- */

.k-gate {
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: var(--r);
  padding: clamp(24px, 3vw, 38px);
  max-width: 540px;
  margin: 0 auto 26px;
  position: relative;
}
.k-gate::before {
  content: "";
  position: absolute; left: -1px; right: -1px; top: -1px; height: 4px;
  background: var(--accent);
}
.k-gate h2 { margin-top: 0; }
.k-gate-note { font-size: 13px; color: var(--ink-3); margin: 16px 0 0; }
.k-consent { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 14px; color: var(--ink-2); }
.k-consent input { margin-top: 3px; accent-color: var(--green); }
.k-locked { display: none; }
.k-msg { font-size: 14px; margin-top: 12px; min-height: 20px; }
.k-msg-error { color: var(--red); font-weight: 600; }
.k-msg-ok { color: var(--green); font-weight: 600; }

/* ---------- Tool grid (hub) ---------- */

.k-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: clamp(10px, 1vw, 16px); }
@media (max-width: 760px) { .k-grid { grid-template-columns: 1fr; } }

.k-tool {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: clamp(22px, 2vw, 32px);
  min-height: 250px;
  text-decoration: none;
  color: var(--ink);
  transition: transform .3s cubic-bezier(.2, .8, .2, 1), border-color .2s;
}
.k-tool:hover { transform: translateY(-4px); border-color: var(--ink); }
.k-tool .k-tool-icon {
  font-family: var(--f-display);
  font-size: clamp(30px, 3vw, 42px);
  font-weight: 700;
  letter-spacing: -.06em;
  line-height: 1;
  color: var(--line-strong);
  margin-bottom: auto;
}
.k-tool:hover .k-tool-icon { color: var(--green); }
.k-tool--green .k-tool-icon { color: rgba(200, 255, 77, .5); }
.k-tool h3 { margin-bottom: 8px; }
.k-tool p { font-size: 15px; line-height: 1.45; color: var(--ink-2); margin: 0 0 16px; }
.k-tool .k-tool-go { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.k-tool.is-locked { opacity: .5; pointer-events: none; }
.k-tool-meta {
  display: block;
  margin-top: 18px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
}
.k-tool--green { background: var(--green); color: var(--on-green); border-color: var(--green); }
.k-tool--green p { color: rgba(244, 240, 228, .72); }
.k-tool--green .k-tool-meta { color: var(--accent); }
.k-tool--green .k-tool-go { color: rgba(244, 240, 228, .6); }

/* ---------- Footer ---------- */

.k-footer {
  border-top: 1px solid var(--line);
  padding: 34px 0 70px;
  font-size: 14px;
  color: var(--ink-3);
  text-align: center;
}
.k-footer a { color: var(--ink-2); border-bottom: 1px solid var(--line); text-decoration: none; }
.k-footer a:hover { color: var(--green); border-color: var(--green); }

/* ---------- Print ---------- */

@media print {
  @page { margin: 16mm; }
  body { background: #fff; font-size: 12pt; }
  .k-topbar, .k-footer, .k-noprint, .k-btn-row, .k-gate, form, .k-progress { display: none !important; }
  .k-card, .k-output { border: 1px solid #ddd; break-inside: avoid; }
  .k-score-hero { background: #fff !important; color: #000 !important; border: 2px solid #000; }
  .k-score-hero .k-score-num, .k-score-hero h2 { color: #000 !important; }
  .k-score-hero::after { display: none; }
  .k-panel { background: #fff !important; color: #000 !important; border: 1px solid #999; }
  .k-panel strong, .k-panel a { color: #000 !important; }
  .k-badge { background: #eee !important; color: #000 !important; }
  .k-actions li::before { background: #eee !important; }
  .k-result { display: block !important; }
  .k-main { padding: 0; }
  a[href]::after { content: ""; }
  .k-print-head { display: block !important; margin-bottom: 18px; }
}
.k-print-head { display: none; }
