/* MasterFresok — калькулятор «Свой размер» (masterfresok.kz) */
.mfk, .mfk-ed { --mfk-accent: #307fdd; --mfk-text: #23262b; --mfk-muted: #6b7480; --mfk-line: #e2e5e9; --mfk-bg: #f6f7f9;
  --mfk-ok: #1e8e5a; --mfk-err: #d23b3b; --mfk-warn: #b8730c; --mfk-r: 10px; }
.mfk { margin: 24px 0; color: var(--mfk-text); font-size: 14px; line-height: 1.4; }
.mfk *, .mfk-ed * { box-sizing: border-box; }
.mfk-box { border: 1px solid var(--mfk-line); border-radius: var(--mfk-r); background: #fff; padding: 20px; }
.mfk-head { margin-bottom: 16px; }
.mfk-title { font-size: 20px; font-weight: 700; line-height: 1.25; }
.mfk-sub { color: var(--mfk-muted); margin-top: 4px; }
.mfk-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.mfk-left { position: sticky; top: 90px; }

/* эскиз стены */
.mfk-sk { position: relative; overflow: hidden; background: var(--mfk-bg); border-radius: var(--mfk-r); padding: 16px 12px 36px 40px; cursor: pointer;
  display: flex; justify-content: center; min-height: 200px; outline: none; }
.mfk-sk:focus-visible { box-shadow: 0 0 0 2px var(--mfk-accent); }
.mfk-sk > .mfk-sk-wall, .mfk-sk-dw, .mfk-sk-dh { position: relative; }
.mfk-sk-wall { flex: none; overflow: hidden; background: #e4e6ea; box-shadow: 0 0 0 1px rgba(0,0,0,.18), 0 6px 20px rgba(0,0,0,.08); transition: box-shadow .15s; }
.mfk-sk-wall img, .mfk-ed-wall img { user-select: none; -webkit-user-select: none; -webkit-user-drag: none; pointer-events: none; }
.mfk-sk-wall img:not([style]) { display: none; }
.mfk-sk-dw { position: absolute !important; bottom: 10px; height: 14px; }
.mfk-sk-dh { position: absolute !important; left: 12px; width: 14px; }
.mfk-sk-dw i, .mfk-ed-dw i { position: absolute; left: 0; right: 0; top: 7px; border-top: 1px solid currentColor; }
.mfk-sk-dh i, .mfk-ed-dh i { position: absolute; top: 0; bottom: 0; left: 7px; border-left: 1px solid currentColor; }
.mfk-sk-dw i::before, .mfk-sk-dw i::after, .mfk-ed-dw i::before, .mfk-ed-dw i::after { content: ''; position: absolute; top: -4px; border: 4px solid transparent; }
.mfk-sk-dw i::before, .mfk-ed-dw i::before { left: -1px; border-right: 7px solid currentColor; border-left: 0; }
.mfk-sk-dw i::after, .mfk-ed-dw i::after { right: -1px; border-left: 7px solid currentColor; border-right: 0; }
.mfk-sk-dh i::before, .mfk-sk-dh i::after, .mfk-ed-dh i::before, .mfk-ed-dh i::after { content: ''; position: absolute; left: -4px; border: 4px solid transparent; }
.mfk-sk-dh i::before, .mfk-ed-dh i::before { top: -1px; border-bottom: 7px solid currentColor; border-top: 0; }
.mfk-sk-dh i::after, .mfk-ed-dh i::after { bottom: -1px; border-top: 7px solid currentColor; border-bottom: 0; }
.mfk-sk-dw span, .mfk-sk-dh span, .mfk-ed-dw span, .mfk-ed-dh span { position: absolute; background: var(--mfk-bg); padding: 0 6px; font-weight: 700;
  font-size: 12px; white-space: nowrap; border-radius: 3px; }
.mfk-sk-dw span, .mfk-ed-dw span { left: 50%; top: -1px; transform: translateX(-50%); }
.mfk-sk-dh span, .mfk-ed-dh span { left: 7px; top: 50%; transform: translate(-50%,-50%) rotate(-90deg); }
.mfk-crop { width: 100%; margin-top: 10px; }
.mfk-note { color: var(--mfk-muted); font-size: 12.5px; margin-top: 8px; text-align: center; min-height: 18px; }
.mfk-warn { color: var(--mfk-warn); }

/* форма */
.mfk-lbl { font-weight: 600; margin: 16px 0 6px; }
.mfk-lbl:first-child { margin-top: 0; }
.mfk-opt { font-weight: 400; color: var(--mfk-muted); font-size: 12.5px; }
.mfk-size { display: flex; align-items: flex-end; gap: 10px; }
.mfk-size b { padding-bottom: 12px; color: var(--mfk-muted); font-weight: 400; }
.mfk-size label { flex: 1; display: block; }
.mfk-size label span { display: block; font-size: 12px; color: var(--mfk-muted); margin-bottom: 3px; }
.mfk input[type=text], .mfk input[type=tel], .mfk-ed input[type=text] {
  width: 100%; height: 44px; border: 1px solid #cfd4da; border-radius: 8px; padding: 0 12px; font: inherit; font-size: 16px;
  color: var(--mfk-text); background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
.mfk input:focus, .mfk-ed input[type=text]:focus { border-color: var(--mfk-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mfk-accent) 18%, transparent); }
.mfk input.bad { border-color: var(--mfk-err); }
.mfk-err { color: var(--mfk-err); font-size: 13px; min-height: 0; }
.mfk-err:not(:empty) { margin-top: 6px; }
.mfk-hp { position: absolute !important; left: -9999px !important; width: 1px !important; height: 1px !important; opacity: 0; }

.mfk-mats { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; padding: 2px; margin: -2px; overscroll-behavior: contain; }
.mfk-mat { display: flex; align-items: center; gap: 10px; border: 1px solid var(--mfk-line); border-radius: 8px; padding: 7px 10px; cursor: pointer;
  transition: border-color .15s, background .15s; min-height: 48px; }
.mfk-mat.on { border-color: var(--mfk-accent); background: color-mix(in srgb, var(--mfk-accent) 7%, #fff); box-shadow: inset 0 0 0 1px var(--mfk-accent); }
.mfk-mat input { position: absolute; opacity: 0; pointer-events: none; }
.mfk-mat img, .mfk-mat-ph { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; flex: none; background: var(--mfk-bg); }
.mfk-mat-n { flex: 1; min-width: 0; }
.mfk-mat-p { font-weight: 700; white-space: nowrap; }
.mfk-mat-p small { font-weight: 400; color: var(--mfk-muted); margin-left: 1px; }
.mfk-mats.nophoto .mfk-mat-ph { display: none; }
.mfk .mfk-more { display: none; width: 100%; margin-top: 6px; min-height: 40px; font-weight: 500; }
.mfk-mdesc { color: var(--mfk-muted); font-size: 12.5px; margin-top: 6px; }
.mfk-mdesc:empty { display: none; }
.mfk-load { color: var(--mfk-muted); padding: 10px 0; }

.mfk-right [data-k="srvWrap"] { margin-top: 18px; }
.mfk-srv { display: flex; flex-direction: column; gap: 6px; }
.mfk-chk { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 8px 10px; border: 1px solid var(--mfk-line); border-radius: 8px; }
.mfk-chk input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--mfk-accent); flex: none; }
.mfk-chk span { flex: 1; }
.mfk-chk small { display: block; color: var(--mfk-muted); font-size: 12px; }
.mfk-chk em { font-style: normal; white-space: nowrap; color: var(--mfk-muted); }

.mfk-sum { margin-top: 16px; background: var(--mfk-bg); border-radius: var(--mfk-r); padding: 12px 14px; }
.mfk-sum:empty { display: none; }
.mfk-sum-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.mfk-sum-row small { display: block; color: var(--mfk-muted); font-size: 12px; }
.mfk-sum-row b { white-space: nowrap; }
.mfk-total { border-top: 1px solid var(--mfk-line); margin-top: 6px; padding-top: 10px; font-size: 18px; }
.mfk-total b { font-size: 22px; }
.mfk-muted { color: var(--mfk-muted); }
.mfk-cg { display: grid; grid-template-columns: 1.3fr 1fr; gap: 8px; }

.mfk-act { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.mfk-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 8px;
  border: 1px solid #c4cad1; background: #fff; color: #2e3640; font: inherit; font-weight: 600; cursor: pointer; text-align: center;
  transition: border-color .15s, color .15s, background .15s, filter .15s; -webkit-tap-highlight-color: transparent; }
.mfk-btn:disabled { opacity: .5; cursor: default; }
.mfk-btn.on { background: color-mix(in srgb, var(--mfk-accent) 9%, #fff); border-color: var(--mfk-accent); color: var(--mfk-accent); }
.mfk-btn.busy { position: relative; color: transparent !important; }
.mfk-btn.busy::after { content: ''; position: absolute; width: 18px; height: 18px; border: 2px solid currentColor; border-color: #9aa3ad transparent #9aa3ad transparent;
  border-radius: 50%; animation: mfk-spin .7s linear infinite; }
.mfk-primary { background: var(--mfk-accent); border-color: var(--mfk-accent); color: #fff; }
.mfk-primary.busy::after { border-color: #fff transparent #fff transparent; }
@keyframes mfk-spin { to { transform: rotate(360deg); } }
.mfk-status { margin-top: 10px; font-size: 13.5px; min-height: 0; }
.mfk-status.mfk-ok { color: var(--mfk-ok); }
.mfk-status.mfk-err { color: var(--mfk-err); }
.mfk-status.mfk-warn { color: var(--mfk-warn); }
.mfk-status a { color: inherit; font-weight: 700; }

/* ---------- редактор кадра ---------- */
.mfk-ed { position: fixed; inset: 0; z-index: 3000; background: rgba(20,22,26,.72); display: flex; align-items: center; justify-content: center;
  color: var(--mfk-text); font: 14px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; outline: none; }
.mfk-ed-box { display: grid; grid-template-columns: minmax(0, 1fr) 360px; grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top top" "stage side" "stage foot"; width: min(1200px, 96vw); height: min(800px, 92vh);
  background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.mfk-ed-top { grid-area: top; display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--mfk-line); }
.mfk-ed-top b { font-size: 16px; }
.mfk-ed-x { border: 0; background: none; width: 40px; height: 40px; border-radius: 8px; cursor: pointer; color: var(--mfk-muted); display: grid; place-items: center; }
.mfk-ed-stage { grid-area: stage; position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 20px 24px 14px; background: var(--mfk-bg); overflow: hidden; }
.mfk-ed-wrap { position: relative; flex: none; margin: 0 0 32px 34px; }
.mfk-ed-wall { position: relative; overflow: hidden; background: #e4e6ea; cursor: grab; touch-action: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,.3), 0 0 0 9999px rgba(20,22,26,.05); }
.mfk-ed-wall:active { cursor: grabbing; }
.mfk-ed-dw { position: absolute; left: 0; right: 0; bottom: -25px; height: 14px; }
.mfk-ed-dh { position: absolute; top: 0; bottom: 0; left: -29px; width: 14px; }
.mfk-ed .mfk-ed-dw span, .mfk-ed .mfk-ed-dh span { background: var(--mfk-bg); }
.mfk-ed-hint { flex: none; margin-top: 0; text-align: center; color: var(--mfk-muted); font-size: 12px; line-height: 1.35; max-width: 100%; pointer-events: none; }
.mfk-ed-side > * { flex: none; }
.mfk-ed-tabs { display: none; }
.mfk-ed-side { grid-area: side; padding: 16px 16px 8px; border-left: 1px solid var(--mfk-line); overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 12px; }
.mfk-ed-side label { display: block; font-size: 12px; color: var(--mfk-muted); }
.mfk-ed-side label > span { display: block; margin-bottom: 4px; }
.mfk-ed-side label b { font-weight: 600; color: var(--mfk-text); }
.mfk-ed-side label input { display: block; width: 100%; margin: 0; }
.mfk-ed-side input[type=range] { accent-color: var(--mfk-accent); height: 24px; }
.mfk-ed-g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mfk-ed .mfk-ed-g2 input[type=text] { height: 40px; }
.mfk-ed-row { display: flex; gap: 6px; }
.mfk-ed-row .mfk-btn { flex: 1 1 0; min-width: 0; padding: 0 6px; white-space: nowrap; min-height: 40px; font-weight: 500; gap: 6px; }
.mfk-ed-info { font-size: 12.5px; color: #4a5562; }
.mfk-ed-info:empty { display: none; }
.mfk-ed-foot { grid-area: foot; display: flex; gap: 8px; padding: 12px 16px 16px; border-left: 1px solid var(--mfk-line); background: #fff; }
.mfk-ed-foot .mfk-btn { flex: 1 1 0; min-height: 44px; font-weight: 700; }
/* цветовые решения: плашки с мини-превью рисунка */
.mfk-tones-lbl { margin-top: 14px; }
.mfk-tones { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.mfk-tone { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 3px 3px 5px; border: 1px solid var(--mfk-line); border-radius: 8px;
  background: #fff; font: inherit; font-size: 12px; line-height: 1.2; color: var(--mfk-text); cursor: pointer; text-align: center; min-width: 0;
  transition: border-color .15s, box-shadow .15s; -webkit-tap-highlight-color: transparent; }
.mfk-tone img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 5px; background: var(--mfk-bg); }
.mfk-tone span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mfk-tone.on { border-color: var(--mfk-accent); box-shadow: inset 0 0 0 1px var(--mfk-accent); color: var(--mfk-accent); font-weight: 600; }
.mfk-btn svg { flex: none; }
.mfk-ed-tones .mfk-tone { font-size: 10.5px; letter-spacing: -.15px; padding: 3px 1px 4px; }
.mfk-ed-tones { gap: 6px; }
.mfk-ed-tl { font-size: 12px; color: var(--mfk-muted); margin-bottom: -4px; }
.mfk-ed-tl b { font-weight: 600; color: var(--mfk-text); }

/* ---------- телефон / узкий экран ---------- */
@media (max-width: 860px) {
  .mfk-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .mfk-left { position: static; }
}
@media (max-width: 560px) {
  .mfk { margin: 18px 0; }
  .mfk-box { padding: 14px; border-radius: 12px; }
  .mfk-title { font-size: 18px; }
  .mfk-sk { padding: 12px 8px 32px 34px; min-height: 0; }
  .mfk-sk-dh { left: 8px; }
  .mfk-mats { max-height: none; overflow: visible; }
  .mfk-mats.collapsed .mfk-mat:not(.on) { display: none; }
  .mfk .mfk-more { display: flex; }
  .mfk .mfk-more[hidden] { display: none; }
  .mfk-ed-box { grid-template-columns: minmax(0, 1fr) !important; }
  .mfk-act { grid-template-columns: 1fr; }
  .mfk-cg { grid-template-columns: 1fr; }

  .mfk-ed { background: #fff; align-items: stretch; }
  .mfk-ed-box { width: 100%; height: 100vh; height: 100dvh; border-radius: 0; box-shadow: none;
    grid-template-rows: auto minmax(0, 1fr) auto auto auto; grid-template-areas: "top" "stage" "tabs" "side" "foot"; }
  .mfk-ed-top { padding: 4px 6px 4px 14px; padding-top: max(4px, env(safe-area-inset-top)); }
  .mfk-ed-stage { padding: 12px 14px 8px; }
  .mfk-ed-wrap { margin: 0 0 30px 30px; }
  .mfk-ed-dh { left: -27px; }
  /* вкладки Кадр / Цвет / Размер — видна одна группа, поле кадрирования остаётся большим */
  .mfk-ed-tabs { grid-area: tabs; display: flex; gap: 4px; padding: 6px 12px 0; border-top: 1px solid var(--mfk-line); background: #fff; }
  .mfk-ed-tabs button { flex: 1 1 0; min-width: 0; height: 36px; border: 0; border-radius: 8px; background: var(--mfk-bg); color: var(--mfk-muted);
    font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; -webkit-tap-highlight-color: transparent; }
  .mfk-ed-tabs button.on { background: color-mix(in srgb, var(--mfk-accent) 12%, #fff); color: var(--mfk-accent); }
  .mfk-ed-tabs i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-left: 4px; vertical-align: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
  .mfk-ed-tabs i[hidden] { display: none; }
  .mfk-ed-side { border-left: 0; padding: 10px 12px; gap: 8px; min-height: 136px; justify-content: center; }
  .mfk-ed-side[data-tab="frame"] [data-g]:not([data-g="frame"]),
  .mfk-ed-side[data-tab="color"] [data-g]:not([data-g="color"]),
  .mfk-ed-side[data-tab="size"] [data-g]:not([data-g="size"]) { display: none !important; }
  .mfk-ed-side[data-tab="color"] .mfk-ed-tl { display: none !important; }
  /* ползунки — в одну строку с подписью */
  .mfk-ed-rng { display: grid !important; grid-template-columns: 104px minmax(0, 1fr); align-items: center; gap: 8px; }
  .mfk-ed-side .mfk-ed-rng > span { margin: 0; }
  .mfk-ed-row .mfk-btn { min-height: 38px; }
  .mfk-ed-row .mfk-btn span { font-size: 13px; }
  .mfk-ed-g2 label { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 6px; }
  .mfk-ed-side .mfk-ed-g2 label > span { margin: 0; }
  .mfk-ed .mfk-ed-g2 input[type=text] { height: 38px; }
  /* в редакторе на телефоне — одна прокручиваемая строка плашек */
  .mfk-ed-tones { display: flex; overflow-x: auto; gap: 6px; margin: 0 -12px; padding: 1px 12px 2px; scroll-padding: 0 12px; scroll-snap-type: x proximity; scrollbar-width: none; }
  .mfk-ed-tones::-webkit-scrollbar { display: none; }
  .mfk-ed-tones .mfk-tone { flex: 0 0 76px; scroll-snap-align: start; padding: 2px 2px 3px; gap: 2px; font-size: 10.5px; }
  .mfk-ed-tones .mfk-tone img { aspect-ratio: 3 / 2; }
  .mfk-tones { gap: 6px; }
  .mfk-tone { font-size: 11px; letter-spacing: -.1px; padding: 3px 2px 5px; }
  .mfk-tone span { text-overflow: clip; }
  .mfk-ed-foot { border-left: 0; border-top: 1px solid var(--mfk-line); padding: 8px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .mfk-ed-foot .mfk-btn { min-height: 46px; }
}
@media (max-width: 380px) { .mfk-tones .mfk-tone { font-size: 10px; letter-spacing: -.2px; padding-left: 1px; padding-right: 1px; } .mfk-ed-row { gap: 5px; } .mfk-ed-row .mfk-btn { gap: 4px; padding: 0 4px; } .mfk-ed-row .mfk-btn span { font-size: 12.5px; } .mfk-ed-row .mfk-btn svg { width: 16px; height: 16px; } .mfk-ed-rng { grid-template-columns: 96px minmax(0, 1fr); } }

/* наведение — только там, где есть мышь (на телефоне кнопка не «залипает» подсвеченной) */
@media (hover: hover) {
  .mfk-tone:hover:not(.on) { border-color: #b9c1ca; }
  .mfk-sk:hover .mfk-sk-wall { box-shadow: 0 0 0 2px var(--mfk-accent), 0 6px 20px rgba(0,0,0,.1); }
  .mfk-mat:hover { border-color: #b9c1ca; }
  .mfk-btn:hover:not(:disabled) { border-color: var(--mfk-accent); color: var(--mfk-accent); }
  .mfk-primary:hover:not(:disabled) { background: var(--mfk-accent); border-color: var(--mfk-accent); color: #fff; }
  .mfk-primary:hover:not(:disabled) { color: #fff; filter: brightness(1.07); }
  .mfk-ed-x:hover { background: var(--mfk-bg); color: var(--mfk-text); }
}

/* ссылка «Рассчитать под свой размер» в блоке покупки карточки товара (template.php) */
.mfk-jump { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 44px; margin-top: 10px; padding: 0 14px;
  border: 1px dashed var(--mfk-accent, #307fdd); border-radius: 8px; color: var(--mfk-accent, #307fdd) !important; font-weight: 600; font-size: 14px;
  text-decoration: none !important; transition: background .15s; }
.mfk-jump svg { flex: none; }
@media (hover: hover) { .mfk-jump:hover { background: color-mix(in srgb, #307fdd 7%, #fff); } }
.catalog-detail__mfcalc { scroll-margin-top: 90px; }
.catalog-detail__mfcalc .mfk { margin-top: 32px; }
