* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--font-rounded); color: var(--ink); background: #fff; }

main {
  max-width: 980px; margin: 0 auto;
  padding: var(--space-8) var(--space-4) var(--space-12);
  display: flex; flex-direction: column; gap: var(--space-8);
}
footer { font: 400 12px/18px var(--font-rounded); color: var(--text-muted); border-top: 1px solid #dfe3e6; padding-top: var(--space-4); }

/* ---------- Header ---------- */
.page-head h1 {
  margin: 0 0 8px;
  font: 900 40px/1.02 var(--font-rounded);
  letter-spacing: -0.01em; text-transform: uppercase; color: var(--ink);
}
.page-head p { margin: 0; font: 400 16px/24px var(--font-rounded); color: var(--label-secondary); }

/* ---------- Form ---------- */
form { display: flex; flex-direction: column; gap: 0; border: 1px solid #dfe3e6; }

/* ---------- Steps ---------- */
.step { padding: var(--space-5); border-bottom: 1px solid #dfe3e6; }
.step-head, .details-step > summary {
  display: flex; align-items: center; gap: 12px; margin: 0 0 var(--space-4);
  font: 900 18px/22px var(--font-rounded); letter-spacing: -0.01em; text-transform: uppercase; color: var(--ink);
}
.step-no {
  flex: none; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  background: var(--ink); color: #fff; font: 700 12px/1 var(--font-rounded);
}
.details-step { padding: 0; }
.details-step > summary { padding: var(--space-5); margin: 0; cursor: pointer; list-style: none; }
.details-step > summary::-webkit-details-marker { display: none; }
.details-step > summary em {
  font: 400 13px/18px var(--font-rounded); text-transform: none; letter-spacing: 0; color: var(--text-muted);
}
.details-step > summary::after { content: "+"; margin-left: auto; font: 400 20px/1 var(--font-rounded); color: var(--text-muted); }
.details-step[open] > summary::after { content: "\2013"; }
.details-step .form-grid { padding: 0 var(--space-5) var(--space-5); }

/* ---------- Role tiles ---------- */
.role-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0; }
.role-tile {
  min-height: 120px; margin: -0.5px 0 0 -0.5px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  border: 1px solid #dfe3e6; border-radius: 0; background: #fff; cursor: pointer;
  padding: var(--space-3); color: var(--ink);
  font: 700 13px/16px var(--font-rounded); text-align: center;
}
.role-tile svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.role-tile:hover { background: #eeeff1; }
.role-tile.is-selected { background: var(--ink); border-color: var(--ink); color: #fff; z-index: 1; }
.role-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }

.route-preview {
  margin: var(--space-4) 0 0; padding-left: 20px; position: relative;
  font: 500 14px/20px var(--font-rounded); color: var(--ink); min-height: 20px;
}
.route-preview::before { content: "»"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
.route-preview.is-bad { color: var(--danger); }

.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-4); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.col-span { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font: 700 12px/16px var(--font-rounded); letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.field select, .field input {
  width: 100%; height: 48px; padding: 0 12px;
  border: 1px solid #dfe3e6; border-radius: 0; background: #fff;
  font: 500 15px/20px var(--font-rounded); color: var(--ink);
  appearance: none; -webkit-appearance: none;
}
.field select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px;
}
.field select:focus, .field input:focus { outline: 0; border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.input-unit { position: relative; }
.input-unit span { position: absolute; right: 12px; top: 14px; font: 500 15px/20px var(--font-rounded); color: var(--text-muted); }
.hint { font: 500 12px/16px var(--font-rounded); color: var(--label-secondary); min-height: 16px; }
.hint.is-bad { color: var(--danger); }
.hint.is-good { color: var(--success); }

.clay-segmented { display: flex; gap: 0; }
.clay-segmented .inset-chip {
  flex: 1; border: 1px solid #dfe3e6; border-radius: 0; margin-left: -1px; background: #fff;
  height: 48px; padding: 0 10px; cursor: pointer;
  font: 600 13px/16px var(--font-rounded); color: var(--label-secondary); white-space: nowrap;
}
.clay-segmented .inset-chip:first-child { margin-left: 0; }
.clay-segmented .inset-chip.is-selected { background: var(--ink); border-color: var(--ink); color: #fff; }

.cta-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); padding: var(--space-5); }
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  height: 52px; padding: 0 24px; border: 0; border-radius: 0; cursor: pointer;
  background: var(--accent); color: #fff; text-decoration: none;
  font: 700 15px/20px var(--font-rounded); letter-spacing: .02em;
}
.btn-primary:hover { background: #24353f; }
.btn-primary.is-small { height: 40px; padding: 0 18px; font-size: 13px; }
.link-more {
  border: 0; background: none; padding: 0; cursor: pointer;
  font: 600 14px/20px var(--font-rounded); color: var(--ink);
}
.link-more::before { content: "» "; color: var(--accent); }
.link-more:hover { color: var(--accent); }

/* ---------- Results ---------- */
#results:empty { display: none; }
.panel { display: flex; flex-direction: column; min-width: 0; }

/* Route: one dark slate band, nothing inside it. */
.route-band { background: #24353f; color: #fff; padding: var(--space-6); }
.band-role { font: 600 12px/16px var(--font-rounded); letter-spacing: .06em; text-transform: uppercase; color: #b6c0c6; margin-bottom: 10px; }
.band-title { margin: 0 0 14px; font: 900 24px/1.1 var(--font-rounded); letter-spacing: -0.01em; text-transform: uppercase; }
.band-lines { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.band-lines li { font: 400 14px/20px var(--font-rounded); color: #dfe3e6; padding-left: 20px; position: relative; }
.band-lines li::before { content: "»"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
.band-lines li.is-bad { color: #ffb3a1; }

/* Candidates: horizontal carousel of square tiles. */
.rail-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-4) 0 var(--space-3); }
.rail-count { font: 700 12px/16px var(--font-rounded); letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.rail-arrows { display: none; gap: 0; margin-left: auto; }
@media (min-width: 720px) and (hover: hover) { .rail-arrows { display: flex; } }
.rail-arrow {
  width: 40px; height: 40px; border: 1px solid #dfe3e6; border-radius: 0; margin-left: -1px;
  background: #fff; color: var(--ink); cursor: pointer; font: 400 20px/1 var(--font-rounded);
}
.rail-arrow:first-child { margin-left: 0; }
.rail-arrow:hover { background: var(--ink); color: #fff; border-color: var(--ink); }

.cand-rail {
  display: flex; gap: var(--space-4); overflow-x: auto; scroll-snap-type: x mandatory;
  padding-bottom: var(--space-3); scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.cand {
  flex: 0 0 300px; max-width: 300px; scroll-snap-align: start;
  border: 1px solid #dfe3e6; background: #fff; display: flex; flex-direction: column;
}
.cand-photo { position: relative; aspect-ratio: 4 / 5; background: #eeeff1; overflow: hidden; }
.cand-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.cand-photo .initials { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 900 40px/1 var(--font-rounded); color: var(--text-muted); }
.cand-body { padding: var(--space-4); display: flex; flex-direction: column; gap: 2px; flex: 1; }
.cand-name { font: 900 18px/22px var(--font-rounded); text-transform: uppercase; color: var(--ink); }
.cand-meta { font: 400 13px/18px var(--font-rounded); color: var(--label-secondary); }
.cand-light { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.cand-light .dot { width: 10px; height: 10px; background: var(--light-color); flex: none; }
.cand-light .word { font: 700 12px/16px var(--font-rounded); letter-spacing: .04em; text-transform: uppercase; color: var(--label-secondary); }
.cand-score { margin-left: auto; font: 900 18px/22px var(--font-rounded); color: var(--ink); white-space: nowrap; }
.cand-score small { font: 600 12px/16px var(--font-rounded); color: var(--text-muted); }
.cand-reason { font: 400 14px/20px var(--font-rounded); color: var(--ink); margin-top: 10px; }
.cand-timing { font: 500 13px/18px var(--font-rounded); color: var(--label-secondary); margin-top: 6px; }
.cand .act { margin-top: auto; align-self: flex-start; }

.flags { margin: 10px 0; }
.flags summary { cursor: pointer; list-style: none; font: 600 12px/18px var(--font-rounded); color: var(--text-muted); }
.flags summary::-webkit-details-marker { display: none; }
.flags summary::before { content: "+ "; }
.flags[open] summary::before { content: "\2013 "; }
.flags ul { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.flags li { font: 400 13px/18px var(--font-rounded); color: var(--ink); padding-left: 10px; border-left: 2px solid #dfe3e6; }
.flags li.is-blocker { border-left-color: var(--danger); }
.flags li.is-lever { border-left-color: var(--success); }
.flags li .todo { display: block; color: var(--label-secondary); }

.empty { font: 400 14px/20px var(--font-rounded); color: var(--label-secondary); padding: var(--space-4) 0; }
.error { border: 1px solid var(--danger); color: var(--danger); padding: var(--space-4); font: 500 14px/20px var(--font-rounded); }

/* ---------- Motion ---------- */
.enter { animation: fade-up .36s cubic-bezier(.2,.8,.4,1); }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) {
  .enter { animation: none; }
}

@media (max-width: 640px) {
  main { padding-top: var(--space-6); gap: var(--space-6); }
  .page-head h1 { font-size: 30px; }
  .form-grid { grid-template-columns: 1fr; gap: var(--space-3); }
  .row-3 { grid-template-columns: 1fr; gap: var(--space-3); }
  .step, .details-step > summary, .details-step .form-grid, .cta-wrap { padding: var(--space-4); }
  .details-step .form-grid { padding-top: 0; }
  .details-step > summary { flex-wrap: wrap; }
  .role-tiles { grid-template-columns: repeat(3, 1fr); }
  .role-tile { min-height: 96px; gap: 8px; padding: var(--space-2, 8px); font-size: 12px; line-height: 15px; }
  .role-tile svg { width: 26px; height: 26px; }
  .cand { flex-basis: 260px; max-width: 260px; }
  .btn-primary { width: 100%; }
  .btn-primary.is-small { width: auto; height: 44px; }
  .route-band { padding: var(--space-4); }
  .band-title { font-size: 20px; overflow-wrap: break-word; hyphens: auto; }
  .band-lines li, .cand-reason, .route-preview { overflow-wrap: break-word; }
  .flags summary { display: flex; align-items: center; min-height: 44px; }
  .details-step > summary { min-height: 44px; }
}
@media (max-width: 400px) {
  .role-tiles { grid-template-columns: repeat(2, 1fr); }
}
