/* Общие токены, формы, кнопки, модальные окна и уведомления (витрина + админка). */
:root {
  /* Пять базовых цветов задаются палитрой из админки (UI.applyPalette), остальное считается от них. */
  --bg: #fff4e6;
  --panel: #ffffff;
  --text: #2b1d12;
  --accent: #ff8a1f;
  --accent-2: #ff5d73;
  --accent-ink: #0a1410;
  --bg-2: color-mix(in srgb, var(--bg), var(--panel) 55%);
  --panel-2: color-mix(in srgb, var(--panel), var(--text) 9%);
  --line: color-mix(in srgb, var(--text) 11%, transparent);
  --line-strong: color-mix(in srgb, var(--text) 22%, transparent);
  --muted: color-mix(in srgb, var(--text) 60%, var(--bg));
  --ease: cubic-bezier(.22, .8, .3, 1);
  --grad: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 45%, var(--accent-2)));
  --danger: #ff6b6b;
  --warn: #ffc15e;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  color-scheme: light;
}

/* во время первой загрузки цветовые переходы выключены, чтобы палитра не «перетекала» на глазах (boot.js) */
.no-anim *, .no-anim *::before, .no-anim *::after { transition: none !important; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }

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

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--panel-2);
  font-weight: 600; cursor: pointer; transition: transform .3s var(--ease), background .35s var(--ease), border-color .35s var(--ease), box-shadow .35s var(--ease), filter .35s var(--ease), opacity .3s;
  text-decoration: none; color: var(--text); white-space: nowrap;
}
.btn:hover { background: color-mix(in srgb, var(--panel-2), var(--text) 8%); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--grad); color: var(--accent-ink); border-color: transparent; box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn-primary:hover { background: var(--grad); filter: brightness(1.08); box-shadow: 0 8px 26px color-mix(in srgb, var(--accent) 50%, transparent); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: rgba(255, 107, 107, .4); background: transparent; }
.btn-danger:hover { background: rgba(255, 107, 107, .12); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 6px 9px; min-width: 34px; }
.btn-block { width: 100%; }

/* ---------- формы ---------- */
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.hint { display: block; margin-top: 5px; font-size: 12.5px; color: var(--muted); }
.input, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--line-strong); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input.invalid { border-color: var(--danger); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14px; color: var(--text); margin: 8px 0; }
.check input { appearance: none; flex: none; width: 20px; height: 20px; margin: 1px 0 0; border: 1.5px solid var(--line-strong); border-radius: 6px; background: var(--bg-2); display: grid; place-content: center; cursor: pointer; }
.check input::before { content: ""; width: 10px; height: 10px; transform: scale(0); transition: transform .12s; background: var(--accent-ink); clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::before { transform: scale(1); }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: 22px; cursor: pointer; transition: .15s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: var(--muted); border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::before { transform: translateX(18px); background: var(--accent-ink); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- модальные окна ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh 14px; overflow-y: auto; background: rgba(4, 7, 11, .72); backdrop-filter: blur(5px);
  animation: fade .4s var(--ease);
}
.modal {
  width: 100%; max-width: 520px; background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 18px; box-shadow: var(--shadow); animation: pop .5s var(--ease);
}
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 0; }
.modal-head h2 { font-size: 19px; }
.modal-close { background: transparent; border: 0; color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.modal-close:hover { color: var(--text); background: var(--panel-2); }
.modal-body { padding: 18px 22px 22px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---------- уведомления ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: grid; gap: 8px; max-width: calc(100vw - 32px); }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line-strong); box-shadow: var(--shadow); animation: pop .18s ease-out; max-width: 380px; }
.toast.ok { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.toast.err { border-color: rgba(255, 107, 107, .6); }

/* ---------- иконки ---------- */
.ico { display: inline-block; vertical-align: -0.2em; flex: none; }
.btn .ico { vertical-align: middle; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; }

/* ---------- заглушка товара без картинки ---------- */
.ph { width: 100%; height: 100%; display: grid; place-items: center; }
.ph span { font-size: 64px; font-weight: 900; color: rgba(255, 255, 255, .85); text-shadow: 0 6px 24px rgba(0, 0, 0, .45); font-family: ui-monospace, Consolas, monospace; }
.ph-sm span { font-size: 26px; }

.error-text { color: var(--danger); font-size: 13.5px; margin-top: 8px; }
.muted { color: var(--muted); }

/* ---------- телефон: окна выезжают снизу, поля и кнопки крупнее ---------- */
@media (max-width: 560px) {
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-width: none; border-radius: 24px 24px 0 0; max-height: 94vh; max-height: 94dvh; overflow-y: auto; overscroll-behavior: contain; animation: sheet .45s var(--ease); }
  .modal-head { padding: 16px 18px 0; position: sticky; top: 0; background: var(--panel); z-index: 2; padding-bottom: 8px; }
  .modal-body { padding: 10px 18px calc(22px + env(safe-area-inset-bottom)); }
  .input, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], select, textarea { font-size: 16px; min-height: 50px; }
  .btn { min-height: 46px; }
  .btn-sm { min-height: 38px; }
  .check { padding: 6px 0; font-size: 15px; }
  .check input { width: 24px; height: 24px; }
  .modal-actions .btn-primary, form > .modal-actions .btn { width: 100%; min-height: 52px; font-size: 16px; }
  .modal-close { font-size: 30px; padding: 6px 12px; }
  .modal form > .modal-actions { position: sticky; bottom: 0; margin: 14px -18px calc(-22px - env(safe-area-inset-bottom)); padding: 12px 18px calc(14px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); z-index: 2; }
  /* клавиатура открыта (фокус в окне): кнопка «Оплатить» не липнет к низу и не закрывает поля */
  .modal:focus-within { max-height: 100dvh; border-radius: 0; }
  .modal:focus-within .modal-head { position: static; }
  .modal:focus-within form > .modal-actions { position: static; margin: 14px 0 0; padding: 0; border-top: 0; background: none; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
