:root {
  --ink: #1d2b22;
  --ink-soft: #52605a;
  --paper: #eef1ec;
  --card: #f9faf8;
  --line: #cdd5ce;
  --marigold: #e8a019;
  --leaf: #3f7a3a;
  --warn: #9a3412;
  --sky-top: #d9e5de;
  --sky-bottom: #f1f4ef;
  --radius: 10px;
  font-family: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
  font-optical-sizing: auto;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(320px, 380px) 1fr;
  background: var(--paper);
}

:focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ------------------------------------------------------------ panel */

.panel {
  overflow-y: auto;
  padding: 28px 24px 48px;
  border-right: 1px solid var(--line);
  margin: 0;
}

.intro h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0 0 8px;
}
.intro p { margin: 0 0 28px; color: var(--ink-soft); font-size: 0.95rem; line-height: 1.4; }

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; }

.group { margin: 0 0 30px; }
.group__title {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 10px;
}

textarea {
  width: 100%;
  resize: vertical;
  font-size: 1.9rem;
  line-height: 1.15;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 10px 12px;
}
textarea:focus-visible { outline-offset: 0; }
#text { resize: none; overflow: hidden; }

.hint { margin: 6px 0 12px; font-size: 0.82rem; color: var(--ink-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit;
  font-size: 0.85rem;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.chip:hover { border-color: var(--ink); }

/* skrift */
.font-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.font-tile {
  position: relative;
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  min-width: 0;
}
.font-tile input { position: absolute; opacity: 0; pointer-events: none; }
.font-tile__sample { font-size: 1.35rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.font-tile__name { font-size: 0.75rem; color: var(--ink-soft); }
.font-tile:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.font-tile:has(input:focus-visible) { outline: 3px solid var(--marigold); outline-offset: 2px; }

/* avanceret: skrift og læseretning, lukket fra start */
.advanced { border-block: 1px solid var(--line); }
.advanced summary {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 0;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before {
  content: ''; flex: none;
  width: 6px; height: 6px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
.advanced[open] summary::before { transform: rotate(45deg); }
.advanced__current { font-weight: 400; font-size: 0.88rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adv-field { margin-bottom: 16px; }
.adv-field legend { font-size: 0.92rem; margin-bottom: 6px; }
@media (prefers-reduced-motion: reduce) { .advanced summary::before { transition: none; } }

/* skydere */
.slider {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  row-gap: 4px;
  margin-bottom: 16px;
}
.slider label { font-size: 0.92rem; }
.slider output { font-variant-numeric: tabular-nums; font-size: 0.92rem; font-weight: 600; }
.slider input { grid-column: 1 / -1; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; background: transparent; margin: 0; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--ink); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--ink); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; margin-top: -8px; border-radius: 50%;
  background: var(--marigold); border: 3px solid var(--card); box-shadow: 0 0 0 1.5px var(--ink);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--marigold); border: 3px solid var(--card); box-shadow: 0 0 0 1.5px var(--ink);
}
input[type="range"]:focus-visible { outline-offset: 0; }

/* segmenterede valg */
.seg-field { margin-bottom: 16px; }
.seg-field legend { font-size: 0.92rem; margin-bottom: 6px; }
.seg {
  display: flex;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
}
.seg label { flex: 1; position: relative; min-width: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  height: 100%;
  padding: 8px 6px;
  font-size: 0.85rem;
  text-align: center;
  cursor: pointer;
  line-height: 1.15;
}
.seg label + label span { border-left: 1px solid var(--line); }
.seg input:checked + span { background: var(--ink); color: var(--paper); }
.seg input:focus-visible + span { outline: 3px solid var(--marigold); outline-offset: -3px; }
.seg svg { width: 12px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* farver: en lille prøve af markøren i hver kombination */
.seg--scheme span { gap: 8px; padding: 9px 8px; }
.tone {
  display: inline-grid; place-items: center;
  width: 30px; height: 20px;
  border-radius: 5px;
  font-style: normal; font-weight: 800; font-size: 0.72rem;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.25);
}
.tone--bw { background: #efefe9; color: #262826; }
.tone--wb { background: #262826; color: #efefe9; }
.seg input:checked + span .tone { box-shadow: 0 0 0 1.5px var(--paper); }

/* kurv */
.group__title span { color: var(--ink-soft); font-weight: 400; }
.basket__list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.basket__item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.basket__text { display: grid; min-width: 0; }
.basket__text strong, .basket__text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.basket__text strong { font-weight: 600; }
.basket__text small { font-size: 0.78rem; color: var(--ink-soft); }
.basket__qty { display: flex; align-items: center; gap: 2px; }
.basket__qty button {
  width: 28px; height: 28px;
  font: inherit; font-size: 1rem; line-height: 1;
  color: var(--ink); background: transparent;
  border: 1px solid var(--line); border-radius: 6px;
  cursor: pointer;
}
.basket__qty button:hover { border-color: var(--ink); }
.basket__n { min-width: 24px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.link-btn {
  font: inherit; font-size: 0.85rem;
  background: none; border: 0; padding: 0;
  color: var(--ink-soft); text-decoration: underline; cursor: pointer;
}

/* bestilling */
.checkout { margin-top: 4px; }
.field { display: grid; gap: 4px; margin-bottom: 12px; font-size: 0.92rem; }
.field input, .field textarea {
  font: inherit; font-size: 1rem;
  padding: 9px 11px;
  color: var(--ink); background: var(--card);
  border: 1.5px solid var(--line); border-radius: var(--radius);
}
.field textarea { resize: vertical; font-size: 0.95rem; line-height: 1.35; }
.field input:focus-visible, .field textarea:focus-visible { border-color: var(--ink); outline-offset: 0; }
.field-row { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 10px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.checkout__status { margin: 10px 0 0; font-size: 0.88rem; }
.checkout__status.is-error { color: var(--warn); font-weight: 600; }
.order-done { padding: 14px 16px; background: var(--card); border: 1.5px solid var(--leaf); border-radius: var(--radius); }
.order-done p { margin: 0; line-height: 1.45; }

/* ------------------------------------------------------------ scene */

.stage {
  position: relative;
  overflow: hidden;
  min-height: 0;
  background: linear-gradient(var(--sky-top), var(--sky-bottom) 70%);
}
.stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.labels { position: absolute; inset: 0; pointer-events: none; }
.dim-label {
  position: absolute; left: 0; top: 0;
  font-size: 0.8rem; font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  white-space: nowrap;
  box-shadow: 0 0 0 1.5px var(--marigold);
  font-variant-numeric: tabular-nums;
  will-change: transform;
}
.dim-label--soil { background: #2b1d14; color: #f3e6d6; }

.stage__bar {
  position: absolute; top: 16px; right: 16px;
  display: flex; gap: 8px; align-items: stretch;
}
.ghost-btn {
  font: inherit; font-size: 0.85rem;
  padding: 0 14px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.ghost-btn:hover { background: var(--paper); }

.readout {
  position: absolute; left: 16px; bottom: 16px;
  width: min(320px, calc(100% - 32px));
  padding: 14px 16px;
  border-radius: 12px;
  background: rgb(249 250 248 / 0.9);
  backdrop-filter: blur(8px);
  box-shadow: 0 0 0 1px var(--line);
}
.readout p { margin: 0; }
.readout__big { font-size: 2rem; font-weight: 800; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.readout__sub { font-size: 0.85rem; color: var(--ink-soft); margin: 4px 0 10px !important; }
.readout dl { margin: 0 0 10px; display: grid; gap: 3px; }
.readout dl div { display: flex; justify-content: space-between; gap: 12px; font-size: 0.85rem; }
.readout dt { color: var(--ink-soft); }
.readout dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.cta {
  width: 100%; margin-top: 12px; padding: 11px 14px;
  font: inherit; font-size: 1rem; font-weight: 600;
  color: var(--paper); background: var(--ink);
  border: 0; border-radius: var(--radius);
  cursor: pointer;
}
.cta:hover { background: #2c3d32; }
.cta:disabled { opacity: 0.45; cursor: not-allowed; }
.cta--free { margin-top: 8px; background: var(--leaf); }
.cta--free:hover { background: #356a31; }
.readout__notes p { font-size: 0.85rem; margin-top: 6px; color: var(--warn); font-weight: 600; line-height: 1.35; }

.debug { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.debug__title { font-size: 0.75rem; color: var(--ink-soft); margin-bottom: 4px !important; }
.debug dl { margin: 0; }
.debug__actions { display: flex; gap: 8px; margin-top: 10px; }
.debug__actions { flex-wrap: wrap; }
.debug__actions .ghost-btn { padding: 7px 12px; }
.ghost-btn--primary { background: var(--ink); color: var(--paper); }
.ghost-btn--primary:hover { background: var(--ink); opacity: 0.9; }
.ghost-btn:disabled { opacity: 0.5; cursor: progress; }
.debug__status { font-size: 0.8rem; margin-top: 8px !important; line-height: 1.35; }
.debug__status.is-error { color: var(--warn); font-weight: 600; }

.status {
  position: absolute; top: 16px; left: 16px;
  margin: 0; padding: 8px 12px;
  border-radius: 8px;
  background: var(--card);
  font-size: 0.88rem;
  box-shadow: 0 0 0 1px var(--line);
}
.status.is-error { color: var(--warn); box-shadow: 0 0 0 1.5px var(--warn); }

/* ------------------------------------------------------------ smal skærm */

@media (max-width: 820px) {
  body { display: flex; flex-direction: column; height: auto; }
  .stage { order: -1; position: sticky; top: 0; z-index: 1; height: 56dvh; flex: none; }
  .panel { border-right: 0; overflow: visible; padding: 22px 16px 40px; }
  .readout { width: auto; right: 12px; left: 12px; bottom: 12px; padding: 10px 12px; }
  .readout__big { font-size: 1.4rem; }
  .readout__sub { margin-bottom: 6px !important; }
  .stage__bar { top: 12px; right: 12px; left: 12px; justify-content: flex-end; }
}
