/* One dark interface. Its ground follows the stage, its accent follows the flowers (ui/theme.js). */
:root {
  --stage: #0b0710;
  --ground: #0b0710;
  --bloom: #ff9fbd;
  --surface: color-mix(in srgb, var(--ground) 95%, #fff);
  --raised: color-mix(in srgb, var(--ground) 90%, #fff);
  --raised-2: color-mix(in srgb, var(--ground) 85%, #fff);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.2);
  --control: rgba(255, 255, 255, 0.42); /* edges of fields: 3:1 on the panel */
  --text: #f3edf1;
  --soft: #bfb5bd;
  --gift: #f1cf8e;
  --error: #ff9d9d;
  --solid: #f5eff2;
  --solid-ink: #17101a;
  --radius: 8px;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { color-scheme: dark; background: var(--ground); }
body { background: var(--ground); color: var(--text); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--bloom); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon { display: block; flex: none; }
h1, h2, h3, p, ul { margin: 0; }

/* --- buttons --- */
.btn {
  color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; font-weight: 500; text-decoration: none; white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, transform 0.08s;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn--primary { background: var(--solid); color: var(--solid-ink); }
.btn--quiet { background: var(--raised); }
.btn--light { background: var(--solid); color: var(--solid-ink); height: 46px; padding: 0 30px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
@media (hover: hover) and (pointer: fine) {
  .btn--primary:hover:not(:disabled), .btn--light:hover { background: #fff; }
  .btn--quiet:hover:not(:disabled) { background: var(--raised-2); }
}

.chip {
  height: 32px; padding: 0 12px; border: 0; border-radius: var(--radius);
  background: color-mix(in srgb, var(--stage) 82%, #fff); color: #efe6ee; font: 13px var(--mono); text-decoration: none;
  display: inline-flex; align-items: center; white-space: nowrap; transition: background-color 0.15s, color 0.15s;
}
.chip:active { transform: scale(0.98); }
.chip--solid { background: var(--solid); color: var(--solid-ink); }
@media (hover: hover) and (pointer: fine) {
  .chip:hover { background: color-mix(in srgb, var(--stage) 74%, #fff); color: #fff; }
  .chip--solid:hover { background: #fff; color: var(--solid-ink); }
}

.link { background: none; border: 0; border-radius: 4px; padding: 0; color: var(--soft); font: 500 13px var(--sans); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 4px; }
@media (hover: hover) and (pointer: fine) { .link:hover { color: var(--text); text-decoration-color: currentColor; } }

.iconbtn { width: 36px; height: 36px; flex: none; border: 0; border-radius: var(--radius); background: none; color: var(--soft); display: grid; place-items: center; padding: 0; transition: background-color 0.15s, color 0.15s; }
.iconbtn:disabled { opacity: 0.32; }
@media (hover: hover) and (pointer: fine) { .iconbtn:hover:not(:disabled) { background: var(--raised); color: var(--text); } }

/* --- top bar --- */
.builder { height: 100vh; height: calc(100dvh - var(--kb, 0px)); display: flex; flex-direction: column; overflow: hidden; background: var(--ground); transition: background-color 0.3s; }
.topbar {
  display: flex; align-items: center; gap: 12px; flex: none;
  padding: max(10px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left));
  background: var(--ground); border-bottom: 1px solid var(--line); transition: background-color 0.3s;
}
.wordmark { font: 600 17px var(--mono); color: var(--text); text-decoration: none; letter-spacing: -0.02em; display: flex; align-items: center; gap: 7px; border-radius: 4px; }
.wordmark__mark { color: var(--bloom); transition: color 0.3s; }
.history { display: flex; gap: 2px; margin-left: 8px; }
.topbar__actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.plan-state {
  height: 38px; padding: 0 12px; border: 0; border-radius: var(--radius); background: none; color: var(--soft); font: 500 14px var(--sans);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; transition: background-color 0.15s;
}
.plan-state.is-gift { color: var(--gift); }
#planPrice { font-variant-numeric: tabular-nums; }
#planPrice:empty { display: none; }
@media (hover: hover) and (pointer: fine) { .plan-state:hover { background: var(--raised); } }

/* --- layout --- */
.workspace { flex: 1; min-height: 0; position: relative; display: grid; grid-template-columns: minmax(0, 1fr) clamp(380px, 31vw, 540px); grid-template-rows: auto minmax(0, 1fr); }
.stage { grid-column: 1; grid-row: 1 / 3; position: relative; min-width: 0; background: var(--stage); transition: background-color 0.3s; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage__tools { position: absolute; left: 20px; bottom: 20px; display: flex; gap: 8px; }
.stage__tools .chip { gap: 7px; padding: 0 12px 0 9px; }

.steps { grid-column: 2; grid-row: 1; display: flex; gap: 2px; padding: 10px 14px; background: var(--surface); border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); counter-reset: step; transition: background-color 0.3s; }
.tab {
  counter-increment: step; flex: 1 1 auto; display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 0 8px; border: 0; border-radius: var(--radius); background: none;
  color: var(--soft); font: 500 14px var(--sans); white-space: nowrap; transition: background-color 0.15s, color 0.15s;
}
.tab::before { content: counter(step); font: 500 12px var(--mono); color: var(--soft); transition: color 0.15s; }
.tab[aria-selected="true"] { background: var(--raised-2); color: var(--text); }
.tab[aria-selected="true"]::before { color: var(--bloom); }
@media (hover: hover) and (pointer: fine) { .tab:hover { color: var(--text); } }

.panel { grid-column: 2; grid-row: 2; min-height: 0; min-width: 0; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); transition: background-color 0.3s; }
.panel__head { display: none; }
.panel__body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; container: body / inline-size; }
.tabpanel { padding: 22px 24px 8px; }
.next { padding: 20px 24px 28px; }
.next .btn { width: 100%; height: 44px; }

.lede { font: 500 17px/1.4 var(--sans); margin-bottom: 18px; text-wrap: balance; }
.group { margin-top: 28px; }
.group__title { font: 500 14px/1.4 var(--sans); margin-bottom: 10px; display: flex; align-items: baseline; gap: 8px; }
.kinds + .group__title { margin-top: 26px; }
.field__label { font: 500 13px/1.4 var(--sans); color: var(--soft); margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.count { font: 400 13px var(--mono); color: var(--soft); font-variant-numeric: tabular-nums; }
.empty { color: var(--soft); font-size: 14px; padding: 12px 0; }
.error { color: var(--error); font-size: 14px; margin-top: 8px; }
.error:empty { display: none; }
.rowhead { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; min-height: 32px; }
.rowhead .group__title { margin: 0; margin-right: auto; }
.rowhead__tools { display: flex; gap: 16px; }

/* --- pictures --- */
.pic { display: block; width: 100%; border-radius: var(--radius); background: var(--stage); transition: box-shadow 0.15s, opacity 0.2s; box-shadow: inset 0 0 0 1px var(--line); }
canvas.pic { opacity: 0; box-shadow: 0 0 0 1px var(--line); }
canvas.pic.is-ready { opacity: 1; }
.opt, .preset, .kind, .flowerbtn, .stem__btn { position: relative; border: 0; padding: 0; background: none; text-align: left; border-radius: var(--radius); }
.opt:active, .preset:active, .kind:active, .flowerbtn:active { transform: scale(0.985); }
@media (hover: hover) and (pointer: fine) {
  :is(.opt, .preset, .flowerbtn, .stem__btn, .kind):hover .pic { box-shadow: 0 0 0 1px var(--control); }
}
:is(.opt, .preset, .flowerbtn, .stem__btn, .kind)[aria-pressed="true"] .pic { box-shadow: 0 0 0 2px var(--bloom); }

/* step 1 */
.kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.kind .pic { aspect-ratio: 1 / 1; }
.kind__text { display: block; padding: 10px 2px 0; }
.kind b { display: block; font: 500 16px/1.3 var(--sans); }
.kind small { display: block; color: var(--soft); font-size: 13px; line-height: 1.4; margin-top: 2px; }
.kind[aria-pressed="true"] b { color: var(--bloom); }
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 14px; }
.preset .pic { aspect-ratio: 4 / 5; }
.preset__name { display: block; padding: 8px 2px 0; font-size: 14px; line-height: 1.35; }
.hscroll { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: contain; margin: 0 -24px 14px; padding: 2px 24px; }
.hscroll::-webkit-scrollbar { display: none; }
.filter { flex: none; height: 34px; padding: 0 13px; border: 0; border-radius: 17px; background: var(--raised); color: var(--soft); font-size: 14px; white-space: nowrap; transition: background-color 0.15s, color 0.15s; }
.filter[aria-pressed="true"] { background: var(--solid); color: var(--solid-ink); }
@media (hover: hover) and (pointer: fine) { .filter:not([aria-pressed="true"]):hover { color: var(--text); background: var(--raised-2); } }

/* step 2 */
.strip { list-style: none; display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; margin: 0 -24px; padding: 4px 24px 10px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; overscroll-behavior-x: contain; }
.strip:empty { display: none; }
.stem { flex: none; width: 72px; transition: transform 0.18s var(--ease); }
.stem.is-held { transition: none; z-index: 2; position: relative; opacity: 0.92; }
.stem.is-held .pic { box-shadow: 0 0 0 2px var(--control); }
.stem.is-new { animation: stemIn 0.3s var(--ease); }
@keyframes stemIn { from { opacity: 0; transform: scale(0.8); } }
.stem__btn { width: 72px; display: block; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.stem__btn .pic { aspect-ratio: 1; }
.stem__name { display: block; padding-top: 5px; font-size: 12px; line-height: 1.3; color: var(--soft); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stem__btn[aria-pressed="true"] .stem__name { color: var(--text); }
.editor { margin-top: 10px; padding: 14px; border-radius: 12px; background: var(--raised); display: grid; gap: 14px; }
.toolrow { display: flex; gap: 6px; }
.tool { height: 36px; padding: 0 12px; border: 0; border-radius: var(--radius); background: var(--raised-2); font-size: 14px; display: inline-flex; align-items: center; justify-content: center; transition: background-color 0.15s; flex: 1 1 auto; white-space: nowrap; }
.tool--icon { padding: 0 8px; flex: 0 1 40px; }
.tool:disabled { opacity: 0.35; }
.tool[aria-pressed="true"] { background: var(--solid); color: var(--solid-ink); }
@media (hover: hover) and (pointer: fine) { .tool:hover:not(:disabled):not([aria-pressed="true"]) { background: color-mix(in srgb, var(--raised-2) 90%, #fff); } }
.florist { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--raised); display: flex; align-items: center; gap: 14px; }
.florist p { flex: 1; font-size: 14px; color: var(--soft); line-height: 1.45; }
.florist b { display: block; color: var(--text); font-weight: 500; }
.florist .btn { background: var(--raised-2); height: 36px; padding: 0 12px; font-size: 14px; white-space: normal; text-align: left; line-height: 1.25; }
.palette { position: relative; flex: none; width: 124px; padding: 0; border: 0; background: none; border-radius: var(--radius); text-align: left; }
.palette__dots { display: flex; height: 44px; border-radius: var(--radius); overflow: hidden; }
.palette__dots i { flex: 1; }
.palette__name { display: block; padding: 6px 2px 0; font-size: 13px; line-height: 1.3; color: var(--soft); }
.palette[aria-pressed="true"] .palette__dots { box-shadow: 0 0 0 2px var(--ground), 0 0 0 4px var(--bloom); }
.palette[aria-pressed="true"] .palette__name { color: var(--text); }
.palettes { padding-top: 5px; padding-bottom: 5px; gap: 12px; }
.seg { display: flex; padding: 3px; border-radius: var(--radius); background: var(--raised); }
.seg button { height: 30px; padding: 0 12px; border: 0; border-radius: 6px; background: none; color: var(--soft); font-size: 13px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--raised-2); color: var(--text); }
.search input {
  width: 100%; height: 40px; padding: 0 12px 0 38px; border: 1px solid transparent; border-radius: var(--radius); appearance: none; -webkit-appearance: none;
  background: var(--raised) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23bfb5bd' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M16 16l5 5M18 11a7 7 0 1 1-14 0 7 7 0 0 1 14 0z'/%3E%3C/svg%3E") 12px 50% no-repeat;
}
.search input::placeholder { color: var(--soft); opacity: 1; }
.search input:focus-visible { outline-offset: 0; }
.flowergroup { margin-top: 18px; }
.flowergroup .count { font-family: var(--sans); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.flowergrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.flowerbtn .pic { aspect-ratio: 1; }
.flowerbtn__name { display: block; padding-top: 6px; font-size: 13px; line-height: 1.3; text-align: center; }
.flowerbtn__count { position: absolute; left: 6px; top: 6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--bloom); color: #17101a; font: 600 12px/22px var(--mono); text-align: center; }
.flowerbtn__count:empty { display: none; }
.flowerbtn:disabled { opacity: 0.4; cursor: not-allowed; }

/* swatches */
.colorrow { display: flex; flex-wrap: wrap; gap: 0; align-items: center; margin: 0 -4px; }
.swatch, .custom { width: 36px; height: 36px; padding: 4px; border: 0; background: none; border-radius: 50%; display: block; position: relative; }
.swatch span { display: block; width: 100%; height: 100%; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22); transition: transform 0.12s; }
.swatch[aria-pressed="true"] span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--bloom); }
.editor .swatch[aria-pressed="true"] span { box-shadow: 0 0 0 2px var(--raised), 0 0 0 4px var(--bloom); }
.swatch:active span { transform: scale(0.9); }
.custom { cursor: pointer; padding: 0; }
.custom.is-on::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; pointer-events: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--bloom); }
.editor .custom.is-on::after { box-shadow: 0 0 0 2px var(--raised), 0 0 0 4px var(--bloom); }
.custom:not(.is-on)::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; pointer-events: none; background: var(--raised-2) linear-gradient(var(--text), var(--text)) 50% 50% / 12px 1.6px no-repeat; box-shadow: inset 0 0 0 1px var(--line-strong); }
.custom:not(.is-on)::before { content: ""; position: absolute; z-index: 1; left: 50%; top: 50%; width: 1.6px; height: 12px; margin: -6px 0 0 -0.8px; background: var(--text); pointer-events: none; }
.custom:focus-within { outline: 2px solid var(--bloom); }
.swatchinput { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 100%; padding: 0; border: 4px solid transparent; border-radius: 50%; background: none; cursor: pointer; overflow: hidden; }
.swatchinput::-webkit-color-swatch-wrapper { padding: 0; }
.swatchinput::-webkit-color-swatch { border: 0; border-radius: 50%; }
.swatchinput::-moz-color-swatch { border: 0; border-radius: 50%; }

/* tiles */
.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
.options--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.options--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.options--fonts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.opt .pic { aspect-ratio: 1; }
.options--tall .pic { aspect-ratio: 4 / 5; }
.options--2.options--tall .pic { aspect-ratio: 1; }
.options--wide .pic { aspect-ratio: 2 / 1; }
.opt__text { display: block; padding: 7px 2px 0; }
.opt b { display: block; font: 500 13px/1.3 var(--sans); }
.opt[aria-pressed="true"] b { color: var(--bloom); }
.opt[aria-pressed="true"] .pic--font { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--bloom) !important; }
.pic--card { display: grid; place-items: center; }
.options--4 .pic--card { aspect-ratio: 5 / 4; }
.opt .pic--font { aspect-ratio: auto; height: 60px; display: grid; place-items: center; background: var(--card-paper, #fff7ec); color: var(--card-ink, #a3324f); padding: 0 10px; overflow: hidden; }
.sample { font-size: 22px; line-height: 1.2; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.mini { position: relative; display: block; width: 46px; height: 34px; background: var(--card-paper, #fff7ec); color: var(--card-ink, #a3324f); border-radius: 2px; }
.mini i { position: absolute; left: 8px; right: 8px; height: 2px; background: currentColor; opacity: 0.75; }
.mini i:nth-child(1) { top: 9px; right: 22px; }
.mini i:nth-child(2) { top: 16px; }
.mini i:nth-child(3) { top: 23px; }
.mini--note { transform: rotate(-3deg); width: 42px; height: 40px; }
.mini--note i { margin-top: 3px; }
.mini--envelope i { left: 0; right: 0; top: 0; height: 20px; opacity: 1; background: color-mix(in srgb, var(--card-paper) 82%, #000); clip-path: polygon(0 0, 100% 0, 50% 100%); }
.mini--envelope i:nth-child(1) { right: 0; }
.mini--envelope i:nth-child(2) { top: 14px; left: 18px; right: 18px; height: 10px; background: currentColor; clip-path: circle(4px at 50% 50%); }
.mini--envelope i:nth-child(3) { display: none; }
.mini--postcard { width: 54px; }
.mini--postcard i { right: 28px; }
.mini--postcard i:nth-child(3) { left: 33px; right: 6px; top: 6px; height: 12px; background: none; box-shadow: inset 0 0 0 2px currentColor; }
.mini--tag { width: 56px; height: 28px; clip-path: polygon(12px 0, 100% 0, 100% 100%, 12px 100%, 0 50%); }
.mini--tag i { left: 20px; }
.mini--tag i:nth-child(1) { top: 8px; }
.mini--tag i:nth-child(2) { top: 16px; }
.mini--tag i:nth-child(3) { left: 8px; right: auto; width: 5px; height: 5px; top: 12px; border-radius: 50%; background: var(--stage); opacity: 1; }
.choice { margin-top: 10px; min-height: 36px; padding: 0 14px; border: 0; border-radius: var(--radius); background: var(--raised); color: var(--soft); font-size: 14px; }
.choice[aria-pressed="true"] { color: var(--bloom); box-shadow: 0 0 0 2px var(--bloom); }
.bgrow { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.bgbtn { border: 0; padding: 0; background: none; border-radius: var(--radius); font-size: 12px; color: var(--soft); }
.bgbtn span { display: block; }
.bgbtn i { display: block; height: 44px; border-radius: var(--radius); box-shadow: inset 0 0 0 1px var(--line-strong); margin-bottom: 5px; }
.bgbtn[aria-pressed="true"] { color: var(--text); }
.bgbtn[aria-pressed="true"] i { box-shadow: 0 0 0 2px var(--bloom); }

/* form fields */
.field { display: block; margin-top: 16px; }
.field:first-child { margin-top: 0; }
.field .count { margin-left: auto; }
.field .count.is-over { color: var(--error); }
.field input:not([type]), .field input[type="email"], .field textarea, .field select, .linkbox input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--control); border-radius: var(--radius); background: var(--ground); color: var(--text); transition: border-color 0.15s;
}
.field input::placeholder, .field textarea::placeholder { color: #9b919a; opacity: 1; }
.field :is(input, textarea, select):focus-visible { outline-offset: 0; border-color: transparent; }
.field [aria-invalid="true"] { border-color: var(--error); }
.field textarea { resize: vertical; min-height: 104px; display: block; line-height: 1.45; }
.fields2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fields2 .field { margin-top: 0; }
.fields2 + .field { margin-top: 16px; }
.field--range { margin-top: 28px; }
input[type="range"] { --at: 40%; appearance: none; -webkit-appearance: none; width: 100%; height: 32px; margin: 0; background: none; cursor: pointer; border-radius: 4px; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--bloom) var(--at), var(--control) var(--at)); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--control); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--bloom); }
input[type="range"]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 22px; height: 22px; margin-top: -9px; border-radius: 50%; border: 0; background: var(--solid); }
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--solid); }
.toggle { display: flex; align-items: center; gap: 10px; margin-top: 20px; min-height: 36px; font-size: 14px; cursor: pointer; }
.toggle > span:first-of-type { flex: 0 1 auto; }
.toggle input[role="switch"] { appearance: none; -webkit-appearance: none; order: 3; margin: 0 0 0 auto; flex: none; width: 42px; height: 26px; border-radius: 13px; background: var(--raised-2); box-shadow: inset 0 0 0 1px var(--control); position: relative; cursor: pointer; transition: background-color 0.18s; }
.toggle input[role="switch"]::after { content: ""; position: absolute; left: 4px; top: 4px; width: 18px; height: 18px; border-radius: 50%; background: var(--solid); transition: transform 0.18s var(--ease), background-color 0.18s; }
.toggle input[role="switch"]:checked { background: var(--bloom); box-shadow: none; }
.toggle input[role="switch"]:checked::after { transform: translateX(16px); background: var(--solid-ink); }
.toggle input:not([role="switch"]) { width: 18px; height: 18px; accent-color: var(--bloom); margin: 0; }
.cardpreview { background: var(--stage); border-radius: var(--radius); padding: 24px 16px; display: grid; place-items: center; box-shadow: inset 0 0 0 1px var(--line); transition: background-color 0.3s; overflow: hidden; }

/* gift labels */
.paidtag { font: 500 12px/1 var(--sans); color: var(--gift); }
.paidtag--inline { flex: none; }
:is(.opt, .preset, .flowerbtn, .palette) > .paidtag { position: absolute; right: 6px; top: 6px; padding: 4px 7px; border-radius: 5px; background: rgba(8, 5, 10, 0.82); pointer-events: none; }
/* drawn tiles keep the label off the drawing */
.options--plain .opt { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.options--plain .opt > .paidtag { position: static; padding: 0; background: none; }
body:not(.has-gifts) .paidtag { display: none; }
.photorow { display: flex; gap: 14px; align-items: center; }
.photorow__btns { display: flex; gap: 14px; align-items: center; }
.photobox canvas { display: block; max-width: 96px; height: auto; border: 4px solid #fffaf3; border-radius: 2px; }

/* --- cards --- */
.card {
  --card-paper: #fff7ec; --card-ink: #a3324f;
  position: relative; width: min(320px, 100%); color: var(--card-ink); background: var(--card-paper);
  font-size: 22px; line-height: 1.35; overflow-wrap: anywhere;
}
.card__to { margin-bottom: 6px; }
.card__msg { white-space: pre-wrap; min-height: 1.35em; }
.card__from { margin-top: 12px; text-align: right; }
.card--note {
  padding: 22px 24px 20px; border-radius: 2px; transform: rotate(-1.2deg);
  /* ruled lines like stationery */
  background-image: repeating-linear-gradient(to bottom, transparent 0 calc(1.35em - 1px), rgba(0, 0, 0, 0.08) calc(1.35em - 1px) 1.35em);
  background-position: 0 23px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15), 0 10px 30px rgba(0, 0, 0, 0.35);
}
.card--note::after { content: ""; position: absolute; right: 0; bottom: 0; border-width: 0 0 22px 22px; border-style: solid; border-color: transparent transparent rgba(0, 0, 0, 0.12) transparent; }
.card--postcard { width: min(380px, 100%); display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; padding: 18px; border-radius: 3px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); font-size: 19px; }
.card--postcard .pc__side { border-left: 1px solid currentColor; padding-left: 14px; display: flex; flex-direction: column; gap: 10px; opacity: 0.95; }
.pc__stamp { align-self: flex-end; width: 54px; height: 64px; border: 2px dashed currentColor; display: grid; place-items: center; font: 600 11px/1.05 var(--mono); text-align: center; white-space: pre; }
.pc__line { border-bottom: 1px solid currentColor; padding-bottom: 2px; font-size: 17px; }
.card--tag {
  width: min(300px, 100%); padding: 22px 26px 22px 54px; border-radius: 3px;
  clip-path: polygon(30px 0, 100% 0, 100% 100%, 30px 100%, 0 50%);
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.35));
}
.card--tag::before { content: ""; position: absolute; left: 22px; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%; background: var(--stage, #0b0710); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.2); }
/* Envelope: the flap swings up, then the letter slides out of the pocket. */
.envelope { --card-paper: #fff7ec; position: relative; width: min(340px, 100%); height: 170px; margin-top: 190px; perspective: 800px; }
.envelope__back, .envelope__front, .envelope__flap { position: absolute; left: 0; right: 0; border-radius: 3px; }
.envelope__back { inset: 0; background: color-mix(in srgb, var(--card-paper) 72%, #000); }
.envelope__front { inset: 0; z-index: 3; background: color-mix(in srgb, var(--card-paper) 92%, #000); clip-path: polygon(0 0, 50% 52%, 100% 0, 100% 100%, 0 100%); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }
.envelope__flap {
  top: 0; height: 100px; z-index: 4; background: color-mix(in srgb, var(--card-paper) 90%, #000);
  clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top; transition: transform 0.55s ease, z-index 0s 0.28s;
}
.envelope .card {
  position: absolute; left: 6%; right: 6%; bottom: 10px; width: auto; z-index: 2; padding: 16px 18px;
  max-height: 170px; overflow: hidden; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transform: translateY(0); transition: transform 0.8s cubic-bezier(.2, .8, .2, 1) 0.45s;
}
.envelope.is-open .envelope__flap { transform: rotateX(180deg); z-index: 1; }
.envelope.is-open .card { max-height: 360px; overflow: auto; padding-bottom: 56px; transform: translateY(calc(-100% + 22px)); }

.card__mark {
  position: absolute; top: 8px; right: 10px; z-index: 1; pointer-events: none; opacity: 0.55;
  font: 600 10px/1 var(--mono); letter-spacing: 0.12em; color: inherit;
}

/* The open letter needs its full height above the envelope, or it covers the photo row. */
.cardpreview .envelope { margin-top: 290px; }
.cardpreview .envelope.is-open .card { max-height: 240px; }

/* --- recipient view --- */
.viewer { position: fixed; inset: 0; background: var(--stage); color: #f3e9ef; overflow: hidden; transition: background-color 0.3s; }
.viewer canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.intro {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  text-align: center; padding: 24px; transition: opacity 0.5s ease;
}
.intro.is-leaving { opacity: 0; pointer-events: none; }
.intro__for { margin: 0; font: 600 clamp(28px, 6vw, 44px)/1.1 var(--mono); letter-spacing: -0.02em; }
.intro__line { margin: 0 0 14px; color: #cdbfca; font-size: 17px; }
.viewer__card {
  position: absolute; right: 6vw; top: 50%; transform: translateY(-50%); width: min(380px, 40vw);
  display: grid; place-items: center; animation: cardIn 0.7s cubic-bezier(.2,.8,.2,1);
}
.viewer__card.is-hiding { animation: cardOut 0.35s ease forwards; }
@keyframes cardIn { from { opacity: 0; transform: translateY(calc(-50% + 30px)); } }
@keyframes cardOut { to { opacity: 0; transform: translateY(calc(-50% + 20px)); } }
.viewer__bar { position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 8px; animation: fadeIn 0.5s ease; }
@keyframes fadeIn { from { opacity: 0; } }

.viewer__close { position: absolute; left: 14px; top: max(14px, env(safe-area-inset-top)); height: 36px; }
.viewer__report { position: absolute; right: 10px; top: max(6px, env(safe-area-inset-top)); background: none; border: 0; color: #a696a3; font: 12px var(--mono); padding: 10px; text-decoration: underline; text-underline-offset: 3px; }
.viewer__made { position: absolute; left: 14px; top: max(16px, env(safe-area-inset-top)); color: #cdbfca; font: 12px var(--mono); text-decoration: none; }
.viewer__bar .chip { height: 40px; }
.viewer__photo {
  position: absolute; left: 4vw; bottom: 80px; z-index: 2; padding: 8px 8px 26px; border: 0; border-radius: 2px; background: #fffaf3; transform: rotate(-3deg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); cursor: zoom-in; animation: fadeIn 0.7s ease; transition: transform 0.25s ease;
}
/* sized by .viewer__photo so the stage's full-bleed canvas rule doesn't apply */
.viewer .viewer__photo img, .viewer .viewer__photo canvas { position: static; display: block; width: auto; height: auto; max-width: 190px; max-height: 210px; }
.viewer__photo.is-large { left: 50%; top: 50%; bottom: auto; transform: translate(-50%, -50%); z-index: 6; cursor: zoom-out; animation: none; }
.viewer .viewer__photo.is-large img { max-width: min(86vw, 900px); max-height: 76vh; }
.viewer__card .card { max-height: 74vh; overflow-y: auto; }
.viewer__card .envelope .card { max-height: 170px; overflow: hidden; }
.viewer__card .envelope.is-open .card { max-height: 360px; overflow-y: auto; }


/* --- dialogs --- */
.sheet { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 24px); overflow-y: auto; background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line-strong), 0 24px 70px rgba(0, 0, 0, 0.6); overscroll-behavior: contain; }
.sheet--small { width: min(420px, calc(100vw - 32px)); }
.sheet::backdrop { background: rgba(6, 4, 8, 0.66); }
.sheet[open] { animation: sheetIn 0.22s var(--ease); }
@keyframes sheetIn { from { opacity: 0; transform: translateY(8px); } }
.sheet__inner { padding: 22px 24px 24px; }
.sheet__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sheet__head h2 { font: 600 20px/1.3 var(--sans); }
.sheet__text { margin-top: 12px; color: var(--soft); font-size: 14px; }
.sheet__text:empty { display: none; }
.sheet__status { color: var(--text); }
.sheet__warn { color: var(--error); }
.linkbox { display: flex; gap: 8px; }
.linkbox input { font: 13px var(--mono); min-width: 0; }
.linkbox .btn { height: auto; min-height: 42px; }
.sheet__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.sheet__actions .btn { width: 100%; min-height: 44px; }
.sheet:focus-visible { outline: none; }
.sheet a:not(.btn), .prose a:not(.btn) { color: var(--text); text-decoration-color: var(--control); text-underline-offset: 3px; }
/* 16px stops phones from zooming into the field */
.sheet .field input, .sheet .field textarea, .sheet .field select, .prose .field input, .prose .field textarea, .prose .field select { font-size: 16px; }
.parts { margin: 12px 0 0; padding: 0; list-style: none; max-height: 34vh; overflow-y: auto; }
.parts:empty { display: none; }
.parts li { padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.plan { border-radius: 12px; padding: 16px 18px 18px; margin-top: 12px; background: var(--raised); }
.plan--gift { background: none; box-shadow: inset 0 0 0 1px var(--gift); }
.plan__head { display: flex; justify-content: space-between; align-items: baseline; }
.plan__head h3 { font: 600 17px var(--sans); }
.plan__head span { font: 500 16px var(--sans); font-variant-numeric: tabular-nums; }
.plan--gift .plan__head span { color: var(--gift); }
.plan p { margin-top: 6px; font-size: 14px; color: var(--soft); }
.plan .plan__needs { color: var(--text); }
.plan__row { display: flex; gap: 10px 14px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.plan__row .btn { min-height: 44px; }
.plan .btn--quiet { background: var(--raised-2); }
.plan .sheet__status:empty { display: none; }
.sheet--small .plan__row .btn { flex: 1 1 auto; }
.choices { border: 0; padding: 0; margin: 14px 0 0; display: grid; gap: 2px; }
.choices legend { padding: 0; }
.choices label { display: flex; gap: 12px; align-items: center; min-height: 44px; border-bottom: 1px solid var(--line); cursor: pointer; }
.choices input { width: 18px; height: 18px; accent-color: var(--bloom); margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translate(-50%, 14px); opacity: 0; pointer-events: none;
  background: var(--solid); color: var(--solid-ink); padding: 10px 16px; border-radius: var(--radius); font: 500 14px/1.35 var(--sans);
  transition: opacity 0.2s, transform 0.2s; z-index: 50; max-width: calc(100vw - 32px); width: max-content; text-align: center;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* --- other pages --- */
body.doc { overflow-y: auto; }
.doc .topbar { position: sticky; top: 0; z-index: 5; }
.giftpage { background: var(--stage); }
.prose { max-width: 620px; margin: 0 auto; padding: 40px 20px 72px; }
.prose h1 { font: 600 28px/1.2 var(--sans); margin: 0 0 14px; letter-spacing: -0.01em; text-wrap: balance; }
.prose h2 { font: 600 17px/1.3 var(--sans); margin: 32px 0 6px; }
.prose p, .prose ul { margin: 0 0 12px; color: #d8cfd6; }
.prose ul { padding-left: 20px; }
.prose li { margin-bottom: 6px; }
.prose .sheet__status { color: var(--text); }
.prose__foot { display: flex; gap: 16px; margin-top: 40px !important; border-top: 1px solid var(--line); padding-top: 14px; }
.prose--form .field { margin-top: 18px; margin-bottom: 12px; }
.prose--form .fields2 .field { margin-top: 0; }

/* --- phones and tablets: the menus are a sheet over the stage (ui/sheet.js) --- */
@media (max-width: 900px) and (min-height: 500px), (max-width: 600px) {
  .topbar { padding: max(4px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 4px max(14px, env(safe-area-inset-left)); gap: 4px; border-bottom: 0; }
  .wordmark { min-height: 44px; min-width: 44px; }
  .history { margin-left: 0; }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; overflow: hidden; }
  .stage { grid-column: 1; grid-row: 1; }
  .stage__tools { left: 0; right: 0; top: 0; bottom: auto; padding: 0 4px; justify-content: space-between; }
  .stage__tools .chip { width: 44px; padding: 0; justify-content: center; background: none; color: var(--soft); }
  .stage__tools .chip span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .panel {
    grid-column: 1 / 2; grid-row: 1 / 2; position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; border: 0; border-radius: 16px 16px 0 0;
    box-shadow: 0 -1px 0 var(--line-strong); transition: transform 0.28s var(--ease), background-color 0.3s; will-change: transform;
  }
  .panel.is-dragging, .panel.is-quick { transition: none; }
  .panel__head { display: flex; align-items: center; flex: none; height: 48px; padding: 0 6px 0 0; }
  .panel__grab { position: relative; flex: 1; align-self: stretch; display: flex; align-items: center; padding-left: 18px; touch-action: none; cursor: grab; border-radius: 16px 0 0 0; user-select: none; -webkit-user-select: none; }
  .panel__grab:focus-visible { outline-offset: -3px; }
  .grip { position: absolute; top: 7px; left: 50vw; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--control); }
  .panel__title { font: 600 16px var(--sans); }
  .panel__body { flex: none; height: 300px; }
  .tabpanel { padding: 0 16px 4px; }
  .next { padding: 18px 16px 22px; }
  .hscroll, .strip { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  .steps { grid-column: 1; grid-row: 2; z-index: 3; gap: 0; padding: 0 max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left)); border: 0; border-top: 1px solid var(--line); }
  .tab { flex: 1 1 0; flex-direction: column; gap: 1px; min-height: 56px; padding: 0 2px; border-radius: 0; font-size: 13px; line-height: 1.25; }
  .tab[aria-selected="true"] { background: none; color: var(--bloom); }
  .is-typing .steps, .is-typing .stage__tools { display: none; }
  .toast { bottom: calc(72px + env(safe-area-inset-bottom)); }
  .kind .pic { aspect-ratio: 3 / 2; }
  .lede { font: 400 14px/1.4 var(--sans); color: var(--soft); margin-bottom: 10px; text-wrap: wrap; }
  .group { margin-top: 22px; }
  .strip { padding-bottom: 6px; }
  .rowhead { margin-bottom: 4px; }
  #stemList ~ .group { margin-top: 12px; }

  .viewer__card { left: 50%; right: auto; top: auto; bottom: max(72px, calc(60px + env(safe-area-inset-bottom))); }
}
@media (max-width: 900px) {
  .viewer__card { left: 50%; right: auto; top: auto; bottom: max(72px, calc(60px + env(safe-area-inset-bottom))); transform: translateX(-50%); width: min(360px, calc(100vw - 32px)); animation-name: cardInM; }
  .viewer__card.is-hiding { animation-name: cardOutM; }
  @keyframes cardInM { from { opacity: 0; transform: translate(-50%, 30px); } }
  @keyframes cardOutM { to { opacity: 0; transform: translate(-50%, 20px); } }
  .card { font-size: 19px; }
  .envelope { margin-top: 150px; }
  /* Beside the narrow end of the bouquet, off the flowers. */
  .viewer__photo { left: 10px; top: 33svh; bottom: auto; padding: 4px 4px 14px; }
  .viewer .viewer__photo img, .viewer .viewer__photo canvas { max-width: 84px; max-height: 84px; }
  .viewer__card .card { max-height: 44svh; }

  /* every control is at least 44px */
  .btn, .chip, .viewer__close { height: auto; min-height: 44px; }
  .link, .choice, .filter, .tool, .plan-state { min-height: 44px; min-width: 44px; }
  .filter { border-radius: 22px; }
  .link { padding: 0 2px; }
  .iconbtn { width: 44px; height: 44px; }
  .rowhead { min-height: 44px; }
  .seg button { height: 44px; }
  .seg { padding: 0 3px; }
  .swatch, .custom { width: 44px; height: 44px; padding: 5px; }
  .custom { padding: 0; }
  .swatchinput { border-width: 5px; }
  .custom::after { inset: 5px !important; }
  .colorrow { margin: 0 -5px; }
  .opt, .toggle, .field input, .field select, .linkbox input, .search input { min-height: 44px; }
  .field input:not([type="range"]), .field textarea, .search input { font-size: 16px; }
  input[type="range"] { min-height: 44px; }
  .bgbtn { min-height: 66px; }
  .viewer__report { min-height: 44px; min-width: 44px; }
  .viewer__made { min-height: 44px; top: max(4px, env(safe-area-inset-top)); display: inline-flex; align-items: center; }
}
@media (max-width: 520px) {
  .wordmark__name { display: none; }
  .doc .wordmark__name { display: inline; }
  .wordmark { font-size: 20px; }
  .topbar__actions { gap: 4px; }
  .topbar .btn { padding: 0 13px; }
  .topbar .btn--quiet { background: none; padding: 0 9px; }
  .plan-state { padding: 0 8px; font-size: 13px; }
  .sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 16px 16px 0 0; }
  .sheet__inner { padding: 18px 16px max(20px, env(safe-area-inset-bottom)); }
  .plan .btn { flex: 1 1 auto; }
  .card--postcard { grid-template-columns: 1fr; }
  .card--postcard .pc__side { border-left: 0; border-top: 1px solid currentColor; padding: 10px 0 0; }
  .viewer__bar .chip { padding: 0 9px; font-size: 12px; }
  .options--4 { gap: 12px 10px; }
  .tool { padding: 0 9px; }
  .bgrow { gap: 6px; }
}
@container body (min-width: 600px) {
  .presets { grid-template-columns: repeat(3, 1fr); }
  .flowergrid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .options--3 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .options--2.options--tall, .options--fonts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .options--4 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .kind .pic { aspect-ratio: 2 / 1; }
}
@container body (min-width: 500px) and (max-width: 599px) {
  .flowergrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 601px) and (max-width: 900px) and (max-height: 499px) {
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(340px, 46vw); }
  .topbar { padding-top: 2px; padding-bottom: 2px; }
  .steps { padding: 2px 6px; }
  .tab { min-height: 44px; font-size: 13px; gap: 5px; padding: 0 4px; }
  .tabpanel, .next { padding-left: 14px; padding-right: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  [aria-pressed="true"] .pic, .tab[aria-selected="true"] { outline: 2px solid Highlight; }
}
@media (max-width: 385px) {
  .plan-state.is-gift #planName { display: none; }
  .toolrow { flex-wrap: wrap; }
}
@media (max-width: 345px) {
  .builder .wordmark { display: none; }
}
