/* ─────────────────────────────────────────────────────────────────────────
   noKhaos discovery — styled on the Kronos / noKhaos design system
   Warm paper, one rust accent. Source Serif 4 headings, Source Sans 3 body.
   ───────────────────────────────────────────────────────────────────────── */
@import url("https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,400..700;1,8..60,400..600&family=Source+Sans+3:ital,wght@0,400..700;1,400..600&display=swap");


:root {
  --radius: 0.625rem;
  --brand: #C96442;
  --brand-fg: #ffffff;
  --sans: "Source Sans 3", "Helvetica Neue", sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  --mono: "Source Sans 3", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --rail: 288px;

  --bg: #FAFAF7; --fg: #0A0A0A; --card: #FFFFFF; --popover: #FFFFFF; --muted: #F4F2EC; --muted-fg: rgba(10,10,10,.62); --faint-fg: rgba(10,10,10,.45); --border: rgba(10,10,10,.10); --border-strong: rgba(10,10,10,.18); --input: rgba(10,10,10,.16); --sidebar: #FDFCF9; --primary: #0A0A0A; --primary-fg: #FAFAF7; --grid: rgba(15,23,42,.06); --beam: rgba(15,23,42,.06); --shadow: rgba(0,0,0,.45); --ok: #4c8a1c; --err: #c0341d;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--sans); font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased; min-height: 100dvh; }
[hidden] { display: none !important; }
::selection { background: var(--brand); color: #fff; }

/* ─── Backdrop: faded 44px grid + one slow hairline beam (Kronos §4) ──── */
.backdrop { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.backdrop::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 44px 44px; -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 40%, #000 30%, transparent 100%); mask-image: radial-gradient(ellipse 90% 70% at 50% 40%, #000 30%, transparent 100%); }
.backdrop::after { content: ""; position: absolute; top: -20%; bottom: -20%; width: 1px; left: -10%; background: linear-gradient(to bottom, transparent, var(--beam) 40%, var(--beam) 60%, transparent); transform: rotate(18deg); animation: beam 92s linear infinite; }
@keyframes beam { to { left: 110%; } }
@media (prefers-reduced-motion: reduce) { .backdrop::after { animation: none; } }

/* ─── Type helpers ────────────────────────────────────────────────────── */
.mono { font-family: var(--sans); font-size: 13px; font-weight: 600; letter-spacing: .01em; }
.muted { color: var(--muted-fg); }
.nowrap { white-space: nowrap; }
em { font-style: italic; font-weight: 500; }

.wordmark { display: inline-flex; align-items: center; gap: 9px; color: var(--fg); font-size: 15px; font-weight: 700; letter-spacing: -.01em; text-decoration: none; }
.wordmark img { width: 22px; height: 22px; border-radius: 6px; display: block; }
.wordmark .by { color: var(--muted-fg); font-weight: 400; }

/* ─── Reveal ──────────────────────────────────────────────────────────── */
.reveal { opacity: 0; transform: translateY(12px); animation: rise .7s var(--ease) forwards; animation-delay: calc(var(--d, 0) * 80ms + 60ms); }
@keyframes rise { to { opacity: 1; transform: none; } }

/* ─── Buttons (Kronos button physics) ─────────────────────────────────── */
.btn { font: inherit; font-weight: 600; font-size: 14px; border: 1px solid var(--border-strong); background: var(--card); color: var(--fg); padding: 10px 18px; border-radius: 8px; cursor: pointer; transform: translateZ(0); transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), filter 180ms var(--ease), background-color 180ms var(--ease), color 180ms var(--ease), border-color 180ms var(--ease); }
.btn:not(:disabled):hover { transform: translateY(-1px); filter: saturate(1.06) brightness(1.04); box-shadow: 0 10px 24px -16px var(--shadow); }
.btn:not(:disabled):active { transform: translateY(0) scale(.98); transition-duration: 90ms; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.btn--brand { background: var(--brand); color: var(--brand-fg); border-color: var(--brand); }
.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--muted); }
.btn--text { border: 0; background: transparent; color: var(--muted-fg); font-weight: 500; padding: 8px 6px; }
.btn--text:hover { color: var(--fg); box-shadow: none !important; }
.btn--lg { font-size: 15px; padding: 13px 24px; }
.btn--small { font-size: 12.5px; padding: 6px 12px; }
.btn .arrow { display: inline-block; transition: transform .2s var(--ease); margin-left: 2px; }
.btn:hover .arrow { transform: translateX(3px); }

/* ─── Welcome ─────────────────────────────────────────────────────────── */
.welcome { position: relative; z-index: 1; max-width: 1080px; margin: 0 auto; padding: 24px 24px 56px; min-height: 100dvh; display: flex; flex-direction: column; }
.welcome__top { display: flex; justify-content: space-between; align-items: center; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.welcome__top .right { display: flex; align-items: center; gap: 12px; }
.welcome__hero { padding: clamp(48px, 10vh, 120px) 0 40px; max-width: 860px; }
.eyebrow { color: var(--brand); }
h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(36px, 5vw, 62px); line-height: 1.08; letter-spacing: -.015em; margin: 12px 0 22px; }
h1 em { color: var(--brand); font-style: italic; font-weight: 500; }
.lede { font-size: clamp(17px, 1.4vw, 20px); line-height: 1.55; color: var(--muted-fg); max-width: 720px; margin: 0; }

.welcome__grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 8px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px 20px; }
.card__k { display: block; color: var(--brand); margin-bottom: 8px; }
.card p { margin: 0; font-size: 14.5px; line-height: 1.55; color: var(--muted-fg); }
.card strong, .card em { color: var(--fg); }

.welcome__cta { display: flex; align-items: center; gap: 20px; padding: 40px 0 0; flex-wrap: wrap; }
.welcome__foot { margin-top: auto; padding-top: 56px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ─── Survey layout ───────────────────────────────────────────────────── */
.survey { position: relative; z-index: 1; display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100dvh; }
.rail { position: sticky; top: 0; height: 100dvh; border-right: 1px solid var(--border); padding: 22px 16px; display: flex; flex-direction: column; background: var(--sidebar); }
.rail__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 18px; padding: 0 6px; }
.progress { height: 3px; background: var(--muted); border-radius: 3px; margin: 0 6px 18px; overflow: hidden; }
.progress__bar { height: 100%; width: 0; background: var(--brand); transition: width .5s var(--ease); }
.rail__nav { display: flex; flex-direction: column; gap: 2px; overflow: auto; flex: 1; }
.rail__nav a { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--muted-fg); text-decoration: none; font-size: 13.5px; font-weight: 500; transition: background .15s, color .15s; }
.rail__nav a:hover { background: var(--muted); color: var(--fg); }
.rail__nav a.is-active { background: var(--muted); color: var(--fg); box-shadow: inset 2px 0 0 var(--brand); }
.rail__nav a .n { font-family: var(--serif); font-size: 13px; color: var(--faint-fg); }
.rail__nav a.is-active .n { color: var(--brand); }
.rail__nav a .st { font-size: 12px; color: var(--faint-fg); }
.rail__nav a.is-done .st { color: var(--ok); }
.rail__foot { padding: 14px 6px 0; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rail-toggle { display: none; }

.stage { padding: 52px clamp(24px, 6vw, 88px) 140px; max-width: 880px; }
.section-head { margin-bottom: 34px; }
.section-head .mono { color: var(--brand); }
.section-head h2 { font-family: var(--serif); font-weight: 500; font-size: clamp(28px, 3.4vw, 40px); line-height: 1.1; letter-spacing: -.01em; margin: 8px 0 12px; }
.section-head .blurb { color: var(--muted-fg); font-size: 16px; max-width: 620px; margin: 0; }
.tag { display: inline-block; font-size: 12.5px; font-weight: 600; border: 1px solid var(--border-strong); color: var(--muted-fg); background: var(--muted); padding: 4px 9px; border-radius: 999px; margin-top: 14px; }

.skipped-note { padding: 20px; border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--muted-fg); display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }

/* ─── Questions ───────────────────────────────────────────────────────── */
.q { padding: 24px 0 28px; border-top: 1px solid var(--border); opacity: 0; transform: translateY(8px); animation: rise .5s var(--ease) forwards; animation-delay: calc(var(--i, 0) * 40ms); }
.q__label { display: block; font-family: var(--serif); font-size: 20px; font-weight: 500; line-height: 1.3; margin-bottom: 6px; }
.q__label .req { color: var(--brand); margin-left: 4px; }
.q__hint { color: var(--muted-fg); font-size: 13.5px; margin: 0 0 14px; }
.q.is-invalid .q__label { color: var(--err); }
.q__err { color: var(--err); font-size: 12.5px; margin-top: 8px; }

input[type="text"], input[type="email"], input[type="number"], textarea, select {
  font: inherit; font-size: 14.5px; width: 100%; color: var(--fg); background: var(--card);
  border: 1px solid var(--input); border-radius: 8px; padding: 10px 12px; outline: none;
  transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(201, 100, 66, .25); }
input::placeholder, textarea::placeholder { color: var(--faint-fg); }
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.number-wrap { display: flex; align-items: center; gap: 10px; max-width: 260px; }
.number-wrap .unit { color: var(--muted-fg); font-size: 13px; white-space: nowrap; }
.select-wrap { position: relative; max-width: 420px; }
.select-wrap::after { content: "⌄"; position: absolute; right: 12px; top: 7px; color: var(--muted-fg); pointer-events: none; font-size: 16px; }
select { padding-right: 32px; cursor: pointer; }
select option { color: var(--fg); background: var(--popover); }

.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border-strong); border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 14px; font-weight: 500; background: var(--card); color: var(--muted-fg); transition: all .15s var(--ease); user-select: none; }
.chip:hover { border-color: var(--fg); color: var(--fg); transform: translateY(-1px); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip.is-on { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.chip.is-on::before { content: "✓"; font-size: 11px; color: var(--brand); }
.other-wrap { margin-top: 10px; max-width: 420px; }

.scale { display: grid; grid-template-columns: repeat(var(--n, 5), 1fr); gap: 6px; max-width: 460px; }
.scale button { font: inherit; font-size: 14px; border: 1px solid var(--border-strong); background: var(--card); border-radius: 8px; padding: 11px 0; cursor: pointer; transition: all .15s var(--ease); color: var(--muted-fg); }
.scale button:hover { border-color: var(--fg); color: var(--fg); transform: translateY(-1px); }
.scale button.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.scale-labels { display: flex; justify-content: space-between; max-width: 460px; margin-top: 6px; color: var(--faint-fg); font-size: 12px; }

.rep { display: flex; flex-direction: column; gap: 10px; }
.rep__row { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; background: var(--card); display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 18px; position: relative; animation: rise .35s var(--ease); }
.rep__row input, .rep__row textarea, .rep__row select, .stg__body input, .stg__body textarea, .stg__body select, .td input, .td textarea, .td select { background: var(--bg); }
.f label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted-fg); margin-bottom: 4px; }
.f--wide { grid-column: 1 / -1; }
.rep__row textarea { min-height: 72px; }
.rep__row .scale button, .td .scale button { padding: 8px 0; font-size: 12px; }
.rep__del { position: absolute; top: 8px; right: 10px; border: 0; background: none; color: var(--faint-fg); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px 6px; }
.rep__del:hover { color: var(--err); }
.rep__add { align-self: flex-start; }

.stages { display: flex; flex-direction: column; gap: 8px; }
.stg { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); overflow: hidden; transition: border-color .15s; }
.stg:hover { border-color: var(--border-strong); }
.stg__head { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 12px; padding: 13px 16px; cursor: pointer; user-select: none; }
.stg__n { font-family: var(--serif); font-size: 14px; color: var(--brand); }
.stg__t { font-family: var(--serif); font-size: 17px; font-weight: 500; }
.stg__h { color: var(--muted-fg); font-size: 12.5px; display: block; }
.stg__state { font-size: 12px; color: var(--faint-fg); }
.stg.is-filled .stg__state { color: var(--ok); }
.stg__body { display: none; padding: 6px 16px 18px; border-top: 1px solid var(--border); }
.stg.is-open .stg__body { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 18px; }
.stg.is-open { border-color: var(--border-strong); }
.stg__body .f label { margin-top: 10px; }

.tg__cat { margin-bottom: 16px; }
.tg__cat h4 { font-size: 13px; color: var(--muted-fg); font-weight: 600; margin: 0 0 8px; }
.tg__notlisted { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 14px 16px 16px; margin: 4px 0 26px; }
.tg__note { margin: 0 0 12px; font-size: 13.5px; }
.tg__custom { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 10px 14px; align-items: end; max-width: 620px; }
.tg__custom .f--full, .tg__custom > .f:nth-child(3) { grid-column: 1 / -1; }
.tg__custom .select-wrap { max-width: none; }
.tg__custom .btn { height: 41px; }
.chip--custom { padding-right: 6px; }
.chip__x { border: 0; background: transparent; color: inherit; opacity: .6; font-size: 15px; line-height: 1; padding: 0 4px; cursor: pointer; }
.chip__x:hover { opacity: 1; color: var(--brand); }
.td__cat { margin-left: 8px; font-family: var(--sans); font-size: 12px; font-weight: 500; color: var(--faint-fg); }
.tg__details { display: flex; flex-direction: column; gap: 10px; }
.tg__details h4 { font-family: var(--serif); font-size: 19px; font-weight: 500; margin: 18px 0 4px; }
.tg__details .empty { color: var(--muted-fg); font-size: 14px; }
.td { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); padding: 14px 16px 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 18px; animation: rise .35s var(--ease); }
.td__name { grid-column: 1 / -1; font-family: var(--serif); font-size: 16px; font-weight: 500; display: flex; justify-content: space-between; align-items: center; }
.td__name .mono { color: var(--ok); }

/* ─── Bottom bar ──────────────────────────────────────────────────────── */
.bar { position: fixed; bottom: 0; left: var(--rail); right: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px clamp(24px, 6vw, 88px); background: linear-gradient(to top, var(--bg) 65%, transparent); z-index: 5; }
.bar__mid { flex: 1; text-align: center; }

/* ─── Review ──────────────────────────────────────────────────────────── */
.review { display: flex; flex-direction: column; gap: 8px; }
.review__row { display: grid; grid-template-columns: 30px 1fr auto auto auto; align-items: center; gap: 12px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.review__row .t { font-family: var(--serif); font-size: 16px; font-weight: 500; }
.review__row .st { font-size: 12px; color: var(--faint-fg); }
.review__row.ok .st { color: var(--ok); }
.review__row.warn .st { color: var(--brand); }
.submit-wrap { margin-top: 30px; padding: 24px; border: 1px solid var(--border-strong); background: var(--card); border-radius: var(--radius); display: flex; flex-direction: column; gap: 14px; }
.submit-wrap p { margin: 0; color: var(--muted-fg); }
.submit-wrap .row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }

.toast { position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 20; animation: rise .3s var(--ease); font-size: 14px; }
.toast.err { background: var(--err); color: #fff; }

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1000px) { .welcome__grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 860px) {
  :root { --rail: 0px; }
  .survey { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0; z-index: 30; height: 100dvh; transform: translateX(-100%); transition: transform .3s var(--ease); width: min(320px, 86vw); box-shadow: 30px 0 60px -30px rgba(0,0,0,.6); }
  .rail.is-open { transform: none; }
  .rail-toggle { display: inline-flex; align-items: center; gap: 8px; position: fixed; top: 12px; left: 14px; z-index: 25; border: 1px solid var(--border-strong); background: var(--card); color: var(--fg); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
  .stage { padding: 72px 16px 150px; }
  .bar { padding: 12px 16px; left: 0; }
  .bar .btn { padding: 10px 14px; font-size: 13px; }
}
@media (max-width: 600px) {
  .welcome { padding: 18px 16px 40px; }
  .welcome__grid { grid-template-columns: 1fr; }
  .rep__row, .stg.is-open .stg__body, .td, .tg__custom { grid-template-columns: 1fr; }
  .stg__head { grid-template-columns: 26px 1fr; }
  .stg__state { display: none; }
  .review__row { grid-template-columns: 26px 1fr auto; }
  .review__row .st.count { display: none; }
}
@media (prefers-reduced-motion: reduce) { .reveal, .q { animation: none; opacity: 1; transform: none; } }
