@property --g0 { syntax: "<color>"; inherits: true; initial-value: #33512a; }
@property --g1 { syntax: "<color>"; inherits: true; initial-value: #8da85a; }
@property --g2 { syntax: "<color>"; inherits: true; initial-value: #f0b9b6; }
@property --g3 { syntax: "<color>"; inherits: true; initial-value: #fde9e0; }
:root { --g0: #33512a; --g1: #8da85a; --g2: #f0b9b6; --g3: #fde9e0; --ink: #263f1f; --milk: #fff8ef; --soft: color-mix(in srgb, var(--ink) 82%, var(--milk)); --line: color-mix(in srgb, var(--ink) 14%, transparent); --sponge: #a9b36a; --cream: #f8eedd; --ease: cubic-bezier(.2,.7,.2,1); transition: --g0 .7s var(--ease), --g1 .7s var(--ease), --g2 .7s var(--ease), --g3 .7s var(--ease); }
html { scrollbar-color: var(--g1) transparent; }
html, * { scrollbar-width: thin; box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 1.4 -.35'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E") fixed, linear-gradient(var(--g0), var(--g1) 34%, var(--g2) 66%, var(--g3)) fixed; background-blend-mode: soft-light; font: 400 16px/1.4 Onest, system-ui, sans-serif; overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.app { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 400px; height: 100svh; }
.stage { container-type: size; position: relative; overflow: hidden; min-height: 0; }
h1 { position: absolute; left: 0; right: 0; top: 12cqh; margin: 0; text-align: center; font: 400 min(14.4cqw, 34cqh)/.95 Oi, serif; color: var(--milk); white-space: nowrap; user-select: none; }
.lead, .note { position: absolute; top: 24px; margin: 0; color: var(--milk); }
.lead { left: 32px; font-weight: 500; font-size: 18px; }
.lang { min-width: 44px; min-height: 44px; margin: -10px -12px -10px 4px; padding: 0; border: 0; background: none; color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.lang:focus-visible { outline-color: var(--milk); }
.note { right: 32px; font-size: 14px; line-height: 25px; }
#cake { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-y; cursor: grab; }
#cake:active { cursor: grabbing; }
#cake:focus-visible { outline-color: var(--milk); outline-offset: -6px; }
.cut { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 12px 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--milk); font-weight: 500; transition: background-color .15s; }
.cut:hover { background: #fff; }
.cut:active, .go:active, .plain:active { transform: translateY(1px); }
.cut:active { transform: translate(-50%, 1px); }

.panel { display: flex; flex-direction: column; min-height: 0; margin: 16px 16px 16px 0; padding: 20px; border-radius: 20px; background: var(--milk); }
.tabs { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); }
.tabs button { padding: 4px 4px 12px; border: 0; background: none; color: var(--soft); border-bottom: 3px solid transparent; margin-bottom: -1px; transition: color .15s; }
.tabs button:hover { color: var(--ink); }
.tabs [aria-selected="true"] { color: var(--ink); font-weight: 600; border-color: var(--ink); }
.pages { flex: none; height: 292px; padding: 20px 4px 12px; margin: 0 -4px; overflow: auto; }
.big { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.big output { font: 400 44px/1 Oi, serif; }
.big span { color: var(--soft); }
.hint { margin: 12px 0 0; color: var(--soft); font-size: 14px; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 32px; margin: 0; background: none; cursor: grab; }
input[type="range"]::-webkit-slider-runnable-track { height: 12px; border-radius: 6px; background: linear-gradient(var(--cream) 0 34%, var(--sponge) 34%); border: 1px solid var(--line); }
input[type="range"]::-moz-range-track { height: 12px; border-radius: 6px; background: linear-gradient(var(--cream) 0 34%, var(--sponge) 34%); border: 1px solid var(--line); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 32px; margin-top: -11px; border-radius: 6px; border: 0; background: var(--ink); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 32px; border-radius: 6px; border: 0; background: var(--ink); }
.scale { display: flex; justify-content: space-between; color: var(--soft); font-size: 14px; }

.rows { display: grid; gap: 4px; }
.rows label { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px; min-height: 48px; padding: 4px 12px 4px 8px; border-radius: 12px; cursor: pointer; transition: background-color .15s; }
.rows label:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.rows label:has(:checked) { background: color-mix(in srgb, var(--ink) 11%, transparent); font-weight: 500; }
.rows label:has(:focus-visible), .seg label:has(:focus-visible), .swatches label:has(:focus-visible) { outline: 2px solid var(--ink); outline-offset: 1px; }
.rows small { font-size: 14px; color: var(--soft); font-weight: 400; font-variant-numeric: tabular-nums; }
.rows input, .seg input, .swatches input { position: absolute; opacity: 0; pointer-events: none; }
.slab { width: 44px; height: 32px; border-radius: 6px; }
.tick { width: 24px; height: 24px; margin-left: 8px; border-radius: 6px; border: 1.5px solid var(--soft); display: grid; place-items: center; }
:checked + .tick { background: var(--ink); border-color: var(--ink); }
:checked + .tick::after { content: ""; width: 10px; height: 5px; border: solid var(--milk); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 16px; }
.seg label { display: grid; place-items: center; text-align: center; min-height: 48px; line-height: 1.15; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; font-size: 15px; }
.seg label:has(:checked) { background: var(--ink); color: var(--milk); border-color: var(--ink); }
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.swatches label { cursor: pointer; font-size: 14px; color: var(--soft); border-radius: 12px; }
.swatches i { display: block; height: 52px; margin-bottom: 4px; border-radius: 12px; border: 1px solid var(--line); }
.swatches label:has(:checked) { color: var(--ink); font-weight: 600; }
.swatches :checked + i { box-shadow: inset 0 0 0 3px var(--milk), 0 0 0 2px var(--ink); }
.swatches.off { opacity: .35; }
.step { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 4px 12px 0 8px; }
.step div { display: flex; align-items: center; gap: 4px; }
.step button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: none; font-size: 20px; line-height: 1; }
.step button:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.step output { width: 36px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.field { display: grid; gap: 8px; color: var(--soft); font-size: 14px; }
.field input { min-height: 48px; padding: 0 14px; border: 1px solid color-mix(in srgb, var(--ink) 40%, transparent); border-radius: 12px; background: #fff; color: var(--ink); font-size: 18px; min-width: 0; }
.field input::placeholder { color: color-mix(in srgb, var(--ink) 62%, #fff); }

/* Счёт сложен как разрез торта: слой тем толще, чем больше он стоит */
.bill { flex: 1 1 0; min-height: 96px; display: flex; flex-direction: column; justify-content: flex-end; margin: 0; padding: 0; list-style: none; border-radius: 12px; overflow: auto; }
.bill li { flex: 1 0 28px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 2px 14px; font-size: 15px; background: var(--cream); color: #33251c; transition: flex-grow .35s var(--ease); }
.bill li:nth-last-child(odd) { background: var(--sponge); color: var(--on-sponge, #231a10); }
.bill li:first-child { border-radius: 12px 12px 0 0; }
.bill li:last-child { border-radius: 0 0 12px 12px; }
.bill li:only-child { border-radius: 12px; }
.bill b { font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sum { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 16px; }
.total span { display: block; color: var(--soft); font-size: 14px; }
.total strong { font-weight: 600; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.go { min-height: 52px; padding: 0 28px; border: 0; border-radius: 12px; background: var(--ink); color: var(--milk); font-weight: 600; transition: background-color .15s; }
.go:hover { background: color-mix(in srgb, var(--ink) 86%, #fff); }
.plain { min-height: 52px; padding: 0 20px; border: 1px solid color-mix(in srgb, var(--ink) 40%, transparent); border-radius: 12px; background: none; font-weight: 500; }
.plain:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }

dialog { width: min(880px, calc(100vw - 32px)); max-height: calc(100svh - 32px); padding: 24px; border: 0; border-radius: 20px; background: var(--milk); color: var(--ink); overflow: auto; }
dialog::backdrop { background: color-mix(in srgb, var(--g0) 78%, transparent); }
.dlg-grid { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 28px; }
#card { width: 100%; height: auto; border-radius: 12px; display: block; }
.dlg-side h2 { margin: 0 44px 16px 0; font-weight: 600; font-size: 24px; line-height: 1.15; }
pre { margin: 16px 0; padding: 14px 16px; border-radius: 12px; background: color-mix(in srgb, var(--ink) 7%, transparent); font: 400 15px/1.45 Onest, sans-serif; white-space: pre-wrap; overflow-wrap: anywhere; }
.dlg-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.dlg-btns button { flex: 1 1 auto; padding: 0 14px; }
#copied { min-height: 20px; margin: 8px 0 0; font-size: 14px; }
.x { position: absolute; right: 16px; top: 16px; width: 44px; height: 44px; border: 0; border-radius: 10px; background: none; font-size: 18px; z-index: 1; }
.x:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }

/* Загрузка: коржи ложатся друг на друга */
#boot { position: absolute; left: 50%; top: 56%; width: 168px; height: 116px; margin: -58px -84px; display: flex; flex-direction: column-reverse; gap: 4px; opacity: 0; animation: show .2s .3s forwards; pointer-events: none; }
#boot i { height: 26px; border-radius: 6px; background: var(--milk); opacity: 0; animation: drop 1.8s infinite var(--ease); }
#boot i:nth-child(even) { background: var(--g2); }
#boot i:nth-child(2) { animation-delay: .18s; } #boot i:nth-child(3) { animation-delay: .36s; } #boot i:nth-child(4) { animation-delay: .54s; }
@keyframes show { to { opacity: 1; } }
@keyframes drop { 0% { opacity: 0; transform: translateY(-40px); } 22%, 78% { opacity: 1; transform: none; } 100% { opacity: 0; } }
#boot[hidden], #fail[hidden] { display: none; }
#fail { position: absolute; left: 50%; top: 56%; width: min(320px, 84%); transform: translate(-50%, -50%); padding: 20px; border-radius: 16px; background: var(--milk); text-align: center; }
#fail p { margin: 0 0 12px; }
#fail button { min-height: 44px; padding: 0 20px; border: 0; border-radius: 10px; background: var(--ink); color: var(--milk); }
.nojs { position: fixed; inset: auto 16px 16px; padding: 16px; border-radius: 12px; background: var(--milk); }

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .panel { margin: 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; }
  .pages { height: 250px; padding-top: 12px; padding-bottom: 8px; }
  .rows { gap: 2px; } .rows label { min-height: 44px; padding-block: 0; font-size: 15px; } .seg { margin-bottom: 12px; } .slab { height: 28px; } .step { min-height: 40px; }
  .bill { display: none; }
  .sum { padding-top: 8px; border-top: 1px solid var(--line); margin-top: 4px; }
  h1 { top: 52px; }
  .lead { left: 16px; top: 14px; font-size: 15px; } .note { right: 16px; top: 14px; font-size: 13px; line-height: 21px; }
  .cut { left: 16px; transform: none; bottom: 12px; padding: 9px 16px; font-size: 15px; }
  .cut:active { transform: translateY(1px); }
  .tabs button { padding: 4px 2px 10px; min-height: 40px; }
  .dlg-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  dialog { padding: 16px; }
  #card { max-width: 320px; margin: 0 auto; }
  .dlg-btns button { flex: 1 1 100%; }
}
@media (max-width: 860px) and (max-height: 620px) { .pages { height: 168px; } }
@media (max-height: 520px) and (orientation: landscape) {
  .app { grid-template-columns: minmax(0, 1fr) 360px; grid-template-rows: minmax(0, 1fr); }
  .panel { margin: 8px 8px 8px 0; padding: 10px 14px; border-radius: 16px; }
  .pages { flex: 1 1 0; height: auto; } .bill { display: none; } .lead { font-size: 14px; } .concept { display: none; } .cut { bottom: 8px; padding: 7px 14px; min-height: 44px; }
}
@media (max-width: 400px) { .lead { max-width: 190px; font-size: 14px; line-height: 1.2; top: 10px; } .concept { font-size: 0; } .concept::after { content: "Концепт"; font-size: 13px; } :lang(en) .concept::after { content: "Concept"; } }
@media (max-width: 340px) { .lead { max-width: 150px; font-size: 13px; } .concept::after { font-size: 12px; } .go { padding: 0 16px; } .total strong { font-size: 22px; } .big { gap: 8px; } .big output { font-size: 36px; } }
@media (prefers-reduced-motion: reduce) { :root, * { transition: none !important; } #boot i { animation: none; opacity: 1; } }
