:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #e3e6ea;
  --text: #1d1d1f;
  --muted: #6b7280;
  --accent: #e30613;
  --accent-ink: #ffffff;
  --sel: #1e88e5;
  --err: #c62828;
  --warn: #b26a00;
  --ok: #2e7d32;
  --radius: 10px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--sel) 35%, transparent); border-color: var(--sel); }
textarea { resize: vertical; }
label { display: block; font-size: 12px; color: var(--muted); }
label input, label select { margin-top: 4px; color: var(--text); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 12px; font: inherit; cursor: pointer; color: var(--text); text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #c7ccd3; background: #fafbfc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.small { padding: 5px 9px; font-size: 13px; }
.btn:disabled, .btn.disabled { opacity: .5; pointer-events: none; }

/* Вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); padding: 28px; border-radius: 14px; width: min(360px, 100%); box-shadow: 0 10px 30px rgba(0,0,0,.08); display: grid; gap: 12px; }
.login-card p { margin: 0; color: var(--muted); }
.login-err { color: var(--err); min-height: 1em; }

/* Шапка */
.top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; font-size: 16px; margin-right: 6px; }
.logo-dot { width: 18px; height: 18px; border-radius: 5px; background: var(--accent); display: inline-block; }
#projectSelect { width: 240px; }
.meta { display: flex; gap: 8px; flex: 1; min-width: 280px; }
.meta input { max-width: 220px; }
.meta .short { max-width: 120px; }
.save-state { color: var(--muted); font-size: 12px; min-width: 90px; text-align: right; }

/* Сетка */
.grid { display: grid; grid-template-columns: 300px minmax(0, 1fr) 360px; gap: 14px; padding: 14px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 14px; position: sticky; top: 70px; max-height: calc(100vh - 84px); overflow: auto; }
.panel section { padding: 12px 0; border-bottom: 1px solid var(--line); }
.panel section:last-child { border-bottom: 0; }
.row { display: flex; gap: 8px; margin-top: 8px; align-items: end; }
.row > label { flex: 1; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; line-height: 1.4; }

.cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.cat { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.cat.active { background: var(--text); color: #fff; border-color: var(--text); }
.products { display: grid; gap: 4px; }
.product { text-align: left; border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 7px 9px; cursor: pointer; font: inherit; }
.product:hover { background: var(--bg); }
.product.active { border-color: var(--sel); background: color-mix(in srgb, var(--sel) 8%, #fff); font-weight: 600; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 1px solid #cfd4da; cursor: pointer; position: relative; }
.swatch.active { outline: 2px solid var(--sel); outline-offset: 2px; }
.swatch-label { font-size: 12px; color: var(--muted); margin-top: 6px; }
.check { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.check input { width: auto; margin: 0; }
.bg-row input[type=color] { width: 44px; height: 32px; padding: 2px; }
.notes-label { margin-top: 10px; }

/* Сцена */
.stage { min-width: 0; }
.tabs { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 14px; cursor: pointer; font: inherit; }
.tab.active { background: var(--text); color: #fff; border-color: var(--text); }
.legend { margin-left: auto; display: flex; gap: 12px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 16px; height: 0; border-top: 2px dashed; vertical-align: middle; margin-right: 5px; }
.l-area { color: #1e88e5; } .l-cut { color: #ec008c; border-top-style: solid !important; } .l-safe { color: #43a047; } .l-bleed { color: #e53935; }

.canvas { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-height: 480px; display: grid; place-items: center; position: relative; overflow: hidden;
  background-image: linear-gradient(45deg, #f6f7f9 25%, transparent 25%), linear-gradient(-45deg, #f6f7f9 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #f6f7f9 75%), linear-gradient(-45deg, transparent 75%, #f6f7f9 75%);
  background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0; }
.view { width: 100%; padding: 20px; display: grid; place-items: center; }
.view svg { width: 100%; height: auto; max-height: calc(100vh - 260px); display: block; }
#editorView svg [data-el] { cursor: move; }
#editorView svg .sel-box { pointer-events: none; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; text-align: center; padding: 20px; }
.empty p { background: rgba(255,255,255,.9); padding: 10px 14px; border-radius: 8px; }
.canvas.busy::after { content: "Помощник собирает макет…"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,255,255,.7); font-weight: 600; }

.issues { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.issues li { padding: 8px 12px; border-radius: 8px; background: #fff; border: 1px solid var(--line); border-left-width: 4px; font-size: 13px; }
.issues li.error { border-left-color: var(--err); }
.issues li.warning { border-left-color: var(--warn); }
.issues li.info { border-left-color: #90a4ae; color: var(--muted); }
.issues li[data-el] { cursor: pointer; }

/* Логотипы */
.drop { display: grid; gap: 4px; place-items: center; text-align: center; border: 1.5px dashed #c7ccd3; border-radius: 10px; padding: 16px; cursor: pointer; color: var(--text); font-size: 13px; }
.drop small { color: var(--muted); }
.drop.over { border-color: var(--sel); background: color-mix(in srgb, var(--sel) 6%, #fff); }
.assets { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 8px; }
.asset { display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.asset img { width: 56px; height: 56px; object-fit: contain; background: #f2f3f5; border-radius: 6px; }
.asset .name { font-size: 13px; font-weight: 600; word-break: break-all; }
.asset .sub { font-size: 12px; color: var(--muted); }
.asset .acts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.asset .acts .btn { padding: 3px 7px; font-size: 12px; }
.vec-n { width: auto; padding: 2px 4px; font-size: 12px; }
.btn.confirm { border-color: var(--err); color: var(--err); }
.dots { display: inline-flex; gap: 3px; vertical-align: middle; margin-left: 4px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; border: 1px solid #0002; display: inline-block; }

/* Свойства элемента */
#elFields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#elFields .full { grid-column: 1 / -1; }
#elFields .btns { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }

/* ИИ */
.badge { font-size: 11px; text-transform: none; letter-spacing: 0; background: var(--bg); padding: 2px 6px; border-radius: 6px; font-weight: 500; }
.chat { display: grid; gap: 8px; max-height: 300px; overflow: auto; margin-bottom: 8px; }
.msg { padding: 8px 10px; border-radius: 10px; font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.msg.manager { background: var(--bg); justify-self: end; max-width: 90%; }
.msg.assistant { background: color-mix(in srgb, var(--sel) 7%, #fff); border: 1px solid color-mix(in srgb, var(--sel) 20%, #fff); }
.ai-form { display: grid; gap: 8px; }

.exports { display: grid; gap: 8px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 20; max-width: min(560px, calc(100% - 32px)); }
.toast.error { background: var(--err); }

@media (max-width: 1200px) {
  .grid { grid-template-columns: 280px minmax(0, 1fr); }
  .panel.left { position: static; max-height: none; }
  .panel.right { grid-column: 1 / -1; position: static; max-height: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 18px; }
}
@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; padding: 10px 16px; }
  .panel { position: static; max-height: none; }
  .meta { flex-wrap: wrap; }
  .meta input { max-width: none; }
  #projectSelect { width: 100%; }
  .stage { order: -1; }
}
