* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: #fafaf7;
  color: #1a1a1a;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
img { max-width: 100%; display: block; }

/* === NAV (из других страниц промптбука) === */
.nav {
  padding: 18px 6vw; display: flex; justify-content: space-between; align-items: center;
  background: rgba(250,250,247,0.92); backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  position: sticky; top: 0; z-index: 100;
}
.nav-brand {
  font: 600 13px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.15em; text-transform: uppercase; text-decoration: none; color: inherit;
}
.nav-brand .star { color: #c97c50; }
.nav-cta {
  font: 600 12px/1 'JetBrains Mono'; letter-spacing: 0.15em;
  text-transform: uppercase; text-decoration: none; color: inherit;
  padding: 10px 18px; border: 1px solid #1a1a1a; border-radius: 100px;
}
.nav-cta:hover { background: #1a1a1a; color: white; }

/* === STUDIO === */
.studio { max-width: 1280px; margin: 0 auto; padding: 24px 6vw 60px; }

.label {
  font: 600 11px/1 'JetBrains Mono';
  letter-spacing: 0.2em; text-transform: uppercase;
  color: rgba(0,0,0,0.5);
}
.hint { font: 400 11px/1.4 'JetBrains Mono'; color: rgba(0,0,0,0.4); letter-spacing: 0.05em; }

/* Sets carousel */
.sets-row { margin-bottom: 18px; }
.sets-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.sets {
  display: flex; gap: 12px;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  padding-bottom: 6px;
  scrollbar-width: thin;
}
.sets::-webkit-scrollbar { height: 4px; }
.sets::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 2px; }
.set-card {
  min-width: 200px; max-width: 200px; flex-shrink: 0;
  background: #fff; border: 2px solid transparent; border-radius: 8px;
  padding: 10px; cursor: pointer; transition: border-color 0.15s, transform 0.15s;
  scroll-snap-align: start;
}
.set-card:hover { transform: translateY(-2px); }
.set-card.selected { border-color: #c97c50; background: #fff8f3; }
.set-card.disabled { opacity: 0.45; cursor: not-allowed; }
.set-card.coming-soon { opacity: 0.55; cursor: not-allowed; }
.set-card.coming-soon:hover { transform: none; }
.set-card .soon-badge {
  position: absolute; top: 6px; left: 6px;
  font: 600 9px/1 'JetBrains Mono'; letter-spacing: 0.15em; text-transform: uppercase;
  padding: 4px 8px; background: rgba(255,255,255,0.92); color: #1a1a1a;
  border-radius: 100px;
}
.set-card .cover {
  width: 100%; aspect-ratio: 4/3; border-radius: 5px;
  background: linear-gradient(135deg, #c97c50, #8a4a2c);
  background-size: cover; background-position: center;
  position: relative;
}
.set-card .frames-badge {
  position: absolute; bottom: 6px; right: 6px;
  font: 600 9px/1 'JetBrains Mono'; letter-spacing: 0.1em;
  padding: 3px 7px; background: rgba(0,0,0,0.6); color: white; border-radius: 100px;
}
.set-card .name {
  font: italic 600 16px/1.2 'Playfair Display';
  margin-top: 8px;
}
.set-card.selected .name { color: #c97c50; }
.set-card .sub {
  font: 400 11px/1.3 'Inter';
  color: rgba(0,0,0,0.5); margin-top: 2px;
}
.set-card .muse {
  font: 500 10px/1.2 'JetBrains Mono';
  letter-spacing: 0.05em;
  color: rgba(0,0,0,0.4);
  margin-top: 4px;
}

/* Layout cols */
.cols { display: grid; grid-template-columns: 360px 1fr; gap: 18px; }
.block { background: #fff; border-radius: 8px; padding: 18px; }

/* Photo grid (4 slots default, 2x2) */
.photo-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin: 12px 0;
}
.photo-slot {
  aspect-ratio: 1/1; border-radius: 5px;
  background: #fafaf7; border: 2px dashed rgba(0,0,0,0.18);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative; overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}
.photo-slot:hover, .photo-slot.dragover { border-color: #c97c50; background: #fff8f3; }
.photo-slot.filled { border-style: solid; border-color: rgba(0,0,0,0.06); padding: 0; }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.photo-slot .plus { font: 300 28px/1 'Inter'; color: rgba(0,0,0,0.3); }
.photo-slot .remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: white;
  display: none; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1;
}
.photo-slot.filled .remove { display: flex; }
.add-slot {
  aspect-ratio: 1/1; border: 1px dashed rgba(0,0,0,0.18); border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: rgba(0,0,0,0.4); font: 600 10px/1 'JetBrains Mono';
  letter-spacing: 0.15em; text-transform: uppercase;
}
.add-slot:hover { background: #fff8f3; color: #c97c50; }

.btn-generate {
  width: 100%; margin-top: 14px; padding: 14px;
  background: #c97c50; color: white;
  font: 600 13px/1 'JetBrains Mono'; letter-spacing: 0.2em; text-transform: uppercase;
  border-radius: 100px; transition: background 0.15s, opacity 0.15s;
}
.btn-generate:hover { background: #b56b40; }
.btn-generate:disabled { background: rgba(0,0,0,0.1); color: rgba(0,0,0,0.4); cursor: not-allowed; }
.cost-hint { text-align: center; font: 400 11px/1.4 'JetBrains Mono'; color: rgba(0,0,0,0.4); margin-top: 8px; }

/* Model select под Generate */
.model-select-wrap {
  display: flex; flex-direction: column; gap: 5px;
  margin-top: 12px;
}
.model-select-wrap .label { font-size: 10px; }
.model-select {
  appearance: none; -webkit-appearance: none;
  width: 100%; padding: 9px 32px 9px 12px;
  background: #fff;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1L6 6L11 1' stroke='%23999' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  border: 1px solid rgba(0,0,0,0.1); border-radius: 6px;
  font: 500 12px/1.2 'JetBrains Mono', monospace;
  color: #1a1a1a; cursor: pointer;
  transition: border-color 0.15s;
}
.model-select:hover { border-color: #c97c50; }
.model-select:focus { outline: none; border-color: #c97c50; box-shadow: 0 0 0 3px rgba(201,124,80,0.15); }
.model-select:disabled { opacity: 0.5; cursor: not-allowed; }

/* Result grid */
.result-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.toolbar { display: flex; gap: 6px; }
.ico {
  width: 32px; height: 32px; border-radius: 5px;
  background: #fff; border: 1px solid rgba(0,0,0,0.1);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; color: rgba(0,0,0,0.6);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ico:hover { border-color: #c97c50; color: #c97c50; }
.ico.on { background: #c97c50; color: white; border-color: #c97c50; }
.ico:disabled { opacity: 0.4; cursor: not-allowed; }
.col-right { background: #1a1a1a; color: #e8e8e8; border-radius: 8px; padding: 18px; position: relative; min-height: 600px; }
.col-right .label { color: rgba(255,255,255,0.55); }
.col-right .ico { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); color: rgba(255,255,255,0.7); }
.col-right .ico.on { background: #c97c50; color: white; border-color: #c97c50; }
.result-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
}
.frame-slot {
  aspect-ratio: 3/4; border-radius: 5px;
  background: linear-gradient(135deg, #2a2a2a, #1a1a1a);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.35);
  font: italic 800 36px/1 'Playfair Display';
  cursor: pointer; position: relative; overflow: hidden;
}
.frame-slot.loading {
  background: linear-gradient(90deg, #1f1f1f, #2f2f2f, #1f1f1f);
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
}
.frame-slot.error { color: #e8745a; }
.frame-slot.ready img { width: 100%; height: 100%; object-fit: cover; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Lightbox */
.lightbox {
  position: absolute; inset: 0; background: rgba(0,0,0,0.95);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 30px 60px 80px;
}
.lightbox[hidden] { display: none; }
.lb-image { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.lb-close, .lb-arrow {
  position: absolute; width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,0.1); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; transition: background 0.15s;
}
.lb-close:hover, .lb-arrow:hover { background: rgba(255,255,255,0.25); }
.lb-close { top: 12px; right: 12px; }
.lb-prev { top: 50%; left: 12px; transform: translateY(-50%); }
.lb-next { top: 50%; right: 12px; transform: translateY(-50%); }
.lb-counter {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  font: 600 11px/1 'JetBrains Mono'; letter-spacing: 0.2em; color: rgba(255,255,255,0.7);
  padding: 6px 14px; background: rgba(0,0,0,0.4); border-radius: 100px;
}
.lb-strip {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px;
}
.lb-strip .thumb {
  width: 38px; aspect-ratio: 3/4; border-radius: 3px;
  background: rgba(255,255,255,0.1); cursor: pointer; opacity: 0.5;
  overflow: hidden;
}
.lb-strip .thumb img { width: 100%; height: 100%; object-fit: cover; }
.lb-strip .thumb.active { opacity: 1; outline: 2px solid #c97c50; outline-offset: 1px; }

/* === MOBILE === */
@media (max-width: 767px) {
  .studio { padding: 16px 4vw 100px; }
  .cols { grid-template-columns: 1fr; gap: 12px; }
  .col-right { min-height: 0; padding: 12px; }

  /* Sets — крупные карточки, 1.7 видно */
  .set-card { min-width: 56vw; max-width: 56vw; }
  .set-card .cover { aspect-ratio: 4/3; }

  /* Фото — 4 в строку */
  .photo-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .add-slot { display: none; } /* На мобилке +Add возможен через long-press, пока — только 4 слота. См. Task 10 */

  /* Generate — sticky к низу */
  .btn-generate {
    position: sticky; bottom: 12px; z-index: 10;
    box-shadow: 0 10px 24px -8px rgba(201,124,80,0.5);
  }

  /* Lightbox — fullscreen */
  .lightbox {
    position: fixed; inset: 0; border-radius: 0;
    padding: 60px 16px 90px;
  }
}

/* Очень мелкие — 2 в строку для photo-grid если меньше 320px */
@media (max-width: 359px) {
  .photo-grid { grid-template-columns: 1fr 1fr; }
}

/* === V2 layout toggle ============================================== */
.home-view[hidden], .workspace[hidden] { display: none !important; }
.workspace-head {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 0 20px;
  font-size: 13px; color: var(--ink-soft, #5a4a3a);
}
.link-back {
  background: none; border: none; color: inherit;
  cursor: pointer; font-size: 13px; padding: 0;
}
.link-back:hover { text-decoration: underline; }
.workspace-template { font-weight: 600; color: var(--ink, #1a1410); }
.workspace-id { font-family: monospace; color: var(--ink-soft, #5a4a3a); font-size: 11px; }
.nav-right { display: flex; gap: 12px; align-items: center; }
.my-sets-btn {
  background: #fff; border: 1px solid #e8dccb;
  border-radius: 8px; padding: 6px 12px;
  font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.my-sets-btn .badge {
  background: #1a1410; color: #fff;
  padding: 1px 7px; border-radius: 8px;
  font-size: 10px; font-weight: 700;
}

/* === Slot states (variant B) ======================================= */
.frame-slot {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: 8px;
  overflow: hidden;
  background: #f5ecdc;
  cursor: pointer;
}
.frame-slot.empty {
  border: 1.5px dashed #c9b89a;
  display: flex; align-items: center; justify-content: center;
  color: #b8a07e; font-size: 18px; font-weight: 600;
}
.frame-slot.loading {
  background: linear-gradient(135deg, #2a1810, #4a3525);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 6px;
}
.frame-slot.loading .spinner-big {
  width: 32px; height: 32px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #f5c842;
  border-radius: 50%;
  animation: studio-spin 0.8s linear infinite;
}
.frame-slot.loading .frame-num {
  color: rgba(255,255,255,0.85); font-size: 11px; font-weight: 600;
}
.frame-slot.error {
  background: #fef0ee; color: #c84a3c;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 8px;
}
.frame-slot.ready img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.frame-slot .corner {
  position: absolute;
  width: 26px; height: 26px;
  background: rgba(0,0,0,0.6);
  border: none; border-radius: 50%;
  color: #fff; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 3;
}
.frame-slot:hover .corner { opacity: 1; }
.frame-slot .corner.star { top: 6px; right: 6px; }
.frame-slot .corner.star.on { background: #f5c842; color: #1a1410; opacity: 1; }
.frame-slot .corner.regen { bottom: 6px; right: 6px; }
.frame-slot .arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 28px; height: 38px;
  background: rgba(0,0,0,0.55); color: #fff;
  border: none; cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s;
  z-index: 3;
}
.frame-slot:hover .arrow { opacity: 1; }
.frame-slot .arrow.prev { left: 0; border-radius: 0 8px 8px 0; }
.frame-slot .arrow.next { right: 0; border-radius: 8px 0 0 8px; }
.frame-slot .pos {
  position: absolute; bottom: 6px; left: 6px;
  background: rgba(0,0,0,0.6); color: #fff;
  padding: 2px 6px; border-radius: 10px;
  font-size: 10px; font-weight: 600;
  z-index: 3;
}
.frame-slot .badge-work {
  position: absolute; top: 6px; left: 6px;
  background: #f5c842; color: #1a1410;
  padding: 2px 6px; border-radius: 10px;
  font-size: 10px; font-weight: 700;
  z-index: 4;
  display: flex; align-items: center; gap: 4px;
}
.frame-slot .badge-work .mini-spin {
  width: 7px; height: 7px;
  border: 2px solid #1a1410; border-top-color: transparent;
  border-radius: 50%;
  animation: studio-spin 0.8s linear infinite;
}
@keyframes studio-spin { to { transform: rotate(360deg); } }

/* === Result grid layout ============================================ */
.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* === Status pill ================================================== */
.status-area { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.pill {
  background: #e8dccb; color: #1a1410;
  padding: 4px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.pill.running { background: #f5c842; color: #1a1410; }
.pill.stopped { background: #fef0ee; color: #c84a3c; }
.pill .spin {
  width: 9px; height: 9px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%;
  animation: studio-spin 0.8s linear infinite;
}
.timer { color: var(--ink-soft, #5a4a3a); font-size: 12px; }

/* === Customization block ========================================== */
.custom-block .field { display: block; margin-bottom: 12px; }
.custom-block .field-label { display: block; font-size: 12px; color: #5a4a3a; margin-bottom: 4px; font-weight: 500; }
.custom-block .opt { color: #999; font-weight: 400; }
.custom-block select, .custom-block textarea {
  width: 100%; border: 1px solid #e8dccb;
  border-radius: 6px; padding: 8px 10px;
  font-size: 13px; background: #faf7f2;
  font-family: inherit; color: #1a1410;
  box-sizing: border-box;
}
.custom-block textarea { resize: vertical; min-height: 50px; }
.prompt-extra-saved {
  display: inline-block; font-size: 11px; color: #2d8050; margin-top: 4px;
}
.btn-stop {
  width: 100%; background: #fff;
  color: #c84a3c; border: 1.5px solid #c84a3c;
  border-radius: 8px; padding: 10px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  margin-top: 8px;
}
.btn-stop:hover { background: #fef0ee; }
