/* ===== White Room — переменные темы (клиническая, «белая комната») ===== */
:root{
  --bg: #FFFFFF;
  --bg-soft: #F2F3F4;
  --bg-softer: #E3E6E8;
  --text: #15171B;
  --text-dim: #6B7280;
  --accent: #7C93A6;
  --line: rgba(21,23,27,0.10);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(21,23,27,0.05), 0 1px 1px rgba(21,23,27,0.03);
  --shadow-md: 0 8px 24px rgba(21,23,27,0.09), 0 2px 6px rgba(21,23,27,0.05);
  --shadow-lg: 0 24px 60px rgba(21,23,27,0.16), 0 8px 20px rgba(21,23,27,0.07);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 380ms;
  --font-text: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-title: 'Space Grotesk', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

/* hidden всегда побеждает — иначе любое авторское display: перекрывает атрибут */
[hidden]{ display:none !important; }

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background-color: var(--bg-soft);
  background-image: radial-gradient(circle, rgba(21,23,27,0.06) 1px, transparent 1.4px);
  background-size: 24px 24px;
  color: var(--text);
  font-family: var(--font-text);
  -webkit-font-smoothing: antialiased;
  cursor: default;
}
img{ max-width:100%; display:block; }
button{ font-family: inherit; }
input, textarea, select{ font-family: inherit; }
blockquote{ margin:0; }

::selection{ background: var(--accent); color:#fff; }

/* ===== Экран-заставка с цитатой ===== */
.intro{
  position: fixed; inset:0; z-index: 300;
  background: var(--bg);
  display:flex; align-items:center; justify-content:center;
  padding: 32px;
  transition: opacity 520ms var(--ease), visibility 520ms var(--ease);
}
.intro.is-hidden{ opacity:0; visibility:hidden; pointer-events:none; }
.intro__inner{ max-width: 640px; text-align:center; }
.intro__kicker{
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.28em;
  text-transform: uppercase; color: var(--text-dim); margin: 0 0 30px;
}
.intro__quote{
  font-family: var(--font-title); font-weight:500; font-size: clamp(21px, 3.6vw, 31px);
  line-height:1.45; color: var(--text); margin: 0 0 22px;
}
.intro__quote::after{
  content:'▍'; margin-left:4px; color: var(--accent);
  animation: blink 1.1s step-end infinite;
}
@keyframes blink{ 50%{ opacity:0; } }
.intro__author{
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em;
  color: var(--text-dim); margin: 0 0 40px;
}
.intro__note{
  display:block; font-size: 10px; letter-spacing:0.01em; margin-top:8px; opacity:0.65;
}
.intro__enter{
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  padding: 12px 34px; border-radius: 999px;
  border: 1.5px solid var(--text); background: transparent; color: var(--text);
  cursor:pointer; transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.intro__enter:hover{ background: var(--text); color:#fff; transform: translateY(-1px); }

/* ===== Шапка ===== */
.topbar{
  position: sticky; top:0; z-index: 20;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.topbar__inner{
  max-width: 1180px; margin:0 auto;
  display:flex; align-items:center; gap:20px;
  padding: 14px 24px;
}
.brand{
  display:flex; align-items:center; gap:10px;
  background:none; border:none; cursor:pointer;
  padding:6px 4px; border-radius: 10px;
  transition: opacity var(--dur) var(--ease);
}
.brand:hover{ opacity:0.7; }
.brand__mark{ color: var(--text); flex-shrink:0; }
.brand__text{
  font-family: var(--font-title); font-size: 14px; font-weight:700;
  letter-spacing: 0.16em;
  color: var(--text);
}
.search{
  flex:1; max-width: 420px;
  display:flex; align-items:center; gap:8px;
  background: var(--bg-softer);
  border-radius: 999px;
  padding: 9px 16px;
  color: var(--text-dim);
  transition: box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
.search:focus-within{
  background: #fff;
  box-shadow: 0 0 0 2px var(--accent);
}
.search__icon{ flex-shrink:0; }
.search__input{
  border:none; background:none; outline:none;
  font-size: 14.5px; color: var(--text); width:100%;
}
.search__input::placeholder{ color: var(--text-dim); }
.topbar__actions{ display:flex; align-items:center; gap:6px; }
.iconbtn{
  width:38px; height:38px; border-radius: 12px;
  display:flex; align-items:center; justify-content:center;
  background: transparent; border:1px solid transparent;
  color: var(--text-dim); cursor:pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.iconbtn:hover{ background: var(--bg-softer); color: var(--text); transform: translateY(-1px); }
.iconbtn:active{ transform: translateY(0) scale(0.96); }

/* ===== Подшапка (внутри категории) ===== */
.subbar{
  max-width: 1180px; margin:0 auto;
  padding: 22px 24px 0;
  display:flex; align-items:center; gap:16px;
}
.backbtn{
  display:flex; align-items:center; gap:6px;
  background: #fff; border:1px solid var(--line);
  border-radius: 999px; padding: 8px 16px 8px 12px;
  font-size: 13.5px; font-weight:600; color: var(--text-dim);
  cursor:pointer; box-shadow: var(--shadow-sm);
  transition: all var(--dur) var(--ease);
}
.backbtn:hover{ color: var(--text); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.subbar__title{
  font-family: var(--font-title); font-weight:600; font-style: normal;
  letter-spacing: -0.01em;
  font-size: 24px; margin:0; color: var(--text);
}

/* ===== Основной контент ===== */
.main{ max-width: 1180px; margin: 0 auto; padding: 8px 24px 120px; }
.view__head{ padding: 30px 4px 10px; }
.view__title{
  font-family: var(--font-title); font-style: normal; font-weight: 600;
  letter-spacing: -0.01em;
  font-size: clamp(34px, 6vw, 52px); margin: 0 0 10px;
  color: var(--text);
}
.view__subtitle{
  margin:0; color: var(--text-dim); font-size: 12px;
  font-family: var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase;
}

.grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  padding: 24px 4px 0;
}

.empty{
  text-align:center; padding: 80px 20px; color: var(--text-dim);
  font-size: 15px;
}

/* ===== Карточки ===== */
.card{
  position:relative;
  background:#fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  cursor:pointer;
  overflow:hidden;
  opacity:0; transform: translateY(16px);
  animation: cardIn var(--dur) var(--ease) forwards;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  border: 1px solid var(--line);
}
.card:hover{
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-lg);
}
.card.dragging{ opacity:0.35; }
.card.drag-over{ outline: 2px dashed var(--accent); outline-offset: -8px; }

@keyframes cardIn{
  from{ opacity:0; transform: translateY(16px); }
  to{ opacity:1; transform: translateY(0); }
}

.card__accent{ height:4px; width:100%; background:transparent; }

.card__cover{
  width:100%; aspect-ratio: 4/3; object-fit: cover;
  background: linear-gradient(135deg, var(--bg-softer), #fff);
}
.card__cover-fallback{
  width:100%; aspect-ratio: 4/3;
  display:flex; align-items:center; justify-content:center;
  background: linear-gradient(135deg, var(--bg-softer), #fff);
  color: var(--accent);
  font-family: var(--font-title); font-style: normal; font-weight:700; font-size: 34px;
}
.card__body{ padding: 16px 18px 18px; }
.card__title{
  margin:0 0 4px; font-size: 16px; font-weight:700;
  color: var(--text);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.card__meta{
  margin:0; font-size: 12.5px; color: var(--text-dim);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  display:flex; align-items:center;
}
.card--category .card__body{ padding: 22px 20px; }
.card--category .card__title{ font-size: 18px; white-space: normal; display:flex; align-items:center; }
.card__count{
  display:inline-flex; align-items:center; gap:6px;
  margin-top:8px; font-size:12.5px; color: var(--text-dim);
  font-family: var(--font-mono);
}

.color-dot{
  display:inline-block; flex-shrink:0;
  width:8px; height:8px; border-radius:50%;
  background: var(--dot-color, transparent);
  margin-right:7px;
}

.card__actions{
  position:absolute; top:10px; right:10px;
  display:flex; gap:6px;
  opacity:0; transform: translateY(-4px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.card:hover .card__actions, .card:focus-within .card__actions{
  opacity:1; transform: translateY(0);
}
.card__action{
  width:30px; height:30px; border-radius: 10px;
  display:flex; align-items:center; justify-content:center;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  color: var(--text-dim);
  cursor:pointer;
  transition: all var(--dur) var(--ease);
}
.card__action:hover{ color: var(--text); background:#fff; transform: scale(1.08); }
.card__action--danger:hover{ color:#b3423a; }
.card__drag{
  position:absolute; top:10px; left:10px;
  width:30px; height:30px; border-radius:10px;
  display:flex; align-items:center; justify-content:center;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--line);
  color: var(--text-dim);
  opacity:0; transition: opacity var(--dur) var(--ease);
  cursor: grab;
}
.card:hover .card__drag{ opacity:1; }

/* ===== Плавающая кнопка ===== */
.fab{
  position: fixed; right: 28px; bottom: 28px; z-index: 15;
  width:58px; height:58px; border-radius:50%;
  background: var(--text); color:#fff;
  display:flex; align-items:center; justify-content:center;
  border:none; cursor:pointer;
  box-shadow: var(--shadow-lg);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.fab:hover{ transform: scale(1.08) rotate(90deg); background:#000; }
.fab:active{ transform: scale(0.96) rotate(90deg); }

/* ===== Тост сохранения ===== */
.toast{
  position: fixed; left: 50%; bottom: 28px; z-index: 50;
  transform: translate(-50%, 14px);
  background: var(--text); color:#fff;
  padding: 9px 18px; border-radius: 999px;
  font-size: 13px; font-weight:600;
  opacity:0; pointer-events:none;
  box-shadow: var(--shadow-lg);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast.visible{ opacity:1; transform: translate(-50%, 0); }

/* ===== Модалки ===== */
.modal-backdrop{
  position: fixed; inset:0; z-index: 100;
  background: rgba(21,23,27,0.4);
  backdrop-filter: blur(3px);
  display:flex; align-items:center; justify-content:center;
  padding: 24px;
  opacity:0; animation: backdropIn var(--dur) var(--ease) forwards;
}
@keyframes backdropIn{ from{opacity:0;} to{opacity:1;} }

.modal{
  background:#fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px;
  width:100%;
  max-height: 88vh;
  overflow-y:auto;
  position:relative;
  transform: scale(0.96);
  opacity:0;
  animation: modalIn var(--dur) var(--ease) forwards;
}
@keyframes modalIn{ from{ opacity:0; transform: scale(0.96);} to{opacity:1; transform: scale(1);} }
.modal--xs{ max-width: 360px; }
.modal--sm{ max-width: 420px; }
.modal--md{ max-width: 580px; }
.modal--lg{ max-width: 760px; padding:0; }

.modal__close{
  position:absolute; top:16px; right:16px;
  width:32px; height:32px; border-radius:10px;
  display:flex; align-items:center; justify-content:center;
  background: var(--bg-softer); border:none; color: var(--text-dim);
  cursor:pointer; z-index:5;
  transition: all var(--dur) var(--ease);
}
.modal__close:hover{ color: var(--text); transform: rotate(90deg); }
.modal--lg .modal__close{ background: rgba(255,255,255,0.85); }

.modal__title{
  font-family: var(--font-title); font-style: normal; font-weight:600;
  letter-spacing: -0.01em;
  font-size: 22px; margin: 0 0 20px; padding-right: 30px;
  color: var(--text);
}

/* ===== Формы ===== */
.form{ display:flex; flex-direction:column; gap:16px; }
.field{ display:flex; flex-direction:column; gap:7px; }
.field-row{ display:flex; gap:16px; }
.field-row .field{ flex:1; min-width:0; }
.field__label{ font-size: 13px; font-weight:600; color: var(--text-dim); }
.field__input, .field__textarea{
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px; color: var(--text);
  background: var(--bg-soft);
  outline:none; resize: vertical;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.field__select{ cursor:pointer; }
.field__textarea{ min-height: 140px; line-height:1.55; font-family: var(--font-text); white-space: pre-wrap; }
.field__input:focus, .field__textarea:focus{
  border-color: var(--accent); background:#fff;
}
.form__actions{ display:flex; justify-content:flex-end; gap:10px; margin-top:4px; }

.btn{
  border:none; border-radius: 999px; padding: 11px 22px;
  font-size: 14px; font-weight:700; cursor:pointer;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn--primary{ background: var(--text); color:#fff; }
.btn--primary:hover{ background:#000; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn--ghost{ background: var(--bg-softer); color: var(--text-dim); }
.btn--ghost:hover{ background: var(--line); color: var(--text); }
.btn--danger{ background: #C1483F; color:#fff; }
.btn--danger:hover{ background: #a83c34; transform: translateY(-1px); }

/* ===== Цветовые метки (свотчи) ===== */
.swatches{ display:flex; flex-wrap:wrap; gap:9px; padding-top:2px; }
.swatch{
  width:26px; height:26px; border-radius:50%; padding:0; border:none;
  background: var(--swatch-color, transparent);
  box-shadow: 0 0 0 1.5px var(--line);
  cursor:pointer;
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.swatch:hover{ transform: scale(1.14); }
.swatch.is-selected{ box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--swatch-color, var(--text-dim)); }
.swatch--none{ background: repeating-linear-gradient(45deg, #d7dadd, #d7dadd 3px, #fff 3px, #fff 6px); }
.swatch--none.is-selected{ box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--text-dim); }

/* ===== Дропзона обложки ===== */
.dropzone{
  position: relative;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  min-height: 180px;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; overflow:hidden;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.dropzone:hover, .dropzone:focus-visible{ border-color: var(--accent); background:#fff; }
.dropzone.drag-active{ border-color: var(--accent); background: #EFF3F6; }
.dropzone__preview{
  width:100%; height: 100%; max-height: 260px; object-fit: cover;
  position:absolute; inset:0;
}
.dropzone__hint{
  display:flex; flex-direction:column; align-items:center; gap:10px;
  color: var(--text-dim); font-size: 13px; text-align:center; padding: 20px;
}
.dropzone__remove{
  position:absolute; top:10px; right:10px; z-index:2;
  width:28px; height:28px; border-radius:9px;
  background: rgba(21,23,27,0.6); color:#fff; border:none;
  display:flex; align-items:center; justify-content:center; cursor:pointer;
  backdrop-filter: blur(4px);
  transition: background var(--dur) var(--ease);
}
.dropzone__remove:hover{ background: rgba(21,23,27,0.85); }

/* ===== Редактор текста программы ===== */
.editor{
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  overflow:hidden;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.editor:focus-within{ border-color: var(--accent); background:#fff; }
.editor__toolbar{
  display:flex; align-items:center; gap:2px;
  padding:6px; border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.5);
}
.editor__btn{
  width:28px; height:28px; border-radius:7px; border:none;
  background:transparent; color: var(--text-dim); cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  font-size:13px; font-weight:700; line-height:1;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.editor__btn:hover{ background: var(--bg-softer); color: var(--text); }
.editor__btn.is-active{ background: var(--text); color:#fff; }
.editor__sep{ width:1px; height:18px; background: var(--line); margin:0 4px; }
.editor__area{
  min-height:180px; max-height:380px; overflow-y:auto;
  padding:14px 16px; font-size:15px; line-height:1.6; color: var(--text);
  outline:none;
}
.editor__area.is-empty::before{
  content: attr(data-placeholder);
  color: var(--text-dim);
  pointer-events:none;
}
.editor__area p, .editor__area div{ margin:0 0 10px; }
.editor__area p:last-child, .editor__area div:last-child{ margin-bottom:0; }
.editor__area h3{
  font-family: var(--font-title); font-weight:600; font-size:17px;
  margin:14px 0 8px;
}
.editor__area ul{ margin:0 0 10px; padding-left:20px; }
.editor__area img{
  max-width:100%; border-radius:10px; margin:10px 0; display:block;
}

/* ===== Просмотр программы ===== */
.view-cover{
  width:100%; max-height: 380px; object-fit: cover;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.view-body{ padding: 28px 32px 32px; }
.view-text{
  line-height:1.7; color: var(--text);
  font-size: 15.5px; margin:0;
}
.view-text p, .view-text div{ margin:0 0 14px; }
.view-text p:last-child, .view-text div:last-child{ margin-bottom:0; }
.view-text h3{ font-family: var(--font-title); font-weight:600; font-size:19px; margin:20px 0 10px; }
.view-text ul{ margin:0 0 14px; padding-left:22px; }
.view-text img{ max-width:100%; border-radius: var(--radius-sm); margin:14px 0; display:block; }
.confirm__text{ color: var(--text-dim); font-size: 14px; margin: 0 0 20px; }

/* ===== Скелетон загрузки ===== */
.skeleton-card{
  background: linear-gradient(100deg, var(--bg-softer) 30%, #fff 45%, var(--bg-softer) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: var(--radius-lg);
  aspect-ratio: 3/2.4;
}
@keyframes shimmer{ from{ background-position: 200% 0; } to{ background-position: -200% 0; } }

/* ===== Адаптив ===== */
@media (max-width: 600px){
  .topbar__inner{ padding: 12px 16px; gap: 12px; }
  .brand__text{ display:none; }
  .subbar{ padding: 16px 16px 0; }
  .main{ padding: 8px 16px 120px; }
  .grid{ grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .fab{ right: 18px; bottom: 18px; width:54px; height:54px; }
  .modal{ padding: 20px; }
  .view-body{ padding: 22px 20px 26px; }
  .field-row{ flex-direction:column; gap:16px; }
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
