/* MAGICUM 2027 · Студія примірки тканини (головна, перший екран).
   Усе ізольовано під #mstudio, щоб не зачепити решту index.html. */
#mstudio {
  --ms-ink: #0d0a07;
  --ms-ink-2: #15100b;
  --ms-ink-3: #1d1610;
  --ms-line: rgba(214, 178, 96, .22);
  --ms-line-strong: rgba(226, 192, 110, .55);
  --ms-ivory: #f3ecdc;
  --ms-muted: #a2957c;
  --ms-gold: #d4ae5a;
  --ms-gold-hi: #ecd28c;
  --ms-radius: 18px;
  --ms-ease: cubic-bezier(.2, .7, .2, 1);
  position: relative;
  min-height: auto !important;
  height: auto !important;
  padding: 92px 0 56px !important;
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(212, 174, 90, .13), transparent 60%),
    radial-gradient(80% 60% at 100% 100%, rgba(120, 82, 34, .14), transparent 70%),
    var(--ms-ink);
  color: var(--ms-ivory);
  font-family: Montserrat, system-ui, -apple-system, 'Segoe UI', sans-serif;
  scroll-snap-align: start;
  overflow: visible !important;
}
#mstudio *, #mstudio *::before, #mstudio *::after { box-sizing: border-box; }
#mstudio .ms-wrap { width: min(1120px, 100%); margin: 0 auto; padding: 0 18px; }

/* ── шапка ── */
#mstudio .ms-head { text-align: center; max-width: 720px; margin: 0 auto 22px; }
#mstudio .ms-mark { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 15px; letter-spacing: .62em; padding-left: .62em; color: var(--ms-gold); margin: 0 0 14px; }
#mstudio .hero-eyebrow { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--ms-muted); margin: 0 0 10px; }
#mstudio .hero-title { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 400; font-size: clamp(34px, 8.6vw, 60px); line-height: 1.02; letter-spacing: -.005em; margin: 0; color: var(--ms-ivory); }
#mstudio .hero-title em { display: block; font-style: italic; color: var(--ms-gold-hi); font-size: .62em; margin-top: .32em; line-height: 1.15; }
#mstudio .ms-lede { margin: 14px auto 0; max-width: 520px; font-size: 14.5px; line-height: 1.6; color: #d8ccb2; }

/* ── кроки ── */
#mstudio .ms-steps { list-style: none; display: flex; justify-content: center; gap: 6px; margin: 22px 0 18px; padding: 0; counter-reset: s; }
#mstudio .ms-steps li { counter-increment: s; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ms-muted); padding: 6px 12px 6px 6px; border-radius: 999px; border: 1px solid transparent; transition: color .3s var(--ms-ease), border-color .3s var(--ms-ease), background .3s var(--ms-ease); }
#mstudio .ms-steps li::before { content: counter(s); display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--ms-line); font-size: 11px; font-weight: 600; }
#mstudio .ms-steps li.is-current { color: var(--ms-ivory); border-color: var(--ms-line); background: rgba(212, 174, 90, .06); }
#mstudio .ms-steps li.is-current::before { background: var(--ms-gold); border-color: var(--ms-gold); color: #1a1208; }
#mstudio .ms-steps li.is-done::before { content: '✓'; color: var(--ms-gold); border-color: var(--ms-line-strong); }

/* ── робоча зона ── */
#mstudio .ms-grid { display: grid; gap: 14px; }
@media (min-width: 900px) { #mstudio .ms-grid.ms-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); align-items: start; gap: 18px; } }
#mstudio .ms-card { background: linear-gradient(180deg, rgba(255, 255, 255, .025), rgba(255, 255, 255, 0)), var(--ms-ink-2); border: 1px solid var(--ms-line); border-radius: var(--ms-radius); padding: 16px; }
#mstudio .ms-card-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 0 12px; font-size: 13px; font-weight: 600; letter-spacing: .04em; color: var(--ms-ivory); }
#mstudio .ms-card-title small { font-weight: 400; color: var(--ms-muted); font-size: 12px; letter-spacing: 0; }

/* 1 · фото */
#mstudio .ms-drop { position: relative; display: grid; place-items: center; text-align: center; min-height: 236px; border-radius: 14px; border: 1.5px dashed var(--ms-line-strong); background: repeating-linear-gradient(135deg, rgba(212, 174, 90, .035) 0 10px, transparent 10px 20px), var(--ms-ink-3); cursor: pointer; overflow: hidden; transition: border-color .25s var(--ms-ease), transform .25s var(--ms-ease); -webkit-tap-highlight-color: transparent; }
#mstudio .ms-drop:hover, #mstudio .ms-drop.is-over { border-color: var(--ms-gold); }
#mstudio .ms-drop:active { transform: scale(.995); }
#mstudio .ms-drop:focus-within { outline: 2px solid var(--ms-gold); outline-offset: 3px; }
#mstudio .ms-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
#mstudio .ms-drop-ico { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; background: rgba(212, 174, 90, .12); color: var(--ms-gold-hi); }
#mstudio .ms-drop-title { font-size: 16px; font-weight: 600; margin: 0; }
#mstudio .ms-drop-sub { font-size: 12.5px; color: var(--ms-muted); margin: 6px 0 0; }
#mstudio .ms-drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #0a0806; }
#mstudio .ms-drop.has-photo { border-style: solid; border-color: var(--ms-line); }
#mstudio .ms-drop.has-photo .ms-drop-body { position: absolute; left: 10px; bottom: 10px; right: auto; padding: 7px 12px; border-radius: 999px; background: rgba(10, 8, 6, .78); backdrop-filter: blur(6px); text-align: left; z-index: 2; }
#mstudio .ms-drop.has-photo .ms-drop-ico { display: none; }
#mstudio .ms-drop.has-photo .ms-drop-title { font-size: 12.5px; }
#mstudio .ms-drop.has-photo .ms-drop-sub { font-size: 11px; margin-top: 1px; }
#mstudio .ms-tips { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 2px 0; padding: 0; list-style: none; font-size: 11.5px; color: var(--ms-muted); }
#mstudio .ms-tips li::before { content: '·'; color: var(--ms-gold); margin-right: 6px; }

/* 2 · тканини */
#mstudio .ms-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 12px; padding: 0 16px; }
#mstudio .ms-tabs::-webkit-scrollbar { display: none; }
#mstudio .ms-tab { flex: 0 0 auto; border: 1px solid var(--ms-line); background: transparent; color: #d8ccb2; font: inherit; font-size: 12.5px; padding: 8px 14px; border-radius: 999px; cursor: pointer; min-height: 36px; transition: all .2s var(--ms-ease); }
#mstudio .ms-tab[aria-pressed="true"] { background: var(--ms-ivory); color: #17110a; border-color: var(--ms-ivory); font-weight: 600; }
#mstudio .ms-tab:focus-visible, #mstudio .ms-sw:focus-visible, #mstudio .ms-btn:focus-visible { outline: 2px solid var(--ms-gold-hi); outline-offset: 2px; }
#mstudio .ms-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px 8px; max-height: 296px; overflow-y: auto; padding: 5px 5px 6px; margin: 0 -5px; overscroll-behavior-y: auto; /* дійшовши до краю каталогу, прокрутка переходить до сторінки — не «застрягає» в студії */ scrollbar-width: thin; scrollbar-color: var(--ms-line) transparent; }
#mstudio .ms-coll { grid-column: 1 / -1; font-family: 'Cormorant Garamond', Georgia, serif; font-size: 17px; color: var(--ms-gold-hi); margin: 6px 0 -2px; }
#mstudio .ms-sw { display: grid; gap: 5px; padding: 0; border: 0; background: none; color: #cfc3a9; font: inherit; font-size: 10.5px; line-height: 1.2; text-align: center; cursor: pointer; }
#mstudio .ms-sw img { width: 100%; height: auto; aspect-ratio: 1; border-radius: 12px; object-fit: cover; display: block; background: var(--ms-ink-3); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); transition: transform .2s var(--ms-ease), box-shadow .2s var(--ms-ease); }
#mstudio .ms-sw:hover img { transform: translateY(-1px); }
#mstudio .ms-sw[aria-pressed="true"] img { box-shadow: 0 0 0 2px var(--ms-ink-2), 0 0 0 4px var(--ms-gold); }
#mstudio .ms-sw[aria-pressed="true"] span { color: var(--ms-ivory); font-weight: 600; }
#mstudio .ms-sw span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#mstudio .ms-chosen { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 10px; border-radius: 12px; background: rgba(212, 174, 90, .07); border: 1px solid var(--ms-line); }
#mstudio .ms-chosen img { width: 44px; height: 44px; border-radius: 9px; object-fit: cover; }
#mstudio .ms-chosen b { display: block; font-size: 13px; font-weight: 600; }
#mstudio .ms-chosen span { display: block; font-size: 12px; color: var(--ms-muted); margin-top: 2px; }

/* CTA */
#mstudio .ms-go-wrap { margin-top: 14px; }
#mstudio .ms-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 56px; border-radius: 14px; border: 1px solid transparent; font: inherit; font-size: 15.5px; font-weight: 700; letter-spacing: .01em; cursor: pointer; text-decoration: none; transition: transform .15s var(--ms-ease), filter .2s, opacity .2s; -webkit-tap-highlight-color: transparent; }
#mstudio .ms-btn:active { transform: translateY(1px) scale(.995); }
#mstudio .ms-btn-gold { background: linear-gradient(180deg, #f0d48a 0%, #d3a94f 52%, #b88a34 100%); color: #1a1107; box-shadow: 0 1px 0 rgba(255, 255, 255, .45) inset, 0 10px 30px -10px rgba(212, 174, 90, .55); }
#mstudio .ms-btn-gold:hover { filter: brightness(1.04); }
#mstudio .ms-btn[disabled] { opacity: .38; cursor: not-allowed; box-shadow: none; filter: saturate(.6); }
#mstudio .ms-btn-ghost { background: rgba(243, 236, 220, .04); color: var(--ms-ivory); border-color: var(--ms-line-strong); }
#mstudio .ms-btn-ghost:hover { background: rgba(243, 236, 220, .08); }
#mstudio .ms-hint { min-height: 18px; margin: 8px 0 0; text-align: center; font-size: 12px; color: var(--ms-muted); }
#mstudio .ms-turnstile { display: flex; justify-content: center; margin-top: 10px; }
#mstudio .ms-odin-password { box-sizing: border-box; width: min(100% - 28px, 620px); margin: 12px auto; border: 1px solid rgba(222,180,93,.65); background: rgba(10,23,45,.9); border-radius: 10px; padding: 10px 14px; color: #f9e7af; }
#msOdinPasswordPanel summary { font-size: 13px; cursor: pointer; min-height: 36px; display: flex; align-items: center; }
#msOdinPasswordForm { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; padding-top: 10px; }
#msOdinPasswordForm label { flex: 1 1 180px; min-width: 0; font-size: 12px; }
#msOdinPasswordInput { width: 100%; box-sizing: border-box; margin-top: 5px; border-radius: 7px; border: 1px solid #d4b572; padding: 10px 12px; font-size: 16px; background: #0b1930; color: #fff; }
#msOdinPasswordForm button { border-radius: 7px; background: #f2ce70; color: #101c34; padding: 11px 15px; border: 0; min-height: 44px; cursor: pointer; font-size: 14px; }
#msOdinPasswordStatus { flex: 1 1 100%; margin: 3px 0; font-size: 12px; line-height: 1.5; }
#mstudio .ms-turnstile:empty { display: none; }
#mstudio .ms-error { margin: 12px 0 0; padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(232, 120, 96, .45); background: rgba(232, 120, 96, .08); color: #f4cfc4; font-size: 13px; line-height: 1.5; }
#mstudio .ms-error:focus { outline: none; }

/* прогрес */
#mstudio .ms-progress { margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--ms-ink-3); border: 1px solid var(--ms-line); }
#mstudio .ms-progress:focus { outline: none; }
#mstudio .ms-bar { position: relative; height: 3px; border-radius: 3px; background: rgba(212, 174, 90, .14); overflow: hidden; }
#mstudio .ms-bar::after { content: ''; position: absolute; inset: 0 auto 0 0; width: 38%; border-radius: 3px; background: linear-gradient(90deg, transparent, var(--ms-gold-hi), transparent); animation: ms-sweep 1.6s var(--ms-ease) infinite; }
@keyframes ms-sweep { from { transform: translateX(-100%); } to { transform: translateX(270%); } }
#mstudio .ms-progress p { margin: 10px 0 0; font-size: 13.5px; }
#mstudio .ms-progress small { display: block; margin-top: 3px; font-size: 11.5px; color: var(--ms-muted); }

/* результат */
#mstudio .ms-result { margin-top: 18px; }
#mstudio .ms-result-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 2px 10px; }
#mstudio .ms-result-head h2 { margin: 0; font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 400; font-size: clamp(26px, 6vw, 36px); }
#mstudio .ms-actions { display: grid; gap: 10px; margin-top: 14px; }
@media (min-width: 640px) { #mstudio .ms-actions { grid-template-columns: 1fr 1fr; } #mstudio .ms-actions .ms-btn-pdf { grid-column: 1 / -1; } }
#mstudio .ms-btn small { display: block; font-size: 11.5px; font-weight: 500; opacity: .8; margin-top: 2px; }
#mstudio .ms-btn .ms-btn-txt { text-align: left; line-height: 1.2; }
#mstudio .ms-link-again { display: block; margin: 12px auto 0; background: none; border: 0; color: var(--ms-gold-hi); font: inherit; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 8px; }

#mstudio [hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { #mstudio * { animation: none !important; transition: none !important; } }
@media (max-width: 380px) { #mstudio .ms-wrap { padding: 0 12px; } #mstudio .ms-card { padding: 13px; } }

/* ── Нейтралізація legacy-стилів #hero (100svh, flex, рамка, внутрішній скрол)
   лише для нового хоста студії. Специфічність вища за всі старі правила #hero. ── */
#snap-root #hero.mstudio-host, #hero.mstudio-host {
  display: block !important; height: auto !important; min-height: 0; overflow: visible !important;
  padding: 0 !important; text-align: left; background: #0d0a07;
}
#hero.mstudio-host::after { display: none !important; }
#hero.mstudio-host > .nav-bar { text-align: center; }
/* ── Повноекранний Scroll Snap (DEMO 2027) — лише нативний CSS, існуючий #snap-root ──
   mandatory + scroll-snap-stop:always: один рух = одна наступна зупинка, без «прольоту» секцій.
   Студія й «Про нас» вищі за екран: за специфікацією це «covering» snap-області — усередині них
   прокрутка вільна (нічого не обрізається, студія не «застрягає»), а на межах — чітка зупинка.
   Результат (До/Після → PDF) — окрема зупинка, коли він показаний. Каталог тканин, PDF, повзунок
   і модалки не є snap-областями. Раніше тут був proximity: на 390 px один рух перелітав «Про нас». */
#snap-root:has(#hero.mstudio-host) {
  height: 100vh; height: 100dvh;
  scroll-snap-type: y mandatory !important;
  overscroll-behavior-y: contain;
}
#snap-root > #hero.mstudio-host, #snap-root > #about {
  scroll-snap-align: start; scroll-snap-stop: always;
  min-height: 100vh; min-height: 100dvh;
}
#mstudio #msResult:not([hidden]) { scroll-snap-align: start; scroll-snap-stop: always; scroll-margin-top: 8px; }
@media (prefers-reduced-motion: reduce) {
  #snap-root { scroll-behavior: auto !important; }
}
#mstudio .ms-grid { grid-template-columns: minmax(0, 1fr); }
#mstudio .ms-grid > * { min-width: 0; }
#mstudio .ms-drop-body { display: grid; justify-items: center; padding: 18px; }
#mstudio .ms-drop-body > span { display: block; }
#mstudio .ms-drop.has-photo .ms-drop-body { justify-items: start; padding: 7px 12px; }
#mstudio .hero-title, #mstudio .hero-title em { text-transform: none !important; letter-spacing: -.005em !important; text-shadow: none !important; animation: none !important; }
#mstudio .hero-title em { letter-spacing: 0 !important; font-weight: 400; }
#mstudio .hero-sub { font-family: 'Cormorant Garamond', Georgia, serif; font-style: italic; font-size: clamp(19px, 4.6vw, 24px); color: var(--ms-gold-hi); margin: 12px 0 0; letter-spacing: 0; text-transform: none; }
#mstudio .hero-title em { font-style: normal; font-family: Montserrat, system-ui, sans-serif; font-size: 12px; letter-spacing: .2em !important; text-transform: uppercase !important; color: var(--ms-muted); margin-top: 14px; }
#mstudio .hero-eyebrow { font-family: Montserrat, system-ui, sans-serif; }
#mstudio .ms-proof { margin: 12px 0 0; font-size: 12px; color: var(--ms-muted); }
#mstudio .ms-proof a { color: var(--ms-gold-hi); text-decoration: none; border-bottom: 1px solid var(--ms-line-strong); }

/* ── Автоматичний PDF під слайдером ── */
#mstudio .ms-pdf { margin-top: 16px; }
#mstudio .ms-pdf-status { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 120px; border-radius: var(--ms-radius); border: 1px dashed var(--ms-line-strong); background: var(--ms-ink-3); font-size: 14px; color: #e3d8c0; }
#mstudio .ms-spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(212, 174, 90, .25); border-top-color: var(--ms-gold-hi); animation: ms-rot .9s linear infinite; }
@keyframes ms-rot { to { transform: rotate(360deg); } }
#mstudio .ms-pdf-view { border-radius: 10px; overflow: hidden; background: #fff; box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .7), 0 0 0 1px var(--ms-line); }
#mstudio .ms-pdf-view canvas { display: block; width: 100%; height: auto; }
#mstudio .ms-pdf-view iframe { display: block; width: 100%; aspect-ratio: 210 / 297; border: 0; }
#mstudio .ms-actions { grid-template-columns: 1fr !important; }
#mstudio .ms-more { margin: 12px 0 0; text-align: center; font-size: 13px; color: var(--ms-muted); }
#mstudio .ms-more a { color: var(--ms-gold-hi); text-decoration: none; border-bottom: 1px solid var(--ms-line-strong); padding: 6px 0; }
#mstudio .ms-pdf-note { margin: 0; padding: 28px 18px; text-align: center; font-size: 14px; line-height: 1.55; color: #3a2a1a; background: #fbf6ea; }

/* ── Вузьке верхнє меню (лише на хості студії): один рядок 40px, телефон — іконка ── */
@media (max-width: 639px) {
  #hero.mstudio-host > .nav-bar { height: 40px; align-items: stretch; }
  #hero.mstudio-host > .nav-bar nav { height: 40px; overflow: hidden; background: rgba(13, 10, 7, .86); }
  #hero.mstudio-host .nav-phone { position: static; flex: 0 0 44px; height: auto; padding: 0; border: 0; border-right: 1px solid var(--border, rgba(212,174,90,.25)); background: transparent; font-size: 16px; }
  #hero.mstudio-host .nav-phone [data-i18n="nav_phone"] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  #hero.mstudio-host #sideMenuBtn { min-height: 40px; }
  #mstudio { padding-top: 66px !important; }
}

/* ── Горизонтальний скрол із помітним індикатором (категорії тканин, каталоги) ── */
#mstudio .ms-tabs, #mstudio .ms-scroll {
  scrollbar-width: thin; scrollbar-color: var(--ms-gold) rgba(212, 174, 90, .12);
  padding-bottom: 10px;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 28px), transparent 100%);
          mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 28px), transparent 100%);
}
#mstudio .ms-tabs::-webkit-scrollbar, #mstudio .ms-scroll::-webkit-scrollbar { display: block; height: 4px; }
#mstudio .ms-tabs::-webkit-scrollbar-track, #mstudio .ms-scroll::-webkit-scrollbar-track { background: rgba(212, 174, 90, .12); border-radius: 4px; margin: 0 16px; }
#mstudio .ms-tabs::-webkit-scrollbar-thumb, #mstudio .ms-scroll::-webkit-scrollbar-thumb { background: var(--ms-gold); border-radius: 4px; }
#mstudio .ms-tab { min-height: 44px; padding: 10px 16px; font-size: 13px; }
#mstudio .ms-cat-link { margin-top: 6px; min-height: 44px; }

/* ── Під відкритим PDF — ОДНА основна кнопка «Зберегти / Поділитися»; решта — текстові посилання ── */
#mstudio .ms-again-wrap { margin: 4px 0 0; text-align: center; }
#mstudio .ms-again { display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; background: none; border: 0; color: var(--ms-muted); font: inherit; font-size: 13px; font-weight: 500; text-decoration: underline; text-decoration-color: rgba(162, 149, 124, .45); text-underline-offset: 4px; cursor: pointer; }
#mstudio .ms-again:hover { color: var(--ms-ivory); }
#mstudio .ms-again:focus-visible { outline: 2px solid var(--ms-gold-hi); outline-offset: 2px; border-radius: 6px; }

/* Deploy Preview only (рендериться лише на *--magicum.netlify.app): одноразовий тестовий дозвіл */
/* Лише Deploy Preview: блок перед футером #about; на мобільному — повна ширина, поле ≥ 16px (без авто-зуму iOS),
   великі цілі натискання, відступ і scroll-margin, щоб блок не ховався під нижніми фіксованими панелями. */
.ms-paidtest { position: relative; z-index: 2; margin: 16px auto 24px; padding: 10px 14px; width: min(100% - 32px, 640px); border: 1px dashed #b08d57; border-radius: 8px; font-size: 14px; box-sizing: border-box; background: rgba(10, 8, 6, .92); color: #f1e6d2; scroll-margin: 96px 0 calc(160px + env(safe-area-inset-bottom, 0px)); }
.ms-paidtest summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.ms-paidtest form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }
.ms-paidtest label { display: flex; flex-direction: column; gap: 6px; flex: 1 1 220px; min-width: 0; }
.ms-paidtest input { min-width: 0; width: 100%; max-width: 100%; min-height: 44px; font-size: 16px; padding: 8px 10px; box-sizing: border-box; }
.ms-paidtest button { min-height: 44px; padding: 0 16px; font-size: 15px; }
.ms-paidtest [role="status"] { flex-basis: 100%; }
@media (max-width: 760px) { .ms-paidtest { margin-bottom: calc(120px + env(safe-area-inset-bottom, 0px)); } }

/* номер телефону не розривається посередині (мобільний результат студії) */
.ms-nowrap { white-space: nowrap; }

/* ══ DEMO 2027 · P0 UX: уся форма старту AI-генерації — у першому мобільному екрані ══
   Порядок: навігація → MAGICUM + H1 → один підзаголовок → кроки → завантаження фото →
   «Вибрати тканину» → «Побачити меблі в новій тканині». Повтори реклами приховано (тексти лишаються
   в розмітці для SEO/i18n-перевірок); каталог тканин — ЛИШЕ у вікні #msFabricModal. */
#mstudio { padding: 74px 0 40px !important; }
#mstudio .ms-mark, #mstudio .hero-eyebrow, #mstudio .ms-lede, #mstudio .ms-tips, #mstudio .ms-cat-link { display: none !important; }
#mstudio .ms-sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
#mstudio .ms-head { margin: 0 auto 10px; }
#mstudio .hero-title { font-size: clamp(30px, 8.2vw, 52px); line-height: 1.04; }
#mstudio .hero-title em { margin-top: 6px !important; font-size: 10.5px !important; letter-spacing: .22em !important; }
#mstudio .hero-sub { margin: 8px 0 0; font-size: clamp(17px, 4.4vw, 22px); line-height: 1.25; }
#mstudio .ms-steps { margin: 10px 0 12px; gap: 4px; }
#mstudio .ms-steps li { padding: 4px 10px 4px 4px; font-size: 11.5px; gap: 6px; }
#mstudio .ms-steps li::before { width: 20px; height: 20px; font-size: 10.5px; }
#mstudio .ms-grid, #mstudio .ms-grid.ms-grid { display: grid; grid-template-columns: minmax(0, 1fr) !important; gap: 10px; max-width: 560px; margin: 0 auto; }
#mstudio .ms-grid > .ms-card { padding: 0; border: 0; background: none; }
#mstudio .ms-go-wrap { max-width: 560px; margin-left: auto; margin-right: auto; }
#mstudio .ms-go-wrap { margin-top: 10px; }
/* компактне завантаження: один рядок (іконка + текст); після фото — мініатюра + «замінити» */
#mstudio .ms-drop { min-height: 84px; place-items: stretch; text-align: left; border-radius: 14px; }
#mstudio .ms-drop .ms-drop-body { display: grid !important; grid-template-columns: 48px 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; justify-items: start !important; padding: 14px 16px !important; }
#mstudio .ms-drop .ms-drop-ico { grid-row: 1 / 3; display: grid !important; place-items: center; width: 46px; height: 46px; margin: 0; }
#mstudio .ms-drop .ms-drop-title { font-size: 15px; }
#mstudio .ms-drop .ms-drop-sub { font-size: 11.5px; margin-top: 2px; }
#mstudio .ms-drop.has-photo .ms-drop-body { position: static; background: none; backdrop-filter: none; padding: 10px 14px 10px 86px !important; grid-template-columns: 1fr; min-height: 84px; }
#mstudio .ms-drop.has-photo img { inset: auto; left: 10px; top: 50%; transform: translateY(-50%); width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--ms-ink-3); }
#mstudio .ms-drop.has-photo .ms-drop-title { font-size: 14px; }
#mstudio .ms-drop.has-photo .ms-drop-sub { font-size: 11.5px; color: var(--ms-gold-hi); }
/* тканина: кнопка або компактна картка */
#mstudio .ms-pick { min-height: 52px; font-size: 15px; }
#mstudio .ms-btn-gold#msGo { min-height: 56px; }
#mstudio .ms-fabric .ms-chosen { margin: 0; min-height: 52px; padding: 6px 8px 6px 6px; }
#mstudio .ms-fabric .ms-chosen > div { flex: 1 1 auto; min-width: 0; }
#mstudio .ms-fabric .ms-chosen b, #mstudio .ms-fabric .ms-chosen span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#mstudio .ms-change { flex: 0 0 auto; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--ms-line-strong); background: transparent; color: var(--ms-gold-hi); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
#mstudio .ms-change:focus-visible, #mstudio .ms-modal-x:focus-visible { outline: 2px solid var(--ms-gold-hi); outline-offset: 2px; }
#mstudio .ms-hint { margin: 6px 0 0; min-height: 0; font-size: 12px; text-align: center; }
/* ── вікно каталогу: мобільний — на весь екран; ПК — по центру ── */
#mstudio .ms-modal { position: fixed; inset: 0; z-index: 10050; display: flex; align-items: stretch; justify-content: center; background: rgba(6, 4, 2, .72); backdrop-filter: blur(4px); }
#mstudio .ms-modal[hidden] { display: none !important; }
#mstudio .ms-modal-box { display: flex; flex-direction: column; width: 100%; height: 100%; height: 100dvh; background: var(--ms-ink-2); padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom)); }
#mstudio .ms-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
#mstudio .ms-modal-head h2 { margin: 0; font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 500; font-size: 22px; line-height: 1.15; color: var(--ms-ivory); }
#mstudio .ms-modal-sub { margin: 3px 0 0; font-size: 12px; color: var(--ms-muted); }
#mstudio .ms-modal-x { flex: 0 0 auto; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--ms-line-strong); background: rgba(243, 236, 220, .04); color: var(--ms-ivory); cursor: pointer; }
#mstudio .ms-modal .ms-tabs { flex: 0 0 auto; margin: 0 -16px 10px; }
#mstudio .ms-modal .ms-swatches { flex: 1 1 auto; max-height: none; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); align-content: start; }
#mstudio .ms-modal .ms-sw small { display: block; color: var(--ms-muted); font-size: 10px; }
@media (min-width: 760px) {
  #mstudio .ms-modal { align-items: center; padding: 24px; }
  #mstudio .ms-modal-box { width: min(760px, 100%); height: auto; max-height: min(86vh, 820px); border-radius: 20px; border: 1px solid var(--ms-line); box-shadow: 0 40px 120px -30px rgba(0, 0, 0, .8); padding: 20px 22px; }
  #mstudio .ms-modal .ms-tabs { margin: 0 -22px 12px; padding: 0 22px; }
}
@media (max-height: 640px) { #mstudio { padding-top: 58px !important; } #mstudio .hero-title { font-size: 28px; } #mstudio .hero-sub { font-size: 16px; } }

html.ms-modal-open, html.ms-modal-open body { overflow: hidden !important; overscroll-behavior: none; }
#mstudio .ms-drop.has-photo .ms-drop-ico { display: none !important; }

/* Server-rendered portrait JPG: natural aspect at any viewport width. */
#mstudio #msPosterImage { display: block; width: 100%; height: auto; object-fit: contain; }

/* MAGICUM 2027 · компактна інструкція перед першим фото (portrait 9:16). */
#mstudio .ms-photo-guide-link {
  display: block; margin: 5px 4px 0 auto; padding: 5px 7px; min-height: 30px;
  border: 0; background: transparent; color: #f6d994; font: 600 12px Montserrat, sans-serif;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
#mstudio .ms-photo-guide-link:focus-visible { outline: 2px solid #e6bf6b; outline-offset: 2px; }
#mstudio .ms-photo-guide {
  position: fixed; inset: 0; z-index: 10080; display: flex; align-items: center; justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  background: rgba(5, 13, 29, .84); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
#mstudio .ms-photo-guide[hidden] { display: none !important; }
#mstudio .ms-photo-guide-card {
  position: relative; width: min(100%, 430px); max-height: 100%; overflow-y: auto;
  padding: 17px 18px 18px; border-radius: 18px; border: 1px solid #b6924d;
  background: linear-gradient(155deg, #162f56, #0c1930 58%, #0a1428); color: #f8f5ec;
  box-shadow: 0 25px 85px rgba(0, 0, 0, .65); overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
#mstudio .ms-photo-guide-close {
  position: absolute; right: 10px; top: 8px; display: grid; place-items: center;
  width: 36px; height: 36px; border: none; background: transparent; color: #e6cb8d;
  font: 28px/1 sans-serif; cursor: pointer;
}
#mstudio .ms-photo-guide-brand { margin: 0 0 8px; color: #e8c583; text-align: center; font: 600 15px Georgia, serif; letter-spacing: .15em; }
#mstudio .ms-photo-guide h2 { margin: 0 20px 5px; font: 600 clamp(20px, 5vw, 25px)/1.14 Georgia, serif; color: #fff4da; text-align: center; }
#mstudio .ms-photo-guide-sub { margin: 0 0 11px; font-size: 11.5px; line-height: 1.35; text-align: center; color: #cbd6e5; }
#mstudio .ms-photo-guide-list { list-style: none; counter-reset: photo-guide; display: grid; gap: 7px; margin: 0; padding: 0; }
#mstudio .ms-photo-guide-list li {
  counter-increment: photo-guide; display: grid; grid-template-columns: 26px minmax(0, 1fr);
  grid-template-rows: auto auto; column-gap: 9px; align-items: center; font-size: 12px; line-height: 1.36;
}
#mstudio .ms-photo-guide-list li::before {
  content: counter(photo-guide); grid-row: 1 / 3; display: grid; place-items: center;
  width: 25px; height: 25px; border-radius: 50%; color: #f6d18c; background: #29486e;
  font-weight: 700; font-size: 11px;
}
#mstudio .ms-photo-guide-list b { color: #fff; font-size: 12.5px; }
#mstudio .ms-photo-guide-list span { color: #c9d5e6; }
#mstudio .ms-photo-guide-note { margin: 12px 0 0; color: #f4d79b; font-size: 11.5px; text-align: center; }
#mstudio .ms-photo-guide-foot { margin: 5px 0 12px; color: #d5deed; font-size: 11px; text-align: center; }
#mstudio .ms-photo-guide-continue {
  display: block; width: 100%; min-height: 45px; padding: 9px 12px; border: none; border-radius: 11px;
  background: linear-gradient(180deg, #f4daa0, #d3a34d); color: #15243a;
  font: 700 13px/1.25 Montserrat, sans-serif; cursor: pointer;
}
#mstudio .ms-photo-guide button:focus-visible { outline: 2px solid #fff0c3; outline-offset: 2px; }
@media (max-height: 600px) {
  #mstudio .ms-photo-guide-card { padding: 11px 14px; }
  #mstudio .ms-photo-guide-brand { margin-bottom: 4px; }
  #mstudio .ms-photo-guide-list { gap: 4px; }
  #mstudio .ms-photo-guide-note { margin-top: 6px; }
  #mstudio .ms-photo-guide-foot { margin-bottom: 7px; }
}

/* Заявка на перетяжку (ODIN 2026-12-03): одна кнопка під готовим постером → окрема сторінка. */
#mstudio .ms-actions .ms-btn-quote { grid-column: 1 / -1; text-decoration: none; text-align: center; }
#mstudio .ms-btn[hidden] { display: none !important; }

/* Рамка постера з «⋯ Дії з постером» (ODIN 2026-12-03): окрема верхня смуга — кнопка ніколи не лягає на зображення. */
#mstudio .ms-poster-bar { position: relative; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px; min-height: 48px; padding: 2px 2px 6px; }
#mstudio .ms-poster-menu-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--ms-line-strong); background: var(--ms-ink-3); color: var(--ms-gold-hi); cursor: pointer; -webkit-tap-highlight-color: transparent; }
#mstudio .ms-poster-menu-btn:hover, #mstudio .ms-poster-menu-btn[aria-expanded="true"] { border-color: var(--ms-gold-hi); }
#mstudio .ms-poster-menu-btn:focus-visible, #mstudio .ms-poster-menu-item:focus-visible { outline: 3px solid var(--ms-gold-hi); outline-offset: 2px; }
/* Меню — смуга НАД JPG у потоці сторінки: відкриття зсуває постер униз, нічого не перекриває; закрите — не займає місця. */
#mstudio .ms-poster-menu { position: static; flex: 1 1 100%; min-width: 0; max-width: 100%; box-sizing: border-box; padding: 6px; border-radius: 14px; border: 1px solid var(--ms-line-strong); background: #0c1a33; }
#mstudio .ms-poster-menu[hidden], #mstudio .ms-poster-bar[hidden] { display: none !important; }
#mstudio .ms-poster-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent; color: #f3e7c8; font: inherit; font-size: 15px; font-weight: 600; text-align: left; cursor: pointer; }
#mstudio .ms-poster-menu-item:hover, #mstudio .ms-poster-menu-item:focus { background: rgba(212, 174, 90, .14); }

/* One-screen mobile result: size the preview, never crop the source JPG. */
@media (max-width: 639px) and (min-height: 540px) and (orientation: portrait) {
  #hero.mstudio-host #mstudio #msResult:has(#msQuote:not([hidden])):not(:has(#msPosterMenu:not([hidden]), #msPwaInstallHelp:not([hidden]))) {
    display: flex;
    flex-direction: column;
    min-block-size: 0;
    block-size: calc(100svh - 18px);
    gap: 5px;
    padding-block: 8px;
  }
  #hero.mstudio-host #mstudio #msResult:has(#msQuote:not([hidden])) > :not(#msPdfWrap) {
    flex: 0 0 auto;
    margin-block: 0;
  }
  #hero.mstudio-host #mstudio #msResult:has(#msQuote:not([hidden])) .ms-result-head h2 {
    font-size: clamp(18px, 5.2vw, 24px);
    line-height: 1.12;
  }
  #hero.mstudio-host #mstudio #msResult:has(#msQuote:not([hidden])):not(:has(#msPosterMenu:not([hidden]), #msPwaInstallHelp:not([hidden]))) #msPdfWrap {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    min-block-size: 130px;
    margin: 0;
  }
  #hero.mstudio-host #mstudio #msResult:has(#msQuote:not([hidden])):not(:has(#msPosterMenu:not([hidden]), #msPwaInstallHelp:not([hidden]))) #msPdfView:not([hidden]) {
    display: flex;
    flex: 1 1 0;
    justify-content: center;
    min-block-size: 0;
    background: transparent;
    box-shadow: none;
  }
  #hero.mstudio-host #mstudio #msResult:has(#msQuote:not([hidden])):not(:has(#msPosterMenu:not([hidden]), #msPwaInstallHelp:not([hidden]))) #msPosterImage {
    width: auto;
    max-width: 100%;
    height: 100%;
    object-fit: contain;
  }
  #hero.mstudio-host #mstudio #msResult:has(#msQuote:not([hidden])) .ms-more a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding-block: 0;
  }
  #hero.mstudio-host #mstudio #msResult:has(#msQuote:not([hidden])) #msAgain {
    min-height: 44px;
  }
}
