/* Detailing Masks Studio — оформление */

:root {
  color-scheme: dark;
  --bg:        #0e1116;
  --bg-2:      #151a21;
  --panel:     #171d26;
  --line:      #232c38;
  --line-soft: #1c2531;
  --text:      #e6ecf3;
  --muted:     #8b98a9;
  --accent:    #de205e;
  --accent-2:  #ff5c8a;
  --ok:        #35c48c;
  --warn:      #e5a13c;
  --err:       #ef5a5a;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 10px 30px rgba(0,0,0,.35);
  --font:      "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg:        #f4f6f9;
  --bg-2:      #ffffff;
  --panel:     #ffffff;
  --line:      #dfe5ec;
  --line-soft: #eaeff5;
  --text:      #16202c;
  --muted:     #64748b;
  --shadow:    0 8px 24px rgba(16,32,52,.10);
}

* { box-sizing: border-box; }

/* элементы ниже задают display, который иначе перебивает атрибут hidden */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ───────────────────────────── верхняя панель ───────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  height: 56px;
  flex: 0 0 auto;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 1px rgba(255,255,255,.08) inset;
}

.brand-text { font-size: 15px; letter-spacing: .2px; }
.brand-text b { font-weight: 700; }

.project { display: flex; align-items: baseline; gap: 10px; min-width: 0; }

.proj-name {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 5px 9px;
  width: 26ch;
  max-width: 40vw;
}
.proj-name:hover  { border-color: var(--line); }
.proj-name:focus  { outline: none; border-color: var(--accent); background: var(--bg); }

.slug { color: var(--muted); font-size: 12px; font-family: ui-monospace, monospace; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.engine {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.engine[data-ai="1"], .engine[data-ready="1"] { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.engine[data-ready="0"] { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }

/* ──────────────────────────────── кнопки ────────────────────────────────── */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .06s;
  white-space: nowrap;
}
.btn:hover  { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn.primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.07); }

.btn.ghost  { background: transparent; }
.btn.sm     { padding: 6px 11px; font-size: 13px; }
.btn.tiny   { padding: 4px 10px; font-size: 12px; }
.btn.lg     { padding: 11px 22px; font-size: 15px; }
.btn.icon   { padding: 8px 11px; }
.btn.danger:hover { border-color: var(--err); color: var(--err); }
.btn.file   { position: relative; display: inline-flex; align-items: center; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* ─────────────────────────────── стартовый ──────────────────────────────── */

.start {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
}

.start-inner { max-width: 560px; width: 100%; }

.start h1 {
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.2;
  margin: 0 0 12px;
  letter-spacing: -.02em;
}

.lead { color: var(--muted); margin: 0 0 28px; font-size: 15px; }

.start-form {
  display: grid;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.start-form label { font-size: 13px; color: var(--muted); }
.start-form input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  padding: 11px 13px;
}
.start-form input:focus { outline: none; border-color: var(--accent); }

.start-notes {
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
  display: grid;
  gap: 7px;
}
.start-notes li { padding-left: 20px; position: relative; }
.start-notes li::before {
  content: "";
  position: absolute; left: 4px; top: 9px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
}

/* ─────────────────────────────── рабочая зона ───────────────────────────── */

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 264px minmax(0,1fr) 232px;
  gap: 1px;
  background: var(--line);
}

.panel {
  background: var(--panel);
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 0;
  font-weight: 600;
}

.views { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.view-tab {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.view-tab.is-active {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--text);
}

.upload-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.hint { font-size: 11px; color: var(--muted); }

.part-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }

.part {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  font-size: 13px;
}
.part:hover { background: var(--line-soft); }
.part.is-active {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
}
.part .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--line);
  flex: 0 0 auto;
}
.part.done .dot { background: var(--ok); }
.part .slug { margin-left: auto; font-size: 10px; opacity: .55; }

/* ──────────────────────────────── холст ─────────────────────────────────── */

.stage {
  position: relative;
  background:
    linear-gradient(45deg, var(--line-soft) 25%, transparent 25%) 0 0/22px 22px,
    linear-gradient(-45deg, var(--line-soft) 25%, transparent 25%) 0 11px/22px 22px,
    var(--bg);
  overflow: hidden;
  display: grid;
  place-items: center;
}

#canvas { display: block; max-width: 100%; max-height: 100%; cursor: crosshair; touch-action: none; }
#canvas.pan { cursor: grab; }
#canvas.hidden { display: none; }

.stage-empty {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: 14px;
  color: var(--muted);
  border: 2px dashed var(--line);
  margin: 24px;
  border-radius: var(--radius);
  pointer-events: auto;
}
.stage.dragover .stage-empty { border-color: var(--accent); color: var(--text); }

.stage-badge {
  position: absolute;
  bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 8px 7px 16px;
  box-shadow: var(--shadow);
  font-size: 13px;
}

/* ──────────────────────────── правая панель ─────────────────────────────── */

.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.tool {
  display: grid; justify-items: center; gap: 4px;
  padding: 10px 4px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font: inherit; font-size: 12px;
  cursor: pointer;
}
.tool:hover { background: var(--line-soft); }
.tool.is-active {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--text);
}
.tool-ico { font-size: 16px; line-height: 1; }

.field { display: grid; gap: 7px; }
.field label { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }

input[type="range"] { width: 100%; accent-color: var(--accent); }

.toggles { gap: 9px; }
.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.switch input { accent-color: var(--accent); width: 15px; height: 15px; }

.actions { display: grid; gap: 6px; }

.tips { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.tips h3 { font-size: 12px; color: var(--muted); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .06em; }
.tips ol { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12px; display: grid; gap: 5px; }
kbd {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 4px; padding: 0 5px; font-size: 11px; font-family: ui-monospace, monospace;
}

/* ──────────────────────────── модалка и тосты ───────────────────────────── */

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 40; padding: 20px; }
.modal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; max-width: 620px; width: 100%; max-height: 80vh; overflow: auto; box-shadow: var(--shadow);
}
.modal-card h2 { margin: 0 0 14px; font-size: 18px; }
.modal-actions { margin-top: 18px; display: flex; justify-content: flex-end; }

.issue { display: flex; gap: 9px; padding: 8px 0; border-top: 1px solid var(--line-soft); font-size: 13px; }
.issue:first-child { border-top: 0; }
.issue .tag { flex: 0 0 auto; font-size: 11px; padding: 1px 8px; border-radius: 999px; height: fit-content; }
.issue.error .tag { background: color-mix(in srgb, var(--err) 22%, transparent); color: var(--err); }
.issue.warn  .tag { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.issue.ok    .tag { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); }

.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; }
.toast {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 10px 14px; box-shadow: var(--shadow);
  font-size: 13px; max-width: 340px; animation: slide .2s ease-out;
}
.toast.err { border-left-color: var(--err); }
.toast.ok  { border-left-color: var(--ok); }
@keyframes slide { from { opacity: 0; transform: translateX(12px); } }

.busy { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(0,0,0,.35); }
.busy span {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 22px; box-shadow: var(--shadow);
}

/* ─────────────────────────────── адаптив ────────────────────────────────── */

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 220px minmax(0,1fr); grid-template-rows: 1fr auto; }
  .panel.tools { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; overflow: visible; }
  .panel.tools h2, .tips { display: none; }
  .field { min-width: 170px; }
}

@media (max-width: 720px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .panel.parts { max-height: 30vh; }
  .brand-text, .slug { display: none; }
  .proj-name { width: 14ch; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
