﻿:root {
  --bg: #f3f2ee; --panel: #ffffff; --ink: #1c1b19; --mute: #6f6c66; --line: #dedbd3;
  --acc: #b3261e; --acc-ink: #fff; --sel: #0a6cff; --ok: #1b7f3b; --warn: #b26a00; --bad: #b3261e;
  --r: 10px; --bar: 48px; --tap: 40px;
  font: 13px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (pointer: coarse) { :root { --tap: 44px; } }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
body { overscroll-behavior: none; }
h1 { font-size: 20px; margin: 0 0 4px; } h2 { font-size: 15px; margin: 0 0 8px; } h3 { font-size: 12px; margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .04em; color: var(--mute); }
p { margin: 0 0 8px; } a { color: inherit; }
.mute { color: var(--mute); } .small { font-size: 12px; } .grow { flex: 1; min-width: 0; } .row { display: flex; gap: 8px; align-items: center; } .wrap { flex-wrap: wrap; }
.hide { display: none !important; }

button, .btn {
  font: inherit; min-height: var(--tap); padding: 0 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; white-space: nowrap; touch-action: manipulation; user-select: none;
}
button:hover { border-color: #b9b5ab; } button:disabled { opacity: .5; cursor: default; }
button.pri, .btn.pri { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); font-weight: 600; }
button.ghost { border-color: transparent; background: transparent; }
button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
button.danger { color: var(--bad); }
button.ico { width: var(--tap); padding: 0; font-size: 17px; }
input, select, textarea {
  font: inherit; color: inherit; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  min-height: 36px; padding: 6px 8px; width: 100%; min-width: 0;
}
textarea { resize: vertical; line-height: 1.4; }
/* 16px on touch screens stops iOS from zooming the page when a field gets focus */
@media (pointer: coarse) { input, select, textarea { font-size: 16px; min-height: 40px; } }
input[type=checkbox] { width: 18px; min-height: 18px; height: 18px; padding: 0; }
input[type=color] { padding: 2px; width: 44px; }
input[type=range] { padding: 0; border: 0; background: none; }
label.f { display: block; font-size: 11px; color: var(--mute); margin-bottom: 8px; }
label.f > span { display: block; margin-bottom: 3px; }
label.c { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 6px; }

/* ---------- auth ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.auth form { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.logo { font: 700 22px/1 Georgia, serif; letter-spacing: -.02em; } .logo b { color: var(--acc); }
.err { color: var(--bad); margin: 8px 0; min-height: 18px; }

/* ---------- dashboard ---------- */
.top { position: sticky; top: 0; z-index: 5; background: var(--panel); border-bottom: 1px solid var(--line); }
.top .in { max-width: 1180px; margin: 0 auto; padding: 0 12px; height: var(--bar); display: flex; align-items: center; gap: 12px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 0 12px; height: var(--bar); display: flex; align-items: center; text-decoration: none; color: var(--mute); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-color: var(--acc); font-weight: 600; }
main.dash { max-width: 1180px; margin: 0 auto; padding: 16px 12px 80px; }
.head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; cursor: pointer; position: relative; }
.card:hover { border-color: #b9b5ab; }
.card .th { aspect-ratio: 297 / 400; background: #e9e7e1 center top / cover no-repeat; border-bottom: 1px solid var(--line); display: grid; place-items: center; color: var(--mute); }
.card .bd { padding: 8px 10px; } .card .bd b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .more { position: absolute; top: 4px; right: 4px; background: rgba(255,255,255,.92); width: 34px; min-height: 34px; }
.card.sel { outline: 2px solid var(--sel); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: #eceae4; color: var(--mute); margin: 2px 2px 0 0; }
.tag.ok { background: #e2f3e7; color: var(--ok); } .tag.bad { background: #fbe6e4; color: var(--bad); } .tag.warn { background: #fdf0d8; color: var(--warn); }
.empty { border: 1px dashed #c8c4ba; border-radius: var(--r); padding: 28px 16px; text-align: center; color: var(--mute); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; border-radius: 0; min-height: 34px; } .seg button.on { background: var(--ink); color: #fff; }
table.t { width: 100%; border-collapse: collapse; } table.t td, table.t th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: #bbb; } .dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }

/* ---------- dialogs / sheets ---------- */
.veil { position: fixed; inset: 0; background: rgba(20,18,15,.45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 12px; }
.dlg { background: var(--panel); border-radius: 14px; width: min(520px, 100%); max-height: 92dvh; overflow: auto; padding: 16px; }
.dlg.wide { width: min(860px, 100%); }
.dlg .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
@media (max-width: 640px) {
  .veil { align-items: flex-end; padding: 0; }
  .dlg { width: 100%; border-radius: 16px 16px 0 0; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
}
.menu { position: fixed; z-index: 60; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.18); padding: 4px; min-width: 190px; }
.menu button { width: 100%; justify-content: flex-start; border: 0; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 99px; z-index: 90; max-width: 92vw; text-align: center; }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .7s linear infinite; display: inline-block; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- editor ---------- */
.ed { position: fixed; inset: 0; display: grid; grid-template-rows: var(--bar) 1fr; grid-template-columns: 1fr 330px; background: #d9d6ce; }
.ed-top { grid-column: 1 / -1; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 4px; padding: 0 6px; min-width: 0; }
.ed-top .ttl { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 40px; }
.ed-top .st { font-size: 11px; color: var(--mute); white-space: nowrap; }
.pgnav { display: flex; align-items: center; gap: 0; } .pgnav button.n { min-width: 62px; }
.stage { position: relative; overflow: auto; touch-action: pan-x pan-y; overscroll-behavior: contain; }
.stage-in { margin: 0 auto; padding: 20px 20px 110px; width: max-content; min-width: 100%; display: flex; justify-content: center; }
.scaler { position: relative; flex: none; } .scaler > .pg { transform-origin: 0 0; box-shadow: 0 2px 18px rgba(0,0,0,.28); position: absolute; left: 0; top: 0; }

.ed .blk { cursor: pointer; }
.ed .blk::after { content: ''; position: absolute; inset: 0; outline: calc(1px / var(--z)) dashed rgba(10,108,255,.45); pointer-events: none; }
.ed .blk.is-sample .blk-t { color: #a9a59c !important; }
.ed .blk.is-empty { background: repeating-linear-gradient(45deg, #ecebe7 0 3mm, #e1dfd9 3mm 6mm); }
.ed .blk.is-empty::before { content: 'ФОТО'; position: absolute; inset: 0; display: grid; place-items: center; font: 600 10pt system-ui; color: #99958b; }
.ed.trace .blk.is-sample .blk-t { visibility: hidden; }
.ed.trace .blk-shape { opacity: .28; }
.ed.trace .blk.is-empty { background: rgba(10,108,255,.10); } .ed.trace .blk.is-empty::before { content: ''; }
.ed.trace .blk::after { outline-style: solid; outline-color: rgba(10,108,255,.8); }
.ed .blk.over::after { outline: calc(2px / var(--z)) solid var(--bad); }
.ed .blk.sel::after { outline: calc(2px / var(--z)) solid var(--sel); }
.ed .blk.sel { touch-action: none; cursor: move; z-index: 3; }
.ed .blk .ovf { position: absolute; right: 0; bottom: 0; transform: scale(calc(1 / var(--z))); transform-origin: 100% 100%; background: var(--bad); color: #fff; font: 600 11px system-ui; padding: 2px 6px; border-radius: 6px 0 0 0; pointer-events: none; z-index: 2; }
.ed .blk .lbl { position: absolute; left: 0; top: 0; transform: scale(calc(1 / var(--z))); transform-origin: 0 0; background: rgba(10,108,255,.88); color: #fff; font: 600 10px system-ui; padding: 1px 5px; border-radius: 0 0 6px 0; pointer-events: none; white-space: nowrap; z-index: 2; }
.hnd { position: absolute; width: var(--hs); height: var(--hs); margin: calc(var(--hs) / -2); background: #fff; border: calc(2px / var(--z)) solid var(--sel); border-radius: 50%; z-index: 6; touch-action: none; --hs: calc(12px / var(--z)); }
@media (pointer: coarse) { .hnd { --hs: calc(22px / var(--z)); } }
.hnd[data-h=nw] { left: 0; top: 0; cursor: nwse-resize; } .hnd[data-h=ne] { left: 100%; top: 0; cursor: nesw-resize; }
.hnd[data-h=sw] { left: 0; top: 100%; cursor: nesw-resize; } .hnd[data-h=se] { left: 100%; top: 100%; cursor: nwse-resize; }
.hnd[data-h=n] { left: 50%; top: 0; cursor: ns-resize; } .hnd[data-h=s] { left: 50%; top: 100%; cursor: ns-resize; }
.hnd[data-h=w] { left: 0; top: 50%; cursor: ew-resize; } .hnd[data-h=e] { left: 100%; top: 50%; cursor: ew-resize; }
.guide { position: absolute; background: #ff2d8a; z-index: 7; pointer-events: none; }

/* notes layer (pins, ink) */
.ink { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 8; pointer-events: none; }
.ed.tool-draw .ink, .ed.tool-note .ink, .ed.tool-erase .ink { pointer-events: auto; touch-action: none; cursor: crosshair; }
.pin { position: absolute; z-index: 9; width: 30px; height: 30px; margin: -15px; transform: scale(calc(1 / var(--z))); border-radius: 50%; background: var(--acc); color: #fff; font: 700 13px system-ui; display: grid; place-items: center; box-shadow: 0 1px 6px rgba(0,0,0,.4); cursor: pointer; border: 2px solid #fff; }

/* floating toolbar */
.tools { position: fixed; z-index: 20; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.22); display: flex; gap: 2px; padding: 4px; max-width: calc(100vw - 12px); overflow-x: auto; scrollbar-width: none; }
.tools button { border: 0; flex-direction: column; gap: 1px; min-width: 52px; padding: 2px 6px; font-size: 10px; line-height: 1.1; min-height: 46px; }
.tools button .i { font-size: 18px; line-height: 1; } .tools .sep { width: 1px; background: var(--line); margin: 6px 2px; flex: none; }

/* inspector */
.side { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-h { display: flex; align-items: center; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.side-h .tabs2 { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.side-h .tabs2 button { border: 0; min-height: 34px; padding: 0 9px; } .side-h .tabs2 button.on { background: #eceae4; color: var(--ink); font-weight: 600; }
.side-b { overflow: auto; padding: 10px; flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; }
.side .x { display: none; }
.cnt { font-size: 11px; color: var(--mute); } .cnt.bad { color: var(--bad); font-weight: 600; }
.chat { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.msg { padding: 7px 10px; border-radius: 12px; max-width: 92%; white-space: pre-wrap; } .msg.u { background: #e8eefc; align-self: flex-end; } .msg.a { background: #f1efe9; align-self: flex-start; }
.note-i { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; display: flex; gap: 8px; align-items: flex-start; }
.note-i .n { background: var(--acc); color: #fff; border-radius: 50%; width: 20px; height: 20px; flex: none; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.plist { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.plist .p { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; cursor: pointer; background: #fff; text-align: center; font-size: 11px; }
.plist .p.on { outline: 2px solid var(--sel); } .plist .p .th { aspect-ratio: 297/400; background: #eee center top / cover; display: grid; place-items: center; font-size: 20px; color: #aaa; }
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; } .lib img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; cursor: pointer; border: 1px solid var(--line); }

@media (max-width: 640px) {
  .head { align-items: stretch; } .head > .grow { flex: 1 1 100%; }
  .seg { max-width: 100%; overflow-x: auto; }
  .head > button { flex: 1; }
  .tools button { min-width: 45px; padding: 2px 3px; font-size: 9.5px; }
  .ed-top { gap: 0; } .ed-top .st { display: none; }
}
@media (max-width: 860px) {
  .ed { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: min(52dvh, 460px); border: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.25); transform: translateY(105%); transition: transform .18s ease; padding-bottom: env(safe-area-inset-bottom); }
  .ed.sheet .side { transform: none; }
  .ed.sheet .tools { display: none; }
  .ed.sheet .stage-in { padding-bottom: 56dvh; }
  .side .x { display: inline-flex; }
  .ed-top .hide-m { display: none; }
}

.foot-note { max-width: 1180px; margin: 0 auto; padding: 14px 12px 28px; font-size: 12px; color: var(--mute); }
.foot-note a { color: var(--acc); }
a.btn { display: inline-flex; }
