/* Hallmark · shape: app screen · genre: modern-minimal · theme: custom, Telegram's own theme parameters (the brief: «Тема берётся из Telegram»)
 * nav: bottom tab bar with a sticky order strip · signature: the budget meter, price and repair against the 19,5 million line, coloured by verdict · states: loading, empty, error, full · modes: whatever Telegram sends, light and dark fallbacks
 * axes: native/neutral/photo-led · posture: restrained · contrast: pass · v2.0.0 */
/* Hallmark · pre-emit critique: P4 H4 E4 S4 R4 V4 · weakest: V, a Telegram-coloured screen has little colour of its own, so the photo and the meter carry it */
/* Hallmark · answered F4 · the accent marks the current order and pressed controls as app state; each screen has one filled button */
/* Hallmark · answered F7 · controls are pills; the badge is a count on one */
@import url("./tokens.css");
@import url("./base.css");

@font-face { font-family: "Golos Text"; src: url("./fonts/golos-cyrillic.woff2") format("woff2"); font-weight: 400 900; font-display: swap; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos Text"; src: url("./fonts/golos-latin.woff2") format("woff2"); font-weight: 400 900; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+20BD, U+2122, U+2212; }

:root {
  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px));
  --tab-height: 56px;
  --column: 40rem;
  --edge: var(--space-md);
  --hit: 44px;
  --chip: 36px;
}

html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
html.locked, html.locked body { overflow-y: hidden; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button { color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
h1, h2, h3 { max-width: none; overflow-wrap: break-word; min-width: 0; }
.sprite { position: absolute; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* top: the title scrolls away, the orders stay */
.bar { background: var(--color-paper); padding-top: var(--safe-top); }
.bar-top, .strip-in, .page { max-width: var(--column); margin-inline: auto; }
.bar-top { padding: var(--space-sm) var(--edge) 0; }
.bar h1 { font-size: var(--text-xl); line-height: 1.2; }
.link-quiet { display: block; width: 100%; min-height: 28px; overflow: hidden; color: var(--color-muted); font-size: var(--text-sm); text-align: left; white-space: nowrap; text-overflow: ellipsis; }
.link-quiet em { color: var(--color-error); font-style: normal; }
.strip { position: sticky; top: var(--safe-top); z-index: var(--z-sticky-nav); background: var(--color-paper); }
.strip-in { display: flex; align-items: center; gap: var(--space-xs); padding: var(--space-xs) 0 var(--space-xs) var(--edge); }
.strip-note { flex: 1; color: var(--color-muted); font-size: var(--text-sm); }
.filter-open { position: relative; flex: none; display: grid; place-items: center; width: var(--chip); height: var(--chip); border-radius: var(--radius-pill); background: var(--color-soft); }
.filter-open .icon { width: 20px; height: 20px; }
.filter-open span { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding-inline: var(--space-2xs); border-radius: var(--radius-pill); background: var(--color-accent); color: var(--color-accent-ink); font-size: var(--text-xs); font-weight: 600; line-height: 18px; text-align: center; }
.orders { flex: 1; min-width: 0; display: flex; gap: var(--space-xs); padding-right: var(--edge); overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
.orders::-webkit-scrollbar { display: none; }
.orders button { flex: none; height: var(--chip); padding-inline: var(--space-sm); border-radius: var(--radius-pill); background: var(--color-soft); color: var(--color-ink-2); font-size: var(--text-sm); font-weight: 500; white-space: nowrap; }
.orders button[aria-selected="true"] { background: var(--color-accent); color: var(--color-accent-ink); }
.orders small { font-size: var(--text-xs); font-variant-numeric: tabular-nums; opacity: 0.7; }

/* feed: no boxes, the photo and the space around it hold each flat together */
.page { padding: var(--space-2xs) 0 calc(var(--tab-height) + var(--safe-bottom) + var(--space-lg)); }
.flat { display: block; padding-bottom: var(--space-xl); }
.flat-body { padding: var(--space-sm) var(--edge) 0; cursor: pointer; }
.photos { position: relative; margin-inline: var(--edge); border-radius: var(--radius-card); overflow: hidden; background: var(--color-paper-3); }
.sheet .photos { margin-inline: 0; border-radius: 0; }
.shots { display: flex; aspect-ratio: 4 / 3; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
.shots::-webkit-scrollbar { display: none; }
.shots img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: cover; scroll-snap-align: start; scroll-snap-stop: always; cursor: pointer; }
.shots-empty { display: grid; place-items: center; aspect-ratio: 4 / 3; color: var(--color-muted); font-size: var(--text-sm); }
.shot-count, .tag { position: absolute; padding: var(--space-3xs) var(--space-xs); border-radius: var(--radius-pill); background: var(--color-scrim); color: var(--color-on-photo); font-size: var(--text-xs); font-weight: 500; line-height: 1.5; font-variant-numeric: tabular-nums; pointer-events: none; }
.shot-count { right: var(--space-xs); bottom: var(--space-xs); }
.tags { position: absolute; left: var(--space-xs); top: var(--space-xs); display: flex; gap: var(--space-2xs); pointer-events: none; }
.tag { position: static; }
.tag-fresh { background: var(--color-accent); color: var(--color-accent-ink); }

.head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-sm); }
.head-main { min-width: 0; }
.head h2 { margin-top: var(--space-3xs); font-family: var(--font-body); font-size: var(--text-md); font-weight: 500; letter-spacing: 0; line-height: 1.3; text-wrap: pretty; }
.grade { flex: none; display: grid; justify-items: end; padding-top: var(--space-2xs); line-height: 1.15; }
.grade b { font-size: var(--text-md); font-weight: 600; font-variant-numeric: tabular-nums; }
.grade small { color: var(--color-muted); font-size: var(--text-xs); }
.price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-xs); }
.price b { font-size: var(--text-xl); font-weight: 700; letter-spacing: var(--tracking-display); line-height: 1.25; font-variant-numeric: tabular-nums; }
.price span { color: var(--color-muted); font-size: var(--text-sm); }
.price .drop { color: var(--color-success); }

/* facts: the number first, its name under it */
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-xs); margin: var(--space-sm) 0 0; }
.facts div { display: flex; flex-direction: column-reverse; }
.facts dt { color: var(--color-muted); font-size: var(--text-xs); line-height: 1.35; }
.facts dd { margin: 0; font-size: var(--text-sm); font-weight: 600; line-height: 1.35; font-variant-numeric: tabular-nums; white-space: nowrap; }
.station { margin-top: var(--space-sm); font-size: var(--text-sm); }
.station b { font-weight: 500; }
.station span { color: var(--color-muted); }

/* the budget meter */
.budget { margin-top: var(--space-sm); padding: var(--space-sm); border-radius: var(--radius-inner); background: var(--color-soft); }
.total { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2xs) var(--space-sm); }
.total b { font-weight: 600; font-variant-numeric: tabular-nums; }
.verdict { padding: var(--space-3xs) var(--space-xs); border-radius: var(--radius-pill); background: color-mix(in oklab, var(--verdict) 16%, transparent); color: var(--verdict); font-size: var(--text-xs); font-weight: 600; line-height: 1.5; white-space: nowrap; }
.verdict-fits, .ruler-fits { --verdict: var(--color-success); }
.verdict-edge, .ruler-edge { --verdict: var(--color-warn); }
.verdict-over, .ruler-over { --verdict: var(--color-error); }
.ruler { position: relative; height: 32px; margin-top: var(--space-2xs); }
.ruler-track, .ruler-price, .ruler-work, .ruler-range { position: absolute; top: 20px; height: 8px; }
.ruler-track { inset-inline: 0; border-radius: var(--radius-pill); background: var(--color-paper-3); }
.ruler-price { left: 0; border-radius: var(--radius-pill) 0 0 var(--radius-pill); background: var(--verdict); }
.ruler-work { background: color-mix(in oklab, var(--verdict) 62%, var(--color-paper-3)); }
.ruler-range { border-radius: 0 var(--radius-pill) var(--radius-pill) 0; background: color-mix(in oklab, var(--verdict) 30%, var(--color-paper-3)); }
.ruler-line { position: absolute; top: 16px; height: 16px; width: 2px; margin-left: -1px; border-radius: var(--radius-pill); background: var(--color-ink); }
.ruler-limit { width: 0; margin-left: 0; border-left: 2px dotted var(--color-muted); border-radius: 0; background: none; }
.ruler-mark { position: absolute; top: -2px; transform: translateX(-50%); color: var(--color-muted); font-size: var(--text-xs); line-height: 1.4; font-variant-numeric: tabular-nums; white-space: nowrap; }
.repair { margin-top: var(--space-2xs); color: var(--color-muted); font-size: var(--text-sm); }

.acts { display: flex; gap: var(--space-xs); padding: var(--space-xs) var(--edge) 0; }
.act { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2xs); min-width: 56px; height: var(--hit); padding-inline: var(--space-sm); border-radius: var(--radius-pill); background: var(--color-soft); color: var(--color-ink); font-size: var(--text-sm); font-weight: 500; font-variant-numeric: tabular-nums; }
.act-wide { flex: 1; }
.act:active { background: var(--color-paper-3); }
.act[aria-pressed="true"] { background: var(--color-accent); color: var(--color-accent-ink); }
.act[aria-pressed="true"] .icon-fill { fill: currentColor; }
.act:disabled { opacity: 0.55; cursor: not-allowed; }
@media (hover: hover) { .act:hover, .orders button:hover, .filter-open:hover { filter: brightness(1.08); } }

/* states */
.state { display: grid; justify-items: center; gap: var(--space-sm); padding: var(--space-2xl) var(--space-lg); text-align: center; }
.state h2 { font-size: var(--text-xl); }
.state p { color: var(--color-muted); }
.skeleton { border-radius: var(--radius-inner); background: var(--color-paper-3); animation: breathe 1.4s var(--ease-in-out) infinite alternate; }
.skeleton-photo { aspect-ratio: 4 / 3; margin-inline: var(--edge); border-radius: var(--radius-card); }
.skeleton-line { height: 16px; margin: var(--space-sm) var(--edge) 0; }
.skeleton-line.short { width: 45%; }
@keyframes breathe { from { opacity: 1; } to { opacity: 0.55; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs); min-height: var(--hit); padding: 0 var(--space-lg); border-radius: var(--radius-pill); background: var(--color-accent); color: var(--color-accent-ink); font-size: var(--text-sm); font-weight: 600; }
.btn:active { filter: brightness(0.92); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-line { background: var(--color-soft); color: var(--color-ink); }

/* tab bar */
.tabs { position: fixed; inset: auto 0 0; z-index: var(--z-sticky); display: flex; justify-content: center; padding-bottom: var(--safe-bottom); background: var(--color-glass); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); border-top: var(--rule-hair) solid var(--color-rule); }
.tabs button { position: relative; flex: 1; max-width: 10rem; height: var(--tab-height); display: grid; justify-items: center; align-content: center; gap: var(--space-3xs); color: var(--color-muted); font-size: var(--text-xs); font-weight: 500; }
.tabs button[aria-current="page"] { color: var(--color-link); }
.tabs button em { position: absolute; top: var(--space-2xs); left: calc(50% + 8px); min-width: 16px; padding-inline: var(--space-2xs); border-radius: var(--radius-pill); background: var(--color-paper-3); color: var(--color-ink); font-size: 0.6875rem; font-style: normal; line-height: 16px; font-variant-numeric: tabular-nums; }

/* deck */
.deck { position: relative; height: calc(100dvh - var(--deck-top, 84px) - var(--tab-height) - var(--safe-bottom)); display: flex; flex-direction: column; padding: var(--space-xs) var(--edge) var(--space-sm); gap: var(--space-sm); max-width: var(--column); margin-inline: auto; }
.deck-stage { position: relative; flex: 1; min-height: 0; }
.deck-card { position: absolute; inset: 0; display: flex; flex-direction: column; border-radius: var(--radius-sheet); background: var(--color-paper-2); color: var(--color-ink); box-shadow: var(--shadow-card); overflow: hidden; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.deck-card.next { transform: translateY(6px) scale(0.98); }
.deck-card.gone { transition: transform var(--dur-short) var(--ease-out), opacity var(--dur-short) var(--ease-out); }
.deck-photo { position: relative; flex: 1; min-height: 0; background: var(--color-paper-3); }
.deck-photo img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.deck-bars { position: absolute; inset: var(--space-xs) var(--space-xs) auto; display: flex; gap: var(--space-2xs); pointer-events: none; }
.deck-bars i { flex: 1; height: 3px; border-radius: var(--radius-pill); background: var(--color-on-photo); opacity: 0.45; }
.deck-bars i.on { opacity: 1; }
.deck-info { padding: var(--space-sm); cursor: pointer; }
.deck-info .station { margin-top: var(--space-2xs); }
.deck-info .budget { margin-top: var(--space-xs); padding: 0; background: none; }
.stamp { position: absolute; top: var(--space-lg); padding: var(--space-2xs) var(--space-sm); border-radius: var(--radius-pill); background: var(--color-scrim); font-weight: 600; opacity: 0; pointer-events: none; }
.stamp-yes { left: var(--space-md); color: var(--color-on-photo); }
.stamp-no { right: var(--space-md); color: var(--color-on-photo); }
.deck-acts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-xs); }
.deck-acts .act { min-width: 0; padding-inline: 0; height: 52px; flex-direction: column; gap: 0; border-radius: var(--radius-card); font-size: var(--text-xs); }

/* the flat, full screen */
.sheet { position: fixed; inset: 0; z-index: var(--z-modal); background: var(--color-paper); overflow-y: auto; overscroll-behavior: contain; padding-top: var(--safe-top); animation: rise var(--dur-short) var(--ease-out); }
@keyframes rise { from { transform: translateY(16px); } to { transform: none; } }
.sheet-in { max-width: var(--column); margin-inline: auto; padding-bottom: calc(76px + var(--safe-bottom)); }
.sheet-back { position: absolute; z-index: var(--z-raised); top: var(--space-xs); left: var(--space-xs); display: grid; place-items: center; width: var(--hit); height: var(--hit); border-radius: var(--radius-pill); background: var(--color-scrim); color: var(--color-on-photo); }
.sheet-head { padding: var(--space-md) var(--edge) 0; }
.sheet-head h1 { margin-top: var(--space-3xs); font-family: var(--font-body); font-size: var(--text-lg); font-weight: 500; letter-spacing: 0; line-height: 1.3; }
.sheet-head .price b { font-size: var(--text-2xl); font-variant-numeric: tabular-nums; }
.sources { display: flex; flex-wrap: wrap; gap: var(--space-xs); padding: var(--space-sm) var(--edge) 0; }
.out { display: inline-flex; align-items: center; gap: var(--space-2xs); min-height: var(--chip); padding-inline: var(--space-sm); border-radius: var(--radius-pill); background: var(--color-soft); color: var(--color-link); font-size: var(--text-sm); font-weight: 500; text-decoration: none; font-variant-numeric: tabular-nums; }
.out .icon { width: 16px; height: 16px; }
.part { margin-top: var(--space-lg); padding: var(--space-lg) var(--edge) 0; border-top: var(--rule-hair) solid var(--color-rule); }
.part h2 { font-size: var(--text-lg); margin-bottom: var(--space-xs); }
.part p { color: var(--color-ink-2); font-size: var(--text-sm); }
.part .budget { margin-top: 0; }
.part .repair { color: var(--color-muted); }
.rows { display: grid; margin: 0; }
.rows div { display: flex; justify-content: space-between; gap: var(--space-md); padding: var(--space-xs) 0; border-bottom: var(--rule-hair) solid var(--color-rule); font-size: var(--text-sm); }
.rows div:last-child { border-bottom: 0; }
.rows dt { color: var(--color-ink-2); }
.rows dd { margin: 0; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.rows .sum dd, .rows .sum dt { font-weight: 600; color: var(--color-ink); }
.score-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2xs) var(--space-sm); align-items: center; padding: var(--space-2xs) 0; font-size: var(--text-sm); }
.score-line span:nth-child(2) { white-space: nowrap; text-align: right; color: var(--color-muted); font-variant-numeric: tabular-nums; }
.score-bar { grid-column: 1 / -1; height: 4px; border-radius: var(--radius-pill); overflow: hidden; background: var(--color-paper-3); }
.score-bar i { display: block; height: 100%; border-radius: var(--radius-pill); background: var(--color-accent); }
.stop { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); min-height: 48px; padding-block: var(--space-2xs); border-bottom: var(--rule-hair) solid var(--color-rule); font-size: var(--text-sm); text-decoration: none; }
.stop:last-child { border-bottom: 0; }
.stop small { display: block; color: var(--color-muted); font-size: var(--text-xs); }
.stop b { font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.about { white-space: pre-line; }
.about.cut { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; overflow: hidden; }
.more { min-height: var(--hit); color: var(--color-link); font-size: var(--text-sm); font-weight: 500; }
.aspect { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding-block: var(--space-2xs); font-size: var(--text-sm); }
.aspect div { display: flex; gap: var(--space-2xs); }
.aspect .act { min-width: 52px; }
.checks { margin: 0; padding-left: var(--space-md); font-size: var(--text-sm); color: var(--color-ink-2); }
.sheet-acts { position: fixed; inset: auto 0 0; z-index: var(--z-modal); display: flex; justify-content: center; gap: var(--space-xs); padding: var(--space-xs) var(--edge) calc(var(--space-xs) + var(--safe-bottom)); background: var(--color-glass); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); border-top: var(--rule-hair) solid var(--color-rule); }
.sheet-acts .btn { flex: 1; max-width: 24rem; }
.btn[aria-pressed="true"] { background: var(--color-soft); color: var(--color-ink); }

/* panels */
.panel { width: 100%; max-width: var(--column); max-height: 88dvh; margin: auto auto 0; padding: 0; border: 0; border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; background: var(--color-paper); color: var(--color-ink); overflow: hidden; }
.panel[open] { display: flex; flex-direction: column; animation: rise var(--dur-short) var(--ease-out); }
.panel::backdrop { background: var(--color-scrim); }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-sm) var(--edge) var(--space-2xs); }
.panel-head h2 { font-size: var(--text-lg); }
.panel-close { display: grid; place-items: center; width: var(--hit); height: var(--hit); margin-right: calc(var(--space-xs) * -1); color: var(--color-muted); }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--edge) var(--space-md); }
.panel-foot { display: flex; gap: var(--space-xs); padding: var(--space-xs) var(--edge) calc(var(--space-xs) + var(--safe-bottom)); border-top: var(--rule-hair) solid var(--color-rule); }
.panel-foot .btn { flex: 1; }
.field { display: grid; gap: var(--space-xs); padding-block: var(--space-sm); }
.field > label, .field > span { font-size: var(--text-sm); font-weight: 500; display: flex; justify-content: space-between; gap: var(--space-sm); }
.field output { color: var(--color-muted); font-variant-numeric: tabular-nums; }
.input { width: 100%; height: var(--hit); padding-inline: var(--space-sm); border: 0; border-radius: var(--radius-inner); background: var(--color-soft); color: var(--color-ink); font-size: var(--text-md); outline: 2px solid transparent; outline-offset: -2px; }
.input:focus-visible { outline-color: var(--color-focus); }
input[type="range"] { width: 100%; height: var(--hit); margin: 0; accent-color: var(--color-accent); }
.pills { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.pill { min-height: 40px; padding-inline: var(--space-sm); border-radius: var(--radius-pill); background: var(--color-soft); font-size: var(--text-sm); }
.pill[aria-pressed="true"] { background: var(--color-accent); color: var(--color-accent-ink); }
.viewer { width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--color-night); }
.viewer[open] { display: block; }
.viewer-shots { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.viewer-shots::-webkit-scrollbar { display: none; }
.viewer-shots img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: contain; scroll-snap-align: center; }
.viewer-close { position: fixed; top: calc(var(--safe-top) + var(--space-xs)); right: var(--space-xs); display: grid; place-items: center; width: var(--hit); height: var(--hit); border-radius: var(--radius-pill); background: var(--color-scrim); color: var(--color-on-photo); }
.notice { position: fixed; z-index: var(--z-toast); inset: auto var(--edge) calc(var(--tab-height) + var(--safe-bottom) + var(--space-sm)); max-width: var(--column); margin-inline: auto; padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-inner); background: var(--color-ink); color: var(--color-paper); font-size: var(--text-sm); }

@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } .sheet, .panel[open] { animation: none; } }
