/* Форма добавления / редактирования карточки (общая для сайта и админки).
   Цвета берутся из переменных --cf-* (задаются в style.css и admin.css). */
[hidden] { display: none !important; }
.cf { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; margin-top: 20px; align-items: start; }
@media (min-width: 1000px) { .cf { grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; } }
.cf-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* Шаги-прогресс */
.cf-progress { grid-column: 1 / -1; list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 0; counter-reset: s; }
.cf-progress li { display: flex; align-items: center; gap: 8px; color: var(--cf-muted); font-size: 14px; font-weight: 600; flex: 1; min-width: 0; }
.cf-progress li:not(:last-child)::after { content: ""; flex: 1; height: 3px; border-radius: 3px; margin: 0 10px; background: linear-gradient(to right, var(--cf-accent) 50%, var(--cf-line2) 50%) right / 200% 100% no-repeat; transition: background-position .5s ease; }
.cf-progress li.done:not(:last-child)::after { background-position: left; }
.cf-progress li:last-child { flex: none; }
.cf-progress-dot { position: relative; width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--cf-card); border: 2px solid var(--cf-line2); color: var(--cf-muted); transition: background-color .3s, border-color .3s, color .3s, transform .3s; }
.cf-progress-dot em { font-style: normal; font-size: 13px; }
.cf-progress-dot .ic { position: absolute; opacity: 0; transform: scale(.4); transition: opacity .25s, transform .3s cubic-bezier(.3, 1.6, .5, 1); }
.cf-progress li.on { color: var(--cf-ink); }
.cf-progress li.on .cf-progress-dot { border-color: var(--cf-accent); color: var(--cf-accent-text); }
.cf-progress li.done .cf-progress-dot { background: var(--cf-accent); border-color: var(--cf-accent); color: var(--cf-on-accent); }
.cf-progress li.done .cf-progress-dot em { opacity: 0; }
.cf-progress li.done .cf-progress-dot .ic { opacity: 1; transform: none; }
@media (max-width: 520px) { .cf-progress li > span:last-child { display: none; } .cf-progress li.on > span:last-child { display: inline; } }

/* Блоки-шаги */
.cf-step { position: relative; background: var(--cf-card); border: 1px solid var(--cf-line); border-radius: calc(var(--r) + 8px); padding: 20px; display: flex; flex-direction: column; gap: 16px; min-width: 0; transition: border-color .3s, box-shadow .3s; }
@media (min-width: 700px) { .cf-step { padding: 26px 28px; } }
.cf-step.is-active { border-color: var(--cf-accent-line); box-shadow: 0 0 0 4px var(--cf-accent-soft), 0 18px 40px -24px rgba(23, 32, 51, .35); }
.cf-step-h { display: flex; gap: 14px; align-items: flex-start; }
.cf-step-h h2 { font-size: 19px; line-height: 1.25; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.cf-step-h p { margin: 3px 0 0; font-size: 14.5px; color: var(--cf-muted); }
.cf-num { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--cf-accent); color: var(--cf-on-accent); font-weight: 800; font-size: 15px; box-shadow: 0 6px 16px -6px var(--cf-accent); }

/* Поля */
.cf .f-row { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.cf .f-row > label { font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cf .f-hint { margin: 0; font-size: 13.5px; color: var(--cf-muted); line-height: 1.45; }
.cf .f-err { margin: 0; font-size: 13.5px; color: var(--cf-red); font-weight: 500; }
.f-count { font-size: 12.5px; color: var(--cf-muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.cf input:not([type=checkbox]):not([type=radio]):not([type=file]), .cf select, .cf textarea {
  width: 100%; height: 52px; padding: 0 16px; border-radius: calc(var(--r) - 2px); border: 1.5px solid var(--cf-line2);
  background: var(--cf-input); color: var(--cf-ink); font-size: 16px; line-height: 1.3; margin: 0; transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.cf textarea { height: auto; min-height: 160px; padding: 14px 16px; resize: vertical; line-height: 1.55; }
.cf select { appearance: none; -webkit-appearance: none; padding-right: 44px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--cf-muted) 50%), linear-gradient(135deg, var(--cf-muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 23px, calc(100% - 17px) 23px; background-size: 5px 5px; background-repeat: no-repeat; }
.cf input:hover, .cf select:hover, .cf textarea:hover { border-color: var(--cf-accent-line); }
.cf input:focus, .cf select:focus, .cf textarea:focus { outline: none; border-color: var(--cf-accent); box-shadow: 0 0 0 4px var(--cf-accent-soft); background: var(--cf-card); }
.cf input::placeholder, .cf textarea::placeholder { color: var(--cf-muted); opacity: .75; }
.cf .has-err input:not([type=checkbox]):not([type=radio]):not([type=file]), .cf .has-err select, .cf .has-err textarea { border-color: var(--cf-red); background: color-mix(in srgb, var(--cf-red) 5%, var(--cf-input)); }
.cf .has-err { animation: cf-shake .45s ease 1; }
@keyframes cf-shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* Плитки типа */
.cf-tiles { display: grid; gap: 10px; }
.cf-tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cf-tile { position: relative; cursor: pointer; display: block; }
.cf-tile input { position: absolute; opacity: 0; pointer-events: none; }
.cf-tile-in { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; height: 100%; padding: 14px; border-radius: calc(var(--r) + 2px); border: 1.5px solid var(--cf-line2); background: var(--cf-input); transition: border-color .2s, background-color .2s, transform .2s, box-shadow .2s; }
.cf-tile-in b { font-size: 15.5px; color: var(--cf-ink); }
.cf-tile-in small { font-size: 12.5px; color: var(--cf-muted); line-height: 1.35; }
.cf-tile-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--cf-panel); color: var(--cf-muted); margin-bottom: 8px; transition: background-color .2s, color .2s, transform .35s cubic-bezier(.3, 1.6, .5, 1); }
.cf-tile:hover .cf-tile-in { border-color: var(--cf-accent-line); transform: translateY(-2px); }
.cf-tile input:checked + .cf-tile-in { border-color: var(--cf-accent); background: var(--cf-accent-soft); box-shadow: 0 10px 24px -16px var(--cf-accent); }
.cf-tile input:checked + .cf-tile-in .cf-tile-ic { background: var(--cf-accent); color: var(--cf-on-accent); transform: rotate(-8deg) scale(1.06); }
.cf-tile input:focus-visible + .cf-tile-in { outline: 2px solid var(--cf-accent); outline-offset: 2px; }
@media (max-width: 520px) { .cf-tile-in small { display: none; } .cf-tile-in { align-items: center; text-align: center; padding: 12px 6px; } .cf-tile-ic { margin-bottom: 4px; } }

/* Переключатель «публичный / закрытый» */
.cf-switch { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 999px; background: var(--cf-panel); }
.cf-sw { position: relative; z-index: 1; cursor: pointer; }
.cf-sw input { position: absolute; opacity: 0; pointer-events: none; }
.cf-sw > span { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 46px; padding: 6px 10px; border-radius: 999px; font-weight: 600; font-size: 14.5px; color: var(--cf-muted); transition: color .25s; text-align: center; line-height: 1.2; flex-wrap: wrap; }
.cf-sw small { font-weight: 500; font-size: 12px; opacity: .8; }
.cf-sw input:checked + span { color: var(--cf-ink); }
.cf-sw input:focus-visible + span { outline: 2px solid var(--cf-accent); outline-offset: 2px; }
.cf-sw-thumb { position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 999px; background: var(--cf-card); box-shadow: 0 2px 8px rgba(23, 32, 51, .14); transition: transform .35s cubic-bezier(.3, 1.3, .5, 1); }
.cf-switch:has(.cf-sw:nth-of-type(2) input:checked) .cf-sw-thumb, .cf-switch.is-right .cf-sw-thumb { transform: translateX(100%); }
@media (max-width: 520px) { .cf-sw small { display: none; } }

/* Появление блока при переключении */
.cf-reveal:not([hidden]) { animation: cf-in .35s ease both; }
@keyframes cf-in { from { opacity: 0; transform: translateY(6px); } }

/* Ссылка + кнопка */
.cf-fetch { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
@media (min-width: 560px) { .cf-fetch { grid-template-columns: minmax(0, 1fr) auto; } }
.cf-fetch-solo { grid-template-columns: minmax(0, 1fr) !important; }
.cf .cf-fetch input:not([type=checkbox]):not([type=radio]):not([type=file]) { padding-left: 46px; }
.cf-input-ic { position: absolute; left: 16px; top: 17px; color: var(--cf-muted); pointer-events: none; }
.cf-fetch .btn { height: 52px; min-height: 52px; padding: 0 22px; }
.cf-spin { display: none; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: cf-rot .7s linear infinite; }
.is-busy .cf-spin { display: block; }
.is-busy .cf-spin + .ic { display: none; }
@keyframes cf-rot { to { transform: rotate(360deg); } }
.cf-ok { color: var(--cf-ok, #18A058) !important; }
.cf-filled { animation: cf-flash 1.2s ease 1; }
@keyframes cf-flash { 0% { box-shadow: 0 0 0 0 var(--cf-accent-soft); background: var(--cf-accent-soft); } 100% { box-shadow: 0 0 0 0 transparent; } }

/* Фото */
.cf-photo { display: flex; gap: 18px; align-items: center; }
.cf-drop { position: relative; width: 108px; height: 108px; flex: none; border-radius: 50%; border: 2px dashed var(--cf-line2); background: var(--cf-panel); display: grid; place-items: center; overflow: hidden; cursor: pointer; transition: border-color .2s, transform .25s, box-shadow .25s; }
.cf-drop:hover, .cf-drop.is-over { border-color: var(--cf-accent); transform: scale(1.04); box-shadow: 0 0 0 6px var(--cf-accent-soft); }
.cf-drop img { width: 100%; height: 100%; object-fit: cover; animation: cf-pop .4s cubic-bezier(.3, 1.5, .5, 1) both; }
.cf-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.cf-drop-empty { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--cf-muted); font-size: 13px; font-weight: 600; }
.cf-drop:hover .cf-drop-empty { color: var(--cf-accent-text); }
.cf-photo-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cf-photo-info b { font-size: 15px; }
@keyframes cf-pop { from { transform: scale(.6); opacity: 0; } }

/* Индикатор длины описания */
.cf-meter { height: 4px; border-radius: 4px; background: var(--cf-panel); overflow: hidden; }
.cf-meter i { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--cf-red); transition: width .25s ease, background-color .25s; }
.cf-meter i.ok { background: var(--cf-ok, #18A058); }

.cf-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
@media (min-width: 600px) { .cf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cf-span2 { grid-column: 1 / -1; } }
.cf .check { display: flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }
.cf .check input { width: 18px; height: 18px; margin: 0; accent-color: var(--cf-accent); }

/* Отправка */
.cf-submit { display: flex; flex-direction: column; gap: 10px; position: sticky; bottom: var(--cf-bottom, 0px); z-index: 5; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg, transparent) 70%, transparent); }
.cf-submit .f-hint { text-align: center; }
.cf-go { position: relative; overflow: hidden; min-height: 58px; font-size: 17px; box-shadow: 0 14px 30px -14px var(--cf-accent); }
.cf-go .ic { transition: transform .4s cubic-bezier(.3, 1.4, .5, 1); }
.cf-go:hover .ic { transform: translate(4px, -4px) rotate(-8deg); }
.cf-go::after { content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 30%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .35), transparent); transform: skewX(-20deg); animation: cf-sheen 3.2s ease-in-out infinite; }
@keyframes cf-sheen { 0%, 60% { left: -40%; } 100% { left: 130%; } }

/* Предпросмотр */
.cf-side { display: none; }
@media (min-width: 1000px) { .cf-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 84px; } }
.cf-side-t { margin: 0; font-size: 13.5px; color: var(--cf-muted); font-weight: 600; }
.cf-preview { pointer-events: none; background: var(--cf-card); border: 1px solid var(--cf-line); border-radius: calc(var(--r) + 8px); padding: 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 40px -26px rgba(23, 32, 51, .4); transition: transform .3s; }
.cf-preview.is-pulse { animation: cf-bump .45s ease 1; }
@keyframes cf-bump { 40% { transform: scale(1.02); } }
.cf-pv-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cf-pv-ava { width: 56px; height: 56px; flex: none; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: linear-gradient(145deg, hsl(var(--h, 220) 75% 64%), hsl(calc(var(--h, 220) + 25) 70% 50%)); color: #fff; font-weight: 700; font-size: 22px; box-shadow: 0 0 0 3px var(--cf-card), 0 0 0 5px var(--cf-accent); }
.cf-pv-ava img { width: 100%; height: 100%; object-fit: cover; }
.cf-pv-head { display: flex; flex-direction: column; min-width: 0; }
.cf-pv-head b { font-size: 16px; color: var(--cf-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-pv-head span { font-size: 13.5px; color: var(--cf-accent-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-pv-desc { margin: 0; font-size: 14px; color: var(--cf-muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; min-height: 3em; }
.cf-pv-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--cf-muted); }
.cf-pv-foot b { color: var(--cf-ink); font-size: 14px; }
.cf-pv-cat { background: var(--cf-panel); border-radius: 999px; padding: 3px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.cf-tips { list-style: none; margin: 0; padding: 16px; display: flex; flex-direction: column; gap: 10px; border: 1px dashed var(--cf-line2); border-radius: calc(var(--r) + 4px); font-size: 14px; color: var(--cf-muted); }
.cf-tips li { display: flex; gap: 8px; align-items: flex-start; }
.cf-tips .ic { color: var(--cf-accent-text); margin-top: 2px; }

/* Появление блоков формы */
.js .cf-step, .js .cf-side { animation: cf-rise .5s cubic-bezier(.2, .8, .2, 1) both; }
.js .cf-step:nth-child(2) { animation-delay: .08s; }
.js .cf-step:nth-child(3) { animation-delay: .16s; }
.js .cf-side { animation-delay: .2s; }
@keyframes cf-rise { from { opacity: 0; transform: translateY(14px); } }

@media (prefers-reduced-motion: reduce) {
  .cf *, .cf *::before, .cf *::after, .js .cf-step, .js .cf-side { animation: none !important; transition: none !important; }
}
@media (max-width: 999px) { .cf-submit { position: static; background: none; padding-top: 4px; } }
