/* 온에디트 편집기 — 토큰과 부품. 원칙·쓰임새는 docs/editor-design.md, 견본은 docs/styleguide.html.
   서체는 페이지가 Google Fonts에서 IBM Plex Sans KR(400·500·600·700)을 불러온다. */
:root {
  /* 바탕·면·선 — 쇼핑몰 미리보기가 주인공이라 편집기는 중립 회색 */
  --ed-ground: #F3F4F6;
  --ed-surface: #FFFFFF;
  --ed-subtle: #E5E7EB;
  --ed-line: #E2E4E9;
  --ed-line-strong: #D5D8DF;
  /* 글자 — muted도 흰 바탕 4.5:1 이상 */
  --ed-text: #17181C;
  --ed-muted: #5F6470;
  --ed-faint: #9AA0AC; /* 장식·보조 표식만. 읽어야 하는 글자에 쓰지 않는다 */
  /* 강조는 하나: 발행·선택·켜짐 */
  --ed-accent: #2F4FD8;
  --ed-accent-hover: #1E36A8;
  --ed-accent-soft: #E8ECFC;
  --ed-accent-tint: #F7F8FE;
  /* 상태 */
  --ed-warn-bg: #FEF3C7; --ed-warn-text: #92400E; --ed-warn-line: #FCD34D; --ed-warn-tint: #FFFBEB; /* 대표 디자인 */
  --ed-ok-bg: #DCFCE7; --ed-ok-text: #166534; --ed-ok-line: #BBF7D0; --ed-ok-tint: #F0FDF4;       /* 지금 쇼핑몰 */
  --ed-danger: #B42318;
  /* 미리보기 표식 — extension/preview.js와 같은 값 */
  --ed-area: #3B5BDB;  /* 영역: 점선 */
  --ed-slot: #E8590C;  /* 슬롯: 실선 */
  /* 글자 크기·모양 */
  --ed-font: 'IBM Plex Sans KR', system-ui, sans-serif;
  --ed-fs-xs: 12px; --ed-fs-sm: 13px; --ed-fs-base: 14px; --ed-fs-md: 16px; --ed-fs-lg: 20px; --ed-fs-xl: 24px;
  --ed-radius-sm: 6px; --ed-radius: 8px; --ed-radius-lg: 10px; --ed-radius-xl: 14px; --ed-pill: 999px;
  --ed-shadow-dialog: 0 20px 48px #0000002E;
  color-scheme: light;
}

.ed { font: var(--ed-fs-base)/1.5 var(--ed-font); color: var(--ed-text); background: var(--ed-ground); }
.ed *, .ed *::before, .ed *::after { box-sizing: border-box; }
.ed input, .ed button, .ed select { font: inherit; color: inherit; }
.ed a { color: var(--ed-accent); } .ed a:not(.ed-btn):hover { color: var(--ed-accent-hover); } /* 링크 모양 버튼은 자기 색을 쓴다. 파란 배경에 파란 글자가 된 적이 있다 */
.ed :focus-visible { outline: 2px solid var(--ed-accent); outline-offset: 2px; }
.ed-muted { color: var(--ed-muted); font-size: var(--ed-fs-sm); }

/* 머리 띠: 몰·디자인·대표 배지 … 저장·발행. 발행은 늘 여기 */
.ed-bar { height: 56px; display: flex; align-items: center; gap: 16px; padding: 0 20px; background: var(--ed-surface); border-bottom: 1px solid var(--ed-line); }
.ed-bar .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.ed-bar .sep { width: 1px; height: 24px; background: var(--ed-line); }
.ed-bar .spacer { flex: 1; }

/* 버튼: 기본(흰), primary(강조 — 화면에 하나), dark(단계 마무리), link(글자) */
.ed-btn { height: 36px; padding: 0 16px; border: 1px solid var(--ed-line-strong); border-radius: var(--ed-radius); background: var(--ed-surface); font-weight: 500; cursor: pointer; }
a.ed-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.ed-btn:disabled { opacity: .5; cursor: default; }
.ed-btn.lg { height: 44px; padding: 0 20px; }
.ed-btn.sm { height: 32px; padding: 0 12px; border-radius: var(--ed-radius-sm); font-size: var(--ed-fs-sm); }
.ed-btn.primary { border: 0; background: var(--ed-accent); color: #fff; font-weight: 600; }
.ed-btn.primary:hover:not(:disabled) { background: var(--ed-accent-hover); }
.ed-btn.dark { border: 0; background: var(--ed-text); color: #fff; font-weight: 600; }
.ed-btn.link { height: auto; padding: 0; border: 0; background: none; color: var(--ed-accent); font-size: var(--ed-fs-xs); }
.ed-btn.icon { width: 32px; padding: 0; border-color: var(--ed-line); border-radius: var(--ed-radius-sm); }

/* 배지 */
.ed-badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: var(--ed-pill); font-size: var(--ed-fs-xs); font-weight: 600; background: var(--ed-ground); color: var(--ed-muted); }
.ed-badge.warn { background: var(--ed-warn-bg); color: var(--ed-warn-text); }
.ed-badge.ok { background: var(--ed-ok-text); color: #fff; }
.ed-badge.applied { background: var(--ed-ok-bg); color: var(--ed-ok-text); }
.ed-badge.accent { background: var(--ed-accent-soft); color: var(--ed-accent); }

/* 알림 상자: 대표 디자인 경고 등 */
.ed-notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--ed-radius-lg); font-size: var(--ed-fs-sm); }
.ed-notice.warn { background: var(--ed-warn-tint); border: 1px solid var(--ed-warn-line); color: #78350F; }
.ed-notice.danger { background: #FEF3F2; border: 1px solid #FECDCA; color: var(--ed-danger); }

/* 입력칸 */
.ed-field { display: flex; flex-direction: column; gap: 4px; font-size: var(--ed-fs-sm); }
.ed-input { height: 34px; padding: 0 10px; border: 1px solid var(--ed-line-strong); border-radius: var(--ed-radius-sm); background: var(--ed-surface); font-size: var(--ed-fs-sm); }
.ed-input.lg { height: 44px; padding: 0 12px; border-radius: var(--ed-radius); font-size: 15px; }

/* 스위치(영역 켜기·숨기기): 진짜 checkbox에 모양만 */
.ed-switch { appearance: none; width: 36px; height: 20px; margin: 0; flex-shrink: 0; border-radius: var(--ed-pill); background: var(--ed-line-strong); position: relative; cursor: pointer; transition: background .15s; }
.ed-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: var(--ed-pill); background: #fff; transition: transform .15s; }
.ed-switch:checked { background: var(--ed-accent); }
.ed-switch:checked::after { transform: translateX(16px); }

/* 영역 줄 */
.ed-area { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 10px; border-radius: var(--ed-radius-lg); }
.ed-area .text { display: flex; flex-direction: column; flex: 1; min-width: 0; padding: 6px 0; }
.ed-area .name { font-weight: 500; word-break: keep-all; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; } /* 줄 이름은 운영자 문구라 길 수 있다 */
.ed-area .meta { display: flex; flex-wrap: wrap; gap: 0 8px; color: var(--ed-muted); font-size: var(--ed-fs-xs); }
.ed-area .changed { color: var(--ed-accent); font-size: var(--ed-fs-xs); font-weight: 600; }
.ed-area.off .name { color: var(--ed-muted); text-decoration: line-through; }
.ed-area-open { border: 2px solid var(--ed-accent); border-radius: var(--ed-radius-lg); background: var(--ed-accent-tint); }

/* 슬롯 카드(배너 하나) */
.ed-slot { padding: 12px; background: var(--ed-surface); border: 1px solid var(--ed-line); border-radius: var(--ed-radius); }
.ed-slot.editing { border-color: var(--ed-slot); }
.ed-thumb { border-radius: var(--ed-radius-sm); background: var(--ed-subtle) center / cover no-repeat; }
.ed-thumb.pc { aspect-ratio: 12 / 5; } .ed-thumb.mo { aspect-ratio: 3 / 4; }

/* 구간 선택(미리보기 폭) */
.ed-seg { display: flex; gap: 2px; padding: 3px; border-radius: var(--ed-radius); background: var(--ed-subtle); }
.ed-seg button { height: 30px; padding: 0 12px; border: 0; border-radius: var(--ed-radius-sm); background: transparent; color: var(--ed-muted); font-size: var(--ed-fs-sm); cursor: pointer; }
.ed-seg button[aria-pressed=true] { background: var(--ed-surface); color: var(--ed-text); font-weight: 600; box-shadow: 0 1px 2px #0000001F; }

/* 대화상자: <dialog class="ed-dialog"> */
.ed-dialog { width: min(560px, calc(100vw - 32px)); padding: 28px; border: 0; border-radius: var(--ed-radius-xl); box-shadow: var(--ed-shadow-dialog); }
.ed-dialog::backdrop { background: #17181C80; }
.ed-dialog h2 { margin: 0 0 16px; font-size: var(--ed-fs-lg); }
.ed-dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* 버전 기록 */
.ed-version { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border: 1px solid var(--ed-line); border-radius: var(--ed-radius-lg); }
.ed-version.live { border-color: var(--ed-ok-line); background: var(--ed-ok-tint); }

.ed-addwidget { position: sticky; bottom: -16px; margin: 0 -16px -16px; padding: 12px 16px; background: var(--ed-surface); border-top: 1px solid var(--ed-line); }
.ed-addwidget .ed-btn { width: 100%; min-height: 44px; border: 1px dashed var(--ed-muted); font-weight: 600; }
.ed-addrow { list-style: none; padding: 4px 0 8px; }
.ed-addrow .ed-btn { width: 100%; border-style: dashed; }
.ed-widgetgroup { display: flex; flex-direction: column; gap: 8px; }
.ed-widgets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ed-widgets .ed-btn { min-height: 44px; }

#undo, #redo { display: inline-flex; align-items: center; justify-content: center; }
.ed-variants { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 4px; margin: 6px 0 8px; }
.ed-variant { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 32px; padding: 4px 2px; border: 1px solid var(--ed-line); border-radius: var(--ed-radius-sm); background: var(--ed-surface); color: var(--ed-muted); font-size: var(--ed-fs-xs); line-height: 1.25; word-break: keep-all; text-align: center; cursor: pointer; }
.ed-variant:hover { border-color: var(--ed-line-strong); color: var(--ed-text); }
.ed-variant.on { border-color: var(--ed-accent); box-shadow: inset 0 0 0 1px var(--ed-accent); color: var(--ed-accent); font-weight: 600; }
.ed-variant:focus-visible { outline: 2px solid var(--ed-accent); outline-offset: 1px; }
.ed-tour { position: fixed; z-index: 1000; width: 320px; box-sizing: border-box; padding: 14px 16px; border-radius: var(--ed-radius-lg); background: var(--ed-surface); box-shadow: 0 8px 28px rgb(0 0 0 / .22); }
.ed-tour p { margin: 6px 0 10px; font-size: var(--ed-fs-sm); line-height: 1.55; }
.ed-tour .row { display: flex; align-items: center; gap: 8px; }
.ed-tour .grow { flex: 1; }
.ed-tour-on { outline: 3px solid var(--ed-accent) !important; outline-offset: 2px; }
.ed-rowlink { display: block; margin: 0 0 8px 78px; }
.ed-text { display: block; width: 100%; box-sizing: border-box; field-sizing: content; height: auto; min-height: 34px; max-height: 240px; padding: 7px 10px; line-height: 1.45; resize: vertical; font: inherit; }
.ed-accents { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ed-accent { width: 28px; height: 28px; padding: 0; border: 1px solid var(--ed-border, #d7dae0); border-radius: 50%; background: var(--c, #fff); cursor: pointer; }
.ed-accent.none { background: linear-gradient(135deg, #fff 46%, #b42318 46% 54%, #fff 54%); }
.ed-accent[aria-pressed="true"] { outline: 2px solid var(--ed-accent, #2747d9); outline-offset: 2px; }
#list .ed-unseen { margin: 2px 8px 6px 44px; font-size: 12px; }
#list .ed-stale { margin: 4px 0; font-size: 12px; }
.ed-slot > summary { flex-wrap: wrap; }
.ed-slotval { flex-basis: 100%; overflow: hidden; color: var(--ed-muted, #5f6470); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.ed-slotval:empty, .ed-slot[open] .ed-slotval { display: none; } /* 펼치면 입력칸에 같은 글자가 보인다 */
/* 펼친 내용은 details의 flex·gap이 닿지 않아 칸마다 띄운다 */
.ed-slot[open] > :not(summary) { margin-top: 10px; }
