/* Витрина магазина. Тема — data-theme на <html>, акцент — --accent (задаёт JS). */
:root {
  --accent: #111111; --on-accent: #ffffff;
  --bg: #f5f6f8; --card: #ffffff; --text: #121316; --muted: #858a93; --line: #e7e8ec; --chip: #ffffff;
  --tile: color-mix(in srgb, var(--accent) 9%, var(--card));
  --radius: 16px; --r-sm: 12px; --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  --head: var(--font); --head-weight: 700; --head-track: -.01em; --caps: none; --caps-track: 0;
  --shadow: 0 1px 2px rgba(16,20,30,.05), 0 6px 20px rgba(16,20,30,.05);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
html[data-theme="editorial"] {
  --bg: #ffffff; --card: #ffffff; --chip: transparent; --line: #e9e7e2; --muted: #8c8c8c; --text: #141414;
  --tile: #f4f3ef; --radius: 0px; --r-sm: 0px; --head-weight: 600; --head-track: .02em; --caps: uppercase; --caps-track: .16em;
  --shadow: none;
}
html[data-theme="dark"] {
  --bg: #0b0b0d; --card: #16161a; --chip: #1c1c21; --text: #f3f3f5; --muted: #8d8e98; --line: #26262c;
  --tile: color-mix(in srgb, var(--accent) 16%, #16161a); --radius: 18px; --shadow: none;
}
html[data-theme="soft"] {
  --bg: #f4ede3; --card: #fffaf3; --chip: #fffaf3; --text: #2a2017; --muted: #8b7b69; --line: #e8dccb;
  --tile: color-mix(in srgb, var(--accent) 12%, #fffaf3); --radius: 24px; --r-sm: 16px;
  --head: "Iowan Old Style", "Palatino Linotype", Georgia, serif; --head-weight: 600; --shadow: 0 8px 24px rgba(90,60,20,.07);
}
html[data-theme="telegram"] {
  --bg: var(--tg-theme-secondary-bg-color, #f1f1f4); --card: var(--tg-theme-bg-color, #fff); --chip: var(--tg-theme-bg-color, #fff);
  --text: var(--tg-theme-text-color, #111); --muted: var(--tg-theme-hint-color, #8a8a8f);
  --line: color-mix(in srgb, var(--tg-theme-hint-color, #8a8a8f) 22%, transparent);
  --tile: color-mix(in srgb, var(--accent) 12%, var(--card)); --radius: 14px; --shadow: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 var(--font); }
body { min-height: 100vh; padding-bottom: calc(96px + var(--safe-b)); overflow-x: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; }
img { display: block; }
[hidden] { display: none !important; }
.caps { text-transform: var(--caps); letter-spacing: var(--caps-track); }

/* ---------- шапка ---------- */
.top { padding: 18px 16px 6px; display: flex; gap: 12px; align-items: center; }
.logo { flex: none; width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; font: var(--head-weight) 20px/1 var(--head); }
html[data-theme="editorial"] .logo { border-radius: 0; }
.top-txt { min-width: 0; flex: 1; }
.top h1 { margin: 0; font: var(--head-weight) 20px/1.15 var(--head); letter-spacing: var(--head-track);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html[data-theme="editorial"] .top h1 { font-size: 15px; text-transform: uppercase; letter-spacing: .28em; }
.top p { margin: 3px 0 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.manage { flex: none; height: 36px; padding: 0 14px; border-radius: 18px; background: var(--chip); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; }
html[data-theme="editorial"] .manage { border-radius: 0; text-transform: uppercase; letter-spacing: .1em; font-size: 11px; }

.note { margin: 8px 16px 0; padding: 10px 14px; border-radius: var(--r-sm); background: var(--tile); font-size: 13px; }

.search { display: block; margin: 12px 16px 0; position: relative; }
.search input { width: 100%; height: 44px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--card);
  padding: 0 14px 0 40px; outline: none; font-size: 15px; }
.search input:focus { border-color: var(--accent); }
.search svg { position: absolute; left: 13px; top: 13px; width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2; }
html[data-theme="editorial"] .search input { border: 0; border-bottom: 1px solid var(--text); padding-left: 30px; background: transparent; }
html[data-theme="editorial"] .search svg { left: 2px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 34px; padding: 0 14px; border-radius: 17px; background: var(--chip); border: 1px solid var(--line);
  font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
html[data-theme="editorial"] .chip { border: 0; border-bottom: 1.5px solid transparent; border-radius: 0; padding: 0 2px; margin-right: 10px;
  text-transform: uppercase; letter-spacing: .14em; font-size: 11px; color: var(--muted); background: transparent; }
html[data-theme="editorial"] .chip.on { color: var(--text); border-bottom-color: var(--text); background: transparent; }

/* ---------- сетка ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 16px; }
html[data-theme="editorial"] .grid { gap: 26px 12px; }
.card { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); text-align: left;
  display: flex; flex-direction: column; }
html[data-theme="dark"] .card { border: 1px solid var(--line); }
html[data-theme="editorial"] .card { background: transparent; }
.ph { position: relative; aspect-ratio: 1; background: var(--tile); display: grid; place-items: center; overflow: hidden; }
.ph img { width: 100%; height: 100%; object-fit: cover; }
.ph .emo { font-size: 64px; line-height: 1; filter: saturate(1.05); }
.badge { position: absolute; left: 8px; top: 8px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700;
  padding: 3px 7px; border-radius: 8px; }
html[data-theme="editorial"] .badge { border-radius: 0; letter-spacing: .08em; }
.badge.off { background: #6b7280; color: #fff; }
.cb { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
html[data-theme="editorial"] .cb { padding: 10px 0 0; }
.ct { font-size: 13.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cp { margin-top: auto; display: flex; align-items: baseline; gap: 6px; font-weight: 700; font-size: 15px; }
.cp s, .pp s { color: var(--muted); font-weight: 400; font-size: 12.5px; }
html[data-theme="editorial"] .cp { font-size: 13px; font-weight: 600; }
.add { margin-top: 2px; height: 34px; border-radius: calc(var(--r-sm) - 2px); background: var(--tile); font-weight: 600; font-size: 13px; color: var(--text); }
.add.in { background: var(--accent); color: var(--on-accent); }
html[data-theme="editorial"] .add { border: 1px solid var(--text); background: transparent; text-transform: uppercase; letter-spacing: .1em; font-size: 11px; }
html[data-theme="editorial"] .add.in { background: var(--text); color: var(--bg); }

.empty { text-align: center; color: var(--muted); padding: 60px 30px; }
.empty b { display: block; font-size: 44px; margin-bottom: 8px; }
.closed { padding: 80px 30px; text-align: center; }
.closed h2 { font: var(--head-weight) 22px/1.2 var(--head); margin: 10px 0 6px; }
.closed p { color: var(--muted); margin: 0; }

/* ---------- корзина ---------- */
.cartbar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--safe-b)); z-index: 20; height: 56px; border-radius: var(--r-sm);
  background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: space-between; padding: 0 18px;
  font-weight: 700; box-shadow: 0 10px 30px rgba(0,0,0,.18); animation: up .25s ease; }
.cartbar span { opacity: .85; font-weight: 500; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }

/* ---------- шторки ---------- */
.veil { position: fixed; inset: 0; background: rgba(0,0,0,.42); z-index: 40; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92vh; overflow-y: auto; background: var(--card);
  border-radius: calc(var(--radius) + 6px) calc(var(--radius) + 6px) 0 0; padding: 0 0 calc(18px + var(--safe-b));
  animation: sheet .28s cubic-bezier(.2,.8,.2,1); overscroll-behavior: contain; }
html[data-theme="editorial"] .sheet { border-radius: 0; }
@keyframes sheet { from { transform: translateY(100%); } }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; }
.x { position: absolute; right: 12px; top: 12px; width: 34px; height: 34px; border-radius: 50%; background: rgba(0,0,0,.35); color: #fff;
  font-size: 20px; line-height: 34px; z-index: 2; }
.gal { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; background: var(--tile); }
.gal::-webkit-scrollbar { display: none; }
.gal > * { flex: none; width: 100%; aspect-ratio: 1; scroll-snap-align: start; object-fit: cover; display: grid; place-items: center; }
.gal .emo { font-size: 120px; }
.dots { display: flex; justify-content: center; gap: 5px; margin-top: 10px; }
.dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--line); }
.dots i.on { background: var(--accent); width: 16px; }
.pad { padding: 16px 18px 0; }
.pt { margin: 0; font: var(--head-weight) 21px/1.22 var(--head); letter-spacing: var(--head-track); }
.pp { margin-top: 8px; display: flex; gap: 8px; align-items: baseline; font-size: 20px; font-weight: 700; }
.pd { margin-top: 12px; color: var(--muted); white-space: pre-line; font-size: 14.5px; }
.lbl { margin: 18px 0 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opts button { min-width: 48px; height: 40px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--card); font-weight: 500; }
.opts button.on { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.btn { width: 100%; height: 52px; border-radius: var(--r-sm); background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 16px; margin-top: 18px; }
html[data-theme="editorial"] .btn { text-transform: uppercase; letter-spacing: .12em; font-size: 13px; }
.btn.ghost { background: var(--tile); color: var(--text); }
.btn.danger { background: transparent; color: #d93025; border: 1px solid color-mix(in srgb, #d93025 30%, transparent); }
.btn:disabled { opacity: .5; }
.h2 { margin: 18px 18px 4px; font: var(--head-weight) 20px/1.2 var(--head); }
.line { display: flex; gap: 12px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.line .ph { width: 56px; flex: none; border-radius: var(--r-sm); }
.line .ph .emo { font-size: 28px; }
.line .t { flex: 1; min-width: 0; font-size: 14px; }
.line .t small { display: block; color: var(--muted); }
.qty { display: flex; align-items: center; gap: 2px; background: var(--tile); border-radius: 18px; }
.qty button { width: 32px; height: 32px; font-size: 18px; font-weight: 600; }
.qty b { min-width: 18px; text-align: center; font-size: 14px; }
.sum { display: flex; justify-content: space-between; padding: 14px 18px 0; font-size: 17px; font-weight: 700; }
.form { padding: 0 18px; }
.field { display: block; margin-top: 12px; }
.field span { display: block; font-size: 12.5px; color: var(--muted); margin: 0 0 5px 2px; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: var(--r-sm);
  padding: 12px 13px; outline: none; font-size: 15px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.err { color: #d93025; font-size: 13.5px; margin-top: 10px; }
.ok { text-align: center; padding: 34px 24px 8px; }
.ok b { font-size: 56px; display: block; }
.ok h3 { font: var(--head-weight) 22px/1.2 var(--head); margin: 10px 0 6px; }
.ok p { color: var(--muted); margin: 0; }
.info { margin: 14px 18px 0; padding: 12px 14px; background: var(--tile); border-radius: var(--r-sm); font-size: 13.5px; }

/* ---------- управление ---------- */
.tabs { display: flex; gap: 6px; padding: 12px 16px 4px; }
.tabs button { flex: 1; height: 38px; border-radius: var(--r-sm); background: var(--chip); border: 1px solid var(--line); font-weight: 600; font-size: 13.5px; }
.tabs button.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.list { padding: 8px 16px; display: grid; gap: 10px; }
.row { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); text-align: left; width: 100%; }
html[data-theme="dark"] .row, html[data-theme="editorial"] .row { border: 1px solid var(--line); }
.row .ph { width: 58px; flex: none; border-radius: var(--r-sm); }
.row .ph .emo { font-size: 30px; }
.row .t { flex: 1; min-width: 0; }
.row .t b { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t small { color: var(--muted); font-size: 13px; }
.pill { font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 10px; background: var(--tile); white-space: nowrap; }
.pill.new { background: var(--accent); color: var(--on-accent); }
.plus { margin: 4px 16px 0; height: 50px; width: calc(100% - 32px); border-radius: var(--radius); border: 1.5px dashed var(--line); font-weight: 600; color: var(--accent); background: var(--card); }
.photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.photos > * { aspect-ratio: 1; border-radius: var(--r-sm); overflow: hidden; position: relative; background: var(--tile); }
.photos img { width: 100%; height: 100%; object-fit: cover; }
.photos .del { position: absolute; right: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; line-height: 22px; }
.photos .main { position: absolute; left: 3px; bottom: 3px; font-size: 10px; background: rgba(0,0,0,.6); color: #fff; padding: 1px 5px; border-radius: 6px; }
.photos label { display: grid; place-items: center; font-size: 26px; color: var(--muted); border: 1.5px dashed var(--line); background: transparent; cursor: pointer; }
.toggle { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; padding: 12px 2px; font-weight: 500; }
.toggle input { width: 46px; height: 28px; appearance: none; border-radius: 14px; background: var(--line); position: relative; transition: background .2s; }
.toggle input::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(18px); }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.th { border: 2px solid var(--line); border-radius: 14px; padding: 8px; text-align: left; background: var(--card); }
.th.on { border-color: var(--accent); }
.th i { display: block; height: 46px; border-radius: 8px; margin-bottom: 6px; }
.th span { font-size: 12.5px; font-weight: 600; }
.sw { display: flex; gap: 10px; flex-wrap: wrap; }
.sw button { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--line); }
.sw button.on { box-shadow: 0 0 0 2px var(--text); }
.sub { margin: 12px 16px 0; padding: 14px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); font-size: 13.5px; }
.sub b { display: block; font-size: 15px; margin-bottom: 4px; }
.sub button { margin-top: 10px; color: var(--accent); font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%); background: #111; color: #fff; padding: 10px 16px;
  border-radius: 12px; font-size: 14px; z-index: 60; animation: up .2s ease; max-width: 90vw; }
