/* Ghost Maker — стилі самого конструктора; токени, шапка й кнопки в assets/site.css */

.studio h2 { margin: 0; font-size: 1.1rem; }

/* ---------- Макет ---------- */
.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  gap: 24px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
}

.stage { min-width: 0; display: grid; gap: 16px; align-content: start; }

.preview-wrap { position: relative; width: 100%; max-width: min(720px, calc(100vh - 330px)); min-width: 320px; margin: 0 auto; }
.preview-wrap .watermark { border-radius: 20px; }
.buy-row { display: grid; justify-items: center; gap: 4px; text-align: center; }

.preview {
  aspect-ratio: 1;
  width: 100%;
  border-radius: 20px;
  border: 2px solid var(--text);
  overflow: hidden;
}
.preview svg, .preview canvas { display: block; width: 100%; height: 100%; }
.preview { transition: opacity .15s ease; }
.preview.is-busy { opacity: .75; }

.bg-checker {
  background-color: var(--checker-a);
  background-image:
    linear-gradient(45deg, var(--checker-b) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-b) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-b) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-b) 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}
.bg-light { background: #ffffff; }
.bg-dark { background: #23232d; }

.toolbar, .export {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* ---------- Перемикачі ---------- */
.seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-alt);
}
.seg button {
  padding: .45rem .95rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.seg button.is-on { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.seg-wide { display: flex; }
.seg-wide button { flex: 1; }

/* ---------- Панель ---------- */
.panel {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
}
fieldset {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
}
legend {
  padding: 0 .4rem;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}

.field { display: grid; gap: 6px; font-weight: 500; }
.field-inline { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input, .opt-color input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }

select {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.field-inline select { width: auto; }
input[type=range] { width: 100%; accent-color: var(--accent); }

.opt-color {
  grid-template-columns: 1fr auto;
  align-items: center;
}
.opt-color label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.opt-color input[type=color] {
  width: 44px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  cursor: pointer;
}
.opt-color input[type=color]:disabled { opacity: .3; cursor: not-allowed; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  position: relative;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--c);
  cursor: pointer;
}
.swatch.is-on { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg-alt), 0 0 0 4px var(--accent); }
.swatch-custom {
  background: conic-gradient(#e8711c, #ffd34d, #2f8f4e, #2f6fd6, #9b7fd4, #e0408a, #e8711c);
  overflow: hidden;
}
.swatch-custom.is-on { background: var(--c); }
.swatch-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

.emblem-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Варіації ---------- */
.variants {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
}
.variants-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.variant-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.variant {
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  cursor: pointer;
  overflow: hidden;
  transition: transform .15s ease, border-color .15s ease;
}
.variant:hover { transform: translateY(-2px); border-color: var(--accent); }
.variant svg { display: block; width: 100%; height: 100%; }

/* ---------- Вкладки й плитки ---------- */
.panel-title { margin: 0; font-size: 1.7rem; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); }
.tabs::-webkit-scrollbar { display: none; }
.tabs [role=tab] {
  flex: none;
  padding: 10px 7px;
  border: 0;
  border-bottom: 3px solid transparent;
  font-size: .95rem;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.tabs [role=tab]:hover { color: var(--text); }
.tabs [role=tab][aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }
.tab-panel { display: grid; gap: 14px; align-content: start; min-width: 0; }

.tiles { display: grid; gap: 8px; }
.tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tiles-text { display: flex; flex-wrap: wrap; }
.tile-btn {
  display: grid;
  gap: 6px;
  justify-items: center;
  min-width: 0;
  padding: 6px 4px 8px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: none;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.tile-btn:hover { background: var(--bg-alt); }
.tile-btn[aria-pressed="true"] { border-color: var(--text); background: var(--bg-alt); }
.tile-art { position: relative; display: block; width: 100%; aspect-ratio: 1; border-radius: 8px; background: var(--tile); overflow: hidden; }
.tile-art svg { display: block; width: 100%; height: 100%; }
.tile-art.is-item svg { position: absolute; inset: 14%; width: 72%; height: 72%; }
/* кадруємо обличчя з повного привида */
.tile-art.is-face svg { position: absolute; width: 230%; height: 230%; max-width: none; left: -65%; top: -64%; }
.tile-label { font-size: .8rem; line-height: 1.2; text-align: center; }
.tiles-text .tile-btn { padding: .4rem .9rem; border: 1.5px solid var(--border); border-radius: 999px; }
.tiles-text .tile-btn[aria-pressed="true"] { border-color: var(--text); background: var(--text); color: #fff; }
.tiles-text .tile-label { font-size: .9rem; }

.advanced { border-top: 1px solid var(--border); padding-top: 4px; }
.advanced summary { padding: 10px 0; color: var(--muted); font-weight: 600; cursor: pointer; }
.advanced-body { display: grid; gap: 12px; padding-bottom: 8px; }

/* ---------- Адаптив ---------- */
@media (max-width: 1020px) {
  .studio { --pv: min(100vw - 32px, 36vh); display: flex; flex-direction: column; gap: 16px; padding: 0 16px 16px; }
  .tile-btn, .panel input, .panel .btn, .swatch { scroll-margin: calc(var(--pv) + 80px) 0 96px; }
  .stage { display: contents; }
  [data-page="maker"] .site-header { position: static; }
  .preview-wrap { order: 1; position: sticky; top: 0; z-index: 5; max-width: none; min-width: 0; margin-inline: -16px; width: auto; padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--border); }
  .preview-wrap .preview { width: var(--pv); margin: 0 auto; }
  .preview-wrap .watermark { inset: 10px auto 10px 50%; width: var(--pv); transform: translateX(-50%); }
  .panel { order: 2; }
  /* вкладки тримаються одразу під закріпленим прев'ю */
  .tabs { position: sticky; top: calc(var(--pv) + 21px); z-index: 4; margin-inline: -16px; padding-inline: 16px; background: var(--bg); }
  .panel-title { display: none; }
  .toolbar { order: 3; }
  .variants { order: 4; }
  .export { order: 5; }
  .buy-row { order: 6; position: sticky; bottom: 0; z-index: 5; margin-inline: -16px; padding: 10px 16px; background: var(--bg); border-top: 1px solid var(--border); }
  .buy-row .btn { width: 100%; }
  .buy-row .hint { display: none; }
  .variant-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .panel-title { font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  .variant, .preview { transition: none; }
}
