/* Local-only editing controls. Page typography and layout remain untouched. */
#fomoy-editor-root {
  --fe-accent: #c53735;
  --fe-ink: #2d2829;
  --fe-muted: #746c6e;
  --fe-line: #e8e2e3;
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  color: var(--fe-ink);
  font-family: var(--fomomy-font);
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
  letter-spacing: normal;
  -webkit-font-smoothing: antialiased;
}

#fomoy-editor-root *,
#fe-selection-outline,
#fe-selection-outline * { box-sizing: border-box; }

body.is-opening #fomoy-editor-root { visibility: hidden; }

#fomoy-editor-root[hidden],
#fomoy-editor-root [hidden],
#fe-selection-outline[hidden],
#fe-selection-outline [hidden] { display: none !important; }

#fomoy-editor-root button,
#fomoy-editor-root input,
#fomoy-editor-root textarea,
#fomoy-editor-root select { font: inherit; letter-spacing: inherit; }

#fomoy-editor-root button { cursor: pointer; touch-action: manipulation; }
#fomoy-editor-root button:disabled { cursor: default; opacity: .45; }

#fomoy-editor-root :is(button, input, textarea, select):focus-visible,
#fe-selection-outline .fe-drag-handle:focus-visible {
  outline: 2px solid #c53735;
  outline-offset: 3px;
}

#fomoy-editor-root .fe-launcher {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  min-height: 42px;
  padding: 10px 17px;
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 4px 20px rgba(38, 22, 26, .13);
  color: var(--fe-ink);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}

#fomoy-editor-root .fe-launcher[data-dragging] { cursor: grabbing; }

#fomoy-editor-root .fe-launcher:hover,
#fomoy-editor-root .fe-launcher[aria-expanded="true"] {
  background: var(--fe-accent);
  border-color: var(--fe-accent);
  color: #fff;
  box-shadow: 0 5px 24px rgba(83, 27, 31, .2);
}
@media (min-width: 681px) {
  /* Leave the bottom-centre product controls clickable in Studio. */
  body.fe-open #fomoy-editor-root .fe-launcher { left: 20px; transform: none; }
}

#fomoy-editor-root .fe-panel {
  position: fixed;
  top: 100px;
  right: 20px;
  width: 320px;
  max-width: calc(100vw - 32px);
  max-height: calc(100svh - 125px);
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  overflow: hidden;
  border: 1px solid var(--fe-line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 16px 56px rgba(38, 22, 26, .16);
  isolation: isolate;
  overscroll-behavior: contain;
}
#fomoy-editor-root[data-side="left"] .fe-panel { left: 20px; right: auto; }

#fomoy-editor-root .fe-head {
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px 12px;
  padding: 17px 16px 15px;
  border-bottom: 1px solid var(--fe-line);
}

#fomoy-editor-root .fe-head h2 { margin: 0; font-size: 17px; font-weight: 650; line-height: 1.35; }
#fomoy-editor-root .fe-kicker { margin: 0 0 3px; color: var(--fe-accent); font-size: 10px; font-weight: 650; letter-spacing: .12em; }
#fomoy-editor-root .fe-head-actions { display: flex; align-items: center; gap: 6px; }
#fomoy-editor-root :is(.fe-close, .fe-side) { display: grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: #f6f3f4; color: var(--fe-muted); font-size: 23px; line-height: 1; }
#fomoy-editor-root .fe-side { font-size: 19px; }
#fomoy-editor-root :is(.fe-close, .fe-side):hover { background: #eee8e9; color: var(--fe-ink); }

#fomoy-editor-root .fe-body { min-height: 0; display: grid; gap: 14px; padding: 16px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #d2c9cc transparent; }
#fomoy-editor-root .fe-body :is(section, fieldset) { min-width: 0; margin: 0; padding: 0; border: 0; }
#fomoy-editor-root .fe-body legend { margin: 0 0 8px; padding: 0; color: #51484b; font-size: 12px; font-weight: 600; }
#fomoy-editor-root .fe-selection { margin: 0; overflow-wrap: anywhere; color: var(--fe-ink); font-size: 13px; font-weight: 650; }
#fomoy-editor-root .fe-hint { margin: 0; color: var(--fe-muted); font-size: 12px; line-height: 1.65; }
#fomoy-editor-root .fe-label { display: block; margin: 0 0 6px; color: #51484b; font-size: 12px; font-weight: 600; }
#fomoy-editor-root .fe-field { min-width: 0; margin: 0; }
#fomoy-editor-root .fe-color-row { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; align-items: center; }
#fomoy-editor-root .fe-color-swatch { display: block; width: 52px; height: 40px; min-height: 40px; padding: 4px; border: 1px solid #dcd4d7; border-radius: 7px; background: #fff; cursor: pointer; }
#fomoy-editor-root #fe-color-hex { font-variant-numeric: tabular-nums; }
#fomoy-editor-root #fe-color-hex[aria-invalid="true"] { border-color: var(--fe-accent); }

#fomoy-editor-root .fe-input,
#fomoy-editor-root .fe-select,
#fomoy-editor-root .fe-textarea,
#fomoy-editor-root .fe-step {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid #dcd4d7;
  border-radius: 7px;
  background: #fff;
  color: var(--fe-ink);
  box-shadow: none;
  font-size: 13px;
  line-height: 1.5;
  transition: border-color .15s ease;
}

#fomoy-editor-root .fe-textarea { min-height: 96px; max-height: 240px; resize: vertical; }
#fomoy-editor-root input[type="range"] { width: 100%; margin-inline: 0; accent-color: var(--fe-accent); cursor: pointer; }
#fomoy-editor-root :is(.fe-input, .fe-select, .fe-textarea, .fe-step):focus { border-color: var(--fe-accent); }
#fomoy-editor-root :is(.fe-input, .fe-textarea)::placeholder { color: #a3989c; opacity: 1; }
#fomoy-editor-root :is(.fe-input, .fe-select, .fe-textarea, .fe-step):disabled { background: #f6f3f4; color: #9b9095; }
#fomoy-editor-root .fe-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: 10px; }
#fomoy-editor-root .fe-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

#fomoy-editor-root .fe-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid #dcd4d7;
  border-radius: 7px;
  background: #fff;
  color: var(--fe-ink);
  font-size: 12px;
  font-weight: 550;
  line-height: 1.4;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease;
}

#fomoy-editor-root .fe-button:hover:not(:disabled) { background: #f6f3f4; border-color: #bdb0b5; }
#fomoy-editor-root .fe-button--primary { border-color: var(--fe-accent); background: var(--fe-accent); color: #fff; }
#fomoy-editor-root .fe-button--primary:hover:not(:disabled) { border-color: #a62b2c; background: #a62b2c; }
#fomoy-editor-root .fe-button--danger { color: #b12e38; border-color: #ead1d5; background: #fff; }
#fomoy-editor-root .fe-button--danger:hover:not(:disabled) { background: #fff3f4; border-color: #d9a8b0; }
#fomoy-editor-root .fe-status { min-height: 18px; margin: 0; color: var(--fe-muted); font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
#fomoy-editor-root .fe-status:empty { display: none; }
#fomoy-editor-root .fe-status[data-state="error"] { color: #b12e38; }
#fomoy-editor-root .fe-status[data-state="success"] { color: #347052; }
#fomoy-editor-root .fe-divider { height: 1px; margin: 1px 0; border: 0; background: var(--fe-line); }
#fomoy-editor-root .fe-toggle { display: flex; align-items: center; gap: 9px; min-height: 36px; margin: 0; color: var(--fe-ink); font-size: 12px; cursor: pointer; }
#fomoy-editor-root .fe-toggle input { flex: none; width: 17px; height: 17px; margin: 0; accent-color: var(--fe-accent); cursor: pointer; }
#fomoy-editor-root .fe-check { display: inline-block; flex: none; width: 17px; min-width: 17px; height: 17px; min-height: 0; margin: 0; padding: 0; accent-color: var(--fe-accent); cursor: pointer; }
#fomoy-editor-root .fe-mode { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin: 0; padding: 9px 11px; border: 1px solid var(--fe-line); border-radius: 8px; background: #f8f6f7; color: var(--fe-ink); font-size: 12px; cursor: pointer; }
#fomoy-editor-root .fe-mode input[type="checkbox"] { position: relative; appearance: none; -webkit-appearance: none; flex: none; width: 34px; min-width: 34px; height: 20px; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 999px; background: #cec5c9; cursor: pointer; transition: background .15s ease; }
#fomoy-editor-root .fe-mode input[type="checkbox"]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(38, 22, 26, .15); transition: transform .15s ease; }
#fomoy-editor-root .fe-mode input[type="checkbox"]:checked { background: var(--fe-accent); }
#fomoy-editor-root .fe-mode input[type="checkbox"]:checked::after { transform: translateX(14px); }
#fomoy-editor-root .fe-mode:has(input:checked) { border-color: #e6c2c6; background: #fff5f6; }
#fomoy-editor-root .fe-footer { flex: none; padding: 11px 16px 13px; border-top: 1px solid var(--fe-line); background: #fcfafb; color: var(--fe-muted); font-size: 11px; line-height: 1.65; }
#fomoy-editor-root .fe-footer p { margin: 0; }
#fomoy-editor-root .fe-empty { margin: 0; padding: 18px 13px; border: 1px dashed #dcd4d7; border-radius: 8px; background: #faf8f9; color: var(--fe-muted); font-size: 12px; line-height: 1.7; text-align: center; }
#fomoy-editor-root .fe-help { display: block; margin: 6px 0 0; color: var(--fe-muted); font-size: 11px; line-height: 1.65; }
#fomoy-editor-root .fe-layout { display: inline-flex; align-items: center; width: max-content; max-width: 100%; margin: 0; padding: 3px 8px; border: 1px solid #eed4d8; border-radius: 999px; background: #fff5f6; color: #a33a43; font-size: 10px; font-weight: 550; line-height: 1.5; }

#fomoy-editor-root .fe-move-pad { display: grid; grid-template-columns: repeat(3, minmax(40px, 1fr)); gap: 6px; max-width: 158px; }
#fomoy-editor-root .fe-move-pad button { display: grid; place-items: center; min-width: 40px; min-height: 40px; padding: 6px; border: 1px solid #dcd4d7; border-radius: 7px; background: #fff; color: var(--fe-ink); font-size: 18px; line-height: 1; }
#fomoy-editor-root .fe-move-pad button:hover:not(:disabled) { background: #f6f3f4; border-color: #bdb0b5; }
#fomoy-editor-root .fe-step { text-align: center; }

body.fe-editing [data-fe-id] { cursor: pointer; }
body.fe-editing [data-fe-id]:hover { outline: 1px solid rgba(255, 255, 255, .95); outline-offset: 4px; }
body.fe-editing [data-fe-id][data-fe-selected="true"] { outline: 1px solid #c53735; outline-offset: 4px; }

#fe-selection-outline {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 990;
  pointer-events: none;
  border: 2px solid #c53735;
  border-radius: 2px;
  color: #c53735;
  font-family: var(--fomomy-font);
  font-size: 11px;
  line-height: 1.4;
}

body:not(.fe-editing) #fe-selection-outline { display: none !important; }
#fe-selection-outline .fe-drag-handle { position: absolute; left: 50%; top: -34px; transform: translateX(-50%); display: grid; place-items: center; width: 38px; height: 28px; padding: 0; pointer-events: auto; touch-action: none; cursor: grab; border: 1px solid rgba(255, 255, 255, .8); border-radius: 6px; background: #c53735; color: #fff; box-shadow: 0 2px 8px rgba(38, 22, 26, .16); font: inherit; font-size: 15px; line-height: 1; }
#fe-selection-outline .fe-selection-name { position: absolute; top: calc(100% + 6px); left: -2px; max-width: min(240px, calc(100vw - 24px)); padding: 4px 7px; border: 1px solid #ead1d5; border-radius: 4px; background: #fff; color: #a62b2c; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; box-shadow: 0 2px 8px rgba(38, 22, 26, .08); }
body.fe-dragging,
body.fe-dragging [data-fe-id],
body.fe-dragging #fe-selection-outline .fe-drag-handle { cursor: grabbing !important; }
body.fe-dragging { user-select: none; -webkit-user-select: none; }

@media (max-width: 680px) {
  #fomoy-editor-root .fe-launcher { top: 90px; right: 16px; bottom: auto; left: auto; transform: none; min-height: 36px; padding: 8px 13px; font-size: 11px; }
  #fomoy-editor-root .fe-panel { top: auto; right: 12px; bottom: max(16px, env(safe-area-inset-bottom)); left: 12px; width: auto; max-width: none; max-height: min(65svh, 620px); overflow: auto; border-radius: 13px; }
  #fomoy-editor-root[data-side="left"] .fe-panel { left: 12px; right: 12px; width: auto; }
  #fomoy-editor-root .fe-head { padding: 13px 14px; }
  #fomoy-editor-root .fe-body { flex-shrink: 0; gap: 12px; padding: 14px; overflow: visible; }
  #fomoy-editor-root :is(.fe-input, .fe-select, .fe-textarea, .fe-step) { font-size: 16px; }
  #fomoy-editor-root .fe-footer { padding-inline: 14px; }
  #fomoy-editor-root .fe-textarea { min-height: 80px; }
}

@media (prefers-reduced-motion: reduce) {
  #fomoy-editor-root *,
  #fe-selection-outline * { transition: none !important; animation: none !important; }
}
