/* Menoula editor — warm, calm, phone-first. No external fonts. */
:root {
  --terra: #c2410c; --terra-d: #9a3412; --terra-l: #fff1e8;
  --sea: #0e7490; --sea-d: #155e75; --sea-l: #e6f4f7;
  --bg: #fffaf3; --card: #ffffff; --ink: #1c1917; --ink-2: #44403c; --muted: #78716c;
  --line: #eadfd3; --line-2: #f3ebe2; --field: #fffdfa;
  --ok: #15803d; --warn: #b45309; --err: #b91c1c;
  --r: 16px; --r-s: 10px;
  --shadow: 0 1px 2px rgba(68, 40, 20, .06), 0 6px 20px -10px rgba(68, 40, 20, .18);
  --shadow-l: 0 20px 50px -20px rgba(68, 40, 20, .45);
  --top: 60px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.is-dragging { user-select: none; -webkit-user-select: none; cursor: grabbing; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
a { color: var(--sea-d); }
[hidden] { display: none !important; }
.vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { top: 8px; }
:focus-visible { outline: 3px solid var(--sea); outline-offset: 2px; }
main:focus { outline: none; }
.noscript { padding: 20px; text-align: center; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--r-s);
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover { border-color: #d8c6b4; background: #fffcf8; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--terra); border-color: var(--terra); color: #fff; box-shadow: 0 2px 0 var(--terra-d); }
.btn.primary:hover { background: var(--terra-d); border-color: var(--terra-d); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--line-2); }
.btn.small { min-height: 34px; padding: 5px 12px; font-size: 14px; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn .ico { font-size: 1.05em; line-height: 1; }
.danger-text { color: var(--err) !important; }
.icon-btn {
  width: 36px; height: 36px; flex: none; display: inline-grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); font-size: 16px; cursor: pointer;
}
.icon-btn:hover { background: var(--line-2); }

input[type=text], input[type=tel], input[type=url], input[type=email], input:not([type]), textarea, select {
  width: 100%; min-height: 42px; padding: 9px 12px;
  border: 1.5px solid var(--line); border-radius: var(--r-s); background: var(--field); color: var(--ink);
  font: inherit; font-size: 16px; /* no iOS zoom */
  transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { resize: vertical; min-height: 64px; line-height: 1.4; }
input:hover, textarea:hover, select:hover { border-color: #dccbb9; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--sea); box-shadow: 0 0 0 3px rgba(14, 116, 144, .18); background: #fff; }
input[aria-invalid], input:invalid:not(:placeholder-shown) { border-color: var(--err); box-shadow: 0 0 0 3px rgba(185, 28, 28, .12); }
select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2378716c' stroke-width='2'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
::placeholder { color: #a8a29e; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 650; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.req { color: var(--terra); }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.hint.warn { color: var(--warn); }
.badge-en { font-size: 10px; font-weight: 800; letter-spacing: .04em; padding: 1px 5px; border-radius: 5px; background: var(--sea-l); color: var(--sea-d); }
.pair, .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
body.hide-en .field.en { display: none !important; }
body.hide-en .pair { grid-template-columns: 1fr; }

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

/* switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 14px; position: relative; }
.switch input { position: absolute; opacity: 0; width: 44px; height: 26px; margin: 0; cursor: pointer; }
.switch .track { width: 44px; height: 26px; border-radius: 99px; background: #d6d3d1; position: relative; flex: none; transition: background .2s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid var(--sea); outline-offset: 2px; }
.switch.mini input { width: 36px; height: 22px; }
.switch.mini .track { width: 36px; height: 22px; }
.switch.mini .track::after { width: 16px; height: 16px; }
.switch.mini input:checked + .track::after { transform: translateX(14px); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; height: var(--top);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: rgba(255, 250, 243, .92); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.status { margin: 0; flex: 1; min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.busy { color: var(--sea-d); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.langsw, .seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 99px; padding: 2px; background: #fff; }
.langsw button, .seg button { border: 0; background: transparent; font: inherit; font-size: 12.5px; font-weight: 700; padding: 5px 10px; border-radius: 99px; cursor: pointer; color: var(--muted); }
.langsw button[aria-pressed=true], .seg button[aria-pressed=true] { background: var(--ink); color: #fff; }

/* ---------- start screen ---------- */
.screen-start { max-width: 920px; margin: 0 auto; padding: 36px 18px 80px; }
.start-hero { text-align: center; margin-bottom: 28px; }
.start-hero h1 { font-size: clamp(28px, 5vw, 42px); letter-spacing: -.03em; font-weight: 800; }
.start-hero h1::after { content: ""; display: block; width: 64px; height: 5px; border-radius: 9px; margin: 14px auto 0; background: linear-gradient(90deg, var(--terra), #f59e0b 50%, var(--sea)); }
.lead { color: var(--ink-2); font-size: 17px; max-width: 620px; margin: 14px auto 0; }
.sec-title { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 30px 0 12px; font-weight: 750; }
.tpl-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.tpl { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 18px; text-align: left; cursor: pointer; font: inherit; color: inherit; transition: transform .15s, box-shadow .15s, border-color .15s; }
.tpl:hover { transform: translateY(-3px); box-shadow: var(--shadow-l); border-color: #e2c8b2; }
.tpl-ico { font-size: 34px; line-height: 1; margin-bottom: 10px; width: 58px; height: 58px; display: grid; place-items: center; border-radius: 16px; background: var(--terra-l); }
.tpl[data-tpl=beach_bar] .tpl-ico, .tpl[data-tpl=cafe] .tpl-ico { background: var(--sea-l); }
.tpl strong { font-size: 16.5px; }
.tpl small { color: var(--muted); }
.draft-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; flex-wrap: wrap; border-left: 5px solid var(--terra); }
.draft-actions { display: flex; gap: 8px; }
.mine-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.mine-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; flex-wrap: wrap; }
.mine-info { flex: 1; min-width: 180px; display: flex; flex-direction: column; }
.mine-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.mine .hint { margin-top: 10px; }

/* ---------- message screen ---------- */
.screen-msg { min-height: calc(100vh - var(--top)); display: grid; place-items: center; padding: 24px; }
.msg-card { max-width: 460px; padding: 32px; text-align: center; }
.msg-card h1 { font-size: 22px; margin-bottom: 8px; }
.msg-card p { color: var(--ink-2); }
.msg-actions { margin-top: 18px; display: flex; gap: 10px; justify-content: center; }
.spinner { width: 34px; height: 34px; margin: 0 auto 16px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--terra); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- editor layout ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 28px; max-width: 1280px; margin: 0 auto; padding: 22px 22px 90px; align-items: start; }
.pane-form { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.pane-preview { position: sticky; top: calc(var(--top) + 18px); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.preview-bar { width: 375px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.preview-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.phone { position: relative; width: 375px; height: min(780px, calc(100vh - var(--top) - 90px)); min-height: 480px; border-radius: 46px; background: #1c1917; padding: 12px; box-shadow: var(--shadow-l), inset 0 0 0 2px #44403c; }
.phone-notch { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); width: 120px; height: 24px; background: #1c1917; border-radius: 0 0 16px 16px; z-index: 2; }
.phone-screen { position: relative; width: 100%; height: 100%; border-radius: 34px; overflow: hidden; background: #fff; }
.phone-screen iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; visibility: hidden; background: #fff; }
.phone-screen iframe.show { visibility: visible; }

.banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-radius: var(--r); background: var(--sea-l); border: 1px solid #b6e0ea; color: var(--sea-d); font-weight: 600; margin-bottom: 8px; }
.banner.warn { background: #fef3c7; border-color: #fcd34d; color: #78350f; }
.form-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 2px 4px; }
.form-top .hint { flex: 1; min-width: 200px; }

/* sections */
.sec > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 16px 18px; cursor: pointer; font-weight: 750; font-size: 16.5px; border-radius: var(--r); }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary:hover { background: #fffcf8; }
.sec-ico { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--terra-l); font-size: 17px; }
.chev { margin-left: auto; width: 10px; height: 10px; border-right: 2.5px solid var(--muted); border-bottom: 2.5px solid var(--muted); transform: rotate(45deg); transition: transform .2s; margin-right: 6px; }
.sec[open] > summary .chev { transform: rotate(-135deg); }
.sec-body { padding: 4px 18px 20px; display: flex; flex-direction: column; gap: 14px; }

.media-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.logo-prev { width: 56px; height: 56px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.logo-prev.empty { display: grid; place-items: center; font-size: 24px; background: var(--line-2); }
.photo-prev { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.file-btn { position: relative; }
.file-btn:focus-within { outline: 3px solid var(--sea); outline-offset: 2px; }
.busy { position: relative; opacity: .6; pointer-events: none; }
.busy::after { content: ""; position: absolute; right: 8px; top: 8px; width: 16px; height: 16px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--terra); animation: spin .8s linear infinite; }

/* theme picker */
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-size: 13px; font-weight: 650; color: var(--ink-2); margin-bottom: 8px; padding: 0; }
.theme { display: flex; flex-direction: column; gap: 18px; }
.style-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.style-opt { display: flex; flex-direction: column; gap: 6px; align-items: center; padding: 10px; border: 2px solid var(--line); border-radius: 14px; cursor: pointer; font-size: 13px; font-weight: 650; background: #fff; transition: border-color .15s; }
.style-opt:has(input:checked) { border-color: var(--terra); box-shadow: 0 0 0 3px var(--terra-l); }
.style-opt:has(input:focus-visible) { outline: 3px solid var(--sea); outline-offset: 2px; }
.style-swatch { width: 100%; height: 46px; border-radius: 9px; display: flex; flex-direction: column; gap: 4px; padding: 7px; }
.style-swatch i { display: block; height: 6px; border-radius: 3px; }
.style-swatch i:nth-child(2) { width: 70%; } .style-swatch i:nth-child(3) { width: 45%; }
.s-classic .style-swatch { background: #fffaf3; border: 1px solid var(--line); } .s-classic .style-swatch i { background: #c2410c; } .s-classic .style-swatch i + i { background: #d6d3d1; }
.s-sea .style-swatch { background: #ecfeff; } .s-sea .style-swatch i { background: #0e7490; } .s-sea .style-swatch i + i { background: #a5d8e3; }
.s-dark .style-swatch { background: #1c1917; } .s-dark .style-swatch i { background: #f59e0b; } .s-dark .style-swatch i + i { background: #57534e; }
.s-paper .style-swatch { background: #f5efe3; border: 1px solid #e7dcc6; } .s-paper .style-swatch i { background: #7c2d12; } .s-paper .style-swatch i + i { background: #cfc3ab; }
.accent-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.swatch { width: 34px; height: 34px; border-radius: 50%; background: var(--c); cursor: pointer; position: relative; box-shadow: inset 0 0 0 2px rgba(0,0,0,.08); }
.swatch:has(input:checked), .swatch.custom.on { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); }
.swatch:has(input:focus-visible) { outline: 3px solid var(--sea); outline-offset: 4px; }
.swatch.custom { background: conic-gradient(#ef4444, #f59e0b, #84cc16, #06b6d4, #6366f1, #d946ef, #ef4444); overflow: hidden; }
.color-in { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }

/* ---------- menu: categories & items ---------- */
.menu-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 4px 0; }
.menu-head h2 { font-size: 22px; letter-spacing: -.02em; }
.cats { display: flex; flex-direction: column; gap: 16px; }
.cat { padding: 0; overflow: visible; }
.cat-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 6px; border-bottom: 1px solid var(--line-2); background: linear-gradient(#fffdfa, #fff); border-radius: var(--r) var(--r) 0 0; }
.cat.collapsed .cat-head { border-bottom: 0; border-radius: var(--r); }
.cat-names { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; min-width: 0; }
body.hide-en .cat-names { grid-template-columns: 1fr; }
.cat-names .field > label { display: none; }
.cat-names input { font-weight: 700; font-size: 17px; }
.cat-names .en input { font-weight: 600; font-size: 15px; }
.count { min-width: 28px; height: 24px; padding: 0 8px; border-radius: 99px; background: var(--terra-l); color: var(--terra-d); font-size: 12.5px; font-weight: 800; display: grid; place-items: center; }
.cat-body { padding: 8px 10px 12px; }
.items { display: flex; flex-direction: column; gap: 6px; }
.empty { color: var(--muted); font-size: 14px; padding: 10px 8px; margin: 0; }
p.empty.card { padding: 18px; text-align: center; }
.cat-actions { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.add-cat { width: 100%; min-height: 52px; border: 2px dashed #e2cdb9; background: transparent; color: var(--terra-d); font-size: 15.5px; }
.add-cat:hover { background: var(--terra-l); border-color: var(--terra); }

.handle { width: 30px; height: 36px; flex: none; display: grid; place-items: center; border: 0; background: transparent; color: #a8a29e; border-radius: 8px; cursor: grab; touch-action: none; padding: 0; }
.handle:hover { color: var(--ink-2); background: var(--line-2); }
.handle:active { cursor: grabbing; }

.item { border: 1px solid var(--line-2); border-radius: 12px; background: #fff; transition: box-shadow .15s, border-color .15s; }
.item:hover { border-color: var(--line); }
.item.open { border-color: #e2cdb9; box-shadow: var(--shadow); }
.item.off .item-name-in, .item.off .thumb, .item.off .price-in { opacity: .5; }
.item.off .item-name-in { text-decoration: line-through; text-decoration-color: rgba(0,0,0,.35); }
.item-row { display: grid; grid-template-columns: 30px 44px minmax(0, 1fr) 100px auto 36px; align-items: center; gap: 8px; padding: 6px 6px 6px 2px; }
.thumb { width: 44px; height: 44px; border-radius: 10px; overflow: hidden; border: 0; padding: 0; background: var(--line-2); display: grid; place-items: center; font-size: 18px; cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-main { display: flex; flex-direction: column; min-width: 0; }
.item-name-in { border-color: transparent !important; background: transparent !important; padding: 6px 8px !important; min-height: 36px !important; font-weight: 650; }
.item-name-in:hover { background: var(--field) !important; border-color: var(--line) !important; }
.item-name-in:focus { background: #fff !important; border-color: var(--sea) !important; }
.item-meta { color: var(--muted); font-size: 12px; padding: 0 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1px; }
.item-meta:empty { display: none; }
.price-wrap { position: relative; }
.price-wrap .cur { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }
.price-wrap input { padding-left: 24px !important; text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
.item-detail { padding: 6px 14px 16px 44px; display: flex; flex-direction: column; gap: 14px; border-top: 1px dashed var(--line); }
.variants { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.variant { display: grid; grid-template-columns: 1fr 1fr 110px 36px; gap: 8px; align-items: center; width: 100%; }
body.hide-en .variant { grid-template-columns: 1fr 110px 36px; }
.variant .field > label { display: none; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 2px; padding: 6px 11px; border-radius: 99px; border: 1.5px solid var(--line); background: #fff; font-size: 13.5px; cursor: pointer; user-select: none; transition: background .12s, border-color .12s; }
.chip:hover { border-color: #d6c3b0; }
.chip:has(input:checked) { background: var(--sea-l); border-color: var(--sea); color: var(--sea-d); font-weight: 650; }
.chips:last-of-type .chip:has(input:checked) { background: var(--terra-l); border-color: var(--terra); color: var(--terra-d); }
.chip:has(input:focus-visible) { outline: 3px solid var(--sea); outline-offset: 2px; }
.item-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.move-to { margin-right: auto; display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); }
.move-to select { width: auto; min-height: 34px; padding-top: 4px; padding-bottom: 4px; font-size: 14px; }

.quick-add { display: grid; grid-template-columns: 22px minmax(0, 1fr) 100px auto; gap: 8px; align-items: center; margin-top: 8px; padding: 8px; border-radius: 12px; background: var(--bg); border: 1.5px dashed var(--line); }
.quick-add:focus-within { border-color: var(--sea); border-style: solid; background: #fff; }
.qa-plus { color: var(--terra); font-weight: 800; text-align: center; }
.qa-hint { grid-column: 2 / -1; display: none; }
.quick-add:focus-within .qa-hint { display: block; }

/* drag */
.dragging { box-shadow: var(--shadow-l) !important; transform: rotate(.6deg) scale(1.01); opacity: .96; background: #fff; }
.drop-ph { border: 2px dashed var(--terra); border-radius: 12px; background: var(--terra-l); opacity: .7; }

/* meter & danger */
.meter { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.meter h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.meter-row { display: grid; grid-template-columns: 90px 1fr 110px; gap: 10px; align-items: center; font-size: 13px; }
.meter-bar { height: 8px; border-radius: 9px; background: var(--line-2); overflow: hidden; }
.meter-bar i { display: block; height: 100%; background: var(--sea); border-radius: 9px; transition: width .3s; }
.meter-row.warn .meter-bar i { background: #f59e0b; }
.meter-row.over .meter-bar i { background: var(--err); }
.meter-val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.danger { padding: 14px 18px; box-shadow: none; background: transparent; border-style: dashed; }
.danger summary { cursor: pointer; color: var(--muted); font-weight: 650; }
.danger[open] summary { margin-bottom: 8px; }

/* ---------- dialog ---------- */
.dlg { border: 0; padding: 0; border-radius: 22px; width: min(540px, calc(100vw - 24px)); max-height: calc(100vh - 40px); background: var(--card); color: var(--ink); box-shadow: var(--shadow-l); }
.dlg.wide { width: min(780px, calc(100vw - 24px)); }
.dlg.small { width: min(420px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(28, 25, 23, .5); backdrop-filter: blur(3px); }
.dlg[open] { display: flex; flex-direction: column; animation: pop .18s ease-out; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 6px; }
.dlg-head h2 { font-size: 20px; letter-spacing: -.01em; }
.dlg-body { padding: 8px 20px 16px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.dlg-body p { margin: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; border-top: 1px solid var(--line-2); }
.err-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.bulk-ex { margin: 0; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; white-space: pre-wrap; color: var(--ink-2); }
.bulk-ta { min-height: 180px; font-family: ui-monospace, Consolas, monospace; font-size: 14px; }
.bulk-into { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.bulk-into select { width: auto; flex: 1; max-width: 320px; }
.bulk-preview { font-size: 14px; }
.bulk-preview ul { margin: 6px 0 0; padding-left: 20px; color: var(--ink-2); }

/* share panel */
.share .lead { margin: 0; font-size: 15.5px; text-align: left; max-width: none; }
.share-grid { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; align-items: start; }
.qr-box { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 10px; box-shadow: var(--shadow); }
.qr-box svg { display: block; width: 100%; height: auto; }
.share-main { display: flex; flex-direction: column; gap: 10px; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row input { flex: 1; min-width: 0; }
.qr-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.key-box { border: 2px solid var(--terra); background: #fff7ed; border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.key-warn { color: var(--terra-d); font-size: 17px; }
.key-box p { color: #7c2d12; font-size: 14px; }

/* toasts */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 2000; width: max-content; max-width: calc(100vw - 24px); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 14px; padding: 11px 14px 11px 16px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 14.5px; box-shadow: var(--shadow-l); animation: pop .2s ease-out; transition: opacity .35s, transform .35s; }
.toast.err { background: #7f1d1d; }
.toast.ok { background: #14532d; }
.toast.out { opacity: 0; transform: translateY(6px); }
.toast-act { border: 0; background: rgba(255,255,255,.16); color: #fff; font: inherit; font-weight: 700; padding: 5px 10px; border-radius: 8px; cursor: pointer; }
.toast-act:hover { background: rgba(255,255,255,.28); }

.mobile-tabs { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1060px) {
  .editor { grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; padding: 18px 16px 90px; }
  .phone, .preview-bar { width: 340px; }
}
@media (max-width: 860px) {
  :root { --top: 56px; }
  .topbar { padding: 0 10px; gap: 8px; }
  .brand span { display: none; }
  .editor { display: block; padding: 12px 12px 96px; }
  .pane-preview { display: none; position: static; }
  body.show-preview .pane-form { display: none; }
  body.show-preview .pane-preview { display: flex; }
  .phone { width: 100%; max-width: 420px; height: calc(100vh - var(--top) - 150px); height: calc(100dvh - var(--top) - 150px); border-radius: 30px; padding: 8px; }
  .phone-screen { border-radius: 24px; }
  .phone-notch { display: none; }
  .preview-bar { width: 100%; max-width: 420px; }
  .mobile-tabs {
    display: grid; grid-template-columns: 1fr 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-tabs button { border: 0; background: transparent; font: inherit; font-weight: 700; font-size: 14px; padding: 10px; border-radius: 12px; color: var(--muted); cursor: pointer; }
  .mobile-tabs button[aria-selected=true] { background: var(--terra-l); color: var(--terra-d); }
  .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .tpl-grid { grid-template-columns: 1fr 1fr; }
  .dlg { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 22px 22px 0 0; }
  .dlg.wide, .dlg.small { width: 100vw; }
  .share-grid { grid-template-columns: 1fr; }
  .qr-box { width: 220px; margin: 0 auto; }
}
@media (max-width: 560px) {
  .pair, .row { grid-template-columns: 1fr; }
  .cat-names { grid-template-columns: 1fr; gap: 4px; }
  .cat-names .en input { min-height: 36px; padding-top: 6px; padding-bottom: 6px; }
  .sec-body { padding: 2px 14px 16px; }
  .cat-body { padding: 6px 6px 10px; }
  .item-row { grid-template-columns: 26px minmax(0, 1fr) 84px auto 32px; gap: 4px; }
  .item-row .thumb { display: none; }
  .handle { width: 26px; }
  .icon-btn { width: 32px; }
  .item-detail { padding: 6px 10px 14px; }
  .variant { grid-template-columns: 1fr 96px 32px; }
  .variant .field.en { grid-column: 1 / -1; grid-row: 2; }
  .quick-add { grid-template-columns: minmax(0, 1fr) 84px auto; }
  .qa-plus { display: none; }
  .qa-hint { grid-column: 1 / -1; }
  .style-grid { grid-template-columns: 1fr 1fr; }
  .meter-row { grid-template-columns: 78px 1fr 96px; }
  .top-actions .btn { padding: 6px 12px; min-height: 38px; }
  #btn-share { display: none; }
  .screen-start { padding-top: 22px; }
  .copy-row { flex-wrap: wrap; }
  .copy-row input { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
