/* Конструктор каруселей (/app/carousel/). Токены -- из studio.css (--st-*),
   все классы с приставкой cr-. Белый холст, синяя кнопка, без тёмных панелей.
   С 14.10.2026 каркас студии (.ws: история | полотно | настройки). */
.cr-row { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cr-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cr-chips button { border: 1px solid var(--st-line); background: var(--st-surface); color: var(--st-ink); border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 14px; cursor: pointer; }
.cr-chips button.on { border-color: var(--st-accent); background: var(--st-accent-soft); color: var(--st-accent); font-weight: 600; }
.cr-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--st-surface-2); border-radius: 12px; padding: 4px; width: fit-content; max-width: 100%; }
.cr-seg button { border: 0; background: none; border-radius: 9px; padding: 7px 12px; font: inherit; font-size: 14px; color: var(--st-sub); cursor: pointer; min-width: 38px; }
.cr-seg button.on { background: var(--st-surface); color: var(--st-accent); font-weight: 600; box-shadow: 0 1px 3px rgba(15, 27, 51, .08); }

.cr-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cr-cards button { text-align: left; border: 1px solid var(--st-line); background: var(--st-surface); border-radius: 14px; padding: 12px; font: inherit; cursor: pointer; color: var(--st-ink); }
.cr-cards button small { display: block; color: var(--st-sub); font-size: 12px; margin-top: 2px; }
.cr-cards button.on { border-color: var(--st-accent); box-shadow: 0 0 0 1px var(--st-accent); }
.cr-styles { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.cr-style { border: 1px solid var(--st-line); border-radius: 14px; background: var(--st-surface); padding: 6px; cursor: pointer; font: inherit; color: var(--st-ink); text-align: left; }
.cr-style.on { border-color: var(--st-accent); box-shadow: 0 0 0 1px var(--st-accent); }
.cr-style i { display: block; aspect-ratio: 4 / 5; border-radius: 10px; position: relative; overflow: hidden; padding: 10px; font-style: normal; font-weight: 800; font-size: 22px; line-height: 1; }
.cr-style i b { display: block; width: 36%; height: 6px; border-radius: 3px; margin-top: 10px; }
.cr-style span { display: block; font-size: 13px; padding: 6px 4px 2px; }

.cr-photos { display: flex; gap: 8px; flex-wrap: wrap; }
.cr-photo, .cr-add-photo { width: 84px; height: 105px; border-radius: 12px; border: 1px dashed var(--st-line); background: var(--st-surface-2) center / cover no-repeat; position: relative; display: grid; place-items: center; color: var(--st-sub); font-size: 26px; cursor: pointer; }
.cr-photo { border-style: solid; cursor: default; }
.cr-photo button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer; font-size: 14px; line-height: 1; }
.cr-add-photo input { display: none; }

.cr-cost { border-radius: 14px; background: var(--st-accent-soft); color: var(--st-ink); padding: 12px 14px; font-size: 14px; }
.cr-cost b { color: var(--st-accent); }
.cr-cost.low { background: #fff1f0; }
.cr-err { color: #c0392b; min-height: 1em; }
.cr-warn { color: #b26a00; }

.cr-progress { height: 4px; border-radius: 2px; background: var(--st-surface-2); overflow: hidden; }
.cr-progress i { display: block; height: 100%; width: 0; background: var(--st-accent); transition: width .4s; }
.cr-strip { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px 10px; -webkit-overflow-scrolling: touch; }
.cr-slide { flex: 0 0 min(300px, 78vw); scroll-snap-align: start; aspect-ratio: 4 / 5; border-radius: 14px; overflow: hidden; background: var(--st-surface-2); position: relative; border: 2px solid transparent; cursor: pointer; padding: 0; }
.cr-slide.sel { border-color: var(--st-accent); }
.cr-slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cr-slide .cr-ph { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--st-sub); font-size: 13px; padding: 16px; background: linear-gradient(110deg, var(--st-surface-2) 30%, var(--st-surface) 50%, var(--st-surface-2) 70%); background-size: 300% 100%; animation: cr-shine 1.4s linear infinite; }
.cr-slide .cr-badge { position: absolute; left: 8px; top: 8px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; padding: 3px 8px; border-radius: 999px; }
.cr-slide.busy::after { content: 'Рисуем…'; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255, 255, 255, .7); font-weight: 600; color: var(--st-accent); }
@keyframes cr-shine { to { background-position: -150% 0; } }
.cr-dots { display: flex; justify-content: center; gap: 6px; }
.cr-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--st-line); }
.cr-dots i.on { background: var(--st-accent); }

#cr-fields { display: flex; flex-direction: column; gap: 10px; }
.cr-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--st-sub); border-radius: 14px; padding: 6px; margin: -6px; border: 2px solid transparent; }
.cr-field.on { border-color: var(--st-accent-soft); background: color-mix(in srgb, var(--st-accent-soft) 45%, transparent); }
.cr-field.on .cr-field-name { color: var(--st-accent); font-weight: 600; }
#cr-fields textarea { min-height: 44px; resize: vertical; }

/* Превью выбранного слайда с рамками блоков */
.cr-preview { position: relative; aspect-ratio: 4 / 5; border-radius: 14px; overflow: hidden; background: var(--st-surface-2); }
.cr-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cr-preview.busy img { opacity: .75; transition: opacity .2s; }
.cr-hit { position: absolute; border: 2px dashed transparent; border-radius: 8px; background: none; padding: 0; cursor: pointer; }
.cr-hit:hover { border-color: rgba(37, 99, 235, .55); background: rgba(37, 99, 235, .06); }
.cr-hit.on { border: 2px solid var(--st-accent); box-shadow: 0 0 0 2px rgba(255, 255, 255, .7); }

/* Типографика блока */
.cr-type { display: flex; flex-direction: column; gap: 12px; border: 1px solid var(--st-line); border-radius: 16px; padding: 14px; }
.cr-type-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cr-type-head b { font-size: 15px; }
.cr-row-inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.cr-row-inline > div { display: flex; flex-direction: column; gap: 8px; }
.cr-row .st-label output { font-weight: 600; color: var(--st-ink); margin-left: 4px; }
.cr-row input[type=range] { width: 100%; accent-color: var(--st-accent); }
.cr-weight { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 160px; }
.cr-weight select { padding: 9px 10px; }
.cr-italic { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--st-line); background: var(--st-surface); color: var(--st-ink); font: 600 18px Georgia, serif; cursor: pointer; }
.cr-italic.on { background: var(--st-accent); border-color: var(--st-accent); color: #fff; }
.cr-italic:disabled { opacity: .4; cursor: not-allowed; }
.cr-fontbtn { width: 100%; text-align: left; border: 1px solid var(--st-line); background: var(--st-surface); color: var(--st-ink); border-radius: 12px; padding: 10px 36px 10px 12px; font-size: 18px; cursor: pointer; position: relative; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-fontbtn::after { content: '▾'; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font: 14px system-ui, sans-serif; color: var(--st-sub); }
.cr-swatches .cr-auto { width: auto; border-radius: 999px; padding: 0 10px; font-size: 12px; background: var(--st-surface); color: var(--st-sub); }
.cr-slideopts { border: 1px solid var(--st-line); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.cr-slideopts summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.cr-slideopts[open] summary { margin-bottom: 10px; }
.cr-slideopts .cr-row + .cr-row { margin-top: 12px; }

/* Выбор шрифта */
.cr-fontpick { position: fixed; inset: 0; z-index: 60; background: rgba(15, 23, 42, .45); display: grid; place-items: center; padding: 16px; }
.cr-fontpick[hidden] { display: none; }
.cr-fp-box { width: min(560px, 100%); max-height: min(720px, calc(100vh - 32px)); display: flex; flex-direction: column; gap: 10px; background: var(--st-surface); border-radius: 20px; padding: 16px; box-shadow: 0 30px 60px -20px rgba(15, 23, 42, .45); }
.cr-fp-head { display: flex; justify-content: space-between; align-items: center; }
.cr-fp-list { overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-auto-rows: 50px; align-content: start; gap: 6px; padding: 2px; min-height: 120px; flex: 1 1 auto; }
.cr-fp-item { border: 1px solid var(--st-line); background: var(--st-surface); color: var(--st-ink); border-radius: 12px; padding: 12px 10px; font-size: 19px; text-align: left; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-fp-item:hover { border-color: var(--st-accent); }
.cr-fp-item.on { border-color: var(--st-accent); background: var(--st-accent-soft); }
.cr-swatches { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cr-swatches button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--st-line); cursor: pointer; padding: 0; }
.cr-swatches button.on { border-color: var(--st-accent); box-shadow: 0 0 0 2px var(--st-accent-soft); }
.cr-swatches input[type=color] { width: 34px; height: 34px; border: 0; background: none; padding: 0; cursor: pointer; }
.cr-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.cr-wrap button { font-size: 13px; }
.cr-caption { background: var(--st-surface); border: 1px solid var(--st-line); border-radius: 16px; padding: 12px 16px; }
.cr-caption summary { cursor: pointer; font-weight: 600; }
.cr-caption textarea { width: 100%; margin: 10px 0; }


/* ══ Каркас студии (14.10.2026) ══════════════════════════════════════════ */
[hidden] { display: none !important; }
.cr-ws { font-family: 'Onest', var(--font, system-ui, sans-serif); color: var(--st-ink); padding-bottom: 32px; }
.cr-ws:not([data-view="new"]) [data-view-only="new"],
.cr-ws:not([data-view="work"]) [data-view-only="work"] { display: none !important; }
.cr-ws[data-view="login"] .ws-right { display: none; }
.cr-ws[data-view="login"] .ws-form { grid-template-columns: minmax(0, 1fr); }

/* вкладки студии ссылками; пятая — «Карусель» */
.cr-tabs { grid-template-columns: repeat(5, 1fr) !important; width: min(680px, 100%) !important; }
.cr-tabs a { display: grid; place-items: center; padding: 10px 6px; border-radius: 11px; font-weight: 600; font-size: 14px; line-height: 1; color: var(--st-sub); text-decoration: none; }
.cr-tabs a:hover { color: var(--st-ink); }
.cr-tabs a.on { background: var(--st-surface); color: var(--st-accent); box-shadow: 0 1px 3px rgba(15, 27, 51, .08); }

.cr-login { align-items: flex-start; padding: 22px; }
.cr-login p { margin: 0; color: var(--st-sub); }

/* слева: мои карусели */
.cr-history-list { display: flex; flex-direction: column; gap: 4px; }
.cr-history-list a { display: flex; flex-direction: column; gap: 2px; padding: 9px 10px; border-radius: 12px; color: var(--st-ink); text-decoration: none; font-size: 13.5px; line-height: 1.3; }
.cr-history-list a:hover { background: var(--st-surface-2); }
.cr-history-list a.on { background: var(--st-accent-soft); color: var(--st-accent); font-weight: 600; }
.cr-history-list a span { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cr-history-list a small { color: var(--st-sub); font-size: 12px; font-weight: 400; }
.ws-left-head b { font-size: 15px; }

/* центр: живой макет обложки */
.cr-canvas { min-height: min(56vh, 560px); }
.cr-intro { display: grid; grid-template-columns: auto minmax(0, 340px); gap: 40px; align-items: center; }
.cr-intro-tx h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: -.02em; line-height: 1.1; }
.cr-intro-tx p { margin: 0 0 16px; color: var(--st-sub); font-size: 15px; line-height: 1.5; }
.cr-how { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: h; }
.cr-how li { counter-increment: h; display: grid; grid-template-columns: 28px 1fr; column-gap: 10px; align-items: center; font-size: 14px; }
.cr-how li::before { content: counter(h); grid-row: span 2; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--st-accent-soft); color: var(--st-accent); font-weight: 700; font-size: 13px; }
.cr-how li span { color: var(--st-sub); font-size: 13px; }

.cr-mock { --m-bg: #111; --m-ink: #fff; --m-accent: #2563eb; position: relative; width: 236px; aspect-ratio: 4 / 5; margin-right: 70px; }
.cr-mock-s { position: absolute; inset: 0; border-radius: 16px; background: var(--m-bg); color: var(--m-ink); padding: 18px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 22px 40px -24px rgba(15, 26, 46, .55); transition: background .25s, color .25s; overflow: hidden; }
.cr-mock-2 { transform: translateX(42px) rotate(5deg) scale(.94); opacity: .9; }
.cr-mock-3 { transform: translateX(80px) rotate(10deg) scale(.88); opacity: .75; }
.cr-mock-s > b { font-size: 34px; font-weight: 800; color: var(--m-accent); line-height: 1; }
.cr-mock-s > i { display: block; height: 8px; border-radius: 4px; background: currentColor; opacity: .25; }
.cr-mock-s > i:nth-of-type(2) { width: 80%; }
.cr-mock-s > i:nth-of-type(3) { width: 60%; }
.cr-mock-1 small { align-self: flex-start; background: var(--m-accent); color: #fff; font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.cr-mock-1 strong { margin-top: auto; font-size: 22px; line-height: 1.12; font-weight: 800; letter-spacing: -.01em; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.cr-mock-1 span { font-size: 12px; opacity: .7; min-height: 1em; }
.cr-mock.ref .cr-mock-s { background: linear-gradient(135deg, #fde68a, #f472b6 55%, #818cf8); color: #111; }

/* строка темы */
.cr-composer #cr-topic { border: 0; min-height: 56px; padding: 6px 4px; resize: none; background: none; font-size: 16px; width: 100%; }
.cr-composer #cr-topic:focus { outline: none; }
.cr-composer #cr-topic[aria-invalid="true"]::placeholder { color: #c0392b; }
.cr-ideas { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 2px 8px; }
.cr-ideas:empty { display: none; }
.cr-ideas button { border: 1px dashed var(--st-line); background: none; color: var(--st-sub); border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 12.5px; cursor: pointer; }
.cr-ideas button:hover { border-color: var(--st-accent); color: var(--st-accent); }
.cr-composer .cr-cost { flex-basis: 100%; order: 3; margin: 0; padding: 0; background: none; font-size: 12.5px; color: var(--st-sub); text-align: right; }
.cr-composer .cr-cost.low { background: none; color: #c0392b; }
.cr-composer .cr-err { flex-basis: 100%; order: 4; text-align: right; }
.cr-composer .cr-err:empty { display: none; }

/* справа */
.ws-card h3 small { font-weight: 400; }
.cr-chips button { padding: 6px 11px; font-size: 13px; }
.cr-styles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cr-style { padding: 4px; border-radius: 12px; }
.cr-style i { font-size: 18px; padding: 8px; border-radius: 9px; }
.cr-style i b { height: 5px; margin-top: 8px; }
.cr-style span { font-size: 12px; padding: 5px 2px 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-off .cr-styles { opacity: .4; pointer-events: none; }
.cr-off h3::after { content: " — берём из образца"; font-weight: 400; color: var(--st-sub); }
.cr-inline { display: flex; gap: 8px; align-items: center; }
.cr-inline .st-text { flex: 1; min-width: 0; padding: 8px 10px; }
.cr-cards { grid-template-columns: 1fr 1fr; }
.cr-cards button { padding: 9px 10px; font-size: 13px; }
.cr-adv summary, .cr-slideopts summary { cursor: pointer; font-size: 14px; font-weight: 700; }
.cr-adv[open] { gap: 14px; }
.cr-photo, .cr-add-photo { width: 72px; height: 90px; }
.cr-seg { gap: 2px; }
.cr-seg button { padding: 7px 10px; font-size: 13px; min-width: 32px; }

/* работа: крупный слайд и лента */
.cr-work { display: flex; flex-direction: column; gap: 12px; }
.cr-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.cr-bar-title { display: flex; flex-direction: column; min-width: 0; flex: 1 1 240px; }
.cr-bar-title b { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-bar-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cr-more { position: relative; }
.cr-more summary { list-style: none; }
.cr-more summary::-webkit-details-marker { display: none; }
.cr-more-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 230px; background: var(--st-surface); border: 1px solid var(--st-line); border-radius: 14px; padding: 6px;
  box-shadow: 0 18px 40px -18px rgba(15, 26, 46, .45); display: flex; flex-direction: column; }
.cr-more-menu button { text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 9px; font: inherit; font-size: 14px; color: var(--st-ink); cursor: pointer; }
.cr-more-menu button:hover { background: var(--st-surface-2); }
.cr-stage { min-height: 0; display: grid; grid-template-columns: 44px minmax(0, 420px) 44px; justify-content: center; align-items: center; gap: 16px; padding: 20px; }
.cr-stage .cr-preview { width: 100%; box-shadow: 0 22px 44px -26px rgba(15, 26, 46, .6); }
.cr-nav { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--st-line); background: var(--st-surface); color: var(--st-ink); font-size: 26px; line-height: 1; cursor: pointer; }
.cr-nav:hover { border-color: var(--st-accent); color: var(--st-accent); }
.cr-stage-cap { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.cr-stage-cap b { font-size: 14px; }
.cr-work.running .cr-stage { display: none; }
.cr-strip { justify-content: safe center; padding: 2px 2px 6px; gap: 8px; }
.cr-slide { flex: 0 0 96px; border-radius: 10px; }
.cr-work.running .cr-slide { flex-basis: min(220px, 60vw); }
.cr-work:not(.running) .cr-dots { display: none; }
.cr-slide.busy::after { font-size: 12px; }
.cr-caption { padding: 12px 16px; }
.cr-caption summary { font-size: 14px; }
.cr-editor { display: flex; flex-direction: column; gap: 12px; }
#cr-fields .cr-field { margin: 0; padding: 4px; }
.cr-fontbtn { font-size: 16px; }

/* узкие экраны */
@media (max-width: 1180px) {
  .cr-ws .ws-left { order: 3; }
}
@media (max-width: 900px) {
  .cr-tabs { grid-template-columns: repeat(5, auto) !important; overflow-x: auto; justify-content: start; }
  .cr-tabs a { padding: 10px 12px; font-size: 13px; white-space: nowrap; }
  .cr-intro { grid-template-columns: 1fr; justify-items: center; gap: 20px; text-align: center; }
  .cr-how { align-items: center; }
  .cr-how li { text-align: left; }
  .cr-mock { width: 190px; margin-right: 60px; }
  .cr-mock-1 strong { font-size: 18px; }
  .cr-intro-tx h1 { font-size: 22px; }
  .cr-stage { grid-template-columns: 36px minmax(0, 1fr) 36px; gap: 8px; padding: 12px; }
  .cr-nav { width: 36px; height: 36px; font-size: 22px; }
  .cr-ws .cr-composer { position: static; order: 3; }
  .cr-ws[data-view="new"] .ws-right > * { order: 2; }
}
.cr-ws .ws-empty { visibility: visible; }
.cr-style i { aspect-ratio: 6 / 5; }
/* пока слайды рисуются, редактора нет — центр во всю ширину */
.cr-ws[data-view="work"] .ws-form:has(#cr-editor[hidden]) { grid-template-columns: minmax(0, 1fr); }
/* полотно студии получает order: 1 — здесь порядок по разметке */
.cr-work > * { order: 0 !important; }
.cr-stage .cr-preview { width: min(100%, calc((100vh - 300px) * .8)); min-width: 240px; justify-self: center; }
/* телефон: тема сразу под макетом и липнет к низу, настройки — ниже */
@media (max-width: 900px) {
  .cr-ws .cr-composer { order: 1; position: sticky; bottom: 8px; }
  .cr-ws[data-view="new"] .cr-how { display: none; }
  .cr-ws .cr-canvas { padding: 18px 12px; }
  .cr-mock { width: 150px; margin-right: 52px; }
  .cr-mock-1 strong { font-size: 15px; }
  .cr-mock-s { padding: 12px; }
  .cr-intro-tx p { margin: 0; font-size: 14px; }
}
@media (max-width: 900px) {
  .cr-ws .cr-composer { position: static; }
  .cr-ws .cr-composer .ws-bar-l { display: none; }
  .cr-ws .cr-composer .st-go, .cr-ws .cr-composer .st-go .sc-btn { width: 100%; }
}
@media (max-width: 900px) { .cr-ws .cr-canvas { min-height: 0; } }
.cr-work { min-width: 0; width: 100%; }
.cr-strip { max-width: 100%; }
