/* Client Website Intake — styles. Design authority: ../DESIGN.md ("the well-made work order"). */

:root {
  --paper: #F6F2E9;
  --paper-2: #EEE8DB;
  --card: #FFFDF8;
  --ink: #17191D;
  --ink-2: #5E5A52;
  --line: #D9D2C3;
  --mark: #F7C600;
  --mark-soft: #FBE38A;
  --mark-ink: #3A2E00;
  --ok: #1F7A4D;
  --err: #B42318;
  --err-bg: #FBECEA;
  --radius: 12px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(23, 25, 29, .08);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --rail-w: 280px;
  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 96px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  font-feature-settings: 'tnum' 1;
  caret-color: var(--ink);
  min-height: 100dvh;
}
::selection { background: var(--mark); color: var(--ink); }
:focus-visible { outline: 3px solid var(--mark); outline-offset: 2px; border-radius: 6px; }
* { scrollbar-width: thin; scrollbar-color: var(--ink-2) var(--paper); }
*::-webkit-scrollbar { width: 10px; }
*::-webkit-scrollbar-thumb { background: var(--ink-2); border-radius: 8px; border: 2px solid var(--paper); }
code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .92em; background: var(--paper-2); padding: 2px 6px; border-radius: 6px; }
.muted { color: var(--ink-2); }
[hidden] { display: none !important; }
svg.ico { width: 20px; height: 20px; flex: none; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100dvh; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px 0;
}
.topbar-row { display: flex; align-items: center; gap: 12px; padding-bottom: 10px; }
.topbar-nav { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; min-height: 44px; margin: -6px 0 -6px -8px; padding: 6px 8px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.topbar-nav:active { background: var(--paper-2); }
.topbar-nav .ico { width: 22px; height: 22px; }
.topbar-count { font-weight: 800; font-size: 15px; white-space: nowrap; }
.topbar-title { font-weight: 600; font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved, .rail-saved { font-size: 13px; color: var(--ink-2); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.saved::before, .rail-saved:not(:empty)::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.saved:empty { display: none; }

.bar { height: 4px; background: var(--line); border-radius: 0; overflow: hidden; margin: 0 -16px; }
.bar > span { display: block; height: 100%; width: 100%; background: var(--mark); transform: scaleX(0); transform-origin: left; transition: transform .4s var(--ease); }
.bar-rail { margin: 16px 0 8px; border-radius: 4px; height: 6px; }

/* Below 1024 the rail is a slide-in drawer opened from the top bar; same list, same handlers. */
.rail {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 30; width: min(320px, 86vw);
  display: flex; flex-direction: column; gap: 20px; overflow-y: auto;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom)); background: var(--paper-2); border-right: 1px solid var(--line);
  transform: translateX(-104%); transition: transform .28s var(--ease); visibility: hidden;
  box-shadow: 0 1px 2px rgba(23,25,29,.08), 12px 0 32px -16px rgba(23,25,29,.3);
}
.app.is-nav-open .rail { transform: none; visibility: visible; }
.rail-close { align-self: flex-end; width: 44px; height: 44px; margin: -6px -8px -10px 0; border: 0; border-radius: 10px; background: transparent; color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.rail-close:active { background: rgba(23,25,29,.06); }
.rail-title { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.025em; line-height: 1.1; text-wrap: balance; }
.rail-for { margin: 6px 0 0; font-size: 15px; color: var(--ink-2); }
.rail-for strong { color: var(--ink); font-weight: 700; }
.rail-pct { margin: 0; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.rail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.rail-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); font: inherit; font-size: 16px; font-weight: 500; text-align: left; cursor: pointer; transition: background .15s, color .15s; }
.rail-item:hover { background: rgba(23,25,29,.05); color: var(--ink); }
.rail-item .dot { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; flex: none; background: var(--card); color: var(--ink); transition: background .15s, border-color .15s; }
.rail-item .dot svg { width: 14px; height: 14px; opacity: 0; }
.rail-item.is-done .dot { background: var(--mark); border-color: var(--mark); }
.rail-item.is-done .dot svg { opacity: 1; }
.rail-item.is-active { color: var(--ink); font-weight: 700; background: var(--card); box-shadow: 0 1px 2px rgba(23,25,29,.08); }
.rail-item.is-active .dot { border-color: var(--ink); }
.rail-saved { margin-top: auto; }
.backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(23,25,29,.35); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); animation: fade .2s ease-out both; }
@keyframes fade { from { opacity: 0; } }
body.nav-locked { overflow: hidden; }

.main { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); max-width: 760px; width: 100%; min-width: 0; margin: 0 auto; }

/* ---------- card ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 24px 20px 28px;
  animation: card-in .24s var(--ease) both;
}
.card:focus { outline: none; }
.card.is-leaving { animation: card-out .12s ease-in both; }
@keyframes card-in { from { opacity: 0; transform: translateY(12px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes card-out { to { opacity: 0; filter: blur(3px); } }

.card-step { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.card-title { margin: 0 0 8px; font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; text-wrap: balance; }
.card-intro { margin: 0 0 28px; color: var(--ink-2); font-size: 17px; max-width: 60ch; }
.fine { margin: 24px 0 0; font-size: 14px; color: var(--ink-2); }

/* ---------- fields ---------- */
.fields { display: flex; flex-direction: column; gap: 26px; }
.field { display: flex; flex-direction: column; gap: 8px; scroll-margin-top: 110px; }
.field-label { font-weight: 600; font-size: 17px; line-height: 1.35; }
.field-label .req { color: var(--err); font-weight: 800; margin-left: 2px; }
.field-help { margin: -4px 0 0; font-size: 14px; color: var(--ink-2); line-height: 1.45; }
.field-err { display: none; margin: 0; font-size: 14px; color: var(--err); font-weight: 600; align-items: center; gap: 6px; }
.field.has-error .field-err { display: flex; }
.field.has-error .input, .field.has-error .chip-group { border-color: var(--err); }
.field.has-error .input { box-shadow: 0 0 0 3px var(--err-bg); }

.input {
  width: 100%; min-height: 52px; padding: 13px 14px;
  font: inherit; font-size: 17px; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
.input::placeholder { color: #8E887C; }
.input:hover { border-color: #B9B19F; }
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--mark-soft); }
textarea.input { resize: vertical; min-height: 92px; line-height: 1.45; }
input[type=time].input { min-width: 0; padding-inline: 10px; }

.chip-group { display: flex; flex-wrap: wrap; gap: 10px; border: 1px solid transparent; border-radius: var(--radius); padding: 0; margin: 0; }
.chip-group legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.chip { position: relative; display: inline-flex; }
.chip input { position: absolute; inset: 0; z-index: 1; opacity: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 10px 16px;
  border: 1px solid var(--line); border-radius: 999px; background: #fff;
  font-size: 16px; font-weight: 500; line-height: 1.2; user-select: none;
  transition: border-color .15s, background .15s, transform .12s var(--ease);
}
.chip span::before { content: ''; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--line); flex: none; transition: background .15s, border-color .15s, transform .15s var(--ease); }
.chip input:hover + span { border-color: #B9B19F; }
.chip input:focus-visible + span { outline: 3px solid var(--mark); outline-offset: 2px; }
.chip input:checked + span { border-color: var(--ink); background: var(--card); font-weight: 600; }
.chip input:checked + span::before { background: var(--mark); border-color: var(--ink); transform: scale(1.15); }
.chip input:active + span { transform: scale(.98); }
.chip-other { flex-basis: 100%; }
.chip-other .input { min-height: 48px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 320px; }
.seg .chip span { justify-content: center; width: 100%; border-radius: var(--radius-sm); }

.hours { display: grid; grid-template-columns: 1fr; gap: 8px; }
.hours-row { display: grid; grid-template-columns: 44px 1fr 1fr auto; align-items: center; gap: 8px; }
.hours-day { font-weight: 700; font-size: 15px; }
.hours-row.is-closed .input { opacity: .4; pointer-events: none; }
.hours-closed { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.hours-closed input { width: 20px; height: 20px; accent-color: var(--ink); margin: 0; }

/* ---------- footer ---------- */
.footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.footer-right { display: flex; align-items: center; gap: 14px; }
.footer-hint { font-size: 13px; color: var(--ink-2); display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 20px; border-radius: var(--radius);
  font: inherit; font-size: 16px; font-weight: 700; letter-spacing: 0;
  cursor: pointer; border: 1px solid transparent; text-decoration: none;
  transition: transform .12s var(--ease), background .15s, border-color .15s, opacity .15s;
}
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .5; cursor: default; transform: none; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: #000; }
.btn-primary.is-busy { color: transparent; position: relative; }
.btn-primary.is-busy::after { content: ''; position: absolute; width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid rgba(246,242,233,.35); border-top-color: var(--paper); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-secondary:hover { background: var(--paper-2); }
.btn-ghost { background: transparent; color: var(--ink); padding-inline: 12px; }
.btn-ghost:hover { background: var(--paper-2); }
.btn-ghost[disabled] { opacity: 0; pointer-events: none; }
.actions-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }

/* ---------- review ---------- */
.review { display: flex; flex-direction: column; gap: 8px; }
.review-sec { border-top: 1px solid var(--line); padding: 18px 0 6px; }
.review-sec:first-child { border-top: 0; padding-top: 0; }
.review-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.review-head h3 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.review-edit { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.review-edit:hover { background: var(--paper-2); }
.review-edit svg { width: 16px; height: 16px; }
.review dl { margin: 0; display: grid; grid-template-columns: 1fr; gap: 10px 20px; }
.review dt { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.review dd { margin: 2px 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.review .empty { color: var(--ink-2); font-style: italic; }
.review-count { font-size: 14px; color: var(--ink-2); font-weight: 500; }
.review-missing { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--err-bg); color: var(--err); font-weight: 600; font-size: 15px; margin: 0 0 20px; }
.review-missing svg { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.review-missing button { background: none; border: 0; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 0; }

.card-done { text-align: left; }
.done-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.done-head .card-title { margin: 0; }
.done-mark { width: 40px; height: 40px; border-radius: 50%; background: var(--mark); color: var(--mark-ink); display: grid; place-items: center; flex: none; }
.done-mark svg { width: 24px; height: 24px; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 20; margin: 0 auto; max-width: 560px; padding: 14px 16px; border-radius: var(--radius); background: var(--ink); color: var(--paper); font-size: 15px; font-weight: 600; box-shadow: var(--shadow); display: flex; gap: 10px; align-items: center; animation: card-in .24s var(--ease) both; }
.toast.is-error { background: var(--err); }
.toast svg { width: 20px; height: 20px; flex: none; }

/* ---------- rail (desktop) ---------- */
@media (min-width: 1024px) {
  body { font-size: 18px; }
  .app { grid-template-columns: var(--rail-w) minmax(0, 1fr); max-width: 1120px; margin: 0 auto; }
  .topbar { display: none; }
  .rail {
    position: sticky; top: 0; align-self: start; height: 100dvh; width: auto; z-index: auto;
    transform: none; visibility: visible; transition: none; box-shadow: none; gap: 24px;
    padding: 40px 28px 32px 32px;
  }
  .rail-close, .backdrop, .topbar-nav .ico { display: none; }
  .rail-title { font-size: 26px; }
  .rail-item { min-height: 44px; font-size: 15px; }
  .main { padding: 40px 48px 120px; max-width: none; margin: 0; }
  .card { padding: 40px 44px 44px; max-width: 760px; }
  .card-title { font-size: 40px; }
  .card-step { display: none; }
  .fields { gap: 30px; }
  .footer { position: sticky; bottom: 0; margin: 8px 0 0; max-width: 760px; border-top: 0; backdrop-filter: none; -webkit-backdrop-filter: none; background: linear-gradient(to top, var(--paper) 72%, transparent); padding: 28px 0 24px; }
  .footer-hint { display: inline; }
  .review dl { grid-template-columns: 1fr 1fr; }
  .hours-row { grid-template-columns: 56px 160px 160px auto; }
  .hours-day { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .card.is-leaving, .toast, .backdrop { animation: none; }
  .rail { transition: none; }
  .bar > span, .btn, .chip span { transition: none; }
}
