/* Cost check (/cost-check/, vault DECISIONS D-60). Built from dev option D, "Steps + receipts" (_dev/cost/d.css).
   B's steps on the left, a live receipt on the right, a short two-receipt
   answer. Loads after /assets/style.css. Every color routes through the
   --r-cost-* roles below; components never name a palette token directly.
   Light end of the palette: dark is for type, not blocks. Orange is the
   hero's marker swipe and the answer heading's bar only. */
.cost-d {
  --r-cost-ground:     var(--stone);
  --r-cost-card:       var(--paper);
  --r-cost-rule:       var(--rule);
  --r-cost-text:       var(--ink);
  --r-cost-muted:      var(--ink-soft);
  --r-cost-accent:     var(--teal);
  --r-cost-accent-ink: var(--paper);
  --r-cost-strong:     var(--teal-deep);
  --r-cost-step-done:  var(--teal-soft);
  --r-cost-step-todo:  var(--stone-2);
  --r-cost-field:      var(--teal-wash);
  --r-cost-focus:      var(--teal);
  --r-cost-on:         var(--teal-wash);
  --r-cost-on-rule:    var(--teal);
  --r-cost-keeps:      var(--stone);
  --r-cost-paper:      var(--paper);
  --r-cost-today-top:  var(--ink-soft);
  --r-cost-grr-top:    var(--teal);
  --r-cost-handled:    var(--teal-deep);
  --r-cost-tick:       var(--teal);
  --r-cost-flagged:    var(--teal-wash);
  --r-cost-mark:       var(--teal);
  --r-cost-mark-ink:   var(--paper);
  --r-cost-watch:      var(--paper);
  --r-cost-watch-rule: var(--teal-light);
  --r-cost-link:       var(--teal);
  --r-cost-error:      #9B2C1B;          /* matches .form-error in style.css */
  background: var(--r-cost-ground);
}

/* ---------- hero: modest; the tool is the page ---------- */
.dd-hero { padding: clamp(2.4rem, 5vw, 3.4rem) 0 1.4rem; }
.dd-hero h1 { font-size: clamp(1.9rem, 3.4vw, 2.6rem); line-height: 1.14; margin-bottom: .5em; }
.dd-hero .lede { font-size: 1.1rem; line-height: 1.5; margin-bottom: .7rem; max-width: 42rem; }
.dd-private { font-size: .9rem; color: var(--r-cost-muted); margin: 0; }

/* ---------- tool ---------- */
.dd-tool { padding: 0 0 clamp(3rem, 6vw, 4.5rem); }

.dd-progress { max-width: calc(100% - 22.5rem - clamp(1.75rem, 3vw, 2.75rem)); }
@media (max-width: 900px) { .dd-progress { max-width: none; } }
.dd-progress ol { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; gap: .5rem; }
.dd-progress li { flex: 1 1 0; min-width: 0; }
.dd-progress button {
  width: 100%; display: flex; align-items: center; gap: .55rem; text-align: left;
  font: inherit; font-size: .9rem; font-weight: 600; color: var(--r-cost-muted);
  background: none; border: 0; border-top: 3px solid var(--r-cost-step-todo);
  padding: .65rem 0 .2rem; cursor: pointer;
}
.dd-progress button:disabled { cursor: default; }
.dd-progress button:not(:disabled):hover .dd-step-name { text-decoration: underline; text-underline-offset: 3px; }
.dd-progress .is-done button { border-top-color: var(--r-cost-step-done); color: var(--r-cost-text); }
.dd-progress .is-current button { border-top-color: var(--r-cost-accent); color: var(--r-cost-text); }
.dd-dot {
  flex: none; width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center;
  font-size: .8rem; font-weight: 700; background: var(--r-cost-step-todo); color: var(--r-cost-muted);
}
.dd-progress .is-done .dd-dot { background: var(--r-cost-step-done); color: var(--r-cost-strong); }
.dd-progress .is-current .dd-dot { background: var(--r-cost-accent); color: var(--r-cost-accent-ink); }
.dd-step-name { min-width: 0; }

/* asking: steps + live receipt */
.dd-ask { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 22.5rem); gap: clamp(1.75rem, 3vw, 2.75rem); align-items: start; }
.dd-ask[hidden] { display: none; }

.dd-card {
  background: var(--r-cost-card); border: 1px solid var(--r-cost-rule); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: clamp(1.4rem, 4vw, 2.3rem); min-width: 0;
}
.dd-panel[hidden] { display: none; }
.dd-step-of { font-size: .74rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--r-cost-accent); margin: 0 0 .5rem; }
.dd-panel h2 { font-size: clamp(1.55rem, 2.6vw, 1.95rem); margin: 0 0 .5rem; }
.dd-panel h2:focus, .dd-answer h2:focus { outline: none; }   /* focus lands here on step change; not a control */
.dd-intro { color: var(--r-cost-muted); margin-bottom: 1.6rem; }

@media (prefers-reduced-motion: no-preference) {
  .dd-panel.is-in, .dd-answer.is-in { animation: dd-in .28s ease-out both; }
  @keyframes dd-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

/* questions */
.dd-q { border: 0; padding: 0; margin: 0 0 1.6rem; min-width: 0; }
.dd-q legend, .dd-hours > label {
  display: block; padding: 0; font-size: 1.02rem; font-weight: 650; color: var(--r-cost-text);
  margin-bottom: .6rem; line-height: 1.4;
}
.dd-help { font-size: .9rem; color: var(--r-cost-muted); margin: -.3rem 0 .6rem; line-height: 1.5; }
.dd-note { font-size: .85rem; color: var(--r-cost-muted); margin: -.2rem 0 .6rem; line-height: 1.5;
  padding-left: .75rem; border-left: 2px solid var(--r-cost-rule); }
.dd-error { color: var(--r-cost-error); font-size: .9rem; font-weight: 600; margin: .6rem 0 0; }
.dd-error[hidden] { display: none; }
.dd-q[aria-invalid="true"] .dd-choice { border-color: var(--r-cost-error); }

/* platform choices */
.dd-platforms { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.dd-choice {
  display: flex; gap: .7rem; align-items: flex-start; padding: .8rem .95rem; cursor: pointer;
  border: 1px solid var(--r-cost-rule); border-radius: 12px; background: var(--r-cost-card);
  transition: border-color .15s ease, background .15s ease;
}
.dd-choice:hover { border-color: var(--r-cost-on-rule); }
.dd-choice:has(input:checked) { border-color: var(--r-cost-on-rule); background: var(--r-cost-on); box-shadow: inset 0 0 0 1px var(--r-cost-on-rule); }
.dd-choice:has(input:focus-visible), .dd-pill:has(input:focus-visible) { outline: 2px solid var(--r-cost-focus); outline-offset: 2px; }
.dd-choice input, .dd-pill input { accent-color: var(--r-cost-accent); width: 1.05rem; height: 1.05rem; margin: .2rem 0 0; flex: none; }
.dd-choice-text { display: flex; flex-direction: column; min-width: 0; }
.dd-choice-name { font-weight: 600; line-height: 1.35; }
.dd-choice-hint { font-size: .84rem; color: var(--r-cost-muted); line-height: 1.4; margin-top: .15rem; }

/* pill choices */
.dd-pills { display: flex; flex-wrap: wrap; gap: .5rem; }
.dd-pill {
  display: inline-flex; align-items: center; gap: .5rem; padding: .5rem .9rem; cursor: pointer;
  border: 1px solid var(--r-cost-rule); border-radius: 999px; background: var(--r-cost-card);
  font-size: .95rem; font-weight: 500; line-height: 1.3;
}
.dd-pill input { margin: 0; }
.dd-pill:hover { border-color: var(--r-cost-on-rule); }
.dd-pill:has(input:checked) { border-color: var(--r-cost-on-rule); background: var(--r-cost-on); }

/* line items */
.dd-items > div { display: grid; }
.dd-item { padding: 1.1rem 0; border-top: 1px solid var(--r-cost-rule); }
.dd-item:first-child { border-top: 0; padding-top: .2rem; }
.dd-item-label { display: block; font-weight: 650; margin-bottom: .35rem; }
.dd-select, .dd-money input, .dd-hours input {
  font: inherit; font-size: 1rem; color: var(--r-cost-text); background: var(--r-cost-field);
  border: 1px solid var(--r-cost-rule); border-radius: 10px; padding: .65rem .85rem;
}
.dd-select { width: 100%; max-width: 100%; appearance: none; padding-right: 2.4rem; text-overflow: ellipsis;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 1.15rem) 55%, calc(100% - .85rem) 55%;
  background-size: .3rem .3rem; background-repeat: no-repeat; cursor: pointer; }
.dd-select:focus, .dd-money input:focus, .dd-hours input:focus {
  outline: 2px solid var(--r-cost-focus); outline-offset: 1px; border-color: var(--r-cost-focus); background-color: var(--r-cost-card);
}
.dd-amount { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .6rem; }
.dd-amount[hidden] { display: none; }
.dd-amount--sub { margin-top: .6rem; }
.dd-amount-label { font-size: .88rem; font-weight: 600; color: var(--r-cost-muted); }
.dd-money { position: relative; display: inline-flex; align-items: center; }
.dd-pre { position: absolute; left: .85rem; color: var(--r-cost-muted); pointer-events: none; }
.dd-money input { width: 9rem; padding-left: 1.6rem; }
.dd-hours input { width: 6rem; }
.dd-unit { font-size: .92rem; color: var(--r-cost-muted); }

/* keeps */
.dd-keeps { margin-top: .4rem; padding: 1.1rem 1.2rem; background: var(--r-cost-keeps); border-radius: 12px; }
.dd-keeps h3 { font-size: 1.05rem; margin: 0 0 .3rem; }
.dd-keeps-lede { font-size: .9rem; color: var(--r-cost-muted); margin-bottom: .75rem; line-height: 1.5; }
.dd-keeps ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; font-size: .92rem; line-height: 1.5; }
.dd-keeps li { padding-left: 1rem; position: relative; }
.dd-keeps li::before { content: ""; position: absolute; left: 0; top: .62em; width: .4rem; height: .4rem; border-radius: 50%; background: var(--r-cost-step-done); }
.dd-keeps li strong { font-weight: 650; }
.dd-keeps li span { color: var(--r-cost-muted); }

/* step nav */
.dd-nav { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap;
  margin-top: 1.8rem; padding-top: 1.4rem; border-top: 1px solid var(--r-cost-rule); }
.cost-d .btn:focus-visible { outline: 2px solid var(--r-cost-focus); outline-offset: 3px; }
.dd-progress button:focus-visible, .dd-edit:focus-visible, .dd-bar:focus-visible { outline: 2px solid var(--r-cost-focus); outline-offset: 3px; border-radius: 4px; }

/* ---------- receipts (C's style: hairline rules, tabular figures, a paper card) ---------- */
.dd-live { position: sticky; top: 96px; min-width: 0; }
.dd-bar { display: none; }

.dd-rcpt {
  background: var(--r-cost-paper); border: 1px solid var(--r-cost-rule); border-radius: 12px;
  border-top: 3px solid var(--r-cost-today-top); box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem 1.15rem; font-variant-numeric: tabular-nums; min-width: 0;
}
.dd-rcpt--grr { border-top-color: var(--r-cost-grr-top); }
.dd-rcpt-head { text-align: center; padding-bottom: .65rem; margin-bottom: .15rem; border-bottom: 1px solid var(--r-cost-rule); }
.dd-rcpt-head h3 { font-size: 1rem; margin: 0 0 .1rem; letter-spacing: -.01em; }
.dd-rcpt-meta { font-size: .78rem; color: var(--r-cost-muted); margin: 0; letter-spacing: .02em; }
.dd-rcpt h4 { font-size: .7rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
  color: var(--r-cost-muted); margin: .85rem 0 .1rem; }

.dd-lines { list-style: none; margin: 0; padding: 0; }
.dd-lines li {
  display: flex; justify-content: space-between; align-items: baseline; gap: .75rem;
  padding: .42rem 0; border-bottom: 1px dashed var(--r-cost-rule); font-size: .88rem; line-height: 1.35;
}
.dd-lines li:last-child { border-bottom: 0; }
.dd-l-name { min-width: 0; font-weight: 550; }
.dd-l-detail { display: block; font-weight: 400; font-size: .78rem; color: var(--r-cost-muted); margin-top: .08rem; line-height: 1.4; }
.dd-l-amt { flex: none; text-align: right; font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; gap: .35rem; }
.dd-lines li.is-zero .dd-l-amt { color: var(--r-cost-muted); font-weight: 400; }
.dd-l-inc { color: var(--r-cost-handled); font-weight: 600; display: inline-flex; align-items: center; gap: .3rem; }
.dd-l-inc::before {
  content: ""; width: .7em; height: .38em; border-left: 2px solid var(--r-cost-tick); border-bottom: 2px solid var(--r-cost-tick);
  transform: rotate(-45deg) translateY(-.12em); flex: none;
}
.dd-l-time { font-weight: 600; color: var(--r-cost-text); }
/* "No longer needed": quiet, not a tick. These are lines that drop off the bill, not services. */
.dd-l-gone { color: var(--r-cost-muted); font-weight: 600; font-size: .82rem; }
.dd-rcpt-head + h4 { margin-top: .7rem; }
.dd-empty { color: var(--r-cost-muted); font-size: .84rem !important; justify-content: center !important; text-align: center; padding: 1rem 0 !important; }
.dd-lines--time li { border-top: 1px dashed var(--r-cost-rule); }
.dd-lines li.is-flagged { background: var(--r-cost-flagged); margin: 0 -.5rem; padding-inline: .5rem; border-radius: 6px; }

/* Numbered badges tie an answer on the left receipt to the line that handles it. */
.dd-mark {
  display: inline-grid; place-items: center; flex: none; width: 1.3rem; height: 1.3rem; border-radius: 50%;
  background: var(--r-cost-mark); color: var(--r-cost-mark-ink); font-size: .72rem; font-weight: 700; line-height: 1;
  font-style: normal;
}
.dd-l-amt .dd-mark + .dd-mark { margin-left: -.15rem; }

.dd-total {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: .1rem .75rem;
  margin-top: .8rem; padding-top: .65rem; border-top: 3px double var(--r-cost-rule);
}
.dd-total-label { font-size: .9rem; font-weight: 650; line-height: 1.3; }
.dd-total-amt { font-size: 1.3rem; font-weight: 750; letter-spacing: -.02em; color: var(--r-cost-text); white-space: nowrap; text-align: right; }
.dd-total-amt small { font-size: .78rem; font-weight: 500; color: var(--r-cost-muted); letter-spacing: 0; }
.dd-total-amt--words { font-size: 1.05rem; }
.dd-total-sub { grid-column: 1 / -1; text-align: right; font-size: .8rem; color: var(--r-cost-muted); }

/* ---------- the answer ---------- */
.dd-answer { padding: 0; }                    /* not a page section: undo style.css section padding */
.dd-answer[hidden] { display: none; }
.dd-answer-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem 1.5rem; flex-wrap: wrap; margin: .6rem 0 1rem; }
.dd-answer .d-chapter-head { font-size: clamp(1.45rem, 2.4vw, 1.85rem); margin: 0; }
.dd-edit { font: inherit; font-size: .92rem; font-weight: 650; color: var(--r-cost-link); background: none; border: 0; padding: 0;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.dd-receipts .dd-rcpt { padding-block: 1.1rem 1.15rem; }   /* receipts are <section>s too */
/* Desktop: the next steps sit under the shorter receipt, so the answer stays about one screen tall. */
.dd-receipts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "today grr" "after grr";
  grid-template-rows: auto 1fr; gap: 1.25rem; align-items: start; }
.dd-rcpt--today { grid-area: today; }
.dd-rcpt--grr { grid-area: grr; }
.dd-after { grid-area: after; min-width: 0; }
.dd-keeps-line { font-size: .92rem; color: var(--r-cost-muted); margin: .2rem 0 0; }
.dd-watch { margin-top: .8rem; padding: .7rem 1rem; background: var(--r-cost-watch); border: 1px solid var(--r-cost-watch-rule);
  border-radius: 10px; }
.dd-watch[hidden] { display: none; }
.dd-watch p { margin: 0; font-size: .92rem; line-height: 1.5; }
.dd-watch p + p { margin-top: .4rem; }
.dd-watch .dd-mark { vertical-align: .05em; margin-right: .15rem; }
.dd-watch-k { font-weight: 700; color: var(--r-cost-text); margin-right: .25rem; }
.dd-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1.2rem; }
.dd-actions .btn-lg { padding-inline: 1.35rem; }
.dd-actions .btn { white-space: normal; text-align: center; }
.dd-actions .btn-ghost { background: var(--r-cost-card); }
.dd-foot { font-size: .82rem; color: var(--r-cost-muted); margin: 1.1rem 0 0; }
.dd-print-head, .dd-print-flags { display: none; }

/* ---------- tablets and phones: one column, receipt becomes a bottom bar ---------- */
@media (max-width: 900px) {
  .dd-ask { grid-template-columns: minmax(0, 1fr); }
  body { padding-bottom: 4.5rem; }             /* room for the bar; this sheet only loads on this page */
  body.dd-on-answer { padding-bottom: 0; }
  .dd-live {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto !important; z-index: 50;
    background: var(--r-cost-paper); border-top: 1px solid var(--r-cost-rule);
    box-shadow: 0 -10px 30px -16px rgba(58,58,56,.35);
  }
  .dd-bar {
    display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 1rem;
    font: inherit; color: var(--r-cost-text); background: none; border: 0; cursor: pointer;
    padding: .7rem max(1.25rem, env(safe-area-inset-left)) calc(.7rem + env(safe-area-inset-bottom)); text-align: left; min-height: 56px;
  }
  .dd-bar:focus-visible { outline-offset: -4px; }
  .dd-bar-text { display: grid; line-height: 1.2; }
  .dd-bar-k { font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--r-cost-muted); }
  .dd-bar-v { font-size: 1.1rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
  .dd-bar-more { display: inline-flex; align-items: center; gap: .45rem; font-size: .92rem; font-weight: 650; color: var(--r-cost-link); }
  .dd-chev { width: .5rem; height: .5rem; border: solid currentColor; border-width: 2px 2px 0 0; transform: rotate(-45deg) translate(-1px, 1px); }
  .dd-live.is-open .dd-chev { transform: rotate(135deg) translate(-1px, 1px); }
  .dd-live-body { display: none; padding: 0 1rem 1rem; max-height: min(62vh, 30rem); overflow-y: auto; }
  .dd-live.is-open .dd-live-body { display: block; }
  .dd-live.is-open .dd-bar { border-bottom: 1px solid var(--r-cost-rule); }
  .dd-live .dd-rcpt { border: 0; box-shadow: none; border-radius: 0; padding: .3rem 0 0; }
  .dd-live .dd-rcpt-head { display: none; }
}
@media (max-width: 760px) {
  .dd-receipts { grid-template-columns: minmax(0, 1fr); grid-template-areas: "today" "grr" "after"; grid-template-rows: none; }
}
@media (max-width: 680px) {
  .dd-platforms { grid-template-columns: 1fr; }
  .dd-progress ol { gap: .35rem; }
  .dd-progress button { flex-direction: column; align-items: flex-start; gap: .35rem; font-size: .82rem; line-height: 1.25; }
  .dd-card { padding: 1.3rem 1.1rem; }
  .dd-nav .btn-lg, .dd-actions .btn { width: 100%; text-align: center; white-space: normal; }
  .dd-nav { flex-direction: column-reverse; align-items: stretch; }
  .dd-nav > span:empty { display: none; }
  .dd-nav .btn-ghost { text-align: center; }
  .dd-rcpt { padding-inline: .95rem; }
}
@media (prefers-reduced-motion: reduce) {
  .dd-choice, .dd-chev { transition: none; }
}

/* ---------- print: one page, both receipts side by side ---------- */
@media print {
  @page { margin: 9mm 11mm; }
  html { font-size: 10px; }
  body { background: #fff; font-size: 9.5pt; line-height: 1.38; }
  body > :not(main), .dd-hero, .dd-progress, .dd-ask, .dd-answer-top, .dd-actions { display: none !important; }
  .cost-d, .dd-tool { background: #fff; padding: 0 !important; }
  .dd-answer, .dd-answer[hidden] { display: block !important; animation: none !important; }
  .dd-print-head { display: block; margin: 0 0 3mm; padding-bottom: 2mm; border-bottom: 1px solid #999; }
  .dd-print-head strong { display: block; font-size: 15pt; letter-spacing: -.01em; }
  .dd-print-head span { font-size: 9pt; color: #555; }
  .dd-receipts { grid-template-columns: 1fr 1fr; grid-template-areas: "today grr" "after after"; grid-template-rows: auto auto; gap: 4mm 5mm; }
  .dd-rcpt { box-shadow: none; padding: 3mm 3.5mm; break-inside: avoid; }
  .dd-lines li { padding: .55mm 0; font-size: 8.5pt; line-height: 1.28; }
  .dd-rcpt-head { padding-bottom: 1.5mm; }
  .dd-rcpt h4 { margin: 2.2mm 0 .3mm; }
  .dd-total { margin-top: 2mm; padding-top: 1.5mm; }
  .dd-l-detail { font-size: 7.5pt; }
  .dd-total-amt { font-size: 12pt; }
  .dd-print-flags { display: grid; gap: 1mm; list-style: none; margin: 0; padding: 0; }
  .dd-print-flags li { display: flex; gap: 2mm; font-size: 8.5pt; line-height: 1.35; }
  .dd-print-flags em { color: #444; }
  .dd-keeps-line, .dd-watch p, .dd-foot { font-size: 8.5pt; }
  .dd-keeps-line { margin-top: 3mm; }
  .dd-watch { display: none !important; }      /* the same text is in the numbered list above */
  .dd-foot { margin-top: 2mm; }
  .dd-mark { width: 4mm; height: 4mm; font-size: 6.5pt; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
