:root {
  color-scheme: light;
  /* Собственные пары цветов: hint/button произвольной темы не гарантируют AA. */
  --bg: #f6f4ef;
  --text: #182e2c;
  --muted: #425b55;
  --panel: #ffffff;
  --soft: #e8eee9;
  --border: #c1cec6;
  --accent: #225b4e;
  --on-accent: #ffffff;
  font: 16px/1.5 system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #142320;
  --text: #f2f5f1;
  --muted: #c1d0c8;
  --panel: #20352e;
  --soft: #2c4339;
  --border: #546f61;
  --accent: #b4dfc7;
  --on-accent: #142320;
}
* { box-sizing: border-box; }
.tryon-image { display: block; width: 100%; height: auto; object-fit: contain; }
#tryon-choices label { display: block; margin: 8px 0; }
#tryon select { max-width: 100%; }
#tryon-results button { width: 100%; margin: 4px 0; }
.legacy-choice { display: none; }
body:has(#legacy-mock[open]) .legacy-choice { display: block; }
body { margin: 0; }
main { max-width: 1120px; margin: auto; padding: 12px 12px 24px; padding-top: max(12px, var(--tg-content-safe-area-inset-top, 0px)); overflow-wrap: anywhere; }
.eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .1em; margin: 0; }
.eyebrow span { display: inline-block; margin-left: 6px; border: 1px solid var(--muted); padding: 1px 5px; border-radius: 4px; font-size: .6875rem; letter-spacing: .05em; }
h1 { font-size: 1.625rem; line-height: 1.15; letter-spacing: -.025em; margin: 10px 0; }
.catalog-notes { padding: 10px 12px; background: var(--soft); border-radius: 10px; }
.notice, .disclosure, footer p { color: var(--muted); font-size: .8125rem; line-height: 1.45; }
.notice { margin: 0; }
.disclosure { margin: 6px 0 0; }
#status { font-size: .8125rem; color: var(--muted); min-height: 1.5em; margin: 10px 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 10rem), 1fr)); gap: 12px; align-items: stretch; }
.card { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--panel); min-width: 0; }
.media { width: 100%; aspect-ratio: 4/5; max-height: 15rem; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; background: var(--soft); }
.media img { width: 100%; height: 100%; object-fit: contain; grid-area: 1/1; }
/* Текст не растягивается до высоты фото, в том числе при ошибке загрузки. */
.media:has(.fallback) { aspect-ratio: 4/5; }
.fallback { margin: 0; padding: 12px; color: var(--muted); font-size: .8125rem; line-height: 1.45; }
.card-body { padding: 12px; }
h2 { font-size: 1rem; margin: 0 0 6px; line-height: 1.3; }
.description { margin: 0; font-size: .875rem; line-height: 1.45; }
.presets { font-size: .8125rem; line-height: 1.5; color: var(--muted); margin: 8px 0 0; }
button { font: inherit; font-weight: 600; background: var(--accent); color: var(--on-accent); border: 1px solid var(--accent); border-radius: 10px; padding: 10px 16px; min-height: 48px; max-width: 100%; overflow-wrap: anywhere; cursor: pointer; }
button:disabled { cursor: wait; }
button:focus-visible { outline: 3px solid var(--text); outline-offset: 4px; }
.actions { text-align: center; margin: 16px 0; }
.actions:has(button[hidden]) { display: none; }
.secondary { background: var(--panel); color: var(--text); border-color: var(--muted); width: 100%; }
footer { padding-top: 16px; text-align: center; padding-bottom: var(--tg-content-safe-area-inset-bottom, 0px); }
footer p { margin: 8px 0 0; }
[hidden] { display: none !important; }
@media (min-width: 640px) {
  main { padding-inline: 20px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); gap: 16px; }
}

/* 04.3-Б2: compact controls; the accepted catalog grid/media rules stay unchanged. */
.consultation { margin: 10px 0; padding: 10px 12px; background: var(--soft); border-radius: 10px; }
#consultation-status { margin: 0; font-size: .875rem; }
#selection-name { margin: 6px 0; font-weight: 600; }
.selection-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.selection-actions button { flex: 1 1 10rem; padding: 8px 10px; }
.card.selected { outline: 3px solid var(--accent); outline-offset: -3px; }
.card select { display: block; width: 100%; min-width: 0; min-height: 48px; margin-top: 8px; font: inherit; font-size: .875rem; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
.choose { width: 100%; margin-top: 8px; padding: 8px; font-size: .875rem; }
button:disabled, select:disabled { opacity: .65; cursor: default; }
#mock-image img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
}

/* 04.7 UX: shared row sizing; full text stays available in details. */
#catalog .card { display: flex; flex-direction: column; height: 100%; }
#catalog .media { flex: 0 0 auto; aspect-ratio: 4/5; max-height: none; }
#catalog .card-body { display: flex; flex-direction: column; flex: 1; }
#catalog h2 { min-height: 2.6em; }
#catalog .description { min-height: 4.35em; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
#catalog .description-details { margin: 6px 0; font-size: .8125rem; }
#catalog .choose:not(.legacy-choice) { margin-top: auto; }
#catalog select, .preset-placeholder { min-height: 48px; margin: 8px 0; }
.preset-placeholder { font-size: .8125rem; color: var(--muted); }
.selection-count { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 8px 0; margin: 8px 0; font-weight: 600; }
body[data-role="master"] #catalog, body[data-role="master"] #selection-count { display: none; }
#tryon-choices, #tryon-results { margin-top: 12px; }
.decision-buttons { display: grid; gap: 6px; }
.decision-buttons button { font-size: .8125rem; text-align: left; }
button[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }
details { margin: 12px 0; }
summary { cursor: pointer; min-height: 40px; padding-block: 8px; }

.selection-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 8px 0; }
.selection-toolbar p { margin: 0; white-space: nowrap; font-weight: 600; }
.selection-toolbar button { padding: 8px 12px; font-size: .875rem; }
body[data-role="master"] .selection-toolbar { display: none; }

#catalog .choose { min-height: 64px; line-height: 1.2; }
body:has(#legacy-mock[open]) #catalog .choose:not(.legacy-choice) { display: none; }

/* Before client consent, show only the invitation; catalog layout is unchanged. */
body[data-onboarding="true"] main > :not(#invitation) { display: none; }
#invitation label { display: flex; align-items: flex-start; gap: .6rem; margin: 1rem 0; }
#invitation input[type="checkbox"] { flex: 0 0 auto; width: 1.2rem; height: 1.2rem; margin-top: .15rem; }
#invitation details { margin-top: 1rem; }
#invitation details p { white-space: pre-line; overflow-wrap: anywhere; }

/* Equal review rows, including text-only cards and wrapped decision labels. */
#tryon-choices { align-items: stretch; grid-auto-rows: 1fr; }
.review-card { display: flex; flex-direction: column; min-width: 0; height: 100%; }
.review-card .media { aspect-ratio: 4/5; flex: 0 0 auto; max-height: none; }
.review-card .card-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.review-card .decision-buttons { margin-top: auto; padding-top: .5rem; }
.review-card .decision-buttons button { min-height: 6em; white-space: normal; overflow-wrap: anywhere; }

body[data-tryon-phase="results"] #catalog, body[data-tryon-phase="results"] .selection-toolbar { display: none; }

/* Variant B: shared content tracks, with natural text height and no clipping. */
#tryon-choices { grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); grid-auto-rows: auto; }
#tryon-results { grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.result-card { display: flex; flex-direction: column; gap: .6rem; }
.result-card h3, .result-card p { margin: 0; }
.result-controls { margin-top: auto; }
.result-media { max-height: none; aspect-ratio: 4/5; }
@supports (grid-template-rows: subgrid) {
  .review-card { display: grid; grid-template-rows: subgrid; grid-row: span 5; gap: .6rem; padding: 12px; }
  .review-card .card-body { display: contents; }
  .review-card .decision-buttons { margin-top: 0; }
  .result-card { display: grid; grid-template-rows: subgrid; grid-row: span 6; }
}
.comparison { width: min(94vw, 56rem); max-height: 90dvh; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); color: var(--text); padding: 12px; }
.comparison::backdrop { background: #0009; }
.comparison-frames { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.comparison figure { margin: 0; min-width: 0; }
.comparison figcaption { font-weight: 600; text-align: center; }
.comparison img { display: block; width: 100%; height: 60dvh; object-fit: contain; }
.comparison-switches { display: none; gap: 8px; }
@media (max-width: 34rem) {
  .comparison-frames { grid-template-columns: minmax(0, 1fr); }
  .comparison-switches { display: flex; }
  .comparison[data-compare-side="before"] .compare-after,
  .comparison[data-compare-side="after"] .compare-before { display: none; }
}

/* Ordinary phones keep two compact columns independently of root font scaling. */
@media (min-width: 340px) and (max-width: 639px) {
  #tryon-choices, #tryon-results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-card, .result-card { padding: 6px; gap: 6px; }
  .review-card .decision-buttons button { min-height: 3.75em; line-height: 1.25; padding: 6px 4px; }
  .result-card button { padding: 8px 6px; font-size: .875rem; }
}
@media (max-width: 339px) {
  #tryon-choices, #tryon-results { grid-template-columns: minmax(0, 1fr); }
}

/* Only the selected final bundle uses the full content width. */
#tryon-results[data-view="selected"] { display: block; }
.final-viewer { display: grid; gap: 12px; min-width: 0; }
.final-viewer > h2, .final-viewer > p { margin: 0; }
.final-viewer .final-image { display: block; width: 100%; padding: 0; border: 0; border-radius: 10px; background: var(--panel); overflow: hidden; }
.final-image img { display: block; width: 100%; height: auto; object-fit: contain; }
.angle-switches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 4px; }
.angle-switches button { min-width: 0; padding: 8px 4px; font-size: .875rem; line-height: 1.25; }
.final-decisions { display: grid; gap: 12px; min-width: 0; }
.final-decisions:empty { display: none; }
.final-decisions select { min-width: 0; width: 100%; }
.result-zoom { width: calc(100vw - 16px); max-width: 70rem; max-height: 96dvh; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); overflow-y: auto; }
.result-zoom::backdrop { background: #000c; }
.result-zoom h2 { margin: 0 0 8px; }
.result-zoom button { width: 100%; margin-bottom: 8px; }
.result-zoom img { display: block; width: 100%; height: auto; max-height: 78dvh; object-fit: contain; }
