:root {
  --bg: #08090a;
  --panel: rgba(255,255,255,.035);
  --panel-strong: rgba(255,255,255,.055);
  --text: #f7f8f8;
  --muted: #8a8f98;
  --soft: #d0d6e0;
  --line: rgba(255,255,255,.08);
  --line-soft: rgba(255,255,255,.05);
  --accent: #7170ff;
  --accent-2: #5e6ad2;
  --green: #00ff00;
  --radius: 22px;
  --bar-h: 78px;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  padding: 0 0 calc(var(--bar-h) + env(safe-area-inset-bottom));
  color: var(--text);
  background:
    radial-gradient(circle at 16% -10%, rgba(113,112,255,.18), transparent 34rem),
    radial-gradient(circle at 95% 10%, rgba(0,255,0,.08), transparent 26rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "cv01", "ss03";
}
.shell { width: min(1480px, calc(100% - 28px)); margin: 0 auto; padding: 18px 0 24px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark { width: 46px; height: 46px; border-radius: 15px; background: radial-gradient(circle, transparent 45%, var(--green) 46% 54%, transparent 55%), linear-gradient(135deg, var(--accent), #22243f); border: 1px solid var(--line); box-shadow: 0 0 40px rgba(113,112,255,.25); flex: 0 0 auto; }
.eyebrow, .label { margin: 0 0 4px; color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; font-weight: 600; }
h1 { margin: 0; font-size: clamp(24px, 4vw, 44px); line-height: 1; letter-spacing: -0.045em; font-weight: 590; }
h2 { margin: 0; font-size: 18px; letter-spacing: -0.02em; font-weight: 590; }
.hidden { display: none !important; }
.button { appearance: none; border: 1px solid var(--line); border-radius: 12px; min-height: 44px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: var(--soft); background: rgba(255,255,255,.035); font-weight: 610; text-decoration: none; cursor: pointer; user-select: none; white-space: nowrap; }
.button input { display: none; }
.button:disabled { opacity: .38; cursor: not-allowed; }
.button:not(:disabled):active { transform: translateY(1px); }
.primary { color: #fff; background: linear-gradient(135deg, var(--accent-2), var(--accent)); border-color: rgba(130,143,255,.5); box-shadow: 0 12px 36px rgba(94,106,210,.28); }
.ghost { background: rgba(255,255,255,.035); }
.inline-upload { margin-top: 12px; }
.workflow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 14px; }
.step { min-width: 0; display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line-soft); border-radius: 16px; background: rgba(255,255,255,.025); color: var(--muted); }
.step span { grid-row: span 2; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); color: var(--soft); font-weight: 700; }
.step b { color: var(--soft); font-size: 14px; }
.step small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step.active { border-color: rgba(113,112,255,.45); background: rgba(113,112,255,.09); }
.step.done span { background: rgba(0,255,0,.16); border-color: rgba(0,255,0,.4); color: #b6ffb6; }
.main-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
.card { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 24px 90px rgba(0,0,0,.28); backdrop-filter: blur(18px); }
.editor-panel { padding: 14px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 4px 4px 12px; }
.card-head.compact { padding: 16px 16px 12px; align-items: center; }
.badge { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border: 1px solid rgba(113,112,255,.35); border-radius: 999px; color: #dfe1ff; background: rgba(113,112,255,.12); font-size: 12px; font-weight: 650; }
.badge.muted { border-color: var(--line); color: var(--muted); background: rgba(255,255,255,.025); }
.stage { position: relative; height: min(68vh, 820px); min-height: 540px; border-radius: 18px; overflow: hidden; background: #050608; border: 1px solid var(--line-soft); touch-action: none; }
#editorCanvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#editorCanvas.dragging { cursor: grabbing; }
.stage.locked #editorCanvas, .stage.busy #editorCanvas { cursor: not-allowed; filter: saturate(.75) brightness(.82); }
.stage.locked::after { content: 'Заблокировано: AI результат уже подтверждён'; position: absolute; left: 14px; right: 14px; bottom: 14px; padding: 12px 14px; border-radius: 14px; border: 1px solid rgba(113,112,255,.35); background: rgba(8,9,10,.82); color: var(--soft); font-size: 13px; pointer-events: none; }
.progress-overlay { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; background: rgba(5,6,8,.72); backdrop-filter: blur(8px); pointer-events: all; }
.progress-card { width: min(360px, calc(100% - 34px)); display: grid; justify-items: center; gap: 12px; padding: 22px; border: 1px solid rgba(113,112,255,.38); border-radius: 20px; background: rgba(15,16,17,.92); box-shadow: 0 24px 80px rgba(0,0,0,.45); text-align: center; }
.progress-card strong { font-size: 18px; }
.progress-card span { color: var(--muted); font-size: 13px; line-height: 1.4; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid rgba(255,255,255,.14); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.progress-track { width: 100%; height: 8px; border-radius: 999px; overflow: hidden; background: rgba(255,255,255,.08); }
.progress-fill { width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-2), var(--accent), #00ff88); transition: width .45s ease; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; gap: 7px; padding: 28px; color: var(--muted); pointer-events: none; }
.empty-state .button { pointer-events: auto; }
.empty-icon { font-size: 62px; line-height: 1; color: var(--accent); opacity: .9; }
.empty-state strong { color: var(--text); font-size: 24px; }
.empty-state span { max-width: 360px; line-height: 1.45; }
.notice { margin-top: 12px; display: grid; gap: 4px; padding: 12px 14px; border: 1px solid rgba(113,112,255,.35); border-radius: 14px; background: rgba(113,112,255,.1); color: var(--soft); font-size: 14px; }
.notice span { color: var(--muted); line-height: 1.4; }
.controls-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.control-row { display: grid; gap: 8px; padding: 11px 12px; border: 1px solid var(--line-soft); border-radius: 14px; background: rgba(255,255,255,.025); color: var(--muted); font-size: 12px; font-weight: 650; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.side-stack { display: grid; gap: 14px; }
.preview-canvas { display: block; width: 100%; aspect-ratio: 1 / 1; background: #111318; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.green-preview { background: var(--green); }
.ai-preview { background: radial-gradient(circle at 50% 50%, rgba(113,112,255,.14), transparent 45%), #111318; }
.hint { margin: 12px 16px 16px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.action-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; min-height: var(--bar-h); display: grid; grid-template-columns: .7fr 1fr 1.1fr 1fr; gap: 10px; padding: 10px max(12px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-right)); background: linear-gradient(180deg, rgba(8,9,10,0), rgba(8,9,10,.92) 22%, rgba(8,9,10,.98)); border-top: 1px solid var(--line-soft); }
.action-bar .button { min-height: 54px; font-size: clamp(12px, 3vw, 15px); padding-left: 8px; padding-right: 8px; }
@media (max-width: 1100px) { .main-grid { grid-template-columns: 1fr; } .side-stack { grid-template-columns: 1fr 1fr; } .stage { height: 62vh; } }
@media (max-width: 720px) {
  .shell { width: min(100% - 20px, 1480px); padding-top: 10px; }
  .upload-top { display: none; }
  .workflow { grid-template-columns: 1fr; }
  .main-grid, .side-stack, .controls-grid { grid-template-columns: 1fr; }
  .stage { min-height: calc(100vw - 20px); height: calc(100vw - 20px); }
  .card-head { align-items: flex-start; }
  .action-bar { grid-template-columns: repeat(4, 1fr); gap: 6px; }
}
