/* Palette: grey PETG enclosure, textured PEI plate gold, support magenta */
:root {
  --bg: #e4e7ea;
  --surface: #f4f5f6;
  --stage: #d3d8dd;
  --ink: #24282d;
  --muted: #5d646c;
  --line: #c3c9cf;
  --pei: #c4973f;
  --pei-deep: #7c5a1c;
  --overhang: #c23a73;
  --ok: #1e6f68;
  --danger: #a3242f;
  --radius: 6px;
  --font: 'Archivo', system-ui, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}
a { color: var(--pei-deep); text-underline-offset: 0.15em; }
a:hover { color: var(--ink); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: 0.875rem; margin: 0.5rem 0 0; }

h1, h2 { font-stretch: 125%; line-height: 1.05; margin: 0; }
h1 { font-size: clamp(1.9rem, 4.2vw, 3.3rem); font-weight: 760; letter-spacing: -0.012em; max-width: 18ch; }
h2 { font-size: 1.15rem; font-weight: 700; }

/* ── Header / footer ─────────────────────────────── */
.site-header, .site-footer {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  max-width: 1320px; margin: 0 auto; padding: 1rem clamp(1rem, 3vw, 2rem);
}
.brand { font-stretch: 112%; font-weight: 750; font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.header-wa { font-size: 0.95rem; }
.site-footer { color: var(--muted); font-size: 0.875rem; border-top: 1px solid var(--line); margin-top: 3rem; }
.site-footer p { margin: 0; }

/* ── Quote page ──────────────────────────────────── */
.quote { max-width: 1320px; margin: 0 auto; padding: 0 clamp(1rem, 3vw, 2rem); }
.intro { padding: 1.25rem 0 1.5rem; display: grid; gap: 0.75rem; }
.intro p { margin: 0; max-width: 62ch; color: var(--muted); font-size: 1.05rem; }

.workbench { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1.45fr) minmax(320px, 1fr); align-items: start; }
@media (max-width: 960px) { .workbench { grid-template-columns: 1fr; } }

.stage { position: sticky; top: 1rem; }
@media (max-width: 960px) { .stage { position: static; } .viewer { height: 56vh; } }
.viewer {
  position: relative; height: min(70vh, 640px); min-height: 340px;
  background: radial-gradient(120% 90% at 50% 30%, #e1e5e8 0%, var(--stage) 70%);
  border-radius: var(--radius); overflow: hidden; touch-action: none;
}
.viewer canvas { display: block; width: 100%; height: 100%; }
.viewer.is-dragging { outline: 3px dashed var(--pei-deep); outline-offset: -10px; }

.dropzone {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 0.4rem;
  cursor: pointer; padding: 2rem;
}
.dz-title { font-stretch: 125%; font-weight: 720; font-size: clamp(1.3rem, 2.6vw, 1.9rem); }
.dz-sub { color: var(--muted); }
.dropzone:hover .dz-title { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.2em; }

.readout, .legend {
  position: absolute; margin: 0; padding: 0.35rem 0.6rem; border-radius: 4px;
  background: rgb(244 245 246 / 0.9); font-size: 0.875rem;
}
.readout { top: 0.75rem; left: 0.75rem; font-weight: 600; }
.legend { top: 0.75rem; right: 0.75rem; display: flex; align-items: center; gap: 0.4rem; }
.swatch-overhang { width: 0.8rem; height: 0.8rem; border-radius: 2px; background: var(--overhang); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.6rem; }
.toolbar-label { color: var(--muted); font-size: 0.9rem; margin-right: 0.25rem; }
.toolbar button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 4px;
  padding: 0.45rem 0.75rem; cursor: pointer;
}
.toolbar button:hover { border-color: var(--ink); }
.toolbar .tool-strong { background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* ── Panel ───────────────────────────────────────── */
.panel { background: var(--surface); border-radius: var(--radius); padding: 1.1rem 1.1rem 1.25rem; }
.parts-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; }
.btn-add {
  cursor: pointer; font-weight: 600; font-size: 0.9rem;
  border: 1px solid var(--ink); border-radius: 4px; padding: 0.35rem 0.7rem;
}
.btn-add:hover { background: var(--ink); color: var(--surface); }
.part-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.part {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center;
  border-left: 4px solid transparent; background: var(--bg);
}
.part.is-selected { border-left-color: var(--pei); background: #ebe6db; }
.part.has-error { border-left-color: var(--danger); }
.part-select {
  display: grid; text-align: left; gap: 0.1rem; min-width: 0;
  background: none; border: 0; padding: 0.55rem 0.6rem; cursor: pointer;
}
.part-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part-meta { color: var(--muted); font-size: 0.85rem; }
.has-error .part-meta { color: var(--danger); }
.part-price { font-weight: 650; padding: 0 0.4rem; }
.part-remove { background: none; border: 0; font-size: 1.3rem; line-height: 1; padding: 0.4rem 0.6rem; cursor: pointer; color: var(--muted); }
.part-remove:hover { color: var(--danger); }

.options { margin-top: 1.25rem; display: grid; gap: 1.1rem; border-top: 1px solid var(--line); padding-top: 1.1rem; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-weight: 650; margin-bottom: 0.45rem; padding: 0; }
.options input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }

.material-list { display: grid; gap: 0.4rem; }
.material-card {
  display: grid; gap: 0.1rem; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 4px; cursor: pointer;
}
.material-card small { color: var(--muted); font-size: 0.83rem; line-height: 1.35; }
input:checked + .material-card { border-color: var(--ink); box-shadow: inset 4px 0 0 var(--pei); }
input:focus-visible + .material-card, input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 2px; }

.swatches { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.swatches label { cursor: pointer; }
.swatch {
  display: grid; justify-items: center; gap: 0.25rem; font-size: 0.78rem; color: var(--muted);
}
.swatch::before {
  content: ''; width: 2rem; height: 2rem; border-radius: 50%; background: var(--c);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.18);
}
input:checked + .swatch { color: var(--ink); font-weight: 600; }
input:checked + .swatch::before { box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.18), 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.segmented label { cursor: pointer; }
.segmented label + label > span { border-left: 1px solid var(--line); }
.segmented span { display: grid; place-items: center; text-align: center; height: 100%; padding: 0.45rem 0.25rem; font-size: 0.86rem; line-height: 1.2; }
.segmented small { color: var(--muted); font-size: 0.75rem; }
.segmented input:checked + span { background: var(--ink); color: var(--surface); }
.segmented input:checked + span small { color: #c9ced4; }

.qty-row { display: flex; justify-content: space-between; align-items: center; }
.qty-row > label { font-weight: 650; }
.stepper { display: flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.stepper button { width: 2.4rem; border: 0; background: var(--bg); cursor: pointer; font-size: 1.1rem; }
.stepper button:hover { background: var(--line); }
.stepper input { width: 3.4rem; border: 0; text-align: center; background: var(--surface); -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }

.estimate { display: grid; grid-template-columns: 1fr auto; margin: 0; border-top: 1px solid var(--line); padding-top: 0.7rem; row-gap: 0.25rem; }
.estimate dt { color: var(--muted); }
.estimate dd { margin: 0; text-align: right; font-weight: 600; }
.estimate dd:last-of-type { font-size: 1.15rem; }

/* ── Checkout ────────────────────────────────────── */
.checkout {
  margin-top: 2.5rem; display: grid; gap: 1.5rem;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: start;
}
@media (max-width: 960px) { .checkout { grid-template-columns: 1fr; } }

.receipt { background: var(--surface); border-radius: var(--radius); padding: 1.1rem; }
.receipt-table { width: 100%; border-collapse: collapse; margin-top: 0.75rem; }
.receipt-table th { text-align: left; font-weight: 400; padding: 0.4rem 0.75rem 0.4rem 0; vertical-align: top; }
.receipt-table td { text-align: right; padding: 0.4rem 0; white-space: nowrap; vertical-align: top; }
.receipt-table tr + tr { border-top: 1px dashed var(--line); }
.receipt-table .r-item th { overflow-wrap: anywhere; }
.receipt-table .r-total { border-top: 2px solid var(--ink) !important; }
.receipt-table .r-total th, .receipt-table .r-total td { font-weight: 750; font-stretch: 112%; font-size: 1.2rem; padding-top: 0.6rem; }
.receipt-table .r-fee th, .receipt-table .r-fee td { color: var(--muted); font-size: 0.9rem; }

.customer { display: grid; gap: 1.1rem; }
.delivery { display: grid; gap: 0.4rem; }
.radio-card {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.75rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px; cursor: pointer;
}
.radio-card:has(input:checked) { border-color: var(--ink); }
.radio-card input { accent-color: var(--ink); }
.radio-price { margin-left: auto; font-weight: 600; }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.fields .wide { grid-column: 1 / -1; }
@media (max-width: 560px) { .fields { grid-template-columns: 1fr; } }
.fields label { display: grid; gap: 0.25rem; font-weight: 600; font-size: 0.92rem; }
.fields input, .fields textarea {
  font-weight: 400; padding: 0.55rem 0.65rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: 4px; width: 100%;
}
.fields input:focus, .fields textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 2px var(--ink); }
.terms { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.92rem; }
.terms input { margin-top: 0.25rem; accent-color: var(--ink); width: 1.05rem; height: 1.05rem; flex: none; }

.error { margin: 0; padding: 0.7rem 0.8rem; border-left: 4px solid var(--danger); background: #f6e3e5; color: var(--danger); }

.pay { display: grid; gap: 0.6rem; }
.pay button {
  padding: 0.85rem 1rem; border-radius: 4px; font-weight: 700; cursor: pointer; font-size: 1.02rem;
  border: 2px solid var(--ink); background: transparent;
}
.pay .btn-pay { background: var(--pei); border-color: var(--pei); color: var(--ink); font-stretch: 112%; font-size: 1.1rem; }
.pay .btn-pay:hover { background: #b2862f; border-color: #b2862f; }
.pay .btn-card { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.pay .btn-card:hover { background: #3a4047; }
.pay .btn-wa:hover { background: var(--ink); color: var(--surface); }
.pay button:disabled { opacity: 0.45; cursor: not-allowed; }
.pay button.is-loading { opacity: 0.7; cursor: progress; }

.sent { margin-top: 2rem; background: var(--surface); border-left: 4px solid var(--ok); padding: 1.1rem 1.25rem; border-radius: var(--radius); }
.sent p { margin: 0.5rem 0 0; }

.flash {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translate(-50%, 1rem); margin: 0;
  background: var(--ink); color: var(--surface); padding: 0.7rem 1rem; border-radius: 4px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; max-width: calc(100% - 2rem);
}
.flash.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ── Simple pages (quote, success, terms) ────────── */
.page { max-width: 860px; margin: 0 auto; padding: 1rem clamp(1rem, 3vw, 2rem) 0; }
.page h1 { font-size: clamp(1.7rem, 3.4vw, 2.6rem); margin-bottom: 0.75rem; max-width: none; }
.page .lead { color: var(--muted); font-size: 1.05rem; margin: 0 0 1.5rem; }
.card { background: var(--surface); border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem; }
.status { display: inline-block; font-weight: 650; padding: 0.15rem 0.5rem; border-radius: 3px; background: var(--bg); }
.status-paid, .status-completed, .status-ready, .status-printing { background: #d6ebe8; color: var(--ok); }
.status-cancelled { background: #f6e3e5; color: var(--danger); }
.prose { max-width: 70ch; }
.prose h2 { margin: 1.6rem 0 0.5rem; }
.prose li { margin-bottom: 0.35rem; }

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