/* Approval parts (public/parts.js, src/modules/m2/views-parts.ts). Tokens from portal.css only.
   One card pattern for single items and items with parts (owner 2026-11-17: "dual layer cards"): the part sits directly in
   the item's card, laid out like a single item: photo across the top, then text, Approve, Ask for changes, Details.
   No card inside the card and no second layer peeking under it: only the part on top is shown. */
.parts-deck { margin-top: 0; border-radius: 24px 24px 0 0; overflow: hidden; }
.parts-deck:focus-visible { outline-offset: -4px; } /* inside the clip, so the keyboard ring is not cut off */
.parts-card {
  background: transparent; border: 0; border-radius: 0; box-shadow: none; overflow: visible;
  /* long press must not select text or pop the image menu while swiping */
  -webkit-touch-callout: none;
}
/* swipe.css dims and stacks the cards under the top one (the news deck keeps that look); here they are simply not shown */
.deck.parts-deck[data-deck-ready] > .deck-card:not(.is-top) { display: none; }
.deck.parts-deck > .deck-card.arrive { animation: parts-arrive var(--t-appear, .7s) var(--ease) both; }
@keyframes parts-arrive { from { opacity: 0; } to { opacity: 1; } }
.parts-photo img, .parts-photo .parts-tag { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 0; }
.parts-photo .parts-tag { display: grid; place-items: center; background: var(--linen); color: var(--script); font: 400 56px var(--f-display); }
.parts-body > *, .parts-final > * { margin: 0; }
.parts-progress { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; font: 600 14px var(--f-body); color: var(--script); }
.parts-kind { font-weight: 500; color: var(--muted); margin-right: auto; }
.parts-dots { display: inline-flex; gap: 6px; margin-left: auto; }
.parts-dots i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--script); box-sizing: border-box; }
.parts-dots i.on { background: var(--script); }
.parts-title { font: 700 19px/1.25 var(--f-body); color: var(--charcoal); margin: 0; }
.parts-text { font-size: 16px; line-height: 1.5; color: var(--ink-2); }
.parts-form { margin-top: 0; }
/* the change box lives in the same "Ask for changes" fold a single item has */
.parts-msg { margin: 0; font-size: 15px; }
.parts-card.is-sent { opacity: .5; transition: opacity .35s var(--ease); pointer-events: none; }
@keyframes parts-unfold { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* the last step is a plain section of the same card, not a card of its own */
.parts-final { background: none; border: 0; border-radius: 0; padding: 0; display: grid; gap: 14px; }
.parts-final[hidden] { display: none; }
.parts-final.arrive-final { animation: parts-unfold .45s var(--ease) both; }
.parts-final-title { font: 400 28px/1.15 var(--f-display); text-transform: uppercase; letter-spacing: 0.02em; color: var(--charcoal); margin: 0; }
.parts-final-title:focus { outline: none; }
.parts-tail:empty, .parts-tail:not(:has(*:not([hidden]))) { display: none; }

/* staff */
.parts-staff { width: 100%; display: grid; gap: 10px; justify-self: stretch; }
.parts-staff > p { margin: 0; }
.parts-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.parts-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: start; padding: 10px 12px; border-radius: 14px; background: var(--linen); }
.parts-row p { margin: 0; }
.parts-flag { color: #7a1f1f; font-size: 15px; margin: 4px 0 0; }
.parts-alert { border-left: 4px solid var(--script); }

@media (max-width: 430px) { .parts-title { font-size: 18px; } .parts-final-title { font-size: 24px; } }
@media (prefers-reduced-motion: reduce) {
  .parts-final.arrive-final, .deck.parts-deck > .deck-card.arrive { animation: none; }
}
/* No JavaScript (or parts.js/swipe.js failed to load): swipe.css would dim, stack and disable every card because
   .is-top is only added by swipe.js. Show the cards as a plain readable list with working buttons instead. */
.parts-deck:not(.parts-js) { display: block; }
.parts-deck:not(.parts-js) > .deck-card { grid-area: auto; transform: none; opacity: 1; pointer-events: auto; margin-bottom: 16px; }
.parts-deck:not(.parts-js) > .deck-card + .deck-card { padding-top: 16px; border-top: 1px solid rgba(185, 168, 155, 0.45); } /* a divider line, not a card */

/* ---- Approvals: switch, folded decided rows, folded threads, My choices (src/modules/m2/views-choices.ts, public/parts.js) ---- */
.choice-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; margin: 4px 0 18px; background: var(--linen); border-radius: 999px; }
.choice-switch a {
  display: flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 10px; border-radius: 999px; text-align: center;
  font: 700 17px/1.2 var(--f-body); color: var(--muted); text-decoration: none;
  transition: background .3s var(--ease), color .3s var(--ease);
}
.choice-switch a[aria-current="page"] { background: var(--paper); color: var(--charcoal); box-shadow: 0 1px 4px rgba(33, 31, 32, 0.14); }

/* status tags: the green-ish is derived from the palette (script brown pulled toward a soft sage), never a raw brand colour */
.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 999px; white-space: nowrap;
  font: 700 13px/1.3 var(--f-body); letter-spacing: 0.03em; background: var(--linen); color: var(--charcoal);
}
.tag-ico { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.tag-ok { --sage: color-mix(in srgb, var(--script) 38%, #5d8a5e); background: color-mix(in srgb, var(--sage) 20%, var(--paper)); color: color-mix(in srgb, var(--sage) 60%, var(--charcoal)); }
.tag-lock { background: rgba(64, 108, 140, 0.16); color: #2F5470; border: 1px solid rgba(64, 108, 140, 0.32); } /* see-through, not black (owner 2026-11-17) */
.tag-warm { background: color-mix(in srgb, var(--script) 22%, var(--paper)); color: var(--script); }
.tag-wait { background: var(--linen); color: var(--charcoal); }

/* decided items: slim folded rows under the open cards */
.fold-help { margin: -4px 0 0; }
.appr-folded { border-radius: 20px; }
.fold-sum { list-style: none; display: grid; grid-template-columns: 52px 1fr 28px; gap: 14px; align-items: center; padding: 12px 16px; min-height: 76px; cursor: pointer; }
.fold-sum::-webkit-details-marker { display: none; }
.fold-thumb img, .fold-thumb .appr-tag { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; display: grid; place-items: center; }
.fold-main { display: grid; gap: 4px; min-width: 0; }
.fold-name { font: 700 17px/1.3 var(--f-body); color: var(--charcoal); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fold-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fold-price { font: 700 16px var(--f-body); color: var(--charcoal); }
.fold[open] .fold-body { padding: 4px 18px 20px; display: grid; gap: 14px; border-top: 1px solid rgba(185, 168, 155, 0.35); padding-top: 16px; }
.fold-body > * { margin: 0; }
.fold[open] .fold-body { animation: fold-in .35s var(--ease) both; }
@keyframes fold-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.appr-folded:target { outline: 2px solid var(--script); outline-offset: 3px; }

/* folded message thread: one line, then a phone-style conversation */
.thread { margin: 2px 0; }
.thread-sum {
  list-style: none; cursor: pointer; display: grid; grid-template-columns: 22px auto 1fr auto auto; gap: 4px 10px; align-items: center;
  min-height: 48px; padding: 8px 14px; border-radius: 16px; background: var(--linen); color: var(--charcoal);
}
.thread-sum::-webkit-details-marker { display: none; }
.thread-ico { width: 22px; height: 22px; fill: none; stroke: var(--script); stroke-width: 1.8; stroke-linejoin: round; }
.thread-count { font: 700 15px var(--f-body); white-space: nowrap; }
.thread-preview { font: 500 15px var(--f-body); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.thread-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--script); box-shadow: 0 0 0 3px var(--cream); }
.thread[open] .thread-preview { visibility: hidden; }
.thread-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 12px; }
.thread[open] .thread-list { animation: fold-in .35s var(--ease) both; }
.bubble { max-width: 86%; padding: 10px 14px 8px; border-radius: 20px; display: grid; gap: 2px; }
.bubble > * { margin: 0; }
.bubble-text { font: 500 16px/1.5 var(--f-body); overflow-wrap: anywhere; white-space: pre-wrap; }
.bubble-when { font: 500 12px var(--f-body); }
.bubble-me { justify-self: end; background: var(--charcoal); color: var(--cream); border-bottom-right-radius: 6px; text-align: left; }
.bubble-me .bubble-when { color: var(--on-dark-2); justify-self: end; }
.bubble-studio { justify-self: start; background: var(--linen); color: var(--charcoal); border-bottom-left-radius: 6px; }
.bubble-studio .bubble-when { color: var(--muted); }
.bubble-who { font: 400 26px/1.1 var(--f-script); color: var(--script); }

/* My choices */
.choice-search { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; margin-top: 14px; }
.choice-search .field { margin: 0; }
.choice-search input[type="search"] { width: 100%; min-height: 52px; font-size: 17px; }
.choice-search .btn-solid { min-height: 52px; }
.choices-js .choice-search { grid-template-columns: 1fr; }
.choices-js [data-choices-go] { display: none; }
.choice-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 6px; }
/* .chip-btn filter keys are styled in portal.css ("search screens"): cream raised keys, the selected one green. */
.choice-list { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 14px; }
.choice-row {
  display: grid; grid-template-columns: 56px 1fr; gap: 14px; align-items: center; padding: 12px 14px; min-height: 80px;
  background: var(--paper); border: 1px solid rgba(185, 168, 155, 0.45); border-radius: 20px; text-decoration: none; color: inherit;
}
.choice-thumb img, .choice-thumb .appr-tag { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; display: grid; place-items: center; }
.choice-main { display: grid; gap: 3px; min-width: 0; }
.choice-name { font: 700 17px/1.3 var(--f-body); color: var(--charcoal); overflow-wrap: anywhere; }
.choice-sub, .choice-date { font: 500 14px/1.3 var(--f-body); color: var(--muted); }
.choice-sub:empty { display: none; }
.choice-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.choice-price { font: 700 16px var(--f-body); color: var(--charcoal); }
.choice-empty { margin: 22px 0; padding: 18px; background: var(--linen); border-radius: 16px; text-align: center; }

@media (max-width: 430px) { .fold-sum { gap: 12px; padding: 10px 14px; } .bubble { max-width: 92%; } .thread-sum { grid-template-columns: 22px auto 1fr auto auto; padding: 8px 12px; } }
@media (prefers-reduced-motion: reduce) {
  .fold[open] .fold-body, .thread[open] .thread-list { animation: none; }
  .choice-switch a, .chip-btn { transition: none; }
}

/* new studio reply on a folded decided row */
.fold-dot { display: inline-block; width: 10px; height: 10px; margin-left: 8px; border-radius: 50%; background: var(--script); box-shadow: 0 0 0 3px var(--cream); vertical-align: middle; }

/* ---------- room cards: side by side, each its own soft colour, open/decided counts (owner 2026-11-17) ---------- */
.room-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 18px 0 4px; }
.room-card {
  --tone: 46, 125, 85;
  display: grid; gap: 6px; padding: 16px; border-radius: 20px; text-decoration: none; color: var(--charcoal); min-height: 92px;
  background: linear-gradient(180deg, rgba(var(--tone), 0.10), rgba(var(--tone), 0.18));
  border: 1px solid rgba(var(--tone), 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 8px 16px -12px rgba(var(--tone), 0.6);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform var(--t-release, .5s) var(--ease), box-shadow var(--t-release, .5s) var(--ease), background var(--t-change, .45s) var(--ease), border-color var(--t-change, .45s) var(--ease);
}
.room-card.tone-0 { --tone: 46, 125, 85; }   /* sage */
.room-card.tone-1 { --tone: 181, 101, 29; }  /* clay */
.room-card.tone-2 { --tone: 64, 108, 140; }  /* lake */
.room-card.tone-3 { --tone: 150, 72, 96; }   /* rose */
.room-card.tone-4 { --tone: 120, 98, 40; }   /* brass */
.room-card.tone-5 { --tone: 96, 84, 140; }   /* plum */
.room-name { font: 700 17px/1.25 var(--f-body); }
.room-counts { font-size: 14px; color: var(--muted); }
.room-counts b { font: 700 20px var(--f-body); color: rgb(var(--tone)); margin-right: 2px; }
.room-done { color: rgb(var(--tone)); font-weight: 600; }
.room-card[aria-current="true"] {
  background: linear-gradient(180deg, rgba(var(--tone), 0.20), rgba(var(--tone), 0.32)); border: 2px solid rgba(var(--tone), 0.75);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 10px 20px -12px rgba(var(--tone), 0.8);
}
.room-card:active { transform: scale(0.97); transition-duration: var(--t-press, .26s); }
/* the list fades softly while it is being swapped in place */
[data-choices-list] { transition: opacity var(--t-change, .45s) var(--ease); }
[data-choices-list].is-swapping { opacity: 0.45; }

/* ---------- approvals: the whole card fits on any screen, one at a time (owner 2026-11-17) ---------- */
.app-body:has(.appr-list) { scroll-snap-type: y proximity; }
.appr-list > li { scroll-snap-align: start; scroll-margin-top: 18px; }
.appr-photo img, .appr-photo .appr-tag { height: clamp(110px, 22dvh, 180px); }
.parts-photo img, .parts-photo .parts-tag { aspect-ratio: auto; height: clamp(110px, 22dvh, 180px); }
.parts-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.parts-text.open { -webkit-line-clamp: unset; display: block; }
@media (max-height: 700px) {
  .appr-photo img, .appr-photo .appr-tag { height: clamp(90px, 18dvh, 140px); }
  .parts-photo img, .parts-photo .parts-tag { height: clamp(90px, 18dvh, 140px); }
}
@media (max-height: 700px) {
  .appr-main { padding: 14px 16px 16px; gap: 8px; }
  .appr-price { font-size: 22px; margin-top: -4px !important; }
  .appr-due { font-size: 14px; }
  .parts-photo img, .parts-photo .parts-tag { height: clamp(72px, 13dvh, 110px); }
  .parts-title { font-size: 17px; }
  .parts-text { font-size: 15px; line-height: 1.4; }
  .appr-card .btn-solid, .appr-card .btn-outline, .appr-card summary.btn-outline, .appr-card .hold-btn { min-height: 48px; }
}

/* the part card stays inside its item card at every width */
.appr-main, .appr-card, .parts-deck, .deck { min-width: 0; }
.parts-deck > .deck-card, .deck > .deck-card { min-width: 0; max-width: 100%; box-sizing: border-box; }
.appr-card { overflow: hidden; }

/* ---------- deadline: label over the picture, then a short red tag beside the price ---------- */
.appr-price-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; margin: 0; }
.appr-price-row .appr-price { margin: 0 !important; }
.due-short { font: 700 14px/1.2 var(--f-body); color: var(--alert); padding: 4px 10px; border-radius: 999px;
  background: rgba(179, 38, 30, 0.08); border: 1px solid rgba(179, 38, 30, 0.28); white-space: nowrap; }
.due-short.due-arrive { animation: due-pop .5s var(--ease) both; }
@keyframes due-pop { from { transform: scale(0.85); opacity: 0.4; } to { transform: none; opacity: 1; } }
.has-due { position: relative; }
.due-overlay {
  position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 4; text-align: left;
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 6px 4px 14px; border-radius: 16px; font: 700 15px/1.35 var(--f-body); color: #FFFDF8;
  background: rgba(150, 28, 22, 0.78); border: 1px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px) saturate(1.2); -webkit-backdrop-filter: blur(8px) saturate(1.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 10px 22px -12px rgba(0, 0, 0, 0.6);
}
.due-overlay-text { margin: 0; padding-right: 8px; }
/* The close control (owner 2026-11-17: "click to close" at the bottom right of the card; the explicit close is what the
   database records). A real form button, at least 44px tall and wide; phones read "Tap to close". */
.due-close-row { display: flex; justify-content: flex-end; margin: 2px 0 0; }
.due-close-row[hidden] { display: none; }
.due-close-form { display: none; } /* only hidden fields: the button above submits it */
.due-close {
  min-height: 44px; min-width: 44px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  font: 700 14px/1 var(--f-body); letter-spacing: 0.01em; color: var(--alert); background: rgba(179, 38, 30, 0.08);
  border: 1px solid rgba(179, 38, 30, 0.34); touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: background .25s var(--ease), transform .25s var(--ease);
}
.due-close:hover { background: rgba(179, 38, 30, 0.14); }
.due-close:active { transform: scale(0.97); }
.due-close:disabled { opacity: 0.6; cursor: default; }
.due-close:focus-visible { outline: 3px solid currentColor; outline-offset: 2px; }
.due-overlay .due-close { color: #FFFDF8; background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.5); }
.due-overlay .due-close:hover { background: rgba(255, 255, 255, 0.26); }
.due-close-tap { display: none; }
@media (hover: none) and (pointer: coarse) { .due-close-click { display: none; } .due-close-tap { display: inline; } }
/* Short pictures (phones under 700px tall): the label is one row, sentence left and button right, so the whole
   sentence and the 44px button fit inside the picture strip. If they still cannot (very small phones), parts.js
   shows the label in the page flow instead of clipping it. */
@media (max-height: 700px) {
  .due-overlay { top: 4px; bottom: 4px; left: 8px; right: 8px; flex-direction: row; align-items: center; gap: 6px; padding: 0 4px 0 12px; font-size: 13px; line-height: 1.25; }
  .due-overlay-text { flex: 1 1 auto; min-width: 0; padding-right: 0; }
  .due-close-row { flex: none; margin: 0; }
  .due-close { padding: 0 12px; font-size: 13px; }
}
.due-short:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .due-short.due-arrive { animation: none; } .due-close { transition: none; } }

.parts-deck:not([hidden]) + .parts-tail { padding-top: 0; }

/* "Decide this first" tab removed (owner 2026-11-17: "It still doesn't align like I'd like it to. I think we could remove
   the tab feature."). Waiting cards are still ordered most urgent first (.prioritized); the red deadline label on each
   card says when to decide. */
