/* ---- Phase 4: paints, per-paint results, summary ---- */
:root { --info: #174a46; }
@media (prefers-color-scheme: dark) { :root[data-theme="system"] { --info: #a8e0da; } }
:root[data-theme="dark"] { --info: #a8e0da; }

/* Info buttons: darker glyph and a ring so they read as buttons. */
.info-btn { color: var(--info); font-weight: 700; font-size: 1.45rem; }
.info-btn:hover { background: var(--bg); }
.hint { margin: -4px 0 8px; }

.swatch { display: inline-block; flex: none; width: 1.3em; height: 1.3em; border-radius: 4px; border: 1px solid var(--border); vertical-align: middle; }
.swatch.big { width: 44px; height: 44px; border-radius: 8px; }
.swatch.none { background: repeating-linear-gradient(45deg, transparent 0 4px, var(--border) 4px 6px); }

.print-btn { margin-top: 8px; width: 100%; }
@media (min-width: 900px) { .print-btn { width: auto; } }

.warn.fix { border-left-color: var(--danger); font-weight: 600; }
.notice-inline { margin-bottom: 12px; }
.item-grid.excl .field-err, .field-err { overflow-wrap: anywhere; }

/* results by paint */
/* scroll-margin keeps the heading clear of the sticky top bar */
.buy-h { scroll-margin-top: 70px; margin: 16px 0 0; padding-top: 12px; border-top: 2px solid var(--text); font-size: 1.05rem; }
.caveat { margin-top: 8px; }
.room-paints { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 4px; }
.room-paints li { display: flex; align-items: flex-start; gap: 8px; font-size: 0.9rem; }
.room-paints .swatch { margin-top: 3px; }

/* my paints */
.paint-grid { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.paint-card { margin: 0; }
.paint-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.paint-head .swatch { width: 52px; height: 52px; }
.paint-title { min-width: 0; }
.paint-title h2 { margin: 0; overflow-wrap: anywhere; }
.paint-title h2 a { color: var(--text); text-decoration: none; }
.paint-title h2 a:hover { text-decoration: underline; }
.paint-title p { margin: 0; }
.used-in { overflow-wrap: anywhere; }
.paint-screen .card h2 { margin-bottom: 12px; }
.colour-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; margin-bottom: 8px; }
.colour-row .swatch.big { width: 64px; height: 64px; }
.item-grid.tin { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.item-grid.tin .remove { grid-column: 1 / -1; }
.item-grid.tin .field-label { min-height: 1.4em; }
input[type="date"].input { min-width: 11em; }

/* tables: stacked labelled lines on narrow screens */
.tbl { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.8rem; padding: 4px 8px 6px 0; border-bottom: 2px solid var(--border); }
.tbl td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.tbl tfoot td { border-top: 2px solid var(--text); border-bottom: 0; font-weight: 700; }
.paint-cell { display: inline-flex; align-items: flex-start; gap: 8px; }
.paint-cell .swatch { margin-top: 2px; }
.cell-fig { display: inline-flex; align-items: center; gap: 2px; }
@media screen and (min-width: 560px) { .cell-fig { white-space: nowrap; } }
@media print { .cell-fig { white-space: nowrap; } }
.cell-fig .info-btn { width: 36px; height: 36px; margin: -6px 0; }
.print-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; }
.print-row .select { min-width: 12em; }
.summary-rooms { display: grid; gap: 0; }
.summary-rooms h3 { margin: 0 0 8px; }
.by-room-h { margin: 8px 0 12px; }
.room-swatches { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 16px; }
.room-swatches li { display: inline-flex; align-items: center; gap: 8px; }
.saving { margin-top: 12px; }
.rooms-note { margin: -4px 0 12px; }
@media (max-width: 479px) {
  .pc-facts span { display: block; }
  .pc-facts .sep { display: none; }
}

@media screen and (max-width: 559px) {
  .tbl, .tbl tbody, .tbl tfoot, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tbl tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
  .tbl td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .tbl td::before { content: attr(data-label); color: var(--muted); text-align: left; flex: none; }
  .tbl td.first { font-weight: 600; justify-content: flex-start; text-align: left; }
  .tbl td.first::before { content: none; }
  .tbl td:empty { display: none; }
  .tbl tfoot tr { border-top: 2px solid var(--text); border-bottom: 0; }
}
@media (min-width: 600px) {
  .paint-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item-grid.tin { grid-template-columns: 1fr 1fr auto; }
  .item-grid.tin .remove { grid-column: auto; }
}
@media (min-width: 900px) {
  .paint-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

#add-tin { margin-bottom: 12px; }

/* ---- house overview grid ---- */
.overview th.ov-head { vertical-align: bottom; }
.ov-colour { display: inline-flex; align-items: flex-start; gap: 6px; font-weight: 600; }
.ov-uses { font-size: 0.88rem; }
.ov-cell-name { display: none; }
@media screen and (max-width: 559px) {
  /* Oliver 21/10/2026: a colour square beside each colour name in the stacked phone layout */
  .overview td::before { content: none; }
  .overview .ov-cell-name { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); text-align: left; }
  .overview .ov-cell-name .swatch { flex: none; }
}

/* ---- Suggest paint panel (Phase 9) ---- */
.dlg.dlg-wide { width: min(760px, calc(100vw - 24px)); }
.sp-head { display: grid; grid-template-columns: 35% minmax(0, 1fr); gap: 12px; align-items: center; margin-bottom: 10px; border: 2px solid var(--border); border-radius: 10px; overflow: hidden; }
.sp-head p { margin: 0; }
.sp-target { display: block; align-self: stretch; width: auto; height: auto; min-height: 96px; border: 0; border-radius: 0; border-right: 1px solid var(--border); }
.sp-head-text { padding: 8px 10px 8px 0; min-width: 0; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 14px; border: 2px solid var(--border); border-radius: 22px; background: var(--surface); color: var(--text); font: inherit; font-size: 0.92rem; cursor: pointer; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.chip[disabled] { opacity: 0.6; cursor: default; }
.chip.all { border-style: dashed; }
.sp-filters { display: grid; gap: 4px; margin-bottom: 10px; }
.sp-filters p { margin: 0; }
.sp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sp-row { display: grid; grid-template-columns: 35% minmax(0, 1fr); gap: 12px; align-items: stretch; padding: 0; overflow: hidden; border: 2px solid var(--border); border-radius: 10px; cursor: pointer; }
.sp-row.sel { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); }
.sp-row .sp-info-col { align-self: center; padding: 6px 10px 6px 0; min-width: 0; }
@media (min-width: 600px) { .sp-row, .sp-head { grid-template-columns: 160px minmax(0, 1fr); } }
.sp-row:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.sp-marks { color: var(--accent); font-weight: 700; }
.sp-pair { display: flex; min-height: 96px; border: 0; border-right: 1px solid var(--border); }
.sp-half { flex: 1; }
.sp-info-col p { margin: 0; }
.sp-name { overflow-wrap: anywhere; }
.sp-sub, .sp-price { line-height: 1.35; }
.sp-label.l-indistinguishable, .sp-label.l-very-close { font-weight: 700; color: var(--accent); }
.sp-notes { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 8px; }
.sp-notes p { margin: 0 0 4px; }
.paint-meta-line { margin: 0; }
.pc-badges { margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 4px 6px; }
.pc-badges .badge { padding: 1px 8px; max-width: 100%; overflow-wrap: anywhere; line-height: 1.35; }
.range-select { margin-bottom: 8px; }
.badge { display: inline-block; padding: 0 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 0.78rem; font-weight: 700; }
.badge[hidden] { display: none; }

/* ---- Phase 11: Paint matches chips and actions ---- */
.chips { align-items: center; gap: 6px; }
.chip { min-height: 40px; padding: 0 12px; }
.chip.dim { color: var(--muted); background: var(--bg); border-color: var(--border); font-weight: 400; opacity: 0.8; }
.chip.dim:hover { opacity: 1; border-color: var(--accent); }
.sp-brand-info { width: 40px; height: 40px; }
.sp-act { min-height: 36px; padding: 0 10px; font-size: 0.85rem; }
.sp-err { grid-column: 1 / -1; margin: 0; }
@media (max-width: 599px) { .sp-act, .chip { min-height: 44px; } .sp-brand-info { width: 44px; height: 44px; } }
/* D87: one sticky action bar (the dialog footer) for the selected paint; two rows on a phone */
.sp-bar { flex: 1; display: grid; gap: 6px; min-width: 0; }
.sp-bar p { margin: 0; }
.sp-bar-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.sp-bar-btns .sp-act, .sp-bar-btns .sp-done { flex: 1 1 auto; justify-content: center; }
@media (max-width: 599px) { .sp-bar-btns .sp-act, .sp-bar-btns .sp-done { flex: 1 1 30%; } }
.sp-done { display: inline-flex; align-items: center; min-height: 36px; padding: 0 10px; color: var(--muted); font-size: 0.88rem; font-weight: 600; }
.sp-live { margin: 0 0 6px; min-height: 1.2em; color: var(--muted); }
@media (max-width: 699px) { .sp-done { min-height: 44px; } }

/* D109: Region dropdown at the top of Paint matches */
.sp-region { max-width: 260px; margin-bottom: 6px; }
.paints-region { margin: 0 0 10px; }

/* D120: Paint matches fits results on a phone */
.sp-line { display: flex; flex-wrap: wrap; align-items: end; gap: 0 16px; }
.sp-line .sp-region { margin-bottom: 0; flex: 0 1 auto; }
.sp-line .sp-brand-info { flex: none; align-self: center; }
.chips.sp-extra { padding-top: 6px; border-top: 1px dashed var(--border); }
.chip.more { border-style: dashed; color: var(--text); font-weight: 600; }
.sp-head-info { display: none; }
.sp-head .sp-hex { display: none; }
@media (max-width: 599px) {
  .sp-head { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; margin-bottom: 6px; min-height: 44px; }
  .sp-target { min-height: 44px; }
  .sp-head-text { padding: 4px 0; }
  .sp-head .sp-hex { display: inline; }
  .sp-head .sp-desc, .sp-head .sp-subtitle, .sp-head .sp-current { display: none; }
  .sp-head-info { display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center; }
  .sp-filters { margin-bottom: 6px; }
  .sp-live { margin-bottom: 2px; min-height: 0; }
  .sp-region .select { min-height: 44px; }
}
.sp-line .sp-region { display: flex; align-items: center; gap: 8px; max-width: none; }
.sp-line .sp-region .field-label { margin: 0; flex: none; }
.sp-line .sp-region .select { width: auto; min-width: 5.5em; }
@media (max-width: 599px) {
  .sp-line { gap: 0 10px; }
  .sp-line .sp-region .select { min-height: 40px; padding-inline: 8px; }
  .sp-filters .chip, .sp-filters .sp-brand-info { min-height: 40px; }
  .sp-filters .sp-brand-info { width: 40px; height: 40px; }
  .sp-filters .chip { padding: 0 11px; font-size: 0.88rem; }
  .sp-head-info { width: 40px; height: 40px; margin-right: 2px; }
}
.sp-line .sp-region .select { flex: none; width: auto; min-width: 0; } /* sized by the longest option, so "Australia & NZ" fits */
@media (max-width: 599px) { .sp-line .sp-region .select { padding-inline: 8px 2px; } }
@media (max-width: 599px) {
  .sp-line { gap: 0 8px; }
  .sp-line .sp-region { gap: 6px; }
  .sp-line .sp-region .field-label { font-size: 0.8rem; }
}

/* ---- All paints page (D177 to D181) ---- */
.browse-screen { padding-bottom: 8px; }
.br-intro { margin-bottom: 10px; }
.br-search-field { max-width: 420px; margin-bottom: 10px; }
.br-search-field .input { width: 100%; }
.browse-screen .sp-filters { margin-bottom: 10px; }
.browse-screen .sp-filters .chip, .browse-screen .sp-filters .sp-brand-info { min-height: 44px; }
.browse-screen .sp-filters .sp-brand-info { width: 44px; height: 44px; }
.browse-screen .sp-line .sp-region .select { min-height: 44px; }
.br-toggle { display: none; margin-bottom: 8px; }
.br-rows { display: grid; gap: 8px; margin-bottom: 12px; }
.br-row { display: grid; gap: 2px; }
.br-row-label { color: var(--muted); font-weight: 600; }
@media (min-width: 700px) {
  .br-row { grid-template-columns: 9em minmax(0, 1fr); align-items: center; gap: 8px; }
}
@media (max-width: 699px) {
  .br-toggle { display: inline-flex; }
  .br-rows:not(.open) { display: none; }
  .browse-screen .chip { min-height: 44px; }
}
.br-sortline { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 16px; margin-bottom: 8px; }
.br-sort { display: flex; align-items: center; gap: 8px; margin: 0; }
.br-sort .field-label { margin: 0; }
.br-sort .select { width: auto; }
.br-clear[hidden] { display: none; }
.br-count { margin: 0 0 8px; font-weight: 600; }
.br-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 600px) { .br-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .br-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.br-card { display: flex; flex-direction: column; overflow: hidden; border: 2px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; }
.br-card.sel { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); }
.br-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.br-swatch { display: block; height: 72px; border-bottom: 1px solid var(--border); }
.br-info { padding: 6px 8px 8px; min-width: 0; }
.br-info p { margin: 0; line-height: 1.3; overflow-wrap: anywhere; }
.br-marks:empty { display: none; }
.br-more-wrap { text-align: center; margin: 12px 0; }
.br-empty { padding: 16px 0; }
.br-bar { position: sticky; bottom: 0; z-index: 5; margin: 12px calc(var(--gutter) * -1) -32px; padding: 8px var(--gutter) calc(8px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 2px solid var(--accent); box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.12); }
.br-bar[hidden] { display: none; }
.br-live:empty { display: none; }
.br-bar .sp-act { min-height: 44px; }
@media (min-width: 600px) { .br-bar .sp-bar-btns .sp-act, .br-bar .sp-bar-btns .sp-done { flex: 0 0 auto; padding: 0 18px; } }

/* ---- D220: remove paints in bulk ---- */
.pr-bar { margin: 0 0 12px; }
.pr-status { margin: 0 0 12px; font-weight: 600; }
.pr-quick { margin-bottom: 10px; }
.pr-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.pr-opt { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 8px 10px; border: 2px solid var(--border); border-radius: 10px; cursor: pointer; }
.pr-opt input { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--accent); }
.pr-opt:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 1px; }
.pr-text { min-width: 0; overflow-wrap: anywhere; }
.pr-count { margin: 0 0 8px; font-weight: 600; }
.pr-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
@media (min-width: 600px) { .pr-opt { min-height: 32px; padding: 4px 10px; } .pr-opt input { width: 20px; height: 20px; } }

/* D220 amended: Remove all paints first, then the keep list (greyed out while Remove all paints is ticked) */
.pr-all { margin: 4px 0 10px; }
.pr-keep-h { margin: 0 0 6px; }
.pr-keep.is-off { opacity: 0.5; }

/* ---- D251: Summary on phones (top card, view toggle, jump links, collapsible rooms) ---- */
.summary-screen [id^="sum-"], .summary-screen #overview { scroll-margin-top: calc(var(--bar-h) + 12px); }
.top-card h2 { margin-bottom: 8px; }
.top-figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; margin: 0 0 8px; }
.top-fig dt { color: var(--muted); font-size: 0.8rem; }
.top-fig dd { margin: 0; font-weight: 700; font-size: 1.1rem; overflow-wrap: anywhere; }
.top-note { display: block; font-weight: 400; font-size: 0.8rem; }
.top-rooms { margin: 0 0 4px; }
@media (max-width: 559px) { .top-figs { grid-template-columns: 1fr; } .top-fig { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; } .top-fig dd { text-align: right; } }
.view-toggle { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin: 0 0 12px; }
.view-opt { flex: 1; min-height: 44px; padding: 0 8px; border: 0; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.view-opt + .view-opt { border-left: 1px solid var(--border); }
.view-opt[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.view-opt:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.sum-jumps { display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 0 0 12px; }
.sum-jump { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 22px; background: var(--surface); color: var(--accent); font-size: 0.92rem; white-space: nowrap; text-decoration: none; }
.sum-jump:hover { border-color: var(--accent); background: var(--accent-soft); }
.sum-jump-room { color: var(--text); }
.size-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; color: var(--accent); font-weight: 600; }
.no-sizes { margin: 0 0 8px; }
.room-toggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 44px; padding: 0 4px; border: 0; background: none; color: inherit; font: inherit; font-weight: 700; text-align: left; cursor: pointer; border-radius: 8px; }
.room-toggle:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.room-chevron { flex: none; width: 10px; height: 10px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform 0.15s; margin-right: 4px; }
.room-toggle[aria-expanded="true"] .room-chevron { transform: rotate(-135deg); }
.summary-rooms .sum-room h3 { margin: 0; }
.room-body { margin-top: 8px; }
.room-body[hidden] { display: none; }
/* Shopping list only: the top card and the whole-house paint list, compact */
.summary-screen.shop-only .sum-full { display: none; }
.summary-screen.shop-only td[data-label="Rooms and surfaces"] { display: none; }
@media screen and (min-width: 560px) { .summary-screen.shop-only th:nth-child(2) { display: none; } }
