:root {
  --bg: #fff7f3;
  --bg2: #ffe9e1;
  --card: #ffffff;
  --ink: #2d2a32;
  --muted: #7b7482;
  --line: #f0e2dc;
  --accent: #ef5f8b;
  --accent-ink: #ffffff;
  --accent-soft: #ffe1e9;
  --ok: #25b46b;
  --radius: 16px;
  --bar-h: 76px;
  color-scheme: light only;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: Montserrat, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.logo b { font-family: Unbounded, Montserrat, sans-serif; font-weight: 900; color: var(--accent); text-transform: uppercase; letter-spacing: .03em; }
.logo { color: inherit; text-decoration: none; font-size: 18px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.logo span { color: var(--muted); font-size: 13px; }

.layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(340px, 1fr); gap: 20px; padding: 0 20px 20px; max-width: 1400px; margin: 0 auto; }

.viewer {
  position: sticky; top: 12px; height: calc(100vh - var(--bar-h) - 90px); min-height: 420px;
  border-radius: 24px; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 30%, #ffffff 0%, var(--bg2) 70%);
  border: 1px solid var(--line);
}
#c { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#c:active { cursor: grabbing; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; }
.viewer-tools { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.tool {
  border: 1px solid var(--line); background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(8px);
  border-radius: 999px; padding: 9px 14px; cursor: pointer; font-weight: 600; font-size: 13px;
}
.tool[aria-pressed='true'] { background: var(--accent-soft); border-color: var(--accent); }
.tool:hover { border-color: var(--accent); }
.hint { position: absolute; top: 12px; left: 0; right: 0; text-align: center; color: var(--muted); font-size: 12px; pointer-events: none; }
.toast {
  position: absolute; top: 40px; left: 50%; transform: translate(-50%, -10px); opacity: 0; transition: .3s;
  background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Панель шагов ---------- */
.panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.step > summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; align-items: center; gap: 10px; font-weight: 700; }
.step > summary::-webkit-details-marker { display: none; }
.step > summary .num { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 13px; flex: none; }
.step > summary .sum { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 13px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; }
.step[open] > summary { border-bottom: 1px solid var(--line); }
.step-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.field-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; display: flex; justify-content: space-between; }
.field-label em { font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 8px 12px; cursor: pointer; font-weight: 600; font-size: 13px;
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px;
}
.chip small { color: var(--muted); font-weight: 500; font-size: 11px; }
.chip svg { width: 34px; height: 34px; }
.chip[aria-pressed='true'] { border-color: var(--accent); background: var(--accent-soft); }
.chip:disabled { opacity: .45; cursor: not-allowed; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; padding: 0; box-shadow: inset 0 0 0 2px var(--card); }
.sw[aria-pressed='true'] { border-color: var(--accent); transform: scale(1.1); }
input[type='color'].sw { padding: 0; overflow: hidden; }

.input { width: 100%; border: 1.5px solid var(--line); background: var(--bg); border-radius: 12px; padding: 10px 12px; outline: none; }
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 90px; resize: vertical; }
.row { display: flex; gap: 8px; align-items: center; }
.note { font-size: 12px; color: var(--muted); margin: 0; }

.bead-list { display: flex; flex-wrap: wrap; gap: 6px; }
.bead-item { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 4px; font-size: 12px; }
.bead-item i { width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; font-style: normal; font-size: 10px; font-weight: 800; }
.bead-item button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 2px; font-size: 14px; }

/* ---------- Нижняя панель ---------- */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; min-height: var(--bar-h);
  padding: 10px 20px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; justify-content: space-between;
}
.total { border: 0; background: none; text-align: left; cursor: pointer; display: grid; grid-template-columns: auto auto; column-gap: 10px; align-items: baseline; padding: 0; }
.total small { color: var(--muted); grid-column: 1 / -1; font-size: 12px; }
.total b { font-size: 26px; font-weight: 800; }
.total .chev { color: var(--muted); font-size: 12px; }
.total.bump b { animation: bump .4s; }
@keyframes bump { 40% { transform: scale(1.12); color: var(--accent); } }
.breakdown {
  position: absolute; bottom: calc(100% + 8px); left: 20px; width: min(420px, calc(100vw - 40px)); max-height: 50vh; overflow: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; box-shadow: 0 10px 40px rgba(0,0,0,.12); font-size: 13px;
}
.breakdown div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.breakdown div:last-child { border: 0; font-weight: 800; }
.bar-actions { display: flex; gap: 8px; }

.btn { border: 1.5px solid transparent; border-radius: 999px; padding: 12px 18px; cursor: pointer; font-weight: 700; text-decoration: none; text-align: center; display: inline-block; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: var(--accent); }
.btn.wa { background: #25d366; color: #fff; }
.btn.tg { background: #2aabee; color: #fff; }

dialog { border: 0; border-radius: 20px; padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(20, 10, 20, .45); }
.dlg-body { padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.dlg-body h2 { margin: 0; }
.dlg-body label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.dlg-body label input, .dlg-body label select { border: 1.5px solid var(--line); border-radius: 10px; padding: 10px; background: var(--bg); }
.dlg-body label.check { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 500; color: var(--muted); }
.muted { color: var(--muted); margin: 0; font-size: 13px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
pre#orderPreview { background: var(--bg); border-radius: 12px; padding: 12px; font-size: 12px; white-space: pre-wrap; max-height: 34vh; overflow: auto; margin: 0; font-family: inherit; }
.send-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- Мобильная вёрстка ---------- */
@media (max-width: 860px) {
  :root { --bar-h: 70px; }
  .top { padding: 10px 16px; }
  .logo span { display: none; }
  .layout { grid-template-columns: 1fr; padding: 0 16px 16px; gap: 12px; }
  .viewer { position: sticky; top: 0; z-index: 5; height: 46vh; min-height: 300px; border-radius: 0 0 20px 20px; margin: 0 -16px; }
  .tool span { display: none; }
  .hint { display: none; }
  .bar { padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); gap: 10px; }
  .total b { font-size: 21px; }
  .bar-actions .ghost { display: none; }
  .btn { padding: 11px 14px; }
  .breakdown { left: 16px; }
}
