/* Студия — дизайн-система. Цвет проекта приходит в --brand (атрибут style у .app). */
:root {
  --bg: #f4f4f6; --panel: #ffffff; --side: #fbfbfc; --ink: #141418; --ink-2: #5f5f6b; --ink-3: #8b8b97;
  --line: #e6e6ec; --line-2: #d9d9e1; --hover: #f0f0f4;
  --brand: #6F33F5; --on-brand: #fff;
  --ok: #148a4a; --ok-bg: #e5f5ec; --warn: #a96a00; --warn-bg: #fff3dc; --bad: #c62f3a; --bad-bg: #fdebec;
  --info-bg: #eef1ff; --info: #3346c4;
  --r: 14px; --r-sm: 10px;
  --shadow: 0 1px 2px rgba(20,20,30,.05), 0 6px 20px -8px rgba(20,20,30,.12);
  --shadow-lg: 0 2px 6px rgba(20,20,30,.06), 0 18px 40px -16px rgba(20,20,30,.28);
  --font: ui-sans-serif, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f13; --panel: #18181e; --side: #131318; --ink: #ededf2; --ink-2: #a3a3b1; --ink-3: #74747f;
    --line: #26262e; --line-2: #33333d; --hover: #1f1f27;
    --ok: #4fd18b; --ok-bg: #12291c; --warn: #f0b545; --warn-bg: #2e2412; --bad: #ff6b74; --bad-bg: #331417;
    --info-bg: #1b1f3a; --info: #9aa8ff;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -10px rgba(0,0,0,.6);
    --shadow-lg: 0 2px 6px rgba(0,0,0,.4), 0 18px 40px -16px rgba(0,0,0,.8);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.ell { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- каркас ---------- */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px; background: var(--side); border-right: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 4px 8px 14px; }
.logo-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: var(--ink); color: var(--bg); font-size: 12px; }
.logo-mark.xl { width: 48px; height: 48px; border-radius: 14px; font-size: 18px; }
.side-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 6px 10px; }
.projects { display: flex; flex-direction: column; gap: 2px; }
.proj { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink-2); }
.proj:hover { background: var(--hover); color: var(--ink); }
.proj.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.proj-name { display: flex; flex-direction: column; line-height: 1.25; font-weight: 600; flex: 1; min-width: 0; }
.proj-name small { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.proj-mark { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 9px;
  background: var(--c); color: #fff; font-weight: 700; font-size: 15px; }
.proj-mark.big { width: 46px; height: 46px; border-radius: 13px; font-size: 21px; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--brand); color: var(--on-brand);
  font-size: 12px; font-weight: 600; display: inline-grid; place-items: center; }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.pc { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: var(--r-sm); background: var(--panel); border: 1px solid var(--line); }
.pc b { display: block; font-size: 14px; }
.pc small { color: var(--ink-3); font-size: 12px; line-height: 1.35; display: block; }
.pulse { flex: none; width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background: var(--bad); }
.pc.ok .pulse { background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 8px transparent; } }
.quota { list-style: none; margin: 0; padding: 0 4px; font-size: 12px; color: var(--ink-3); display: grid; gap: 3px; }
.logout { font-size: 13px; color: var(--ink-3); padding: 2px 4px; }
.logout:hover { color: var(--ink); }

.main { min-width: 0; }
.phead { position: sticky; top: 0; z-index: 4; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line); padding: 18px 32px 0; }
.ptitle { display: flex; align-items: center; gap: 14px; }
.ptitle h1 { font-size: 22px; }
.ptitle a { font-size: 13px; }
.tabs { display: flex; gap: 4px; margin-top: 14px; }
.tabs a { padding: 10px 14px; color: var(--ink-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); border-color: var(--brand); }
.content { padding: 26px 32px 80px; max-width: 1180px; }

/* ---------- блоки ---------- */
.block { margin-bottom: 34px; }
.block-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.block-head h2 { font-size: 18px; }
.block-head a { margin-left: auto; color: var(--brand); font-weight: 600; font-size: 14px; }
.block-head p { margin: 0; flex-basis: 100%; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.eyebrow { display: block; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--brand); margin-bottom: 6px; }
.h-big { font-size: 28px; margin-bottom: 6px; }
.back { display: inline-block; color: var(--ink-2); font-size: 14px; margin-bottom: 16px; }
.back:hover { color: var(--ink); }

/* шаблоны */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 16px; }
.tpl { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; transition: transform .18s ease, box-shadow .18s ease, border-color .18s; }
.tpl:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--line-2); }
.tpl-media { position: relative; aspect-ratio: 9 / 13; overflow: hidden; background: #000; }
.tpl-media img, .tpl-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tpl-media video { opacity: 0; transition: opacity .25s; }
.tpl.playing video { opacity: 1; }
.tpl-dur { position: absolute; left: 10px; bottom: 10px; padding: 3px 8px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: rgba(0,0,0,.6); color: #fff; backdrop-filter: blur(6px); }
.tpl-body { display: flex; flex-direction: column; gap: 4px; padding: 13px 14px 15px; flex: 1; }
.tpl-body b { font-size: 15px; }
.tpl-body small { color: var(--ink-2); font-size: 13px; line-height: 1.4; flex: 1; }
.tag { align-self: flex-start; margin-top: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px;
  background: var(--ok-bg); color: var(--ok); }
.tag.warm { background: var(--warn-bg); color: var(--warn); }

/* задания */
.jobs { display: grid; gap: 10px; }
.job { display: flex; align-items: center; gap: 14px; padding: 10px 14px 10px 10px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r); transition: border-color .15s, box-shadow .15s; }
.job:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.job-thumb { flex: none; width: 46px; height: 64px; border-radius: 8px; overflow: hidden; background: var(--hover); }
.job-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.job-thumb img.dim { opacity: .45; filter: grayscale(.4); }
.job-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.job-body b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-body small { color: var(--ink-3); font-size: 13px; }
.mini-steps { display: flex; gap: 4px; margin-top: 4px; }
.mini-steps i { width: 28px; height: 4px; border-radius: 2px; background: var(--line-2); }
.mini-steps i.done { background: var(--brand); }
.mini-steps i.now { background: linear-gradient(90deg, var(--brand), var(--line-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.pill { flex: none; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: var(--hover); color: var(--ink-2); white-space: nowrap; }
.pill.big { font-size: 13px; padding: 6px 12px; }
.st-running { background: var(--warn-bg); color: var(--warn); }
.st-done { background: var(--ok-bg); color: var(--ok); }
.st-failed { background: var(--bad-bg); color: var(--bad); }

/* форма рилса */
.compose { display: grid; grid-template-columns: 300px 1fr; gap: 36px; align-items: start; margin-bottom: 40px; }
.compose-preview { position: sticky; top: 140px; }
.phone { position: relative; aspect-ratio: 9 / 16; border-radius: 26px; overflow: hidden; background: #000;
  box-shadow: var(--shadow-lg); border: 6px solid #0b0b0e; }
.phone video { width: 100%; height: 100%; object-fit: cover; display: block; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.facts div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; }
.facts small { display: block; color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.facts b { font-size: 13px; }
.compose-form { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); }
.compose-form.solo { max-width: 640px; }
.compose-form > p { margin: 0 0 22px; }
.field { display: block; margin: 0 0 20px; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 14px; }
.field small { display: block; margin-top: 8px; line-height: 1.45; }
input, textarea, select { display: block; width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--bg); color: var(--ink); font: inherit; font-size: 15px; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; line-height: 1.55; min-height: 160px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
input:disabled { opacity: .6; }
.meter { display: block; height: 4px; margin-top: 8px; border-radius: 2px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; border-radius: 2px; transition: width .2s, background .2s; }
.meter i.low { background: var(--ink-3); } .meter i.ok { background: var(--ok); } .meter i.high { background: var(--warn); }
.linkbtn { background: none; border: 0; padding: 0; margin-top: 8px; font: inherit; font-size: 13px; font-weight: 600; color: var(--brand); cursor: pointer; }
.field-head .linkbtn { margin: 0; }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; margin: 4px 0 24px; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; }
.track { position: relative; flex: none; width: 42px; height: 24px; border-radius: 99px; background: var(--line-2); transition: background .2s; }
.track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 25%, transparent); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.actions.col { flex-direction: column; align-items: stretch; }
.actions form { margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 11px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { filter: brightness(1.08); background: var(--brand); }
.btn.big { padding: 14px 22px; font-size: 15px; border-radius: 13px; }
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; color: var(--ink-2); cursor: default; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
form .btn.wide { width: 100%; }

.alert { padding: 10px 14px; border-radius: 11px; font-size: 14px; margin: 12px 0 0; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.info { background: var(--info-bg); color: var(--info); }
.empty-state { text-align: center; padding: 48px 24px; background: var(--panel); border: 1px dashed var(--line-2); border-radius: var(--r); }
.empty-state h3 { margin: 14px 0 6px; }
.empty-state p { max-width: 520px; margin: 0 auto; }
.empty-state a { color: var(--brand); font-weight: 600; }

/* задание */
.job-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.job-head p { margin: 0; }
.progress { margin-bottom: 18px; }
.steps { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.steps li { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--bg); color: var(--ink-3); font-weight: 600; font-size: 14px; }
.steps li span { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line-2); font-size: 13px; }
.steps li.done { color: var(--ink); }
.steps li.done span { background: var(--brand); border-color: var(--brand); color: #fff; font-size: 0; }
.steps li.done span::after { content: "✓"; font-size: 13px; }
.steps li.now { color: var(--ink); background: color-mix(in srgb, var(--brand) 10%, var(--panel)); }
.steps li.now span { border-color: var(--brand); border-top-color: transparent; animation: spin 1s linear infinite; font-size: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.now-line { margin: 0 0 6px; color: var(--ink-2); font-family: var(--mono); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.result { display: grid; grid-template-columns: minmax(0, 340px) 1fr; gap: 28px; align-items: start; margin-bottom: 18px; }
.result .phone video { object-fit: contain; }
.novid { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: #bbb; font-size: 14px; }
.result-side { display: flex; flex-direction: column; gap: 16px; }
.caption textarea { min-height: 150px; background: var(--bg); }
.alert-card { border-color: var(--bad); margin-bottom: 18px; }
.alert-card h3 { margin-bottom: 10px; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: 12.5px/1.5 var(--mono); }
.err { background: var(--bad-bg); color: var(--bad); padding: 12px; border-radius: 10px; margin-bottom: 14px; }
.fold { margin-bottom: 10px; padding: 14px 18px; }
.fold summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
.fold summary::before { content: "›"; display: inline-block; transition: transform .15s; color: var(--ink-3); font-size: 18px; line-height: 1; }
.fold[open] summary::before { transform: rotate(90deg); }
.fold summary::-webkit-details-marker { display: none; }
.log { max-height: 440px; overflow: auto; margin-top: 12px; padding: 12px; background: var(--bg); border-radius: 10px; color: var(--ink-2); }
.script { margin: 12px 0 0; white-space: pre-wrap; }

/* готовое */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.shot { position: relative; aspect-ratio: 9 / 16; border-radius: var(--r); overflow: hidden; background: var(--hover); box-shadow: var(--shadow); }
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.shot:hover img { transform: scale(1.04); }
.noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); font-size: 13px; }
.shot-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 30px 12px 12px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.82)); }
.shot-cap b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shot-cap small { opacity: .8; font-size: 12px; }

/* вход */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, #6F33F5 14%, transparent), transparent), var(--bg); }
.login { width: 100%; max-width: 360px; text-align: center; background: var(--panel); border: 1px solid var(--line);
  border-radius: 22px; padding: 34px 28px; box-shadow: var(--shadow-lg); }
.login h1 { margin: 16px 0 4px; font-size: 24px; }
.login p { margin: 0 0 22px; }
.login input { margin-bottom: 12px; text-align: center; }

/* ---------- телефон ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { min-width: 0; position: sticky; top: 0; z-index: 6; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: 8px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .logo { padding: 0; }
  .side-label, .quota, .logout { display: none; }
  .projects { order: 3; flex-basis: 100%; min-width: 0; flex-direction: row; overflow-x: auto; gap: 6px; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
  .projects::-webkit-scrollbar { display: none; }
  .proj { flex: none; padding: 6px 12px 6px 6px; border: 1px solid var(--line); background: var(--panel); }
  .proj.on { border-color: var(--c); box-shadow: none; }
  .proj-mark { width: 26px; height: 26px; font-size: 13px; border-radius: 7px; }
  .proj-name small { display: none; }
  .side-foot { margin: 0 0 0 auto; }
  .pc { padding: 6px 10px; align-items: center; }
  .pc small { display: none; }
  .pc b { font-size: 13px; }
  .pulse { margin: 0; }
  .phead { position: static; padding: 16px 16px 0; }
  .ptitle .proj-mark.big { width: 38px; height: 38px; font-size: 18px; }
  .ptitle h1 { font-size: 20px; }
  .tabs { overflow-x: auto; }
  .content { padding: 18px 16px 60px; }
  .tpl-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tpl-body { padding: 10px 11px 12px; }
  .tpl-body small { display: none; }
  .compose { grid-template-columns: 1fr; gap: 18px; }
  .compose-preview { position: static; display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; }
  .compose-preview .phone { border-radius: 16px; border-width: 4px; }
  .facts { grid-template-columns: 1fr; margin: 0; }
  .compose-form { padding: 20px 16px; border-radius: 16px; }
  .h-big { font-size: 23px; }
  .steps { grid-template-columns: 1fr; }
  .result { grid-template-columns: 1fr; }
  .result .phone { max-width: 250px; width: 100%; margin: 0 auto; }
  .job-head { flex-direction: column-reverse; gap: 8px; }
  .gallery { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
.note { margin: 0 0 16px; }
