:root {
  --cobalt: #1d3c8c;
  --cobalt-dark: #142b66;
  --cobalt-soft: #e7ecf7;
  --glaze: #fbf9f4;
  --paper: #f3efe6;
  --ink: #1f2330;
  --muted: #6b6f7c;
  --line: #e2ddd1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 6px 20px rgba(20, 30, 60, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* Header */
.site-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 24px;
  max-width: 1200px; margin: 0 auto; padding: 28px 24px 18px;
}
.site-header h1 {
  margin: 0; font-family: "Cormorant Garamond", "Big Caslon", Georgia, serif;
  font-size: clamp(28px, 4vw, 40px); font-weight: 600; color: var(--cobalt); letter-spacing: .01em;
}
.site-header p { margin: 4px 0 0; color: var(--muted); max-width: 60ch; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: #fff; flex-shrink: 0; }
.lang button { border: 0; background: none; padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
.lang button.active { background: var(--cobalt); color: #fff; }
.band { display: block; width: 100%; height: 28px; }

/* Layout */
.layout {
  max-width: 1200px; margin: 0 auto; padding: 24px;
  display: grid; grid-template-columns: minmax(320px, 440px) 1fr; gap: 28px; align-items: start;
}
.controls { display: flex; flex-direction: column; gap: 18px; }
.step, .card { background: var(--glaze); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.step { padding: 18px 18px 20px; }
.step h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 17px; }
.num {
  width: 26px; height: 26px; border-radius: 50%; background: var(--cobalt); color: #fff;
  display: inline-grid; place-items: center; font-size: 13px; font-weight: 700;
}
.label { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.step h2 + .label, .panel > .label:first-child, .panel > .upload:first-child { margin-top: 0; }
.hint { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.hint.error { color: #b3261e; }

/* Format cards */
.types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.type {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  padding: 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
  transition: border-color .15s, background .15s;
}
.type:hover { border-color: #b9c3e0; }
.type.active { border-color: var(--cobalt); background: var(--cobalt-soft); }
.type-title { font-weight: 700; font-size: 14px; line-height: 1.2; }
.type-desc { font-size: 12px; color: var(--muted); line-height: 1.3; }
.type-icon { width: 30px; height: 30px; border-radius: 4px; margin-bottom: 4px; display: grid; place-items: center; }
.icon-single { background: radial-gradient(circle, var(--cobalt) 28%, transparent 30%), radial-gradient(circle at 0 0, var(--cobalt) 30%, transparent 32%), radial-gradient(circle at 100% 100%, var(--cobalt) 30%, transparent 32%), #fff; border: 1px solid var(--line); }
.icon-text { background: #fff; border: 1px solid var(--line); color: var(--cobalt); font-family: Georgia, serif; font-weight: 700; font-size: 14px; }
.icon-image { background: linear-gradient(160deg, #8fb0e0 0 45%, var(--cobalt) 45% 70%, #2d5aa8 70%); border: 1px solid var(--line); }

/* Option grids (designs, frames) */
.options { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.option {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 6px;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff; font-size: 12px; font-weight: 600;
}
.option:hover { border-color: #b9c3e0; }
.option.active { border-color: var(--cobalt); background: var(--cobalt-soft); }
.option canvas { display: block; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px;
  border: 1.5px solid var(--line); border-radius: 999px; background: #fff; font-size: 14px;
}
.chip.active { border-color: var(--cobalt); background: var(--cobalt-soft); color: var(--cobalt-dark); font-weight: 600; }
.swatch { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(0,0,0,.1); }

/* Inputs */
textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
  resize: vertical; font-size: 17px;
}
textarea:focus, .stepper input:focus { outline: 2px solid var(--cobalt); outline-offset: 1px; border-color: transparent; }
.size-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stepper { display: inline-flex; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.stepper button { width: 40px; border: 0; background: #fff; font-size: 18px; color: var(--cobalt); }
.stepper button:hover { background: var(--cobalt-soft); }
.stepper input { width: 56px; border: 0; text-align: center; font-weight: 600; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.upload {
  display: flex; align-items: center; justify-content: center; padding: 18px; border: 2px dashed #b9c3e0;
  border-radius: 10px; background: #fff; color: var(--cobalt); font-weight: 600; cursor: pointer;
}
.upload:hover { background: var(--cobalt-soft); }
.upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
input[type=range] { width: 100%; accent-color: var(--cobalt); }

/* Preview */
.preview-col { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 18px; }
.preview-card { padding: 16px; }
.preview-stage {
  display: grid; place-items: center; min-height: 260px; padding: 16px; border-radius: 8px;
  background: repeating-linear-gradient(45deg, #ece7dc 0 10px, #e8e2d6 10px 20px);
}
.preview-stage canvas { display: block; box-shadow: 0 2px 6px rgba(0,0,0,.12), 0 12px 30px rgba(0,0,0,.12); }
.dims { margin: 12px 0 0; text-align: center; font-weight: 600; color: var(--cobalt-dark); }
.repeat { margin-top: 8px; text-align: center; }
.repeat .label { text-align: left; }
.repeat canvas { display: inline-block; border-radius: 4px; }

.price-card { padding: 18px; }
.price-card h3 { margin: 0 0 8px; font-size: 17px; }
.price-card table { width: 100%; border-collapse: collapse; }
.price-card td { padding: 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.price-card td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.price-card .muted { display: block; font-size: 12px; color: var(--muted); }
.price-card tr.total td { border-bottom: 0; padding-top: 12px; font-size: 20px; font-weight: 700; color: var(--cobalt-dark); }
.actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.btn { flex: 1; min-width: 160px; padding: 12px 16px; border-radius: 10px; font-weight: 700; border: 1.5px solid var(--cobalt); }
.btn.primary { background: var(--cobalt); color: #fff; }
.btn.primary:hover { background: var(--cobalt-dark); }
.btn.ghost { background: #fff; color: var(--cobalt); }
.btn.ghost:hover { background: var(--cobalt-soft); }

.site-footer { max-width: 1200px; margin: 0 auto; padding: 8px 24px 32px; color: var(--muted); font-size: 13px; text-align: center; }

button:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; }

/* Mobile: preview first, then controls */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .preview-col { display: contents; }
  .preview-card { order: -1; }
  .price-card { order: 1; }
  .site-header { padding: 20px 16px 14px; }
}
@media (max-width: 480px) {
  .types { grid-template-columns: 1fr; }
  .type { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .type-icon { margin: 0 6px 0 0; }
  .type-desc { width: 100%; }
}
