:root {
  --ink: #2b211b; --ink-2: #5d4c40; --ink-3: #8a7868;
  --paper: #fffcf6; --paper-2: #f6efe3; --line: #e7dccb;
  --accent: #7a2a3a; --accent-2: #9b3a4d; --accent-ink: #fff8f2;
  --sage: #6f8a6a; --gold: #b8925a;
  --shadow-1: 0 1px 2px rgba(59, 36, 18, .12), 0 4px 14px rgba(59, 36, 18, .12);
  --shadow-2: 0 2px 6px rgba(59, 36, 18, .14), 0 18px 44px rgba(59, 36, 18, .24);
  --r: 18px; --ease: cubic-bezier(.2, .8, .2, 1); --spring: cubic-bezier(.34, 1.56, .64, 1);
  --serif: 'Cormorant Garamond', 'Times New Roman', serif;
  --sans: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --top-h: 64px; --demo-h: 30px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; font: 500 15px/1.45 var(--sans); color: var(--ink);
  background: #c9a27a url(/assets/img/table.webp) center top / cover fixed;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
body::before { /* warm vignette like a lamp over the counter */
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(120% 90% at 50% 35%, rgba(255, 236, 205, .18), rgba(40, 22, 10, .36) 100%);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ---------- top ---------- */
.demo-bar {
  position: relative; z-index: 30; height: var(--demo-h); display: flex; align-items: center; justify-content: center;
  padding: 0 12px; font-size: 12.5px; letter-spacing: .01em; color: #fff7ea; background: rgba(43, 33, 27, .82);
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.top {
  position: relative; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 16px; padding: 0 22px;
  background: rgba(255, 250, 242, .78); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid rgba(231, 220, 203, .8);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; margin-right: auto; min-width: 0; }
.brand .logo { width: 34px; height: 34px; color: var(--accent); flex: none; }
.brand span { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand b { font: 500 25px/1 var(--serif); letter-spacing: .01em; white-space: nowrap; }
.brand small { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); margin-top: 3px; white-space: nowrap; }

.mode-switch {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 999px;
  background: rgba(43, 33, 27, .08); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .08);
}
.mode-switch button {
  position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 7px; min-width: 124px; height: 38px;
  padding: 0 16px; border: 0; border-radius: 999px; background: none; font-weight: 700; font-size: 14px; color: var(--ink-2);
  transition: color .25s var(--ease);
}
.mode-switch button svg { width: 18px; height: 18px; }
.mode-switch button[aria-selected=true] { color: var(--accent-ink); }
.mode-switch .pill {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 999px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent)); box-shadow: 0 2px 8px rgba(122, 42, 58, .4);
  transition: transform .38s var(--spring);
}
.mode-switch[data-active=written] .pill { transform: translateX(100%); }

.langs { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(43, 33, 27, .06); }
.langs a {
  min-width: 36px; height: 30px; display: grid; place-items: center; border-radius: 999px; text-decoration: none;
  font-size: 12.5px; font-weight: 800; letter-spacing: .04em; color: var(--ink-2);
}
.langs a[aria-current] { background: var(--paper); color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- studio layout ---------- */
.studio {
  position: relative; z-index: 1; display: grid; gap: 18px; padding: 18px 22px 28px;
  grid-template-columns: minmax(150px, 190px) minmax(380px, 1fr) minmax(150px, 190px) minmax(320px, 360px);
  grid-template-areas: 'left stage right receipt';
  min-height: calc(100dvh - var(--top-h) - var(--demo-h)); max-width: 1680px; margin: 0 auto;
}
.station.left { grid-area: left; } .station.right { grid-area: right; }
.stage-col { grid-area: stage; } .receipt { grid-area: receipt; } .written { grid-area: stage; display: none; }
.studio[data-mode=written] { grid-template-columns: minmax(0, 1fr) minmax(320px, 380px); grid-template-areas: 'written receipt'; max-width: 1180px; }
.studio[data-mode=written] .station, .studio[data-mode=written] .stage-col { display: none; }
.studio[data-mode=written] .written { display: block; grid-area: written; animation: fadeUp .45s var(--ease); }
.studio[data-mode=visual] .stage-col, .studio[data-mode=visual] .station { animation: fadeUp .45s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } }

.station { display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.bucket {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 0; border: 0; background: none;
  touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.b-art { display: block; width: 116px; height: 116px; transition: transform .3s var(--spring), filter .3s; filter: drop-shadow(0 0 0 transparent); }
.b-art svg { width: 100%; height: 100%; overflow: visible; }
.bucket:hover .b-art { transform: translateY(-4px) rotate(-3deg) scale(1.04); }
.bucket.lifting .b-art { transform: scale(.94); opacity: .75; }
.bucket.pulse .b-art { animation: pulse .42s var(--spring); }
@keyframes pulse { 40% { transform: scale(.9); } }
.b-tag {
  margin-top: -10px; display: flex; align-items: baseline; gap: 6px; padding: 4px 10px 4px 11px; border-radius: 8px;
  background: var(--paper); box-shadow: var(--shadow-1); font-size: 12.5px; white-space: nowrap; transform: rotate(-1.5deg);
}
.bucket:nth-child(even) .b-tag { transform: rotate(1.2deg); }
.b-name { font-weight: 700; }
.b-price { color: var(--ink-3); font-weight: 700; font-size: 12px; }
.b-count {
  position: absolute; top: 2px; right: 12px; min-width: 28px; height: 24px; padding: 0 7px; border-radius: 999px;
  display: grid; place-items: center; font-size: 12px; font-weight: 800; color: var(--accent-ink); background: var(--accent);
  box-shadow: 0 2px 6px rgba(122, 42, 58, .45); transform: scale(0); transition: transform .3s var(--spring);
}
.bucket.has .b-count { transform: scale(1); }

.stage-col { display: flex; flex-direction: column; min-width: 0; }
.stage-head { text-align: center; color: #fff9ef; text-shadow: 0 1px 12px rgba(43, 25, 10, .55); }
.stage-head h1 { margin: 4px 0 2px; font: 500 clamp(30px, 3.2vw, 44px)/1.05 var(--serif); letter-spacing: .005em; }
.stage-head .hint { margin: 0 auto; max-width: 440px; font-size: 14px; opacity: .92; }
.stage-box { position: relative; flex: 1; min-height: 420px; display: flex; align-items: center; justify-content: center; border-radius: 28px; transition: background .25s; }
.stage-box::after {
  content: ''; position: absolute; inset: 8% 10%; border-radius: 50%; border: 2px dashed rgba(255, 248, 236, 0); transition: border-color .25s, transform .3s var(--spring);
  pointer-events: none;
}
body.dragging .stage-box::after { border-color: rgba(255, 248, 236, .55); }
.stage-box.over::after { border-color: rgba(255, 248, 236, .95); transform: scale(1.03); }
.stage-box.over { background: rgba(255, 245, 228, .1); }
#stage { width: 100%; height: 100%; max-height: calc(100dvh - 240px); overflow: visible; }
#stage .it { cursor: pointer; transition: transform .5s var(--spring); }
#stage .it.flying { transition: transform .62s cubic-bezier(.22, 1.1, .36, 1); }
#stage .it.landed > .pop { animation: land .5s var(--spring); transform-origin: 0 0; }
#stage .it.leaving { transition: transform .3s ease-in, opacity .3s; opacity: 0; pointer-events: none; }
@media (hover: hover) { #stage .it:not(.flying):hover > .pop { transform: scale(1.06); filter: brightness(1.05); transition: transform .2s, filter .2s; } }
@keyframes land { 0% { transform: scale(1.18); } 55% { transform: scale(.94); } 100% { transform: scale(1); } }
#stage .wrap-back, #stage .wrap-front, #stage .stems, #stage .bow { transition: opacity .3s; }
#stage .card { animation: fadeIn .4s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } }
.drop-hint circle { fill: rgba(255, 249, 238, .1); stroke: rgba(255, 249, 238, .75); stroke-width: 2; stroke-dasharray: 7 9; animation: spin 30s linear infinite; transform-origin: 300px 300px; }
.drop-hint text { font: 500 25px var(--serif); fill: #fff9ef; paint-order: stroke; stroke: rgba(60, 35, 15, .25); stroke-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.stage-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: nowrap; }
/* occasion chips: one swipeable row (six of them never fit beside the tools) */
.presets { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none;
  overscroll-behavior-x: contain; padding: 3px 2px 5px; -webkit-mask-image: linear-gradient(90deg, #000 90%, transparent); mask-image: linear-gradient(90deg, #000 90%, transparent); }
.presets::-webkit-scrollbar { display: none; }
.presets.at-start { -webkit-mask-image: linear-gradient(90deg, #000 90%, transparent); mask-image: linear-gradient(90deg, #000 90%, transparent); }
.presets:not(.at-start) { -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 90%, transparent); mask-image: linear-gradient(90deg, transparent, #000 7%, #000 90%, transparent); }
.presets.at-end:not(.at-start) { -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%); mask-image: linear-gradient(90deg, transparent, #000 7%); }
.presets.at-start.at-end { -webkit-mask-image: none; mask-image: none; }
.presets .chip, .presets .lbl { flex: none; }
.presets .lbl { color: #fff7ea; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; text-shadow: 0 1px 8px rgba(43, 25, 10, .6); margin-right: 2px; }
.chip, .ghost {
  height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .55);
  background: rgba(255, 251, 244, .86); font-weight: 700; font-size: 13.5px; box-shadow: var(--shadow-1);
  display: inline-flex; align-items: center; gap: 6px; transition: transform .2s var(--spring), background .2s;
}
.chip:hover, .ghost:hover:not(:disabled) { transform: translateY(-1px); background: #fff; }
.chip:active, .ghost:active:not(:disabled) { transform: scale(.96); }
.chip[aria-pressed="true"] { background: var(--ink, #2b1d12); color: #fff8ee; border-color: transparent; }
.occ-sel { width: 100%; height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper-2); font: inherit; color: inherit; }
.ghost svg { width: 17px; height: 17px; }
.ghost:disabled { opacity: .5; cursor: default; }
.tool-btns { display: flex; gap: 6px; flex: none; }

.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 90; pointer-events: none;
  filter: drop-shadow(0 16px 18px rgba(43, 25, 10, .35)); will-change: transform;
}
.drag-ghost svg { width: 100%; height: 100%; overflow: visible; }
.drag-ghost.back { transition: transform .28s ease-in, opacity .28s; opacity: 0; }
body.dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }

/* ---------- receipt ---------- */
.receipt { position: relative; align-self: start; position: sticky; top: 16px; }
.receipt .paper {
  position: relative; background: var(--paper); border-radius: 6px 6px 0 0; padding: 18px 20px 20px; box-shadow: var(--shadow-2);
  transform: rotate(.6deg);
}
.receipt .paper::after { /* zig-zag torn edge */
  content: ''; position: absolute; left: 0; right: 0; bottom: -10px; height: 10px;
  background: linear-gradient(-45deg, transparent 6px, var(--paper) 0) 0 0 / 14px 10px repeat-x, linear-gradient(45deg, transparent 6px, var(--paper) 0) 0 0 / 14px 10px repeat-x;
  filter: drop-shadow(0 4px 3px rgba(59, 36, 18, .12));
}
.r-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding-bottom: 10px; border-bottom: 1.5px dashed var(--line); }
.r-title { font: 500 26px/1 var(--serif); }
.r-n { font-size: 12.5px; color: var(--ink-3); font-weight: 700; }
.r-close { display: none; }
.opts { display: grid; gap: 10px; padding: 12px 0; border-bottom: 1.5px dashed var(--line); }
.opt { display: grid; gap: 5px; }
.opt .lbl { font-size: 11.5px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); }
.opt .lbl em { font-style: normal; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--ink-3); opacity: .8; margin-left: 4px; }
.swatches { display: flex; align-items: center; gap: 7px; }
.sw { width: 30px; height: 30px; border-radius: 50%; padding: 3px; border: 1.5px solid transparent; background: none; transition: transform .2s var(--spring), border-color .2s; }
.sw span { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12), inset 0 -3px 5px rgba(0, 0, 0, .08); }
.sw:hover { transform: scale(1.1); }
.sw[aria-checked=true] { border-color: var(--ink); }
.sw-name { font-size: 13px; color: var(--ink-2); margin-left: 4px; font-weight: 600; }
.card-in input {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper-2);
  font-family: Caveat, var(--sans); font-size: 19px;
}
.card-in input::placeholder { font-family: var(--sans); font-size: 13.5px; color: var(--ink-3); }
.lines { list-style: none; margin: 0; padding: 10px 0; display: grid; gap: 4px; min-height: 60px; max-height: 230px; overflow: auto; border-bottom: 1.5px dashed var(--line); font-variant-numeric: tabular-nums; }
.line { display: grid; grid-template-columns: 30px 1fr auto; gap: 6px; font-size: 14px; align-items: baseline; }
.line .q { color: var(--ink-3); font-weight: 700; }
.line .s { font-weight: 700; }
.line.new { animation: lineIn .5s var(--ease); }
@keyframes lineIn { from { background: #fbe9c9; } }
.lines .empty { color: var(--ink-3); font-size: 14px; text-align: center; padding: 14px 0; font-style: italic; }
.sums { display: grid; gap: 4px; padding-top: 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.sums > div { display: flex; justify-content: space-between; }
.sums > div > span:first-child { color: var(--ink-2); }
.free { flex-direction: column; gap: 4px; margin: 4px 0; }
.free i { display: block; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; position: relative; }
.free i::after { content: ''; position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--p)); background: linear-gradient(90deg, var(--sage), #93a88a); transition: transform .5s var(--ease); }
.free small { color: var(--ink-3); font-size: 12px; }
.total { margin-top: 6px; align-items: baseline; }
.total span { font: 500 22px var(--serif); color: var(--ink) !important; }
.total b { font: 700 28px/1 var(--sans); letter-spacing: -.01em; }
.total b.bump { animation: bump .45s var(--spring); }
@keyframes bump { 30% { transform: scale(1.12); color: var(--accent); } }
.cta {
  width: 100%; height: 52px; margin-top: 14px; border: 0; border-radius: 14px; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: var(--accent-ink); font-weight: 800; font-size: 15.5px; letter-spacing: .01em;
  box-shadow: 0 4px 14px rgba(122, 42, 58, .38), inset 0 1px 0 rgba(255, 255, 255, .18); text-decoration: none;
  transition: transform .2s var(--spring), box-shadow .2s, filter .2s;
}
.cta svg { width: 20px; height: 20px; transition: transform .2s; }
.cta:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(122, 42, 58, .45); }
.cta:hover:not(:disabled) svg { transform: translateX(3px); }
.cta:active:not(:disabled) { transform: scale(.98); }
.cta:disabled { background: #cdbfae; box-shadow: none; color: #fff; cursor: default; }

/* ---------- written mode ---------- */
.written .w-inner { background: var(--paper); border-radius: var(--r); padding: 22px 24px 26px; box-shadow: var(--shadow-2); }
.w-title { margin: 0 0 6px; font: 500 34px/1.1 var(--serif); }
.w-cat h2 { margin: 18px 0 8px; font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.w-cat ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.w-row { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 12px; padding: 6px 8px; border-radius: 12px; transition: background .2s; }
.w-row.on { background: #f8efe2; }
.w-ico { width: 52px; height: 52px; border-radius: 12px; background: #efe5d6; display: grid; place-items: center; overflow: hidden; }
.w-ico svg { width: 50px; height: 50px; }
.w-name { font-weight: 700; display: flex; flex-direction: column; }
.w-name small { color: var(--ink-3); font-weight: 600; font-size: 12.5px; }
.step { display: flex; align-items: center; gap: 4px; }
.step button { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 20px; font-weight: 600; line-height: 1; transition: transform .15s var(--spring), background .15s; }
.step button:hover:not(:disabled) { background: var(--paper-2); }
.step button:active:not(:disabled) { transform: scale(.9); }
.step button:disabled { opacity: .35; cursor: default; }
.step button[data-plus] { background: var(--ink); color: #fff; border-color: var(--ink); }
.step output { min-width: 26px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.w-cat textarea { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper-2); resize: vertical; }

/* ---------- dialogs ---------- */
dialog.sheet {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 22px; background: var(--paper);
  color: var(--ink); box-shadow: 0 30px 80px rgba(30, 15, 5, .45); overflow: hidden;
}
dialog.sheet[open] { animation: popIn .42s var(--spring); }
dialog.sheet::backdrop { background: rgba(35, 20, 10, .52); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fadeIn .3s; }
@keyframes popIn { from { opacity: 0; transform: translateY(18px) scale(.96); } }
.co { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.co header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 10px; }
.co h2 { margin: 0; font: 500 28px/1.1 var(--serif); }
.x { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--paper-2); font-size: 22px; line-height: 1; }
.co-body { padding: 4px 22px 14px; overflow: auto; display: grid; gap: 12px; }
.co-mini { display: flex; align-items: center; gap: 14px; padding: 8px 12px; border-radius: 14px; background: #f3e8d8; }
.co-mini svg { width: 64px; height: 72px; flex: none; }
.co-mini div { display: flex; flex-direction: column; font-size: 13.5px; } .co-mini span { color: var(--ink-3); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--paper-2); }
.seg button { height: 40px; border: 0; border-radius: 10px; background: none; font-weight: 700; color: var(--ink-2); }
.seg button[aria-checked=true] { background: #fff; color: var(--ink); box-shadow: var(--shadow-1); }
.co label, .slots-w { display: grid; gap: 5px; font-size: 12.5px; font-weight: 800; color: var(--ink-2); letter-spacing: .02em; }
.slots-w .lab { font-size: 12.5px; }
.co input, .co textarea, .co select {
  width: 100%; min-height: 46px; padding: 10px 13px; border-radius: 12px; border: 1px solid var(--line); background: #fff;
  font-size: 16px; font-weight: 500; color: var(--ink); transition: border-color .2s, box-shadow .2s;
}
.co textarea { resize: vertical; }
.co input:focus, .co textarea:focus, .co select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(122, 42, 58, .14); }
.co [aria-invalid=true] { border-color: #b3261e; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.slots button { height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.slots button[aria-checked=true] { background: var(--ink); color: #fff; border-color: var(--ink); }
.slots button:disabled { opacity: .35; text-decoration: line-through; cursor: default; }
.err { color: #b3261e; font-size: 12.5px; font-weight: 700; }
.err.big { margin: 0; padding: 10px 12px; border-radius: 10px; background: #fbe9e7; }
.pick { margin: 0; padding: 10px 12px; border-radius: 12px; background: #eef2e8; color: #3f5a3a; font-weight: 700; font-size: 14px; }
.co footer { display: flex; align-items: center; gap: 16px; padding: 14px 22px 18px; border-top: 1px solid var(--line); background: #fffaf2; }
.co-total { display: flex; flex-direction: column; line-height: 1.1; }
.co-total span { font-size: 12px; color: var(--ink-3); font-weight: 700; }
.co-total b { font-size: 24px; }
.co-total small { color: var(--ink-3); font-size: 11.5px; }
.co footer .cta { margin: 0; flex: 1; }

.confirm { width: min(440px, calc(100vw - 24px)); }
.cf { padding: 26px 26px 22px; text-align: center; background: radial-gradient(120% 60% at 50% 0%, #f8e7d6, var(--paper) 70%); }
.cf-art { position: relative; height: 210px; margin: -8px auto 0; }
.cf-svg { height: 100%; width: auto; animation: rise .7s var(--spring); }
@keyframes rise { from { transform: translateY(26px) scale(.9); opacity: 0; } }
.spark { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); opacity: 0; animation: spark 1.4s .3s var(--ease) forwards; }
.s1 { left: 22%; top: 30%; } .s2 { right: 20%; top: 18%; animation-delay: .45s; background: #e7a5b0; } .s3 { right: 30%; bottom: 14%; animation-delay: .6s; width: 7px; height: 7px; }
@keyframes spark { 0% { opacity: 0; transform: scale(.2); } 30% { opacity: 1; transform: scale(1.2); } 100% { opacity: 0; transform: translateY(-30px) scale(.6); } }
.cf h2 { margin: 6px 0 4px; font: 500 34px/1.1 var(--serif); }
.cf p { margin: 0 auto 14px; max-width: 320px; color: var(--ink-2); }
.cf-no { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border-radius: 12px; background: #fff; border: 1.5px dashed var(--line); }
.cf-no span { color: var(--ink-3); font-size: 13px; font-weight: 700; }
.cf-no b { font-size: 20px; letter-spacing: .04em; }
.demo-tag { font-style: normal; font-size: 10.5px; font-weight: 800; letter-spacing: .1em; padding: 3px 7px; border-radius: 6px; background: #2b211b; color: #fff; }
.cf-sum { display: flex; justify-content: space-between; padding: 12px 4px 0; font-size: 14px; color: var(--ink-2); }
.cf-sum b { color: var(--ink); font-size: 18px; }
.cf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.cf-row .ghost { justify-content: center; box-shadow: none; border-color: var(--line); height: 42px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 80; display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 18px;
  border-radius: 14px; background: rgba(43, 33, 27, .94); color: #fff7ea; font-weight: 600; font-size: 14px; box-shadow: var(--shadow-2);
  transform: translate(-50%, 140%); opacity: 0; transition: transform .35s var(--spring), opacity .25s; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.toast button { height: 32px; padding: 0 12px; border-radius: 9px; border: 0; background: #fff7ea; color: var(--ink); font-weight: 800; }

.mbar, .scrim { display: none; }

/* ---------- tablet ---------- */
@media (max-width: 1240px) {
  .studio { grid-template-columns: 150px minmax(320px, 1fr) 150px; grid-template-areas: 'left stage right' 'receipt receipt receipt'; }
  .b-art { width: 100px; height: 100px; }
  .receipt { position: static; max-width: 560px; justify-self: center; width: 100%; }
  .studio[data-mode=written] { grid-template-columns: minmax(0, 1fr) 340px; grid-template-areas: 'written receipt'; }
  .studio[data-mode=written] .receipt { position: sticky; }
}

/* ---------- phone ---------- */
@media (max-width: 899px) {
  :root { --top-h: 56px; --demo-h: 26px; }
  body { background-attachment: scroll; font-size: 14.5px; }
  .demo-bar { font-size: 11px; }
  .top { padding: 0 12px; gap: 8px; }
  .brand b { font-size: 21px; } .brand small { display: none; } .brand .logo { width: 28px; height: 28px; }
  .mode-switch button { min-width: 0; padding: 0 11px; height: 34px; font-size: 13px; gap: 5px; }
  .mode-switch button svg { width: 16px; height: 16px; }
  .langs a { min-width: 30px; height: 28px; font-size: 11.5px; }
  .studio, .studio[data-mode=written] {
    display: flex; flex-direction: column; gap: 6px; padding: 8px 0 calc(92px + env(safe-area-inset-bottom)); min-height: 0;
  }
  .stage-col { order: 1; padding: 0 12px; }
  .stage-head h1 { font-size: 27px; margin-top: 2px; }
  .stage-head .hint { font-size: 12.5px; max-width: 300px; }
  .stage-box { min-height: 0; height: min(58vh, 420px); flex: none; }
  #stage { max-height: none; }
  .stage-tools { margin-top: 2px; }
  .presets .lbl { display: none; }
  .tool-btns { flex: none; }
  body.receipt-open .toast { opacity: 0; pointer-events: none; }
  .chip, .ghost { height: 34px; padding: 0 11px; font-size: 12.5px; }
  .tool-btns .ghost span { display: none; }
  .station { order: 2; flex-direction: row; justify-content: flex-start; gap: 2px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity;
    padding: 6px 12px 2px; scrollbar-width: none; }
  .station::-webkit-scrollbar { display: none; }
  .station.right { order: 3; }
  .bucket { flex: none; scroll-snap-align: start; touch-action: pan-x; }
  .b-art { width: 86px; height: 86px; }
  .b-tag { font-size: 11.5px; padding: 3px 8px; margin-top: -8px; }
  .b-price { font-size: 11px; }
  .b-count { right: 4px; }
  .written { order: 1; padding: 0 10px; }
  .written .w-inner { padding: 16px 14px 18px; border-radius: 16px; }
  .w-title { font-size: 28px; }
  .w-row { grid-template-columns: 46px 1fr auto; gap: 10px; padding: 5px 4px; }
  .w-ico, .w-ico svg { width: 46px; height: 46px; }
  .step button { width: 42px; height: 42px; }

  /* the sheet and its scrim must share the root stacking context, otherwise the
     body-level scrim sits above the sheet and swallows taps on its buttons */
  .studio { z-index: auto; }
  .receipt {
    position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; top: auto; max-width: none; padding: 0;
    transform: translateY(105%); transition: transform .42s var(--spring); max-height: 88dvh; overflow: auto;
  }
  .receipt .paper { transform: none; border-radius: 22px 22px 0 0; padding: 16px 18px calc(20px + env(safe-area-inset-bottom)); }
  .receipt .paper::after { display: none; }
  .r-close { display: block; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--paper-2); font-size: 22px; line-height: 1; margin-left: 6px; }
  .r-head { align-items: center; } .r-n { margin-left: auto; }
  body.receipt-open .receipt { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(35, 20, 10, .45); opacity: 0; pointer-events: none; transition: opacity .3s; }
  body.receipt-open .scrim { opacity: 1; pointer-events: auto; }
  .lines { max-height: 26dvh; }

  .mbar { display: block; position: fixed; z-index: 50; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); }
  .mb {
    width: 100%; height: 62px; display: flex; align-items: center; gap: 12px; padding: 0 10px 0 10px; border: 0; border-radius: 18px;
    background: rgba(43, 33, 27, .95); color: #fff7ea; box-shadow: 0 12px 30px rgba(30, 15, 5, .4); text-align: left;
  }
  .mb-n { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent); font-weight: 800; font-size: 17px; }
  .mb-t { flex: 1; display: flex; flex-direction: column; font-size: 12px; opacity: .95; line-height: 1.15; }
  .mb-t b { font-size: 19px; }
  .mb-go { display: flex; align-items: center; gap: 2px; height: 42px; padding: 0 12px 0 16px; border-radius: 12px; background: #fff7ea; color: var(--ink); font-weight: 800; font-size: 14px; }
  .mb-go svg { width: 18px; height: 18px; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100vw - 24px); }

  dialog.sheet { width: 100vw; max-width: 100vw; max-height: 94dvh; margin: auto 0 0; border-radius: 22px 22px 0 0; }
  dialog.sheet[open] { animation: sheetUp .42s var(--spring); }
  @keyframes sheetUp { from { transform: translateY(40%); opacity: .4; } }
  .co { max-height: 94dvh; }
  .co header { padding: 14px 16px 8px; } .co h2 { font-size: 24px; }
  .co-body { padding: 4px 16px 12px; }
  .grid2 { grid-template-columns: 1fr; }
  .co footer { padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); }
  .confirm { width: 100vw; }
  .cf { padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
  .cf-art { height: 180px; }
}
@media (max-width: 440px) {
  /* logo only — the wordmark would slide under the mode switch */
  .brand > span { display: none; }
  .top { gap: 10px; padding: 0 12px; }
}
@media (max-width: 380px) {
  .mode-switch button span { display: none; }
  .mode-switch button { padding: 0 12px; }
}

/* ---------- tracking ---------- */
.track-wrap { position: relative; z-index: 1; max-width: 760px; margin: 26px auto 40px; padding: 0 14px; }
.track-card { background: var(--paper); border-radius: 22px; box-shadow: var(--shadow-2); overflow: hidden; }
.tr-top { display: grid; grid-template-columns: 200px 1fr; gap: 18px; padding: 22px 24px; background: radial-gradient(120% 90% at 0% 0%, #f6e3d1, var(--paper) 70%); }
.tr-art svg { width: 100%; height: 220px; }
.tr-meta h1 { margin: 2px 0 2px; font: 500 34px/1.1 var(--serif); }
.tr-meta .code { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .04em; font-size: 18px; }
.tr-meta .when { color: var(--ink-2); margin-top: 6px; }
.tr-meta .auto { color: var(--ink-3); font-size: 12.5px; margin-top: 10px; display: flex; align-items: center; gap: 6px; }
.tr-meta .auto::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #5d9a5a; box-shadow: 0 0 0 0 rgba(93, 154, 90, .6); animation: ping 2s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 8px rgba(93, 154, 90, 0); } 100% { box-shadow: 0 0 0 0 rgba(93, 154, 90, 0); } }
.steps { list-style: none; margin: 0; padding: 22px 24px 10px; display: grid; grid-template-columns: repeat(4, 1fr); position: relative; }
.steps li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; font-size: 13px; font-weight: 700; color: var(--ink-3); }
.steps li::before { content: ''; position: absolute; top: 15px; left: -50%; width: 100%; height: 3px; background: var(--line); z-index: 0; }
.steps li:first-child::before { display: none; }
.steps li.done::before, .steps li.cur::before { background: var(--sage); }
.steps .dot { position: relative; z-index: 1; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: #fff; border: 3px solid var(--line); transition: all .4s var(--spring); }
.steps .dot svg { width: 16px; height: 16px; opacity: 0; }
.steps li.done .dot { background: var(--sage); border-color: var(--sage); color: #fff; }
.steps li.done .dot svg { opacity: 1; }
.steps li.cur { color: var(--ink); }
.steps li.cur .dot { border-color: var(--sage); box-shadow: 0 0 0 6px rgba(111, 138, 106, .18); }
.steps li.cur .dot::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--sage); position: absolute; }
.steps small { font-weight: 600; color: var(--ink-3); font-size: 11.5px; min-height: 1em; }
.cancelled-note { margin: 18px 24px 0; padding: 12px 14px; border-radius: 12px; background: #fbe9e7; color: #8c1d18; font-weight: 700; }
.tr-lines { padding: 8px 24px 22px; }
.tr-lines .lines { max-height: none; border: 0; }
.tr-lines .sums { border-top: 1.5px dashed var(--line); }
.tr-actions { display: flex; gap: 8px; padding: 0 24px 24px; }
.tr-actions .cta { margin: 0; width: auto; padding: 0 22px; }
@media (max-width: 640px) {
  .tr-top { grid-template-columns: 1fr; padding: 16px; text-align: center; }
  .tr-meta .code, .tr-meta .auto { justify-content: center; }
  .tr-art svg { height: 190px; }
  .steps { padding: 18px 8px 6px; }
  .steps li { font-size: 11.5px; }
  .tr-lines { padding: 6px 16px 18px; } .tr-actions { padding: 0 16px 18px; } .tr-actions .cta { width: 100%; }
}

/* ---------- admin ---------- */
.page-admin { background: #efe6d8; }
.page-admin::before { display: none; }
.adm { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 20px 18px 40px; }
.login { max-width: 380px; margin: 9vh auto; background: var(--paper); border-radius: 20px; padding: 26px; box-shadow: var(--shadow-2); }
.login h1 { margin: 0 0 14px; font: 500 30px var(--serif); }
.login form { display: grid; gap: 10px; }
.login input { height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 16px; }
.login .cta { margin-top: 4px; }
.adm-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.adm-head h1 { margin: 0; font: 500 32px var(--serif); }
.kpis { display: flex; gap: 10px; flex-wrap: wrap; }
.kpi { background: var(--paper); border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow-1); min-width: 120px; }
.kpi span { display: block; font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.kpi b { font-size: 22px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; }
.tabs button { flex: none; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); font-weight: 700; font-size: 13.5px; }
.tabs button[aria-selected=true] { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs button i { font-style: normal; opacity: .65; margin-left: 4px; }
.olist { display: grid; gap: 10px; }
.ord { background: var(--paper); border-radius: 16px; box-shadow: var(--shadow-1); display: grid; grid-template-columns: 110px 1fr auto; gap: 16px; padding: 14px 16px; align-items: start; }
.ord.fresh { animation: fresh 2.5s var(--ease); }
@keyframes fresh { 0%, 30% { box-shadow: 0 0 0 3px var(--gold), var(--shadow-1); } }
.ord .art svg { width: 110px; height: 120px; }
.ord h3 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 17px; flex-wrap: wrap; }
.ord .badge { font-size: 11px; font-weight: 800; letter-spacing: .06em; padding: 3px 8px; border-radius: 999px; background: var(--paper-2); color: var(--ink-2); text-transform: uppercase; }
.ord .badge.st-new { background: #fbe3c3; color: #7a4a0c; } .ord .badge.st-preparing { background: #e8e1f7; color: #4b3a86; }
.ord .badge.st-on_the_way { background: #dcecf7; color: #1d5b85; } .ord .badge.st-delivered { background: #e1efdc; color: #2f6b2a; }
.ord .badge.st-cancelled { background: #f6dcdc; color: #8c1d18; }
.ord .meta { color: var(--ink-2); font-size: 13.5px; margin-top: 4px; display: grid; gap: 2px; }
.ord .meta a { color: var(--accent); font-weight: 700; text-decoration: none; }
.ord .comp { margin-top: 6px; font-size: 13.5px; }
.ord .cardtxt { font-family: Caveat, var(--sans); font-size: 19px; color: var(--ink); }
.ord .right { text-align: right; display: grid; gap: 8px; justify-items: end; }
.ord .right b { font-size: 20px; }
.ord .act { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.ord .act button { height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-weight: 700; font-size: 13px; }
.ord .act button.next { background: var(--ink); color: #fff; border-color: var(--ink); }
.ord .act button.cancel { color: #8c1d18; }
.empty-list { text-align: center; padding: 40px; color: var(--ink-3); background: var(--paper); border-radius: 16px; }
@media (max-width: 720px) {
  .ord { grid-template-columns: 74px 1fr; }
  .ord .art svg { width: 74px; height: 84px; }
  .ord .right { grid-column: 1 / -1; text-align: left; justify-items: stretch; grid-template-columns: auto 1fr; align-items: center; }
  .ord .act { justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
