/* box.css — the box designer: the lid on the left (on top on phones), the controls beside it. */

.page-top.slim { padding-bottom: 0; }
.page-top.slim .bar { padding-block: 12px; }

/* The three steps of printing a set, shown when the designer is one of them. */
.steps { background: var(--paper); border-bottom: 1px solid var(--line); }
.steps[hidden] { display: none; }
.steps ol { max-width: 1320px; margin: 0 auto; padding: 12px var(--gutter); list-style: none; display: flex; flex-wrap: wrap; gap: 4px 0; counter-reset: step; font-size: 0.95rem; font-weight: 500; }
.steps li { counter-increment: step; color: var(--ink-soft); }
.steps li::before { content: counter(step) ". "; }
.steps li + li::before { content: "→ " counter(step) ". "; padding-left: 14px; color: var(--ink-soft); }
.steps li[aria-current] { color: var(--ink); font-weight: 700; }
.steps a { color: inherit; }

.box-app {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px var(--gutter) 64px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: clamp(20px, 3vw, 44px);
  align-items: start;
}
@media (max-width: 900px) { .box-app { grid-template-columns: minmax(0, 1fr); padding-top: 12px; } }

/* ---------- The lid ---------- */

.stage { position: sticky; top: 12px; }
@media (max-width: 900px) { .stage { position: static; } }
.stage-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.facts { margin: 0; font-size: 0.92rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; align-items: center; padding: 3px; border-radius: 10px; background: #fff; box-shadow: inset 0 0 0 1px var(--line); }
.seg[hidden] { display: none; }
.seg button { border: 0; background: none; font: 600 0.95rem var(--font); color: var(--ink); padding: 7px 13px; border-radius: 8px; cursor: pointer; min-width: 36px; }
.seg button[aria-pressed="true"] { background: var(--navy); color: var(--cream); }
.seg .seg-label { font-size: 0.88rem; color: var(--ink-soft); padding: 0 4px; }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; }

.preview {
  background: #E6E2D8;
  border-radius: 10px;
  padding: clamp(10px, 2.2vw, 24px);
  display: grid;
  place-items: center;
  min-height: 320px;
}
.preview[hidden] { display: none; }
.preview > svg { width: 100%; height: auto; max-height: 74vh; filter: drop-shadow(0 6px 10px rgb(30 42 90 / 0.18)); touch-action: none; user-select: none; }
.preview .spot, .preview .label { fill: transparent; cursor: grab; }
.preview .spot.empty { fill: rgb(30 42 90 / 0.04); stroke: rgb(30 42 90 / 0.35); stroke-width: 0.5; stroke-dasharray: 1.5 1.5; cursor: pointer; }
.preview .spot:hover, .preview .label:hover { stroke: var(--navy); stroke-width: 0.6; }
.preview .label.sel { stroke: var(--navy); stroke-width: 0.8; stroke-dasharray: 2 1.2; }
.preview .handle { fill: #fff; stroke: var(--navy); stroke-width: 0.8; cursor: nwse-resize; }
.preview .ghost { fill: rgb(30 42 90 / 0.12); stroke: var(--navy); stroke-width: 0.9; pointer-events: none; }
.preview .ghost.no { fill: rgb(192 39 45 / 0.12); stroke: var(--red); }
.preview.dragging, .preview.dragging * { cursor: grabbing; }
.preview.three { padding: 0; aspect-ratio: 4 / 3; background: linear-gradient(#EFECE5, #DAD5CA); }
.preview.three canvas { width: 100%; height: 100%; display: block; border-radius: 10px; touch-action: none; }
.preview .status { margin: 0; color: var(--ink-soft); }
.hint { margin: 8px 0 0; font-size: 0.9rem; color: var(--ink-soft); }
.hint.off { visibility: hidden; }

/* ---------- Controls ---------- */

.controls h1 { font-size: clamp(2rem, 4vw, 2.8rem); line-height: 1; margin: 6px 0 14px; }
.controls .group { border-top: 1px solid var(--line); padding: 16px 0 18px; }
.controls .group[hidden] { display: none; }
.controls fieldset.group { border: 0; border-top: 1px solid var(--line); margin: 0; min-width: 0; }
.controls legend.label { float: left; width: 100%; padding: 0; }
.controls legend.label + * { clear: both; }
.choices { display: grid; gap: 2px; }
.choices label { display: flex; align-items: center; gap: 10px; min-height: 38px; cursor: pointer; font-size: 1rem; }
.choices input { accent-color: var(--navy); width: 18px; height: 18px; margin: 0; flex: none; }
.choices label:has(input:disabled) { color: var(--ink-soft); cursor: default; }
#words { display: grid; gap: 12px; margin-top: 14px; }
#words[hidden] { display: none; }
#words .row { margin-top: 0; }
.color-row[hidden] { display: none; }
.controls .label { font-weight: 700; font-size: 1.05rem; letter-spacing: 0; margin: 0 0 10px; }
.controls label { font-size: 0.98rem; }
.controls select, .controls input[type="text"] {
  font: inherit; font-size: 1rem; color: var(--ink); background: #fff;
  border: 1px solid #CFC5AA; border-radius: 8px; padding: 7px 10px; min-height: 40px;
}
.controls select:focus-visible, .controls input:focus-visible { outline: 3px solid var(--yellow); outline-offset: 1px; }
.row { display: flex; gap: 10px 14px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.size-row { margin-top: 0; }
.size-row > span[aria-hidden] { font-weight: 600; }
.row label { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.note { font-size: 0.9rem; color: var(--ink-soft); margin: 10px 0 0; }
.size-row .note { margin: 0; }
.note.warn { color: #8E1A1F; }
.note[hidden] { display: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.starts { display: flex; flex-wrap: wrap; gap: 6px; }
.starts button, .label-list button {
  font: 500 0.95rem var(--font); color: var(--ink); background: #fff; cursor: pointer;
  border: 1px solid #CFC5AA; border-radius: 8px; padding: 6px 12px; min-height: 36px;
}
.starts button:hover, .label-list button:hover { border-color: var(--navy); }
.label-list { display: grid; gap: 6px; margin-bottom: 10px; }
.label-list:empty { display: none; }
.label-list button { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.label-list button[aria-pressed="true"] { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }

.link-btn { font: 600 0.98rem var(--font); color: var(--ink); background: none; border: 0; padding: 6px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 0.2em; }
.link-btn:hover { color: var(--red); }
.link-btn[hidden] { display: none; }
.link-btn.danger { color: var(--red-deep); }

#label-edit { display: grid; gap: 12px; margin-bottom: 8px; }
#label-edit[hidden] { display: none; }
#label-edit .row { margin-top: 0; }
#lines[hidden] { display: none; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; margin-top: 6px; }
.line:first-child { margin-top: 0; }
.line input { width: 100%; }

.colors { display: grid; gap: 6px; }
.color-row { display: grid; grid-template-columns: 8.5em minmax(0, 1fr); align-items: center; gap: 8px; font-size: 0.98rem; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches button {
  width: 32px; height: 32px; border-radius: 7px; cursor: pointer; padding: 0;
  background: var(--c); border: 1px solid rgb(30 42 90 / 0.25);
}
.swatches button[data-c="none"] { background: linear-gradient(135deg, transparent 46%, #8E1A1F 46% 54%, transparent 54%), #fff; }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--navy); }

.next { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; }
.next .btn { min-height: 48px; }
.next:not(.lead) .btn { --face: #fff; --text: var(--ink); --edge: #CFC5AA; }

.dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 420px) { .dl { grid-template-columns: 1fr; } }
.dl-item {
  text-align: left; cursor: pointer; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid #CFC5AA; border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px;
}
.dl-item:hover { border-color: var(--navy); }
.dl-item b { font-weight: 650; }
.dl-item small { font-size: 0.82rem; opacity: 0.8; line-height: 1.3; }
.dl-item:disabled { opacity: 0.5; cursor: progress; }

/* ---------- Design picker ---------- */

.picker { width: min(760px, calc(100% - 24px)); max-height: min(86vh, 900px); border: 0; border-radius: 14px; padding: 0; color: var(--ink); background: var(--paper); }
.picker::backdrop { background: rgb(20 28 64 / 0.5); }
.picker form { padding: 18px 20px 22px; }
.picker-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.picker h2 { font-size: 1.5rem; margin: 0; }
.picker .close { border: 0; background: none; font-size: 2rem; line-height: 1; cursor: pointer; color: var(--ink); padding: 0 6px; }
.paste { display: grid; gap: 6px; font-size: 0.95rem; margin-bottom: 14px; }
.paste-row { display: flex; gap: 8px; }
.paste-row input { flex: 1; min-width: 0; font: inherit; border: 1px solid #CFC5AA; border-radius: 8px; padding: 8px 10px; }
.paste-row .btn { min-height: 42px; padding: 0 16px; font-size: 0.95rem; box-shadow: none; }
.pick-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.pick-list button { width: 100%; border: 1px solid #DCD2B8; border-radius: 10px; background: #fff; padding: 6px; cursor: pointer; font: 500 0.85rem var(--font); color: var(--ink); }
.pick-list button:hover { border-color: var(--navy); }
.pick-list svg { display: block; width: 100%; height: auto; margin-bottom: 4px; }
.picker-foot { margin: 14px 0 0; }
