:root {
  --bg: #fbfaf7;
  --text: #1a1612;
  --muted: #6b645c;
  --card: #f0ede5;
  --border: #b9b2a5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter Tight", sans-serif;
}

.header {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px;
  border-bottom: 1px solid #e8e4da;
}
.logo { font-weight: 800; font-size: 22px; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px 60px; }

.hero { padding: 60px 0 40px; }
.hero h1 {
  font-size: clamp(36px, 6vw, 72px);
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin: 0 0 20px;
}
.hero p { font-size: 18px; color: var(--muted); max-width: 520px; }

.collection-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.collection-head h2 { margin: 0; font-size: 22px; }
.counter {
  font-family: "JetBrains Mono", monospace;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
}

/* Сетка 3x3: чтобы сделать ячейки меньше или больше, меняйте max-width */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.slot {
  aspect-ratio: 2 / 3;
  border: 1px dashed var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  position: relative;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  transition: background 0.2s;
}
.slot:hover { background: rgba(0, 0, 0, 0.04); }

.slot .num {
  position: absolute;
  top: 8px;
  left: 10px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
}
.slot .plus {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 20px;
}

/* Заполненная ячейка */
.slot.filled {
  border: none;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.slot.filled img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.slot.filled .num {
  z-index: 1;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  padding: 2px 6px;
  border-radius: 4px;
  top: 6px;
  left: 6px;
}
.remove {
  position: absolute;
  z-index: 1;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}
.slot.filled:hover .remove { opacity: 1; }

/* Окно поиска */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(26, 22, 18, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px;
  z-index: 10;
}
.modal[hidden] { display: none; }

.modal-box {
  background: #fff;
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  display: flex;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid #e8e4da;
}
.modal-head input {
  flex: 1;
  font: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  outline: none;
}
.modal-head input:focus { border-color: var(--text); }

.close {
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--muted);
}

.results { overflow-y: auto; padding: 8px; }
.hint { color: var(--muted); text-align: center; padding: 24px; margin: 0; }

.result {
  display: flex;
  gap: 14px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  align-items: center;
}
.result:hover { background: var(--card); }
.result img {
  width: 48px;
  height: 72px;
  object-fit: cover;
  border-radius: 3px;
  background: var(--card);
  flex-shrink: 0;
}
.result .title { font-weight: 600; }
.result .author { color: var(--muted); font-size: 14px; }

/* ===== Раскладка: сетка слева, панель справа ===== */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 560px) 340px;
  gap: 32px;
  align-items: start;
}
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
}

/* ===== Карточка постера с темами ===== */
.poster-card {
  --p-bg: #f0ede5; --p-text: #1a1612; --p-muted: #6b645c; --p-border: #b9b2a5;
  background: var(--p-bg);
  color: var(--p-text);
  padding: 20px 16px 16px;
  border-radius: 20px;
}
.poster-card[data-theme="sage"]   { --p-bg: #dfe7da; --p-text: #1f2b1f; --p-muted: #55654f; --p-border: #9db095; }
.poster-card[data-theme="cream"]  { --p-bg: #f7ead0; --p-text: #6b2418; --p-muted: #9a6b4f; --p-border: #d6b98a; }
.poster-card[data-theme="walnut"] { --p-bg: #3b2a20; --p-text: #f5e9d8; --p-muted: #c2a98d; --p-border: #7a5f4a; }
.poster-card[data-theme="ink"]    { --p-bg: #1d2022; --p-text: #f2f2f2; --p-muted: #a0a4a8; --p-border: #565b60; }
.poster-card[data-theme="neon"]   { --p-bg: linear-gradient(135deg, #14082b, #2a0f4d 55%, #0b1a3a); --p-text: #ffffff; --p-muted: #c7b8ee; --p-border: #8a6bd1; }

.poster-card { background: var(--p-bg); }
.poster-card .slot { border-color: var(--p-border); color: var(--p-muted); }
.poster-card .slot .plus { border-color: var(--p-border); }
.poster-card .slot:hover { background: rgba(128, 128, 128, 0.14); }

.poster-title { padding: 0 4px 14px; display: flex; flex-direction: column; gap: 2px; }
.pt-name { font-weight: 800; font-size: 20px; letter-spacing: -0.02em; }
.pt-name:empty { display: none; }
.pt-sub { color: var(--p-muted); font-size: 14px; }

.cell { min-width: 0; }
.caption { padding: 8px 2px 4px; }
.c-title {
  font-weight: 600; font-size: 12px; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.c-author { font-size: 11px; color: var(--p-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== Правая панель ===== */
.panel {
  position: sticky; top: 20px;
  background: #fff;
  border: 1px solid #ece8de;
  border-radius: 20px;
  padding: 22px;
}
.panel h2 { margin: 0 0 18px; font-size: 22px; }
.field-label {
  display: flex; justify-content: space-between;
  font-weight: 600; font-size: 14px; margin: 16px 0 8px;
}
.field-label span { font-weight: 400; color: var(--muted); }
.panel input[type="text"] {
  width: 100%; font: inherit; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); outline: none;
}
.panel input[type="text"]:focus { border-color: var(--text); }

.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.swatch {
  font: inherit; font-size: 12px; color: var(--muted);
  background: none; border: none; padding: 0; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.swatch b {
  width: 100%; height: 56px; border-radius: 10px;
  display: grid; place-items: center; font-size: 16px;
  border: 2px solid transparent;
}
.swatch.active { color: var(--text); font-weight: 600; }
.swatch.active b { border-color: var(--text); }
.swatch[data-theme="paper"] b  { background: #f0ede5; color: #1a1612; }
.swatch[data-theme="sage"] b   { background: #dfe7da; color: #1f2b1f; }
.swatch[data-theme="cream"] b  { background: #f7ead0; color: #6b2418; }
.swatch[data-theme="walnut"] b { background: #3b2a20; color: #f5e9d8; }
.swatch[data-theme="ink"] b    { background: #1d2022; color: #f2f2f2; }
.swatch[data-theme="neon"] b   { background: linear-gradient(135deg, #14082b, #2a0f4d); color: #fff; }

.toggle-row {
  display: flex; justify-content: space-between; align-items: center;
  margin: 20px 0; font-weight: 600; font-size: 14px; cursor: pointer;
}
.toggle-row input { width: 20px; height: 20px; accent-color: var(--text); cursor: pointer; }

.progress-row {
  display: flex; justify-content: space-between;
  border-top: 1px solid #ece8de; padding-top: 16px;
  font-size: 14px; color: var(--muted);
}
.mono { font-family: "JetBrains Mono", monospace; }
.progress { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; margin: 10px 0 16px; }
.progress i { height: 4px; border-radius: 2px; background: #e4dfd3; }
.progress i.on { background: var(--text); }

.create {
  width: 100%; font: inherit; font-weight: 600; font-size: 16px;
  padding: 14px; border: none; border-radius: 12px; cursor: pointer;
  background: var(--text); color: #fff; transition: opacity 0.2s;
}
.create:disabled { background: #e4dfd3; color: #9a948a; cursor: not-allowed; }

/* ===== Окно с готовым постером ===== */
.poster-box {
  background: #fff; width: 100%; max-width: 520px; max-height: 92vh;
  border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 14px;
}
.poster-preview { display: flex; flex-direction: column; align-items: center; min-height: 0; }
.poster-preview canvas {
  display: block; max-width: 100%; max-height: 66vh;
  border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}
.poster-preview .hint { padding: 12px; }
.poster-actions { display: flex; gap: 10px; }
.poster-actions .create { flex: 1; }
.ghost {
  font: inherit; font-weight: 600; padding: 14px 20px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 12px; background: none; color: var(--text);
}

/* ===== Перетаскивание ===== */
.slot.filled { cursor: grab; }
.sortable-ghost { opacity: 0.35; }
.sortable-chosen .slot.filled { cursor: grabbing; }

/* ===== Шаг 7: верхний блок, мелочи, телефон ===== */
.hero { display: flex; align-items: center; justify-content: space-between; gap: 32px; }
.hero-art { width: min(320px, 34%); flex-shrink: 0; }

.head-right { display: flex; align-items: center; gap: 12px; }
.link-btn {
  font: inherit; font-size: 14px; color: var(--muted);
  background: none; border: none; cursor: pointer; text-decoration: underline;
}
.link-btn:hover { color: var(--text); }
.drag-hint { color: var(--muted); font-size: 14px; margin: 12px 4px 0; }
.footer {
  max-width: 1100px; margin: 0 auto; padding: 24px 20px 40px;
  border-top: 1px solid #e8e4da; color: var(--muted); font-size: 13px;
}

/* на сенсорных экранах нет наведения, поэтому крестик показываем всегда */
@media (hover: none) { .remove { opacity: 1; } }

@media (max-width: 700px) {
  .header { padding: 18px 16px; }
  .container { padding: 0 16px 32px; }
  .hero { padding: 32px 0 24px; }
  .hero-art { display: none; }
  .hero p { font-size: 16px; }
  .layout { gap: 20px; }
  .poster-card { padding: 14px 10px 10px; border-radius: 16px; }
  .grid { gap: 8px; }
  .slot:not(.filled) > span:last-child { display: none; }
  .c-title { font-size: 11px; }
  .c-author { font-size: 10px; }
  .panel { position: static; padding: 18px; }
  .modal { padding: 16px 12px; }
  .modal-box { max-height: 88vh; }
  .footer { padding: 20px 16px 32px; }
}