:root {
  --bg: #f3eee6;
  --bg-deep: #e9e0d2;
  --card: #fffcf7;
  --ink: #1c1916;
  --muted: #5c5348;
  --line: #e2d8c8;
  --gold: #8d6b2c;
  --gold-soft: #c4a46a;
  --gold-pale: #f3e6c8;
  --danger: #8a3b12;
  --ok: #1f6b3a;
  --shadow: 0 10px 30px rgba(28, 25, 22, 0.08);
  --radius: 18px;
  --sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --serif: "Cormorant Garamond", "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 500px at 50% -80px, #fffaf0 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.page {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(40px, env(safe-area-inset-bottom));
}

.hero { text-align: center; margin-bottom: 22px; }
.eyebrow {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  color: var(--gold);
  margin: 0 0 6px;
}
.hero h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(32px, 7vw, 48px);
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.lede {
  margin: 0 auto;
  max-width: 36rem;
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.45;
}

.meta-card, .box-card, .actions {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.meta-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  margin-bottom: 18px;
}
.field { display: grid; gap: 6px; }
.field span {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input[type="text"],
.field input[type="tel"],
.field input[type="email"],
.field textarea,
.dim input {
  font-family: var(--sans);
  font-size: 16px; /* keep iOS from zooming */
  color: var(--ink);
  background: #fff;
  border: 1px solid #ddd2c0;
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  width: 100%;
}
.field input:focus,
.field textarea:focus,
.dim input:focus,
.field input[type="tel"]:focus,
.field input[type="email"]:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(141, 107, 44, 0.18);
}
.field textarea { resize: vertical; min-height: 64px; }
.field .req, .dim .opt {
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  font-size: 10px;
  margin-left: 4px;
}
.field .req { color: var(--gold); }
.dim .opt {
  color: var(--gold-soft);
  background: var(--gold-pale);
  border-radius: 999px;
  padding: 1px 6px;
  margin-left: 6px;
}
.field.invalid input { border-color: var(--danger); background: #fff6ef; }
.customer, .set-fields { display: grid; gap: 14px; }

.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

@media (min-width: 840px) {
  .customer { grid-template-columns: 1.1fr 1fr 1.3fr; }
  .set-fields { grid-template-columns: 1fr 1.2fr; }
}

.box-card { padding: 8px 8px 18px; overflow: visible; }
.box-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}
.box-head h2 {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  margin: 0;
}
.box-head .he {
  margin: 0;
  color: var(--gold);
  font-family: var(--serif);
  font-size: 22px;
}

.box-body {
  display: grid;
  gap: 8px;
}
.view-wrap {
  position: relative;
  width: 100%;
  margin: 0 auto;
  padding: 4px 4px 0;
}
.diagram {
  width: 100%;
  height: auto;
  display: block;
}

.measures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 4px 10px 8px;
}
.measures .optional { grid-column: 1 / -1; }

.dim {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
  min-width: 0;
}
.dim .letter {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--gold);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 2px rgba(28,25,22,0.2);
  flex-shrink: 0;
}
.dim.optional .letter { background: var(--gold-soft); }
.dim-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.dim-name {
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
  line-height: 1.2;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
.dim .hint {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}
.dim .input-wrap { position: relative; }
.dim input {
  width: 5.1rem;
  height: 2.6rem;
  padding: 0 22px 0 6px;
  text-align: center;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  border-color: var(--gold-soft);
  background: #fff;
  box-shadow: 0 2px 6px rgba(28,25,22,0.06);
}
.dim .unit {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 650;
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--gold);
  pointer-events: none;
}
.dim.warn input,
.dim.invalid input {
  border-color: var(--danger);
  background: #fff6ef;
}

@media (max-width: 399px) {
  .page { padding-left: 10px; padding-right: 10px; }
  .lede { font-size: 14.5px; }
  .measures { grid-template-columns: 1fr; padding-left: 8px; padding-right: 8px; }
  .dim { grid-template-columns: 28px 1fr auto; }
  .dim input { width: 4.6rem; height: 2.55rem; }
  .actions { padding: 10px 12px; }
  .save { padding: 12px 16px; }
  .hero { margin-bottom: 16px; }
  .field textarea { min-height: 52px; }
}

@media (min-width: 840px) {
  .box-body {
    grid-template-columns: 1.25fr 0.9fr;
    align-items: center;
    gap: 8px 12px;
    padding: 4px 8px 4px 0;
  }
  .measures {
    grid-template-columns: 1fr;
    padding: 8px 12px 8px 4px;
  }
}

.alerts {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f8efe6;
  border: 1px solid #e6c9a8;
  color: var(--danger);
  font-size: 14px;
  line-height: 1.45;
}
.alerts ul { margin: 6px 0 0; padding-left: 1.1em; }

.actions {
  margin-top: 18px;
  padding: 16px;
  display: grid;
  gap: 10px;
  position: sticky;
  bottom: 0;
  z-index: 5;
  background: rgba(255,252,247,0.96);
  backdrop-filter: blur(8px);
}
form { padding-bottom: 132px; }
.save {
  appearance: none;
  border: 0;
  cursor: pointer;
  background: var(--ink);
  color: #f8f1e4;
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.01em;
  padding: 14px 18px;
  border-radius: 12px;
  width: 100%;
}
.save:hover { background: #2a2520; }
.save:disabled { opacity: 0.55; cursor: default; }
.status {
  margin: 0;
  text-align: center;
  min-height: 0;
  font-size: 14.5px;
  color: var(--muted);
}
.status:empty { display: none; }
.status.ok { color: var(--ok); font-weight: 650; }
.status.err { color: var(--danger); font-weight: 650; }

.set-block { margin-bottom: 22px; }
.set-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 8px 12px;
}
.set-kicker {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  color: var(--gold);
  margin: 0 0 2px;
}
.set-head h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(28px, 5vw, 36px);
  letter-spacing: -0.02em;
  margin: 0;
}
.set-head .he {
  margin: 0 0 4px;
  color: var(--gold);
  font-family: var(--serif);
  font-size: 26px;
}
.set-block .box-card { margin-bottom: 14px; }
.set-block .box-card:last-child { margin-bottom: 0; }
.box-head h3 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  margin: 0;
}
.box-head-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.box-card[data-box$="-yad"] .box-head {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: stretch;
}

.switch-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 2px 2px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
}
.switch-row input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.switch {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #ddd2c0;
  position: relative;
  flex-shrink: 0;
  margin-top: 2px;
  transition: background 0.15s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(28, 25, 22, 0.25);
  transition: transform 0.15s ease;
}
.switch-row input:checked + .switch { background: var(--gold); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row input:focus-visible + .switch {
  box-shadow: 0 0 0 3px rgba(141, 107, 44, 0.18);
}
.switch-copy { display: grid; gap: 2px; min-width: 0; }
.switch-name {
  font-size: 15px;
  font-weight: 650;
  color: var(--ink);
  line-height: 1.3;
  text-transform: none;
  letter-spacing: 0;
}
.switch-hint {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.35;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.need-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  padding: 2px 2px 6px;
  user-select: none;
}
.need-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
  flex-shrink: 0;
  margin: 0;
}
.box-card.is-skipped .yad-body { display: none; }
.box-card.is-skipped {
  padding-bottom: 8px;
}

@media (min-width: 600px) {
  .box-card[data-box$="-yad"] .box-head {
    grid-template-columns: 1fr auto;
    align-items: baseline;
  }
  .need-row { padding: 0; }
}
/* add to styles.css */
.design-link { display: inline-block; text-align: center; text-decoration: none; margin-top: 10px; background: var(--card); color: var(--ink); border: 1px solid var(--gold-soft); }
