:root {
  --green: #1F5F4A;
  --orange: #E8772E;
  --ink: #1B1F1D;
  --paper: #F7F5F0;
  --card: #FFFFFF;
  --line: #CFCBC0;
  --muted: #4A524E;
  --btn-bg: #1F5F4A;
  --btn-ink: #FFFFFF;
  --chip-on-bg: #1F5F4A;
  --chip-on-ink: #FFFFFF;
  --tag-bg: #FBE3D0;
  --tag-ink: #7A3508;
  --accent-text: #1F5F4A;
  --warn-bg: #FFF1DE;
  --focus: #0B57D0;
  --orange-text: #A64B0E; /* the orange as text: 5.3:1 on the paper */
  --field-line: #85816F; /* edge of a text field: 3.6:1 on the paper */
}
@media (prefers-color-scheme: dark) {
  :root {
    --green: #7FD1B0;
    --orange: #F29A5C;
    --ink: #EEF2EF;
    --paper: #16231E;
    --card: #1E2F28;
    --line: #3C5249;
    --muted: #B5C4BC;
    --btn-bg: #7FD1B0;
    --btn-ink: #10201A;
    --chip-on-bg: #7FD1B0;
    --chip-on-ink: #10201A;
    --tag-bg: #4A2C17;
    --tag-ink: #F8C9A3;
    --accent-text: #7FD1B0;
    --warn-bg: #3A3020;
    --focus: #9CC2FF;
    --orange-text: #F29A5C;
    --field-line: #6C8A7D;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 1.125rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-wrap: anywhere;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--card); padding: 14px 16px; z-index: 50; }

.top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 1.25rem; color: var(--accent-text); }

main { max-width: 640px; margin: 0 auto; padding: 16px 16px 24px; outline: none; }
h1[tabindex="-1"]:focus { outline: none; } /* focus moves here after a page change; it is a heading, not a control */
h1 { font-size: 1.6rem; line-height: 1.2; margin: 8px 0 8px; }
h2 { font-size: 1.25rem; margin: 22px 0 8px; }
h3 { font-size: 1.1rem; margin: 0; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.pad { padding: 16px; }
.small { font-size: 1rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 0 0 14px; }

label, .label { display: block; font-weight: 700; margin: 14px 0 6px; }
.hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=number], input[type=search], input[type=email], select, textarea {
  width: 100%; min-height: 52px; font: inherit; padding: 8px 12px; color: var(--ink);
  background: var(--card); border: 2px solid var(--field-line); border-radius: 10px;
}

::placeholder { color: var(--muted); opacity: 1; }
button { font: inherit; color: inherit; cursor: pointer; }
.btn {
  display: block; width: 100%; min-height: 56px; padding: 12px 16px; border: 0; border-radius: 12px;
  background: var(--btn-bg); color: var(--btn-ink); font-weight: 800; font-size: 1.1rem; text-align: center; text-decoration: none;
}
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.second { background: transparent; color: var(--accent-text); border: 2px solid var(--green); }
.link-btn { background: none; border: 0; color: var(--accent-text); text-decoration: underline; min-height: 48px; min-width: 48px; padding: 8px 10px; font-weight: 700; }
a.link-btn { display: inline-flex; align-items: center; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  min-height: 48px; min-width: 48px; padding: 8px 16px; border: 2px solid var(--line); border-radius: 12px;
  background: var(--card); font-weight: 600; text-align: left;
}
.chip[aria-pressed=true] { background: var(--chip-on-bg); color: var(--chip-on-ink); border-color: var(--chip-on-bg); }
.chip .sub { display: block; font-weight: 400; font-size: 1rem; }
.chips.stack { flex-direction: column; }
.chips.stack .chip { width: 100%; }
.big-choice {
  display: block; width: 100%; min-height: 64px; margin: 0 0 10px; padding: 12px 16px; text-align: left;
  border: 2px solid var(--line); border-radius: 14px; background: var(--card); font-weight: 800; font-size: 1.15rem;
}
.big-choice[aria-pressed=true] { border-color: var(--green); box-shadow: inset 0 0 0 2px var(--green); }
.big-choice .sub { display: block; font-weight: 400; font-size: 1rem; color: var(--muted); }

.bar-actions { margin-top: 22px; }
.bar-actions .btn + .btn, .bar-actions .btn + .link-btn { margin-top: 10px; }
.backrow { margin-top: 4px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--card); border-top: 2px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 58px; padding: 4px 2px;
  text-decoration: none; color: var(--muted); font-size: clamp(16px, 4.6vw, 1rem); font-weight: 600; overflow-wrap: normal; text-align: center; line-height: 1.15;
}
.tabs a .n { font-weight: 800; }
.tabs a[aria-current=page] { color: var(--accent-text); box-shadow: inset 0 4px 0 var(--orange); font-weight: 800; }

.toast {
  position: fixed; left: 12px; right: 12px; bottom: 76px; z-index: 30; max-width: 616px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--ink); color: var(--paper); padding: 6px 8px 6px 16px; border-radius: 12px;
}
.toast[hidden] { display: none; }
.toast .link-btn { color: var(--paper); }

.roomhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.q { margin: 12px 0 4px; font-weight: 700; }

.tag { display: inline-block; background: var(--tag-bg); color: var(--tag-ink); border-radius: 6px; padding: 1px 8px; font-size: 1rem; font-weight: 700; }
.tag.maybe { background: var(--warn-bg); color: var(--ink); border: 1px solid var(--orange); }
.warnbox { background: var(--warn-bg); border-left: 5px solid var(--orange); padding: 10px 12px; border-radius: 8px; margin: 10px 0; }

details.room { background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin: 0 0 14px; }
details.room > summary { list-style: none; min-height: 64px; padding: 12px 14px; cursor: pointer; }
details.room > summary::-webkit-details-marker { display: none; }
details.room > summary::after { content: "Show lines"; display: block; color: var(--accent-text); font-weight: 700; margin-top: 2px; }
details.room[open] > summary::after { content: "Hide lines"; }
.price { font-weight: 800; }
.lines { list-style: none; margin: 0; padding: 0 8px 8px; }
.lines li { border-top: 1px solid var(--line); }
.linebtn { width: 100%; min-height: 56px; padding: 10px 6px; text-align: left; background: none; border: 0; display: block; }
.linebtn .l1 { display: flex; justify-content: space-between; gap: 10px; }
.linebtn .l1 .price { white-space: nowrap; }
.linebtn .l2 { color: var(--muted); font-size: 1rem; }
.linebtn.removed { opacity: .55; text-decoration: line-through; }
.edited { font-size: 1rem; color: var(--accent-text); font-weight: 700; }

.total-box { text-align: center; padding: 20px 12px; border-radius: 16px; background: var(--green); color: #fff; margin: 8px 0 14px; }
@media (prefers-color-scheme: dark) { .total-box { background: #27483C; color: #fff; } }
.total-box .big { font-size: clamp(2rem, 11vw, 2.6rem); overflow-wrap: normal; font-weight: 900; line-height: 1.1; }
.total-box .what { font-size: 1.1rem; }
.total-box .rng { font-size: 1.1rem; margin-top: 6px; }
.parts { width: 100%; border-collapse: collapse; }
.parts td { padding: 6px 0; vertical-align: top; }
.parts td:last-child { text-align: right; white-space: nowrap; font-weight: 700; padding-left: 10px; }
.parts tr.sum td { border-top: 2px solid var(--line); font-weight: 800; }
.disclaimer { border: 2px solid var(--orange); border-radius: 12px; padding: 10px 12px; margin: 14px 0; }
.soon { list-style: none; padding: 0; margin: 0; }
.soon li { padding: 10px 0; border-top: 1px solid var(--line); color: var(--muted); }
.soon li:first-child { border-top: 0; }

.summary-card { background: #fff; color: #1B1F1D; border: 2px solid #1F5F4A; border-radius: 14px; padding: 16px; }
.summary-card h2 { margin: 0 0 4px; color: #1F5F4A; }
.summary-card .tot { overflow-wrap: normal; font-size: 2rem; font-weight: 900; color: #1F5F4A; }
.summary-card p, .summary-card li { color: #1B1F1D; }
.summary-card .made { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-weight: 700; color: #1F5F4A; }
.summary-card .small { color: #3A413E; }

dialog { width: min(100vw - 24px, 560px); max-height: 92vh; overflow: auto; background: var(--card); color: var(--ink); border: 2px solid var(--line); border-radius: 16px; padding: 16px; }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog h2 { margin-top: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 380px) { .two { grid-template-columns: 1fr; } }
.help { font-size: 1rem; color: var(--muted); margin: 4px 0 0; }

@media print {
  body { background: #fff; }
  .top, .tabs, .toast, .noprint, dialog, .skip, .foot { display: none !important; }
  main { padding: 0; max-width: none; }
  main:has(.summary-card) > :not(.summary-card) { display: none !important; }
  .summary-card { border-color: #000; break-inside: avoid; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* footer, static pages (guides, privacy, terms) and the save panel */
.foot { max-width: 640px; margin: 0 auto; padding: 8px 16px 24px; border-top: 1px solid var(--line); }
.foot.with-tabs { padding-bottom: 130px; }
.foot nav { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.foot a, .top a { display: inline-block; min-height: 48px; padding: 12px 8px; color: var(--accent-text); font-weight: 700; }
.top a { text-decoration: none; display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.draft { background: var(--warn-bg); border: 2px solid var(--orange); border-radius: 12px; padding: 10px 12px; font-weight: 700; margin: 0 0 14px; }
.prose ul { padding-left: 1.2em; }
.prose li { margin: 0 0 8px; }
a.btn { text-decoration: none; }
.gtable { width: 100%; border-collapse: collapse; margin: 0 0 18px; background: var(--card); border: 1px solid var(--line); }
.gtable caption { text-align: left; font-weight: 800; padding: 8px 0; }
.gtable th, .gtable td { border: 1px solid var(--line); padding: 8px; vertical-align: top; text-align: left; font-size: 1rem; }
.gtable thead th { background: var(--paper); }
.gtable td span { display: block; }
.gtable tr.fin th { background: var(--paper); font-weight: 700; }
.gtable tr.fin th .muted { font-weight: 400; }
.gtable td { width: 50%; }
.gtable td .likely { font-weight: 800; }
.glist { padding-left: 1.2em; }
.glist li { margin: 0 0 8px; }
.guide-links { list-style: none; padding: 0; margin: 0 0 12px; }
.guide-links li { margin: 0; }
.guide-links a { display: block; min-height: 48px; padding: 12px 4px; border-top: 1px solid var(--line); color: var(--accent-text); font-weight: 700; }
.save-panel { border: 2px solid var(--green); }
.save-panel h2 { margin-top: 0; }
.save-panel .msg { font-weight: 700; margin: 10px 0 0; }
.save-panel .msg.bad { color: var(--tag-ink); background: var(--tag-bg); padding: 8px 10px; border-radius: 8px; }
/* motion: press feedback and short entrances; nothing moves for people who ask for reduced motion */
:root { --ease-out: cubic-bezier(0.23, 1, 0.32, 1); }
@media (prefers-reduced-motion: no-preference) {
  .chip, .btn, .big-choice, .seg button { transition: transform 160ms var(--ease-out), background-color 120ms ease, border-color 120ms ease, color 120ms ease; }
  .chip:active, .btn:active:not([disabled]), .big-choice:active, .seg button:active { transform: scale(0.97); }
  .linebtn { transition: background-color 120ms ease; }
  .linebtn:active { background-color: var(--paper); }
  dialog[open] { transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out); }
  @starting-style { dialog[open] { opacity: 0; transform: translateY(8px) scale(0.98); } }
  dialog[open]::backdrop { transition: opacity 200ms ease; }
  @starting-style { dialog[open]::backdrop { opacity: 0; } }
  .toast { transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out); }
  @starting-style { .toast { opacity: 0; transform: translateY(100%); } }
}
@media (hover: hover) and (pointer: fine) {
  .linebtn:hover { background-color: var(--paper); }
  .big-choice:hover { border-color: var(--green); }
}

/* money lines up */
.price, .total-box .big, .total-box .rng, .parts td, .bid-table td, .tot { font-variant-numeric: tabular-nums; }

/* homeowner or contractor: one switch, two equal halves */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; margin: 4px 0 6px; }
.seg button { min-height: 48px; border: 0; background: var(--card); font-weight: 700; padding: 8px 10px; }
.seg button + button { border-left: 2px solid var(--line); }
.seg button[aria-pressed=true] { background: var(--chip-on-bg); color: var(--chip-on-ink); }

/* additions and line overrides */
.parthead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 12px 0 0; padding: 8px 14px 4px; font-size: 1rem; background: var(--paper); border-top: 1px solid var(--line); }
.parthead .price { white-space: nowrap; }
.tag.mine { background: var(--paper); color: var(--ink); border: 1px solid var(--green); }
.tag.quote { background: var(--green); color: var(--btn-ink); }
.warnbox.strong { border-left-width: 8px; }
.btnrow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .btnrow { grid-template-columns: 1fr; } }

/* Floor plan view on the rooms step */
.plan { margin: 0 0 14px; }
.floor { border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px 12px; margin: 0 0 12px; background: var(--paper); }
.floor-name { font-size: 1.1rem; margin: 0 0 8px; }
.plan-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.roombox {
  display: flex; flex-direction: column; justify-content: space-between; gap: 4px; min-height: 96px; padding: 10px 12px;
  border: 2px solid var(--line); border-radius: 10px; background: var(--card); text-align: left;
}
.roombox.size-L { grid-column: span 2; min-height: 110px; }
.roombox.size-S { min-height: 84px; }
.roombox[aria-pressed=true] { border-color: var(--green); box-shadow: inset 0 0 0 2px var(--green); }
.roombox.add { align-items: center; justify-content: center; border-style: dashed; color: var(--accent-text); font-weight: 700; }
.rb-name { font-weight: 800; }
.rb-sub { font-size: 1rem; color: var(--muted); }
.rb-price { font-weight: 700; color: var(--accent-text); }
.floor .card { margin: 10px 0 0; }
@media (max-width: 340px) { .roombox.size-L { grid-column: auto; } }

/* Floor plan pictures (step 2): the picture with room names pinned on it */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.filebtn { display: flex; align-items: center; justify-content: center; cursor: pointer; margin-top: 12px; }
.filebtn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.planpic-wrap { margin-top: 12px; }
.planpic { position: relative; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; cursor: crosshair; touch-action: manipulation; }
.planpic img { display: block; width: 100%; height: auto; }
.pin {
  /* left/top and the matching translate keep the pin inside the picture, even at the edges */
  position: absolute; min-height: 44px; min-width: 44px; max-width: 45%; padding: 4px 10px;
  border: 2px solid #fff; border-radius: 18px; background: var(--chip-on-bg); color: var(--chip-on-ink);
  font-weight: 700; font-size: 0.95rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .45);
}
.pin.on { background: var(--orange); color: #1B1F1D; }
.pin.temp { min-width: 36px; text-align: center; background: var(--orange); color: #1B1F1D; pointer-events: none; }

/* Bid sheet: on screen a preview, on paper one page per contractor or room */
.bid-page { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 0 0 14px; }
.bid-page h2 { margin: 6px 0 10px; }
.bid-fill { display: none; }
.fill { display: flex; align-items: flex-end; gap: 8px; margin: 10px 0 0; }
.fill > span:first-child:not(.fill-line) { white-space: nowrap; }
.fill-line { flex: 1; border-bottom: 1px solid var(--ink); min-height: 1.4em; }
.bid-table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.bid-table th, .bid-table td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; font-size: 1rem; }
.bid-table thead th { background: var(--paper); }
.bid-table td.yours, .bid-table th.yours { width: 22%; }
.bid-table tfoot th { text-align: right; }
@media (max-width: 480px) { .bid-table th, .bid-table td { padding: 5px; font-size: .95rem; } }
@media print {
  .bid-page { border: 0; border-radius: 0; padding: 0; margin: 0; background: #fff; color: #000; break-before: page; }
  .bid-page:first-child { break-before: auto; }
  .bid-fill { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; margin-bottom: 10px; }
  .bid-fill .fill:nth-child(3), .bid-fill p { grid-column: 1 / -1; }
  .bid-table th, .bid-table td { border-color: #000; color: #000; }
  .bid-table thead th { background: #fff; }
  .bid-table tr { break-inside: avoid; }
  .bid-table td.yours { min-height: 28px; }
  .fill-line { border-color: #000; }
  .bid-sheet .muted { color: #333; }
}
.bid-table .qty { white-space: nowrap; }

/* your own lines */
.addline { padding: 4px 14px 10px; }
.card .addline { padding: 8px 0 0; }

/* contractor: rates, price book, proposal */
textarea { min-height: 88px; resize: vertical; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 700; margin: 14px 0 4px; min-height: 44px; padding: 6px 0; }
label.check input { width: 24px; height: 24px; margin: 2px 0 0; flex: none; }
label.check .hint { display: block; }
.bookrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.bookrow:first-child { border-top: 0; }
.prop-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin: 0 0 12px; }
.prop-co { font-size: 1.25rem; }
.prop-date { text-align: right; font-weight: 800; font-size: 1.2rem; }
.proposal .prop-sign { display: grid; grid-template-columns: 2fr 1fr; gap: 6px 24px; margin-top: 24px; }
.proposal .prop-sign .fill { margin-top: 22px; }
@media print {
  .bid-page.proposal { break-before: auto; }
  .proposal .prop-sign { display: grid; grid-template-columns: 2fr 1fr; }
}

/* saved estimates and the full report */
.estcard .btnrow { grid-template-columns: 1fr auto auto; align-items: center; }
@media (max-width: 480px) { .estcard .btnrow { grid-template-columns: 1fr 1fr; } .estcard .btnrow .btn { grid-column: 1 / -1; } }
.rep-h { display: flex; justify-content: space-between; gap: 12px; margin: 22px 0 2px; }
.report h4 { margin: 12px 0 2px; }
@media print {
  .report .total-box { border: 2px solid #000; background: #fff; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report .card { border-color: #000; }
  .report h3 { break-after: avoid; }
}

/* compare */
.cmp-wrap { overflow-x: auto; margin: 12px 0; }
.cmp th[scope=row] { font-weight: 700; background: var(--paper); white-space: nowrap; }
.cmp td { white-space: nowrap; }

/* spending tracker */
input[type=date] { width: 100%; min-height: 52px; font: inherit; padding: 8px 12px; color: var(--ink); background: var(--card); border: 2px solid var(--field-line); border-radius: 10px; }
.meter { height: 10px; border-radius: 6px; background: color-mix(in srgb, currentColor 25%, transparent); margin-top: 10px; overflow: hidden; }
.meter span { display: block; height: 100%; background: currentColor; }
.quickadd label.small { margin-top: 4px; }
.spend-t td.over { color: var(--orange-text); font-weight: 800; }
.spend-t tr.sub > td { padding: 0 0 0 16px; border-top: 0; }
.spend-t tr.sub .parts { margin: 0; }

/* account and paywall */
.top .acct { margin-left: auto; min-height: 44px; padding: 10px 4px; font-weight: 700; }
.okbox { background: var(--card); border: 2px solid var(--green); border-radius: 12px; padding: 10px 12px; margin: 0 0 14px; font-weight: 700; }
.lock { border: 2px solid var(--green); }
.lock h2 { margin-top: 0; }
.quickadd .two { grid-template-columns: 2fr 3fr; }
.quickadd .bar-actions { margin-top: 10px; }

/* signing on a phone */
.sigpad {
  display: block; width: 100%; height: 180px; margin: 4px 0 0; touch-action: none; cursor: crosshair;
  color: var(--ink); background: var(--card); border: 2px dashed var(--line); border-radius: 12px;
  background-image: linear-gradient(var(--line), var(--line)); background-repeat: no-repeat;
  background-size: calc(100% - 40px) 1px; background-position: 20px 78%;
}
.sigpad:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sign-card h2 { margin-top: 0; }
.sigbox { position: relative; max-width: 360px; margin: 8px 0 16px; color: var(--ink); }
.sig { display: block; width: 100%; height: auto; }
.typed-sig { position: absolute; left: 6%; bottom: 22%; font: italic 600 1.9rem/1 "Segoe Script", "Bradley Hand", "Brush Script MT", cursive; }
.btnrow-mini { display: flex; flex-wrap: wrap; justify-content: flex-end; }
.doc-view .foot.with-tabs { padding-bottom: 24px; }
@media print { .sigbox, .sig { color: #000; } }
.doc-view .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }
.sign-card label.check { font-weight: 400; }

/* measuring on the plan picture */
.planpic.measuring { cursor: crosshair; outline: 3px solid var(--orange); outline-offset: 2px; }
.measure-help { font-weight: 700; color: var(--ink); }
.mdot { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--orange); border: 2px solid #fff; pointer-events: none; }
.mbox { position: absolute; border: 2px solid var(--orange); background: color-mix(in srgb, var(--orange) 12%, transparent); pointer-events: none; }
.mbox span { position: absolute; left: 2px; top: 2px; font-size: .8rem; font-weight: 800; background: var(--card); color: var(--ink); padding: 0 4px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.measure-row { margin: 8px 0; }

/* the logo is the way home */
.top .home { display: flex; align-items: center; gap: 10px; min-height: 44px; text-decoration: none; color: inherit; }
/* short words in table columns don't break mid-word ("Materials") */
.bid-table td, .bid-table th { overflow-wrap: normal; word-break: normal; }

/* wide screens: steps become a top bar under the header, and pages get more room */
@media screen and (min-width: 1024px) {
  body { display: flex; flex-direction: column; min-height: 100vh; }
  .tabs { order: 1; position: sticky; top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line);
    grid-template-columns: repeat(5, minmax(0, 168px)); justify-content: center; padding-bottom: 0; }
  .tabs a { flex-direction: row; gap: 6px; min-height: 52px; font-size: 1rem; }
  .tabs a[aria-current=page] { box-shadow: inset 0 -3px 0 var(--orange); }
  main { order: 2; flex: 1 0 auto; width: 100%; max-width: 760px; padding: 24px 24px 32px; }
  main:has(.report) { max-width: 960px; }
  .foot { order: 3; }
  .foot.with-tabs { padding-bottom: 24px; }
  .toast { bottom: 24px; }
  .top { padding-left: max(24px, calc((100% - 1072px) / 2)); padding-right: max(24px, calc((100% - 1072px) / 2)); }
}

/* two columns on wide screens; on phones these wrappers are plain blocks in reading order */
.split > *, .floor-grid > * { min-width: 0; }
@media screen and (min-width: 1024px) {
  main:has(.split), main:has(.planpic-wrap) { max-width: 1120px; }
  .split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 0 40px; align-items: start; }
  .split.lead { grid-template-columns: 400px minmax(0, 1fr); }
  .split.flip > .split-side { grid-column: 2; grid-row: 1; }
  .split.flip > .split-main { grid-column: 1; grid-row: 1; }
  .split-side.sticky { position: sticky; top: 72px; }
  .split-side > :first-child, .split-main > :first-child, .split-main > .noprint:first-child h2 { margin-top: 0; }
  .split-side { padding-top: 6px; }
  .choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
  .choices .big-choice { margin: 0; }
  .floor-grid:has(> .planpic-wrap) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 0 32px; align-items: start; }
}
@media screen and (min-width: 1024px) {
  main:has(.split) > :not(.split), main:has(.planpic-wrap) > :not(.plan) { max-width: 760px; }
  .choices:has(> :nth-child(3):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* short question cards sit side by side on wide screens */
@media screen and (min-width: 1024px) {
  main:has(.card-grid) { max-width: 1120px; }
  main:has(.card-grid) > :not(.card-grid) { max-width: 760px; }
  .card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 12px; align-items: stretch; margin-bottom: 14px; }
  .card-grid > .card { margin: 0; }
}
@media (hover: hover) and (pointer: fine) {
  .chip:hover:not([aria-pressed=true]) { border-color: var(--green); }
  .seg button:hover:not([aria-pressed=true]) { color: var(--accent-text); }
  .tabs a:hover:not([aria-current=page]) { color: var(--accent-text); }
}
/* the action buttons under a result pair up on wide screens; the first one stays full width */
@media screen and (min-width: 1024px) {
  .bar-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .bar-actions > .btn { margin: 0; }
  .bar-actions > :first-child, .bar-actions > .link-btn { grid-column: 1 / -1; }
  .bar-actions > .link-btn { justify-self: start; }
}
/* report prices line up on the right so they can be compared down the column */
.report .bid-table td:last-child, .report .bid-table th:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* first-visit intro on the start page */
.intro { margin: 4px 0 18px; padding: 0 0 16px; border-bottom: 1px solid var(--line); max-width: 62ch; }
.intro-lead { font-size: 1.3rem; font-weight: 800; line-height: 1.25; color: var(--accent-text); margin: 0 0 6px; }
.intro .muted { margin: 0; }
/* jumps and focus land below the sticky step bar, not under it */
@media screen and (min-width: 1024px) { html { scroll-padding-top: 68px; } }
/* plain links inside text use the app's link color, not the browser's blue (unreadable on dark boxes) */
:where(a) { color: var(--accent-text); }
/* the contractor note under the switch gets room before the next line */
.seg + .help { margin: 8px 0 12px; }
/* "Ask your inspector about" list */
.era-list { padding: 0; margin: 0; list-style: none; }
.era-list .era { padding: 10px 0; border-top: 1px solid var(--line); }
.era-list .era:first-child { border-top: 0; }
.era-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.era-head .price { white-space: nowrap; }
/* receipt photo in the purchase form */
.receipt-row { display: flex; align-items: center; gap: 12px; }
.receipt-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); }
.receipt-btns { display: flex; flex-wrap: wrap; gap: 4px; }
.receipt-btns .link-btn { display: inline-flex; align-items: center; }
/* the spending summary table has five columns; keep it inside a phone screen */
@media (max-width: 480px) { .spend-t th, .spend-t td { padding: 5px 3px; font-size: .9rem; } .spend-t td:first-child { overflow-wrap: anywhere; } }

/* good, better, best: three options side by side, stacked on a phone */
.opts { display: grid; gap: 10px; margin: 12px 0; }
@media (min-width: 640px) { .opts { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.opt { display: flex; flex-direction: column; gap: 4px; width: 100%; min-height: 44px; text-align: left; font: inherit; color: inherit; background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 12px; }
button.opt { cursor: pointer; }
.opt[aria-pressed=true], .opt.chosen { border-color: var(--green); box-shadow: inset 0 0 0 2px var(--green); }
.opt-head { display: flex; align-items: center; gap: 10px; }
.opt-box { flex: none; width: 24px; height: 24px; border: 2px solid currentColor; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; line-height: 1; }
button.opt[aria-pressed=true] .opt-box::after, .opt-box.on::after { content: "\2713"; }
.opt-price { font-size: 1.4rem; font-weight: 800; line-height: 1.2; }
.opt-rows { list-style: none; padding: 0; margin: 6px 0 0; font-size: .95rem; border-top: 1px solid var(--line); }
.opt-rows li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; }
.opt-rows li span:last-child { white-space: nowrap; }
.opt-chosen { margin-top: 16px; }
@media print {
  .opts { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .opt { border: 1px solid #000; box-shadow: none; color: #000; background: #fff; break-inside: avoid; padding: 8px; }
  .opt-rows { border-color: #000; }
}

/* saved products in the price book */
.prodbox { margin-top: 4px; }
.prodbox .chips { margin-bottom: 4px; }
.l2.prodname { color: var(--ink); }
.small.prodname { color: inherit; }
.bookgroup { padding: 8px 0; border-top: 1px solid var(--line); }
.bookgroup:first-child { border-top: 0; }
.bookprods { list-style: none; margin: 6px 0 0; padding: 0 0 0 12px; border-left: 3px solid var(--line); }
.bookprods .bookrow:first-child { border-top: 0; }
.bookbtns { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

/* feedback link, example note, backup box */
.feedback { margin: 16px 0 0; text-align: center; }
.feedback a { display: inline-block; min-height: 44px; padding: 10px 12px; color: var(--accent-text); font-weight: 700; }
.exnote { margin: 0 0 14px; padding: 12px 14px; border: 2px solid var(--green); border-radius: 12px; background: var(--card, transparent); }
.exnote p { margin: 0 0 10px; }
.backup .btnrow { margin-top: 8px; }
