/* RO Furniture Sofa Visualizer - Mask Painter. All selectors are prefixed rofsv-me-. */

.rofsv-me-root {
  --rofsv-me-accent: #0A5EB0;
  --rofsv-me-accent-dark: #084b8d;
  --rofsv-me-accent2: #00C6B7;
  --rofsv-me-panel: #ffffff;
  --rofsv-me-panel2: #f3f5f8;
  --rofsv-me-line: #d8dee7;
  --rofsv-me-text: #1d2733;
  --rofsv-me-muted: #5b6878;
  --rofsv-me-danger: #b42318;
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 1000000;
  display: flex;
  background: rgba(20, 28, 40, 0.55);
  color: var(--rofsv-me-text);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-align: left;
  letter-spacing: normal;
}
.rofsv-me-root *, .rofsv-me-root *::before, .rofsv-me-root *::after { box-sizing: border-box; }

.rofsv-me-modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: var(--rofsv-me-panel2);
  overflow: hidden;
}

/* header */
.rofsv-me-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 16px;
  padding: 8px 14px;
  background: var(--rofsv-me-panel);
  border-bottom: 1px solid var(--rofsv-me-line);
}
.rofsv-me-root .rofsv-me-title {
  margin: 0; padding: 0;
  font-size: 16px; font-weight: 600; line-height: 1.3; color: var(--rofsv-me-text);
  flex: 1 1 200px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rofsv-me-header-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* toolbar + options */
.rofsv-me-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  padding: 8px 14px;
  background: var(--rofsv-me-panel2);
  border-bottom: 1px solid var(--rofsv-me-line);
}
.rofsv-me-group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.rofsv-me-toolbar > .rofsv-me-group + .rofsv-me-group { padding-left: 10px; border-left: 1px solid var(--rofsv-me-line); }
.rofsv-me-toolbar > .rofsv-me-group.rofsv-me-seg { padding-left: 0; border-left: 1px solid var(--rofsv-me-line); }
.rofsv-me-options {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 22px;
  padding: 6px 14px;
  min-height: 44px;
  background: var(--rofsv-me-panel);
  border-bottom: 1px solid var(--rofsv-me-line);
}
.rofsv-me-opt-fabric { display: none; align-items: center; flex-wrap: wrap; gap: 6px 22px; }
.rofsv-me-opt-fabric.rofsv-me-show { display: flex; }
.rofsv-me-root[data-tool="magic"] .rofsv-me-opt-magic { display: inline-flex; }
.rofsv-me-root:not([data-tool="magic"]) .rofsv-me-opt-magic { display: none; }

.rofsv-me-field { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--rofsv-me-muted); font-size: 12px; cursor: default; }
.rofsv-me-field-label { font-weight: 600; color: var(--rofsv-me-text); white-space: nowrap; }
.rofsv-me-root .rofsv-me-field-val { min-width: 42px; font-variant-numeric: tabular-nums; color: var(--rofsv-me-muted); background: none; border: 0; padding: 0; font-size: 12px; }

.rofsv-me-root input.rofsv-me-range {
  -webkit-appearance: auto; appearance: auto;
  width: 140px; height: 24px; margin: 0; padding: 0;
  accent-color: var(--rofsv-me-accent);
  background: transparent; border: 0; box-shadow: none; min-height: 0;
  cursor: pointer;
}
.rofsv-me-root select.rofsv-me-select {
  height: 32px; min-height: 32px; max-width: 220px; margin: 0; padding: 0 28px 0 8px;
  font: inherit; color: var(--rofsv-me-text);
  background-color: #fff; border: 1px solid var(--rofsv-me-line); border-radius: 6px; box-shadow: none;
  line-height: 30px;
}
.rofsv-me-root select.rofsv-me-select:focus { outline: 2px solid var(--rofsv-me-accent); outline-offset: 1px; border-color: var(--rofsv-me-accent); box-shadow: none; }

.rofsv-me-hint {
  padding: 6px 14px; font-size: 12px; color: var(--rofsv-me-muted);
  background: #eaf3fb; border-bottom: 1px solid #d3e4f4;
}

/* buttons */
.rofsv-me-root button.rofsv-me-btn {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; min-height: 34px; min-width: 34px; margin: 0; padding: 0 9px;
  font: 600 13px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--rofsv-me-text); text-transform: none; text-decoration: none; letter-spacing: normal;
  background: var(--rofsv-me-panel); border: 1px solid var(--rofsv-me-line); border-radius: 7px;
  box-shadow: none; text-shadow: none; cursor: pointer;
  white-space: nowrap; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s;
}
.rofsv-me-root button.rofsv-me-btn:hover:not(:disabled) { background: #eef2f7; border-color: #b9c4d2; color: var(--rofsv-me-text); }
.rofsv-me-root button.rofsv-me-btn:focus-visible { outline: 2px solid var(--rofsv-me-accent); outline-offset: 2px; box-shadow: none; }
.rofsv-me-root button.rofsv-me-btn:disabled { opacity: .45; cursor: not-allowed; }
.rofsv-me-root button.rofsv-me-btn.rofsv-me-active,
.rofsv-me-root button.rofsv-me-btn[aria-pressed="true"] {
  background: var(--rofsv-me-accent); border-color: var(--rofsv-me-accent); color: #fff;
}
.rofsv-me-root button.rofsv-me-btn.rofsv-me-active:hover:not(:disabled) { background: var(--rofsv-me-accent-dark); border-color: var(--rofsv-me-accent-dark); color: #fff; }
.rofsv-me-root button.rofsv-me-btn-primary { background: var(--rofsv-me-accent); border-color: var(--rofsv-me-accent); color: #fff; padding: 0 16px; }
.rofsv-me-root button.rofsv-me-btn-primary:hover:not(:disabled) { background: var(--rofsv-me-accent-dark); border-color: var(--rofsv-me-accent-dark); color: #fff; }
.rofsv-me-root button.rofsv-me-btn-primary.rofsv-me-saved { background: #0d8a63; border-color: #0d8a63; }
.rofsv-me-root button.rofsv-me-btn-primary.rofsv-me-busy:disabled { opacity: .8; cursor: progress; }
.rofsv-me-root button.rofsv-me-btn-secondary { background: #fff; }
.rofsv-me-root button.rofsv-me-btn-ghost { background: transparent; border-color: transparent; color: var(--rofsv-me-muted); }
.rofsv-me-root button.rofsv-me-btn-ghost:hover:not(:disabled) { background: #eef2f7; border-color: var(--rofsv-me-line); }
.rofsv-me-root button.rofsv-me-btn-danger { background: var(--rofsv-me-danger); border-color: var(--rofsv-me-danger); color: #fff; }
.rofsv-me-root button.rofsv-me-btn-danger:hover:not(:disabled) { background: #8f1c12; border-color: #8f1c12; color: #fff; }
.rofsv-me-root button.rofsv-me-btn-icon { padding: 0; width: 34px; }
.rofsv-me-ico { display: inline-flex; flex: none; line-height: 0; }
.rofsv-me-ico svg { display: block; }
.rofsv-me-btn-label { display: inline; }

.rofsv-me-zoomval { min-width: 48px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--rofsv-me-text); }

/* segmented view control */
.rofsv-me-seg { gap: 0; border: 1px solid var(--rofsv-me-line); border-radius: 8px; overflow: hidden; background: #fff; flex-wrap: nowrap; }
.rofsv-me-root button.rofsv-me-segbtn { border: 0; border-radius: 0; border-right: 1px solid var(--rofsv-me-line); height: 32px; background: #fff; }
.rofsv-me-root button.rofsv-me-segbtn:last-child { border-right: 0; }
.rofsv-me-root button.rofsv-me-segbtn.rofsv-me-active:hover:not(:disabled) { border-right-color: var(--rofsv-me-line); }

/* confirm bar */
.rofsv-me-confirm {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 8px 14px; background: #fff4e5; border-bottom: 1px solid #f3cf9b; color: #6b3d00; font-weight: 600;
}
.rofsv-me-confirm[hidden] { display: none; }
.rofsv-me-confirm-text { flex: 1 1 260px; }

/* viewport / stage */
.rofsv-me-viewport {
  position: relative; flex: 1 1 auto; min-height: 0;
  overflow: hidden; background: #dfe4ea; outline: none;
  touch-action: none; -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
.rofsv-me-viewport.rofsv-me-cur-pan { cursor: grab; }
.rofsv-me-viewport.rofsv-me-cur-pan.rofsv-me-grabbing { cursor: grabbing; }
.rofsv-me-viewport.rofsv-me-cur-paint { cursor: none; }
.rofsv-me-viewport.rofsv-me-cur-magic { cursor: crosshair; }
.rofsv-me-viewport.rofsv-me-working, .rofsv-me-viewport.rofsv-me-working * { cursor: progress !important; }

.rofsv-me-stage {
  position: absolute; top: 0; left: 0; transform-origin: 0 0;
  will-change: transform; touch-action: none;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #d5dae1 25%, transparent 25%, transparent 75%, #d5dae1 75%),
    linear-gradient(45deg, #d5dae1 25%, transparent 25%, transparent 75%, #d5dae1 75%);
  background-size: 24px 24px; background-position: 0 0, 12px 12px;
  box-shadow: 0 2px 14px rgba(20, 28, 40, .28);
}
.rofsv-me-stage[data-mode="mask"] { background: #000; }
.rofsv-me-c { position: absolute; top: 0; left: 0; display: block; max-width: none !important; pointer-events: none; }
.rofsv-me-stage.rofsv-me-pixelated .rofsv-me-c { image-rendering: pixelated; image-rendering: crisp-edges; image-rendering: pixelated; }
.rofsv-me-c-base, .rofsv-me-c-preview, .rofsv-me-c-overlay { display: none; }
.rofsv-me-stage[data-mode="overlay"] .rofsv-me-c-base { display: block; }
.rofsv-me-stage[data-mode="overlay"] .rofsv-me-c-overlay { display: block; opacity: .55; }
.rofsv-me-stage[data-mode="mask"] .rofsv-me-c-overlay { display: block; opacity: 1; }
.rofsv-me-stage[data-mode="photo"] .rofsv-me-c-base { display: block; }
.rofsv-me-stage[data-mode="fabric"] .rofsv-me-c-preview { display: block; }

.rofsv-me-brush {
  position: absolute; top: 0; left: 0; display: none; pointer-events: none; z-index: 5;
  border-radius: 50%; border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .65), inset 0 0 0 1px rgba(0, 0, 0, .65);
  will-change: transform;
}
.rofsv-me-root[data-tool="erase"] .rofsv-me-brush { border-style: dashed; }

.rofsv-me-banner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 8; display: flex; align-items: flex-start; gap: 8px;
  max-width: min(720px, calc(100% - 20px)); padding: 8px 8px 8px 14px;
  border-radius: 8px; font-weight: 500; box-shadow: 0 4px 18px rgba(0, 0, 0, .22);
  background: #fdecea; color: #7a1710; border: 1px solid #f3b8b3;
}
.rofsv-me-banner[hidden] { display: none; }
.rofsv-me-banner[data-kind="warn"] { background: #fff4e5; color: #6b3d00; border-color: #f3cf9b; }
.rofsv-me-banner[data-kind="info"] { background: #eaf3fb; color: #0a3d70; border-color: #b9d6ee; }
.rofsv-me-banner-text { flex: 1; padding-top: 5px; }
.rofsv-me-root .rofsv-me-banner button.rofsv-me-btn { height: 28px; min-height: 28px; width: 28px; min-width: 28px; flex: none; color: inherit; }

.rofsv-me-emptyhint {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 6;
  padding: 8px 16px; border-radius: 999px; pointer-events: none;
  background: rgba(29, 39, 51, .88); color: #fff; font-weight: 600;
}
.rofsv-me-emptyhint[hidden] { display: none; }

.rofsv-me-loading {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: rgba(243, 245, 248, .9); font-weight: 600; color: var(--rofsv-me-muted);
}
.rofsv-me-loading[hidden] { display: none; }
.rofsv-me-spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid #cbd6e2; border-top-color: var(--rofsv-me-accent2);
  animation: rofsv-me-spin .8s linear infinite;
}
@keyframes rofsv-me-spin { to { transform: rotate(360deg); } }

/* status bar */
.rofsv-me-status {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 18px;
  padding: 6px 14px; font-size: 12px; color: var(--rofsv-me-muted);
  background: var(--rofsv-me-panel); border-top: 1px solid var(--rofsv-me-line);
  font-variant-numeric: tabular-nums;
}
.rofsv-me-seg-item { white-space: nowrap; }
.rofsv-me-st-note { color: #9a5b00; font-weight: 600; white-space: normal; }
.rofsv-me-st-note:empty { display: none; }
.rofsv-me-st-state { margin-left: auto; font-weight: 600; color: #0d8a63; }
.rofsv-me-st-state.rofsv-me-dirty { color: #b4620a; }

/* narrower screens, touch */
@media (max-width: 900px) {
  .rofsv-me-toolbar > .rofsv-me-group + .rofsv-me-group { padding-left: 0; border-left: 0; }
  .rofsv-me-toolbar > .rofsv-me-group.rofsv-me-seg { border-left: 1px solid var(--rofsv-me-line); }
  .rofsv-me-toolbar { gap: 8px 10px; padding: 8px 10px; }
  .rofsv-me-header, .rofsv-me-options, .rofsv-me-hint, .rofsv-me-status { padding-left: 10px; padding-right: 10px; }
}
@media (max-width: 700px) {
  .rofsv-me-root button.rofsv-me-btn { padding: 0 9px; }
  .rofsv-me-group:not(.rofsv-me-seg) .rofsv-me-btn:not(.rofsv-me-btn-primary) .rofsv-me-btn-label { display: none; }
  .rofsv-me-root button.rofsv-me-btn.rofsv-me-tool { min-width: 38px; }
  .rofsv-me-root input.rofsv-me-range { width: 110px; }
  .rofsv-me-hint { display: none; }
  .rofsv-me-st-state { margin-left: 0; }
}
@media (pointer: coarse) {
  .rofsv-me-root button.rofsv-me-btn { height: 42px; min-height: 42px; min-width: 42px; }
  .rofsv-me-root button.rofsv-me-btn-icon { width: 42px; }
  .rofsv-me-root button.rofsv-me-segbtn { height: 40px; }
  .rofsv-me-root input.rofsv-me-range { height: 32px; }
  .rofsv-me-root select.rofsv-me-select { height: 40px; min-height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .rofsv-me-root *, .rofsv-me-root *::before, .rofsv-me-root *::after { transition: none !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
