/* Cover Studio — coproducerhub design system (light, Apple-style) */
:root{
  /* CO>APPS design tokens (same as the hub) */
  --bg:#F2F2F2;
  --card:#ffffff;
  --text:#1A1A1A;
  --muted:#767676;
  --faint:#AFAFAF;         /* labels */
  --line:#E8E8E8;
  --line-soft:rgba(0,0,0,.06);
  --field:#ffffff;
  --field-bg:#F5F5F5;      /* panels */
  --accent:#1A1A1A;        /* segments / borders active */
  --accent-hover:#333;
  --lime:#C6FF00;          /* CTA */
  --lime-logo:#C6D92C;     /* active stripe */
  --ring:rgba(26,26,26,.10);
  --ok:#10b981; --warn:#ef4444;
  --r-sm:10px; --r:12px; --r-lg:16px;
  --shadow:0 1px 2px rgba(0,0,0,.05);
}
*{box-sizing:border-box}
html,body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
body{margin:0;background:var(--bg);color:var(--text);
  font-family:Inter,-apple-system,BlinkMacSystemFont,system-ui,sans-serif;
  font-size:14px;line-height:1.5}

::-webkit-scrollbar{width:6px;height:6px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:rgba(0,0,0,.14);border-radius:99px}
::-webkit-scrollbar-thumb:hover{background:rgba(0,0,0,.24)}

/* ---- topbar ---- */
.topbar{display:flex;justify-content:space-between;align-items:center;
  padding:14px 24px;background:rgba(255,255,255,.7);backdrop-filter:saturate(180%) blur(12px);
  border-bottom:1px solid var(--line-soft);position:sticky;top:0;z-index:20}
.brand{font-weight:700;letter-spacing:-.01em;display:flex;align-items:center;gap:9px;font-size:15px}
.brand .dot{width:9px;height:9px;border-radius:50%;background:var(--accent)}
.muted{color:var(--muted)} .small{font-size:12px} .hidden{display:none}

/* ---- layout: sidebar flush-left, workspace full-width (общий вид CO>APPS) ---- */
.layout{display:grid;grid-template-columns:260px minmax(380px,1fr) 1fr;gap:18px;
  padding:0 20px 20px 0;align-items:start}

/* ---- history sidebar ---- */
.history{align-self:stretch;position:sticky;top:56px;height:calc(100vh - 56px);
  max-height:calc(100vh - 56px);display:flex;flex-direction:column}
.history.panel{border-radius:0;border:0;border-right:1px solid var(--line);
  box-shadow:none;background:#fff}
.form,.result{margin-top:20px}
.history-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}
.history-head .ghost{padding:4px 12px;font-size:18px;line-height:1}
.history-list{overflow-y:auto;display:flex;flex-direction:column;gap:8px}
.hist-item{display:flex;gap:10px;align-items:center;padding:8px;border-radius:10px;
  border:1px solid transparent;border-left:3px solid transparent;background:var(--field-bg);
  cursor:pointer;transition:background .15s,border-color .15s}
.hist-item:hover{background:#EBEBEB}
.hist-item.active{background:#fff;border-color:var(--line);
  border-left:3px solid var(--lime-logo)}
.hist-item img{width:38px;height:38px;object-fit:cover;border-radius:6px;background:#fff;flex:none}
.hist-item .hi-body{min-width:0;flex:1}
.hist-item .hi-title{font-size:12px;font-weight:600;white-space:nowrap;overflow:hidden;
  text-overflow:ellipsis}
.hist-item .hi-meta{font-size:10.5px;color:var(--muted)}
.hist-item .hi-del{flex:none;width:22px;height:22px;border-radius:6px;background:transparent;
  border:1px solid transparent;color:var(--muted);font-size:11px;line-height:1;
  display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .15s}
.hist-item:hover .hi-del{opacity:1}
.hist-item .hi-del:hover{color:#d33;border-color:#d33}
.panel{background:var(--card);border:1px solid var(--line-soft);border-radius:var(--r-lg);
  padding:20px;box-shadow:var(--shadow)}
.panel h2{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.12em;
  color:var(--faint);margin:22px 0 10px;display:flex;align-items:baseline;gap:6px}
.panel h2:first-child{margin-top:0}
.panel h2 .small{font-size:11px;text-transform:none;letter-spacing:0;font-weight:400}

/* ---- form fields ---- */
label{display:block;margin:11px 0;font-size:13px;color:var(--muted)}
input,textarea,select{width:100%;margin-top:6px;background:var(--field);
  border:1px solid var(--line);color:var(--text);border-radius:var(--r);
  padding:10px 12px;font:inherit;font-size:14px;transition:border-color .15s,box-shadow .15s}
input::placeholder,textarea::placeholder{color:var(--faint)}
input:focus,textarea:focus,select:focus{outline:none;border-color:#a1a1aa;
  box-shadow:0 0 0 3px var(--ring)}
textarea{resize:vertical;min-height:62px}
select{appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 12px center;padding-right:34px;cursor:pointer}
input[type=file]{padding:8px 10px;font-size:13px;color:var(--muted);cursor:pointer}
input[type=file]::file-selector-button{margin-right:10px;border:1px solid var(--line);
  background:#f4f4f5;color:var(--text);border-radius:8px;padding:6px 12px;font:inherit;
  font-size:12px;font-weight:500;cursor:pointer}
input[type=file]::file-selector-button:hover{background:#e4e4e7}
.row{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.row.tight{grid-template-columns:1fr auto;gap:8px;align-items:end}
/* a row wrapping a single segmented control must span full width, else pills wrap */
.row:has(> .seg){grid-template-columns:1fr}

/* ---- buttons ---- */
button{cursor:pointer;font:inherit;border:none;border-radius:var(--r);transition:all .15s}
.ghost{background:#f4f4f5;border:1px solid transparent;color:#3f3f46;
  padding:10px 16px;font-size:14px;font-weight:500;white-space:nowrap}
.ghost:hover{background:#e8e8ea}
.ghost:active{background:#e0e0e3}
.primary{width:100%;margin-top:18px;background:var(--lime);color:#111;
  font-weight:800;padding:12px;font-size:14px}
.primary:hover{filter:brightness(.94)}
.primary:active{background:#000}
.primary:disabled{opacity:.4;cursor:not-allowed}

/* ---- segmented pills ---- */
.seg{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.seg>span{font-size:12px;color:var(--faint);margin-right:4px;min-width:58px;font-weight:500;
  align-self:center}
.seg button{background:#fff;border:1px solid var(--line);color:var(--muted);
  height:34px;padding:0 14px;font-size:13px;font-weight:500;border-radius:9px;
  display:inline-flex;align-items:center;line-height:1}
.seg button:hover{border-color:#c4c4c8;color:var(--text)}
.seg button.on{background:var(--accent);color:#fff;border-color:var(--accent)}
/* breathing room around / between segmented rows so the fills don't read as merged */
.row:has(> .seg){margin-top:14px}
.row:has(> .seg) + .row:has(> .seg){margin-top:8px}

/* ---- analysis / asset cards ---- */
.analysis{background:var(--field-bg);border:1px solid var(--line);border-radius:var(--r);
  padding:14px;margin:8px 0}
.swatches{display:flex;gap:7px;margin-bottom:10px}
.sw{width:28px;height:28px;border-radius:7px;border:1px solid var(--line-soft);box-shadow:var(--shadow)}
.assets{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}
.asset{margin:0;cursor:pointer;position:relative}
.asset img{width:70px;height:70px;object-fit:contain;background:#fff;border-radius:9px;
  border:2px solid var(--line);padding:3px;transition:border-color .15s}
.asset img:hover{border-color:#c4c4c8}
.asset input{position:absolute;top:5px;left:5px;width:auto;margin:0;accent-color:var(--accent)}
.asset input:checked ~ img{border-color:var(--accent)}

/* ---- result ---- */
.result{position:sticky;top:78px;align-self:start}
.status{padding:8px 0;font-size:13px}
.imgwrap img{width:100%;border-radius:var(--r);border:1px solid var(--line);display:block;
  box-shadow:var(--shadow)}
.imgwrap .download,#downloadLink{display:inline-block;margin-top:12px;background:#f4f4f5;
  border:1px solid transparent;color:#3f3f46;padding:9px 16px;border-radius:var(--r);
  text-decoration:none;font-size:14px;font-weight:500}
.imgwrap .download:hover,#downloadLink:hover{background:#e8e8ea}
pre{white-space:pre-wrap;background:var(--field-bg);border:1px solid var(--line);
  border-radius:var(--r);padding:12px;font-size:12px;line-height:1.55;color:var(--muted);
  margin-top:10px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}
details summary{cursor:pointer;color:var(--muted);font-size:13px;margin-top:14px;
  list-style:none;user-select:none}
details summary::-webkit-details-marker{display:none}
details summary::before{content:"›";display:inline-block;margin-right:6px;transition:transform .15s}
details[open] summary::before{transform:rotate(90deg)}

/* ---- result versions strip ---- */
.versions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:10px}
.ver-thumb,.imgwrap img.ver-thumb{width:56px;height:42px;object-fit:cover;border-radius:7px;
  cursor:pointer;border:2px solid var(--line);background:var(--field-bg);
  transition:border-color .15s}
.ver-thumb:hover{border-color:var(--accent)}
.ver-thumb.on{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}

/* ---- embed mode (iframe inside the post editor) ---- */
body.embed .topbar{display:none}
body.embed .layout,body.embed .editor-layout{padding:12px;gap:12px}
body.embed .history{display:none}
body.embed .layout{grid-template-columns:minmax(340px,1fr) 1fr}

@media(max-width:880px){
  .layout{grid-template-columns:1fr;padding:0 14px 14px;gap:14px}
  .result{position:static}
  .history{position:static;height:auto;max-height:320px}
  .history.panel{border:1px solid var(--line);border-radius:var(--r-lg);margin-top:14px}
  .form,.result{margin-top:0}
}

/* ---- editor ---- */
.editor-layout{display:grid;grid-template-columns:1fr 340px;gap:18px;padding:20px}
.toolbar{display:flex;gap:14px;align-items:center;flex-wrap:wrap;margin-bottom:14px}
.brushctl{margin:0;display:flex;align-items:center;gap:8px;font-size:12px;color:var(--faint);font-weight:500}
.brushctl input{width:120px;margin:0;accent-color:var(--accent)}
.stage{position:relative;display:inline-block;line-height:0;background:#fafafa;
  border:1px solid var(--line);border-radius:var(--r);overflow:hidden}
.stage canvas{display:block;cursor:crosshair;touch-action:none}
#overlays{position:absolute;inset:0;pointer-events:none}
.region-tip{position:absolute;transform:translate(-2px,-2px)}
.region-tip .rtag{background:var(--accent);color:#fff;font-weight:600;font-size:11px;
  padding:2px 7px;border-radius:6px;box-shadow:0 2px 6px rgba(0,0,0,.18)}
.side{align-self:start}
.region-list{display:flex;flex-direction:column;gap:10px;margin-bottom:14px}
.region-item{background:var(--field-bg);border:1px solid var(--line);border-radius:var(--r);padding:10px}
.ri-head{display:flex;align-items:center;gap:8px;margin-bottom:6px;font-size:13px}
.ri-head .del{margin-left:auto;background:#fff;color:var(--muted);
  border:1px solid var(--line);width:24px;height:24px;border-radius:7px;line-height:1}
.ri-head .del:hover{color:#fff;background:var(--warn);border-color:var(--warn)}
.region-item textarea{margin:0}
@media(max-width:880px){.editor-layout{grid-template-columns:1fr}}
