.color-builder-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(44,44,44,0.55);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  /* щоб скрол не “пробивався” на фон */
  overflow: hidden;
  overscroll-behavior: contain;
}

.color-builder-modal-content {
  background: #fff;
  border-radius: 28px;
  padding: 0;
  min-width: 80vw;
  min-height: 84vh;
  width: 90vw;
  height: 90vh;
  box-shadow: 0 8px 32px #0002;
  position: relative;
  display: flex;
  flex-direction: column;
}

.color-builder-header {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 32px 42px 18px 42px;
  border-bottom: 1px solid #eee;
}

.cb-logo { height: 58px; }
.cb-slogan {
  font-family: 'Dancing Script', cursive;
  font-size: 2.2em;
  color: #25313B;
  font-weight: bold;
  letter-spacing: 1px;
}

.color-builder-main {
  display: flex;
  flex: 1;
  min-height: 0;
  height: 100%;
}

/* Область схеми */
.cb-scheme-area {
  flex: 2;
  position: relative;
  background: #fff;
  border-radius: 0 0 0 28px;
  padding: 32px;
  overflow: auto;           /* на десктопі допускаємо внутрішній скрол */
  min-height: 400px;
  border: 1px solid #eaeaea;
}

/* Контейнер для SVG */
.cb-scheme-area-inner {
  width: 100%;
  height: 100%;
  position: relative;
  min-height: 580px;
}

/* Окремі SVG-шари (дефолт) */
.cb-scheme-area svg.svg-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  background: transparent;
  display: block;
}

/* Прибрали жорсткі 600×600; все під 100% контейнера */
#cb-scheme-area svg {
  background: inherit;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
}

/* Дебаг-режим: переключається класом на .cb-scheme-area */
.cb-scheme-area.debug-mode #cb-scheme-area svg {
  border: 2px dashed red;
  margin: 10px 0;
}
.cb-scheme-area.debug-mode { background-color: #f0f0f0; }

.cb-controls-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: #f8f7f3;
  border-radius: 0 0 28px 0;
  padding: 32px 30px;
  min-width: 340px;
  max-width: 420px;
  overflow-y: auto;        /* на десктопі скролиться права колонка */
}

.cb-label {
  font-size: 1.15em;
  font-family: Georgia, Cambria, Times, serif;
  font-weight: 600;
  color: #2d3741;
  margin-bottom: 0.4em;
}
.cb-quick-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin: 10px 0 16px;
}

.cb-action-btn {
  appearance: none;
  border: 1px solid #c9b889;
  background: #fff;
  color: #1f2a37;
  border-radius: 9999px;
  padding: 8px 14px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
}

.cb-action-btn:hover { background: #f7f4ec; }
.cb-action-btn:focus-visible { outline: 2px solid #b89447; outline-offset: 2px; }

/* Іконки-кнопки: круглі, без тексту */
.cb-icon-btn {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 97% 97%;
}

/* YouTube */
.cb-icon-youtube {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><rect x='2' y='6' width='20' height='12' rx='3' ry='3' fill='%23FF0000'/><polygon points='10,9 16,12 10,15' fill='%23FFFFFF'/></svg>");
}

/* Etsy (спрощена "E" на фірмовому кольорі) */
.cb-icon-etsy {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 64'><rect x='8' y='8' width='80' height='48' rx='12' ry='12' fill='%23F1641E'/><text x='48' y='42' text-anchor='middle' font-family='Georgia,Times,serif' font-size='28' font-weight='700' fill='%23FFFFFF'>Etsy</text></svg>");
}

/* Download (стрілка вниз) */
.cb-icon-download {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 4v9m0 0l4-4m-4 4l-4-4' stroke='%231f2a37' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'/><path d='M5 16h14v3H5z' fill='%231f2a37'/></svg>");
}

.cb-icon-btn:hover { filter: brightness(1.03); }

.cb-select, .cb-select option {
  font-size: 1.1em;
  padding: 0.3em 0.8em;
  border-radius: 1em;
  border: 1px solid #b8a57c;
  margin-bottom: 0.9em;
  font-family: Georgia, Cambria, Times, serif;
  background: #fff;
  color: #25313B;
  width: 100%;
  box-sizing: border-box;
}

.cb-shopping-list {
  background: #fff;
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 2px 8px #0001;
  margin-top: 10px;
}
.cb-shopping-list h4 { margin: 0 0 10px 0; font-size: 1.1em; color: #2d3741; }
.cb-shopping-list ul { margin: 0; padding-left: 18px; font-size: 1.05em; }

.color-builder-close {
  position: absolute;
  top: 24px;
  right: 32px;
  font-size: 2.4em;
  color: #555;
  cursor: pointer;
  font-weight: bold;
  border: none;
  background: none;
  z-index: 10;
}
.color-builder-close:hover { color: #f34343; }

/* Індикатор завантаження SVG */
.svg-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 1.2em;
  height: 100%;
  width: 100%;
}

/* Помилка завантаження SVG */
.svg-error {
  color: #cc2222;
  padding: 20px;
  text-align: center;
  border: 1px dashed #cc2222;
  margin: 20px;
  border-radius: 8px;
}

.cb-bg-table {
  display: grid;
  grid-template-columns: repeat(6, 36px);
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 16px;
}
.cb-bg-swatch {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid #e0e0e0;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: border 0.2s;
}
.cb-bg-swatch:hover {
  border: 2px solid #b2b2b2;
}
.cb-bg-swatch.selected {
  border: 2.5px solid #415058;
  box-shadow: 0 2px 4px rgba(65,80,88,0.12);
}

/* Кнопки */
.btn,
#cb-paint-btn {
  background: #b8a57c;
  color: white;
  border: none;
  border-radius: 1em;
  padding: 0.6em 1.2em;
  font-size: 1.1em;
  cursor: pointer;
  transition: background-color 0.3s, opacity 0.2s, transform 0.02s;
}
.btn:hover, #cb-paint-btn:hover { background: #a09068; }
.btn.secondary {
  background: #e9dec5;
  color: #2d3741;
}
.btn.secondary:hover { background: #d8c59d; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.toggled { outline: 2px solid #6aa6c8; }

/* Toolbar для дрібних дій */
.cb-actions { display: flex; flex-direction: column; gap: 10px; }
.cb-toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

/* Eyedropper індикатор курсора */
.cb-scheme-area.eyedropper-active { cursor: crosshair; }

/* === Export layout v3: схема зверху, список у 2 колонки під схемою === */
.cb-export-wrap {
  display: grid;
  grid-template-columns: 1fr;  /* одна колонка: ряд 1 — схема; ряд 2 — блок списків */
  gap: 20px;
  padding: 24px;
  background: #fff;
}
.cb-export-scheme {
  padding: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}
.cb-export-scheme svg { display: block; height: auto !important; }
.cb-export-lists {
  display: grid;
  grid-template-columns: repeat(2, 420px);
  column-gap: 32px;
  row-gap: 10px;
  justify-content: center;
  align-items: start;
}
.cb-export-title {
  grid-column: 1 / -1;
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.25;
}
.cb-export-list {
  font-size: 18px;
  line-height: 1.35;
}
.cb-export-list ul { margin: 0; padding-left: 10px; }
.cb-export-list li { margin-bottom: 6px; }

/* ===== Mobile layout/fix: один скрол-контейнер, патерн sticky ===== */
@media (max-width: 1100px) {
  /* модалка на всю висоту екрана (iOS-friendly) */
  .color-builder-modal-content {
    min-width: 100vw;
    min-height: 100dvh;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    padding: 0;
    border-radius: 0;
  }

  .color-builder-header {
    padding: 18px 8vw 12px 8vw;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  /* ГОЛОВНИЙ скрол-контейнер */
  .color-builder-main {
    flex-direction: column;
    overflow-y: auto;                 /* саме тут скролимо всю сторінку білдера */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Патерн зверху — липкий, без власного скролу */
  .cb-scheme-area {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 18px 6vw;
    border-radius: 0;
    min-width: 0;
    max-width: 100vw;

    height: 46vh;                     /* видима зона для схеми */
    min-height: 46vh;
    max-height: 60vh;

    overflow: hidden;                 /* ВАЖЛИВО: не перехоплювати скрол усередині */
    border-top: 1px solid #eaeaea;
  }
  .cb-scheme-area-inner { height: 100%; min-height: 0; }
  .cb-scheme-area svg.svg-layer { position: static; width: 100%; height: 100%; }
  .cb-controls-area { overflow-y: visible; padding: 18px 6vw 28px; }

  /* Щоб SVG не зникав у Safari: static + 100% висота */
  .cb-scheme-area-inner {
    height: 100%;
    min-height: 0;
  }
  .cb-scheme-area svg.svg-layer {
    position: static;                 /* замість absolute на мобільному */
    width: 100%;
    height: 100%;
    display: block;
    background: inherit;
  }

  /* Параметри внизу — без власного overflow, все скролить .color-builder-main */
  .cb-controls-area {
    border-radius: 0;
    padding: 18px 6vw 28px 6vw;
    min-width: 0;
    max-width: 100vw;
    overflow-y: visible;              /* не створюємо “вкладений” скрол */
  }
}

/* Загальний колір тексту у футері (приклад) */
.site-footer { color: #b2c0c4; 
    font-family: ui-sans-serif, system-ui, sans-serif;
    font-size: 1em;
 }

/* Посилання у списках футера наслідують колір тексту і без підкреслення */
.site-footer .footer-list a,
.site-footer .footer-socials a,
.site-footer a[href^="mailto:"] {
  color: inherit;
  text-decoration: none;
}

/* Щоб не ставали фіолетовими після відвідування */
.site-footer .footer-list a:visited,
.site-footer a[href^="mailto:"]:visited {
  color: inherit;
}

/* Ховер/фокус — додамо підкреслення (видимість + доступність) */
.site-footer .footer-list a:hover,
.site-footer .footer-list a:focus,
.site-footer a[href^="mailto:"]:hover,
.site-footer a[href^="mailto:"]:focus {
  text-decoration: underline;
}

/* === Export list sizing overrides === */
.cb-export-list {
  width: 420px;          /* було ~360px */
  font-size: 18px;       /* було 14–16px */
  line-height: 1.5;
}
.cb-export-list h4 {
  font-size: 22px;
  margin: 0 0 12px;
}
.cb-export-list li { margin-bottom: 8px; }

/* Підстраховка від медіа-правил теми: показувати блок, якщо JS не сховав його inline-стилем */
#cb-quick-actions.cb-quick-actions {
  display: flex;
}
@media (max-width: 767px) {
  #cb-quick-actions.cb-quick-actions { display: flex; }
}
@media (min-width: 1024px) {
  #cb-quick-actions.cb-quick-actions { display: flex; }
}