:root {
  color-scheme: light;
  --bg: #eef0ea;
  --surface: #fbfbf8;
  --ink: #22302e;
  --muted: #56635e;
  --line: #d9ddd4;
  --line-strong: #b9c0b5;
  --accent: #2c5a6b;
  --accent-dark: #224857;
  --accent-ink: #f6f9f9;
  --accent-soft: #e1eaea;
  --ochre: #9c6f28;
  --ochre-soft: #f4ead8;
  --radius: 12px;
  --title: "Young Serif", Georgia, "Times New Roman", serif;
  --text: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--text);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}
button, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.inapp {
  padding: 10px 16px;
  background: var(--ink);
  color: var(--surface);
  font-size: 15px;
  text-align: center;
}
.inapp a { color: #fff; font-weight: 700; }

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  text-decoration: none;
  font: 21px/1 var(--title);
}

/* ——— Buttons ——— */

.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08), 0 6px 16px -8px rgba(34, 72, 87, 0.7);
}
.primary:hover { background: var(--accent-dark); }
.primary:active { transform: translateY(1px); }
.secondary {
  width: 100%;
  min-height: 48px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}
.secondary:hover { background: var(--surface); }
.link {
  border: 0;
  background: none;
  padding: 10px 4px;
  min-height: 44px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ——— Address field ——— */

.address { display: grid; gap: 10px; }
.field { position: relative; }
.field .pin { position: absolute; left: 14px; top: 16px; width: 20px; height: 20px; pointer-events: none; }
.pin { width: 20px; height: 20px; fill: none; stroke: var(--accent); stroke-width: 1.8; flex: none; }
.field input {
  width: 100%;
  min-height: 54px;
  padding: 0 14px 0 44px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: #fff;
  font-size: 17px;
}
.field input::placeholder { color: #6b7570; }
.field input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(44, 90, 107, 0.2); }
.suggestions {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 16px 36px -12px rgba(34, 48, 46, 0.4);
}
.suggestions li {
  display: grid;
  padding: 10px 12px;
  min-height: 48px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.3;
}
.suggestions li b { font-weight: 600; }
.suggestions li span { font-size: 14px; color: var(--muted); }
.suggestions li:hover, .suggestions li[aria-selected="true"] { background: var(--accent-soft); }
.status { margin: 0; font-size: 15px; color: #8a3b1e; }
.address.busy .primary { opacity: 0.7; pointer-events: none; }

/* ——— Home ——— */

.home { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.hero { display: grid; gap: 18px; padding: 4px 0 28px; }
.hero h1 {
  margin: 0 0 14px;
  font: 400 clamp(27px, 8vw, 46px)/1.1 var(--title);
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.price-line { margin: 12px 0 0; font-size: 14.5px; line-height: 1.45; color: var(--muted); }
.sample { margin: 0; }
.sample-board {
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  background: #f6f4ec;
  aspect-ratio: 68 / 44;
  box-shadow: 0 2px 4px rgba(34, 48, 46, 0.08), 0 18px 40px -14px rgba(34, 48, 46, 0.35);
  transform: rotate(-1.2deg);
}
.sample-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sample figcaption { margin-top: 12px; font-size: 13.5px; color: var(--muted); text-align: center; }
.how { padding: 8px 0 40px; border-top: 1px solid var(--line); }
.how h2 { font: 400 24px/1.2 var(--title); margin: 24px 0 12px; }
.how ol { margin: 0; padding-left: 22px; display: grid; gap: 10px; }
.site-foot { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); font-size: 13px; color: var(--muted); text-align: center; border-top: 1px solid var(--line); }
.site-foot p { margin: 0 0 6px; }
.site-foot a { color: inherit; }

@media (min-width: 860px) {
  .bar { padding: 14px 32px; }
  .home { padding: 0 32px; }
  .hero { grid-template-columns: 1fr 1.1fr; align-items: center; gap: 56px; padding: 40px 0 64px; min-height: 70vh; }
  .hero h1 { margin-bottom: 24px; }
  .address:not(.compact) { grid-template-columns: 1fr auto; }
  .address:not(.compact) .status { grid-column: 1 / -1; }
}

/* ——— Designer ——— */

.designer { flex: 1; display: grid; grid-template-columns: 1fr; min-height: 0; }
.place { padding: 0 16px 2px; }
.place-line { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; min-height: 44px; }
.place-line span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-line .link { flex: none; font-size: 15px; }
.address-actions { display: flex; gap: 8px; align-items: center; }
.address-actions .primary { flex: 1; }

.stage {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 10px;
  background: var(--bg);
}
.board {
  position: relative;
  max-width: 100%;
  border-radius: 3px;
  background: #f6f4ec;
  touch-action: none;
  /* The size layout() in src/designer/main.ts gives the default design (1000 pieces, landscape) on a phone, so the panel does not jump when the script starts. */
  aspect-ratio: 68 / 44;
  width: min(100%, calc((min(48svh, 560px) - 29px) * 68 / 44));
  box-shadow: 0 1px 0 rgba(34, 48, 46, 0.06), 0 2px 4px rgba(34, 48, 46, 0.08), 0 14px 30px -12px rgba(34, 48, 46, 0.3);
}
.board:focus-visible { outline-offset: 4px; }
.board canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: 3px; }
#overlay { cursor: grab; }
#overlay.dragging { cursor: grabbing; }
#overlay.on-shape { cursor: move; }
#overlay.on-handle { cursor: pointer; }
.loading {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  background: rgba(251, 251, 248, 0.94);
  box-shadow: 0 1px 3px rgba(34, 48, 46, 0.18);
  font-size: 13px;
  color: var(--muted);
  pointer-events: none;
}
.loading span { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.zoom {
  position: absolute;
  right: 8px;
  top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px 0 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(251, 251, 248, 0.94);
  box-shadow: 0 1px 4px rgba(34, 48, 46, 0.3);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.board.narrow .zoom { padding: 0; width: 44px; justify-content: center; font-size: 0; }
.zoom svg { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; }
.loupe {
  width: min(100vw - 24px, 720px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6);
}
.loupe::backdrop { background: rgba(20, 28, 27, 0.6); }
.loupe-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; }
.loupe-head h2 { font: 400 20px/1.2 var(--title); }
.close { width: 44px; height: 44px; border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; border-radius: 50%; }
.close:hover { background: var(--bg); }
.loupe canvas { display: block; width: 100%; height: min(64dvh, 520px); touch-action: none; cursor: grab; background: #f6f4ec; }
.loupe .note { padding: 10px 16px 14px; }
.hint { margin: 0; color: var(--muted); font-size: 14px; text-align: center; min-height: 1.5em; line-height: 1.4; }

.panel { padding: 0 16px 24px; display: flex; flex-direction: column; }
.group { padding: 16px 0; border-top: 1px solid var(--line); display: grid; gap: 12px; }
.group:first-child { border-top: 0; padding-top: 6px; }
h2, h3, .label-row label { margin: 0; font: 600 14px/1.2 var(--text); color: var(--ink); }

.year { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.year-text { display: grid; justify-items: center; }
#year-out { font: 40px/1.05 var(--title); font-variant-numeric: tabular-nums; }
.series { font-size: 14px; color: var(--muted); }
.step {
  width: 48px; height: 48px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  font-size: 26px;
  line-height: 1;
  padding-bottom: 4px;
  cursor: pointer;
}
.step:hover:not(:disabled) { border-color: var(--ink); }
.step:disabled { opacity: 0.35; cursor: default; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  background: transparent;
  margin: 0;
  cursor: pointer;
  touch-action: pan-y;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--accent) var(--fill, 50%), var(--line) var(--fill, 50%));
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--accent);
  box-shadow: 0 1px 4px rgba(34, 48, 46, 0.3);
}
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); }
.ticks { position: relative; height: 16px; margin-top: -12px; }
.ticks span { position: absolute; transform: translateX(-50%); font-size: 12px; line-height: 1; color: var(--muted); font-variant-numeric: tabular-nums; }
.ticks span.first { transform: none; margin-left: -13px; }
.ticks span.last { transform: translateX(-100%); margin-left: 13px; }

.sizes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
/* Room for what the designer script fills in, so the panel does not jump when it starts. */
.sizes:empty { min-height: 147px; }
#year-out:empty::before, .series:empty::before, .toggle-text small:empty::before { content: "\200b"; }
.size {
  display: grid;
  align-content: start;
  gap: 1px;
  justify-items: start;
  text-align: left;
  min-height: 48px;
  padding: 10px 10px 10px 12px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}
.size:hover { border-color: var(--ink); }
.size b { font: 400 24px/1.05 var(--title); }
.size small { font-size: 13px; color: var(--muted); }
.size em { font-style: normal; font-size: 13px; color: var(--muted); white-space: nowrap; margin-top: 4px; }
.size strong { font-size: 16px; font-weight: 700; margin-top: 2px; }
.size .soon { margin-top: 4px; padding: 2px 8px; border-radius: 999px; background: var(--bg); font-size: 12.5px; font-weight: 600; color: var(--muted); }
.size[aria-disabled="true"] { cursor: default; border-style: dashed; border-color: var(--line-strong); }
.size[aria-disabled="true"] b { color: var(--muted); }
.size[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }

.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}
.toggle:hover { border-color: var(--ink); }
.toggle[aria-pressed="true"] { border-color: var(--ochre); background: var(--ochre-soft); }
.toggle-icon {
  flex: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: conic-gradient(from 200deg, #8aa08f 0 50%, #e2c99a 50% 100%);
  border: 2px solid var(--ink);
}
.toggle-text { flex: 1; display: grid; line-height: 1.3; }
.toggle-text b { font-size: 17px; }
.toggle-text small { font-size: 14px; color: var(--muted); }
.track {
  position: relative;
  flex: none;
  width: 44px; height: 26px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background 0.15s;
}
.track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}
.toggle[aria-pressed="true"] .track, .switch input:checked + .track { background: var(--accent); }
.toggle[aria-pressed="true"] .track::after, .switch input:checked + .track::after { transform: translateX(18px); }

.both { display: grid; gap: 12px; }
.note { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.45; }
.add { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1.5px dashed var(--line-strong);
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}
.ghost:hover:not(:disabled) { border-style: solid; border-color: var(--ink); }
.ghost:disabled { opacity: 0.4; cursor: default; }
.ghost svg, .shape svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; flex: none; }
.shapes { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.shapes:empty { display: none; }
.shapes li { display: flex; border: 1.5px solid var(--line-strong); border-radius: 999px; background: var(--surface); }
.shape { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 4px 0 14px; border: 0; background: none; cursor: pointer; font-weight: 500; }
.shape svg { stroke: var(--ochre); }
.shapes li:has(.shape[aria-pressed="true"]) { border-color: var(--ochre); background: var(--ochre-soft); }
.remove { width: 44px; min-height: 44px; border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; border-radius: 999px; }
.remove:hover { color: var(--ink); }

.switch { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch input:focus-visible + .track { outline: 3px solid var(--accent); outline-offset: 2px; }

.more { gap: 0; }
.more summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: ""; width: 10px; height: 10px; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: rotate(45deg) translateY(-3px); transition: transform 0.15s; }
.more[open] summary::after { transform: rotate(-135deg) translateY(-3px); }
.more-body { display: grid; gap: 18px; padding-top: 10px; }
.more-body h3 { margin-bottom: 8px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.text { width: 100%; min-height: 48px; padding: 0 14px; border: 1.5px solid var(--line-strong); border-radius: var(--radius); background: #fff; font-size: 17px; margin-bottom: 6px; }
.text:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(44, 90, 107, 0.2); }
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 3px;
  gap: 3px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--line);
}
.segmented button { min-height: 44px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; color: var(--muted); cursor: pointer; }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(34, 48, 46, 0.18); }

.send { gap: 8px; }
.send-form { display: grid; gap: 8px; }
.send-form label[for] { font-weight: 600; }
.send-form .text { margin-bottom: 0; }
.check { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; padding: 6px 0; cursor: pointer; font-size: 15px; line-height: 1.45; }
.check input { flex: none; width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); }
.send-done { color: var(--ink); }
.credits { padding-top: 8px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.credits p { margin: 0; }

.order-bar {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: grid;
  gap: 4px;
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.designer:has(input[type="text"]:focus, input[type="email"]:focus) .order-bar { position: static; }
.delivery { margin: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); text-align: center; }
.season { margin: 0; font-size: 12.5px; line-height: 1.35; white-space: pre-line; color: var(--ink); text-align: center; }
.presale { margin: 0; padding: 8px 16px 4px; font-size: 12.5px; line-height: 1.4; color: var(--muted); text-align: center; }
.season:empty, .presale:empty { display: none; }
.order { width: 100%; }
.order span { font-weight: 500; }

.toast {
  position: fixed;
  z-index: 30;
  left: 16px;
  right: 16px;
  bottom: calc(110px + env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--surface);
  font-size: 15px;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.5);
}

@media (min-width: 860px) {
  body.page-designer { height: 100dvh; overflow: hidden; }
  .designer { grid-template-columns: minmax(0, 1fr) 400px; grid-template-rows: auto minmax(0, 1fr) auto auto; }
  .place { grid-column: 1; padding: 0 32px 8px; }
  .stage { grid-column: 1; grid-row: 2 / 5; position: static; justify-content: center; padding: 16px 32px 32px; background: radial-gradient(120% 90% at 50% 40%, #f4f5f0 0%, var(--bg) 70%); }
  .panel { grid-column: 2; grid-row: 1 / 3; overflow-y: auto; background: var(--surface); border-left: 1px solid var(--line); padding: 8px 24px 24px; }
  .presale { grid-column: 2; grid-row: 3; background: var(--surface); border-left: 1px solid var(--line); border-top: 1px solid var(--line); padding: 10px 24px 0; }
  .order-bar { grid-column: 2; grid-row: 4; position: static; background: var(--surface); border-left: 1px solid var(--line); padding: 12px 24px 20px; border-top: 0; }
  .presale:empty + .order-bar { border-top: 1px solid var(--line); }
  .size, .toggle, .step { background: #fff; }
  .toast { bottom: 140px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ——— Thank-you page ——— */

.thanks { max-width: 560px; margin: 0 auto; padding: 24px 16px 40px; display: grid; gap: 16px; }
.thanks h1 { margin: 0; font: 28px/1.15 var(--title); }
.thanks p { margin: 0; }
.thanks p > a[href^="mailto:"] { color: var(--accent); }
.thanks-number strong { letter-spacing: 0.04em; }
.share { display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.share h2 { margin: 0; font: 19px/1.25 var(--title); }
.share-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.share-buttons .primary { text-decoration: none; }
.share-done { font-size: 13.5px; color: var(--muted); overflow-wrap: anywhere; }
