/*! YuniEditor v1.12.0 | (c) YuniSuite. All rights reserved. | Proprietary — LICENSE */
/*!
 * YuniEditor — stylesheet (yunieditor.css)
 * 라이트/다크 자동 대응. 모든 색상은 CSS 변수로 토큰화.
 * (c) YuniSuite. All rights reserved. (독점 라이선스 — LICENSE)
 */

.ye, .ye-modal-bg {
  /* ---- 토큰 (라이트) — 대화상자(.ye-modal-bg)는 <body> 에 붙으므로 같은 값을 둔다(1.8.0) ---- */
  --ye-bg:        #ffffff;
  --ye-fg:        #1b1f24;
  --ye-muted:     #6b7480;
  --ye-border:    #dfe3e8;
  --ye-surface:   #f6f7f9;
  --ye-surface-2: #eef0f3;
  --ye-accent:    #2f6df6;
  --ye-accent-fg: #ffffff;
  --ye-danger:    #d93a3a;
  --ye-ok:        #1a9b57;
  --ye-code-bg:   #f3f4f6;
  --ye-radius:    8px;
  --ye-font:      -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic",
                  "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --ye-mono:      "SFMono-Regular", Consolas, "D2Coding", "Courier New", monospace;
}
.ye {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--ye-border);
  border-radius: var(--ye-radius);
  background: var(--ye-bg);
  color: var(--ye-fg);
  font-family: var(--ye-font);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
  min-height: 320px;
}

@media (prefers-color-scheme: dark) {
  .ye:not([data-theme="light"]), .ye-modal-bg:not([data-theme="light"]) {
    --ye-bg:        #1a1d21;
    --ye-fg:        #e6e8eb;
    --ye-muted:     #9aa3ad;
    --ye-border:    #333941;
    --ye-surface:   #22262b;
    --ye-surface-2: #2a2f35;
    --ye-accent:    #5a8cff;
    --ye-accent-fg: #0d1117;
    --ye-code-bg:   #2a2f35;
    --ye-icon-line: #c9ced6; --ye-icon-accent: #7fa6ff; --ye-icon-fill: transparent; --ye-icon-soft: #2a3550;
    color-scheme: dark;
  }
}
.ye[data-theme="dark"], .ye-modal-bg[data-theme="dark"] {
  --ye-bg:        #1a1d21;
  --ye-fg:        #e6e8eb;
  --ye-muted:     #9aa3ad;
  --ye-border:    #333941;
  --ye-surface:   #22262b;
  --ye-surface-2: #2a2f35;
  --ye-accent:    #5a8cff;
  --ye-accent-fg: #0d1117;
  --ye-code-bg:   #2a2f35;
  --ye-icon-line: #c9ced6; --ye-icon-accent: #7fa6ff; --ye-icon-fill: transparent; --ye-icon-soft: #2a3550;
  color-scheme: dark;
}

.ye * { box-sizing: border-box; }

/* ---- 탭 바 (내용 / 첨부 / 관련링크 / 이력) ---- */
.ye-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 8px 0;
  background: var(--ye-surface);
  border-bottom: 1px solid var(--ye-border);
  flex-wrap: wrap;
}
.ye-tab {
  appearance: none;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: var(--ye-muted);
  padding: 7px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  position: relative;
  top: 1px;
}
.ye-tab:hover { color: var(--ye-fg); }
.ye-tab[aria-selected="true"] {
  background: var(--ye-bg);
  color: var(--ye-accent);
  border-color: var(--ye-border);
  font-weight: 600;
}
.ye-tab .ye-badge {
  display: inline-block;
  min-width: 16px;
  padding: 0 4px;
  margin-left: 5px;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  background: var(--ye-surface-2);
  color: var(--ye-muted);
  border-radius: 8px;
}

/* ---- 모드 바 + 저장 상태 ---- */
.ye-modebar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--ye-surface);
  border-bottom: 1px solid var(--ye-border);
  flex-wrap: wrap;
}
.ye-mode {
  appearance: none;
  border: 1px solid var(--ye-border);
  background: var(--ye-bg);
  color: var(--ye-fg);
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 6px;
}
.ye-mode[aria-pressed="true"] {
  background: var(--ye-accent);
  color: var(--ye-accent-fg);
  border-color: var(--ye-accent);
}
.ye-export { display: inline-flex; align-items: center; gap: 5px; }
.ye-export svg { width: 15px; height: 15px; }
.ye-export:hover { background: var(--ye-surface-2); }
.ye-status {
  margin-left: auto;
  font-size: 12px;
  color: var(--ye-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.ye-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ye-muted); }
.ye-status[data-state="saving"] .dot { background: #e8a33d; animation: ye-pulse 1s infinite; }
.ye-status[data-state="saved"]  .dot { background: var(--ye-ok); }
.ye-status[data-state="error"]  .dot { background: var(--ye-danger); }
@keyframes ye-pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ---- 툴바 ---- */
.ye-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 8px;
  background: var(--ye-bg);
  border-bottom: 1px solid var(--ye-border);
  flex-wrap: wrap;
}
.ye-tool {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ye-fg);
  width: 30px; height: 30px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: inherit;
}
.ye-tool:hover { background: var(--ye-surface-2); }
.ye-tool:active { transform: translateY(1px); }
.ye-tool[aria-pressed="true"] { background: var(--ye-accent); color: var(--ye-accent-fg); }
.ye-tool.wide { width: auto; padding: 0 8px; font-size: 12px; }
.ye-tool svg { display: block; width: 18px; height: 18px; }
.ye-sep { width: 1px; height: 20px; background: var(--ye-border); margin: 0 4px; }

/* ---- 본문 영역 ---- */
.ye-body {
  position: relative;
  flex: 1;
  display: flex;
  min-height: 240px;
  overflow: hidden;
}
.ye-pane {
  flex: 1;
  overflow: auto;
  padding: 16px 20px;
  min-width: 0;
}
.ye-pane[hidden] { display: none !important; }
.ye-split .ye-pane { border-right: none; }

/* 분할 모드 너비 조절 핸들 */
.ye-splitter { display: none; }
.ye-body.ye-split .ye-splitter {
  display: block; flex: 0 0 6px; align-self: stretch;
  cursor: col-resize; background: var(--ye-border); position: relative;
  touch-action: none;
}
.ye-body.ye-split .ye-splitter::before {
  content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 2px; height: 28px; border-left: 2px dotted var(--ye-muted); opacity: .6;
}
.ye-body.ye-split .ye-splitter:hover,
.ye-body.ye-split .ye-splitter:active { background: var(--ye-accent); }
@media (max-width: 640px) { .ye-body.ye-split .ye-splitter { display: none; } }

/* WYSIWYG / Preview 공통 렌더 스타일 */
.ye-rich { outline: none; }
.ye-rich:focus { outline: none; }
.ye-rich.ye-is-empty { position: relative; }
.ye-rich.ye-is-empty::before { content: attr(data-placeholder); position: absolute; color: var(--ye-muted, #8a94a3); pointer-events: none; }
.ye-rich h1, .ye-preview h1 { font-size: 1.7em; margin: .6em 0 .35em; border-bottom: 1px solid var(--ye-border); padding-bottom: .2em; }
.ye-rich h2, .ye-preview h2 { font-size: 1.4em; margin: .6em 0 .3em; }
.ye-rich h3, .ye-preview h3 { font-size: 1.2em; margin: .5em 0 .3em; }
.ye-rich h4, .ye-preview h4 { font-size: 1.05em; }
.ye-rich p, .ye-preview p { margin: .5em 0; }
.ye-rich ul, .ye-rich ol, .ye-preview ul, .ye-preview ol { padding-left: 1.6em; margin: .4em 0; }
.ye-rich blockquote, .ye-preview blockquote {
  margin: .6em 0; padding: .2em 1em; border-left: 3px solid var(--ye-accent);
  color: var(--ye-muted); background: var(--ye-surface);
}
.ye-rich code, .ye-preview code {
  font-family: var(--ye-mono); font-size: .9em;
  background: var(--ye-code-bg); padding: .1em .35em; border-radius: 4px;
}
.ye-rich pre, .ye-preview pre {
  background: var(--ye-code-bg); padding: 12px 14px; border-radius: 6px;
  overflow-x: auto; margin: .6em 0;
}
.ye-rich pre code, .ye-preview pre code { background: none; padding: 0; }
.ye-rich table, .ye-preview table { border-collapse: collapse; margin: .6em 0; width: auto; max-width: 100%; }
.ye-rich th, .ye-rich td, .ye-preview th, .ye-preview td {
  border: 1px solid var(--ye-border); padding: 6px 10px; text-align: left;
}
.ye-rich th, .ye-preview th { background: var(--ye-surface); font-weight: 600; }
.ye-rich img, .ye-preview img { max-width: 100%; height: auto; border-radius: 4px; }
.ye-rich hr, .ye-preview hr { border: none; border-top: 1px solid var(--ye-border); margin: 1em 0; }
.ye-rich a, .ye-preview a { color: var(--ye-accent); }
.ye-task { list-style: none; margin-left: -1.2em; }
.ye-task input { margin-right: 6px; }
/* SVG 그림 (```svg 코드블록 · 본문 <svg>) — 다이어그램 색은 밝은 배경 기준이라 흰 바탕 고정 */
.ye-rich figure.ye-svg, .ye-preview figure.ye-svg {
  margin: .8em 0; padding: 10px; text-align: center; overflow-x: auto;
  background: #fff; border: 1px solid var(--ye-border); border-radius: 6px;
}
.ye-rich figure.ye-svg svg, .ye-preview figure.ye-svg svg { max-width: 100%; height: auto; display: inline-block; vertical-align: top; }
.ye-rich figure.ye-svg { cursor: default; }
.ye-rich figure.ye-svg:focus-within, .ye-rich figure.ye-svg:hover { outline: 1px dashed var(--ye-accent); outline-offset: 2px; }

/* Markdown 소스 textarea */
.ye-source {
  flex: 1;
  width: 100%;
  border: none;
  resize: none;
  padding: 16px 20px;
  font-family: var(--ye-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ye-fg);
  background: var(--ye-bg);
  outline: none;
  tab-size: 2;
  min-width: 0;
}

/* 드래그앤드롭 오버레이 */
.ye-drop {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--ye-accent) 14%, transparent);
  border: 2px dashed var(--ye-accent);
  border-radius: var(--ye-radius);
  color: var(--ye-accent);
  font-size: 15px;
  font-weight: 600;
  z-index: 5;
  pointer-events: none;
}
.ye-body.ye-dragover .ye-drop { display: flex; }

/* ---- 보조 탭 패널 (첨부/링크/이력) ---- */
.ye-panel { flex: 1; overflow: auto; padding: 16px 20px; min-width: 0; }
.ye-panel[hidden] { display: none !important; }
.ye-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ye-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--ye-border);
  border-radius: 6px; background: var(--ye-surface);
}
.ye-item .meta { flex: 1; min-width: 0; }
.ye-item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ye-item .sub { font-size: 12px; color: var(--ye-muted); }
.ye-item .act { display: flex; gap: 6px; flex-shrink: 0; }
.ye-btn {
  appearance: none; border: 1px solid var(--ye-border); background: var(--ye-bg);
  color: var(--ye-fg); padding: 5px 10px; font-size: 12px; border-radius: 6px;
  cursor: pointer; font-family: inherit;
}
.ye-btn:hover { background: var(--ye-surface-2); }
.ye-btn.primary { background: var(--ye-accent); color: var(--ye-accent-fg); border-color: var(--ye-accent); }
.ye-btn.danger { color: var(--ye-danger); }
.ye-empty { color: var(--ye-muted); text-align: center; padding: 28px 10px; font-size: 13px; }
.ye-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.ye-input {
  flex: 1; min-width: 140px; padding: 7px 10px; border: 1px solid var(--ye-border);
  border-radius: 6px; background: var(--ye-bg); color: var(--ye-fg); font-family: inherit; font-size: 13px;
}

/* 이력 다이프 */
.ye-diff ins { background: color-mix(in srgb, var(--ye-ok) 22%, transparent); text-decoration: none; }
.ye-diff del { background: color-mix(in srgb, var(--ye-danger) 22%, transparent); }

/* 반응형 */
@media (max-width: 640px) {
  .ye-split { flex-direction: column; }
  .ye-split .ye-pane { border-right: none; border-bottom: 1px solid var(--ye-border); }
  .ye-tool { width: 28px; height: 28px; }
}

/* 모달 (링크/이미지/표 삽입) */
.ye-modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.ye-modal {
  font-family: var(--ye-font); font-size: 14px; line-height: 1.5; text-align: left; box-sizing: border-box;
  background: var(--ye-bg); color: var(--ye-fg); border: 1px solid var(--ye-border);
  border-radius: 10px; padding: 18px; width: min(420px, 92vw);
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.ye-modal h3 { margin: 0 0 12px; font-size: 15px; }
.ye-modal .ye-field { margin-bottom: 10px; }
.ye-modal label { display: block; font-size: 12px; color: var(--ye-muted); margin-bottom: 4px; }
.ye-modal .ye-modal-text { margin: 0 0 4px; font-size: 13px; line-height: 1.5; color: var(--ye-fg); }
.ye-modal .ye-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ---- 1.8.0 ---- */
/* 대화상자 안 입력칸 · 단추 */
.ye-modal .ye-input { width: 100%; box-sizing: border-box; }
.ye-modal .ye-btn { font-size: 13px; padding: 6px 14px; }
/* 그림 넣기: 고르면 바로 들어감 */
.ye-img-pick {
  display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; box-sizing: border-box;
  padding: 18px 12px; border: 2px dashed var(--ye-border); border-radius: 10px; background: var(--ye-surface);
  color: var(--ye-fg); cursor: pointer; font-family: inherit;
}
.ye-img-pick:hover, .ye-img-pick:focus-visible, .ye-img-pick.on { border-color: var(--ye-accent); background: var(--ye-surface-2); outline: none; }
.ye-img-pick-ico svg { width: 28px; height: 28px; color: var(--ye-accent); }
.ye-img-pick-t { font-weight: 600; font-size: 14px; }
.ye-img-pick-s { font-size: 12px; color: var(--ye-muted); }
.ye-img-or { margin: 14px 0 6px; font-size: 12px; color: var(--ye-muted); }
.ye-img-url { display: flex; gap: 6px; }
.ye-img-url .ye-input { flex: 1; min-width: 0; }
/* 그림 크기 손잡이 */
.ye-imgsel { position: absolute; border: 2px solid var(--ye-accent); box-sizing: border-box; pointer-events: none; z-index: 5; }
.ye-imgsel[hidden] { display: none; }
.ye-imgsel-h {
  position: absolute; right: -7px; bottom: -7px; width: 12px; height: 12px; pointer-events: auto; touch-action: none;
  background: var(--ye-accent); border: 2px solid #fff; border-radius: 3px; cursor: nwse-resize; box-shadow: 0 0 0 1px rgba(0,0,0,.15);
}
.ye-imgsel-size {
  position: absolute; right: 0; top: -22px; padding: 1px 6px; border-radius: 4px; font-size: 11px; line-height: 18px;
  background: var(--ye-accent); color: var(--ye-accent-fg); white-space: nowrap;
}
.ye-rich img { cursor: pointer; }
/* 글꼴 · 글자 크기 */
.ye-fmenu { position: relative; display: inline-flex; }
.ye-fmenu-btn { gap: 4px; min-width: 56px; justify-content: space-between; }
.ye-fmenu-c { font-size: 10px; color: var(--ye-muted); }
.ye-fmenu-list {
  position: absolute; top: 100%; left: 0; z-index: 20; margin-top: 2px; min-width: 150px; max-height: 280px; overflow: auto;
  background: var(--ye-bg); border: 1px solid var(--ye-border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); padding: 4px;
}
.ye-fmenu-list[hidden] { display: none; }
.ye-fmenu-item {
  display: block; width: 100%; text-align: left; border: 0; background: transparent; color: var(--ye-fg);
  padding: 5px 10px; border-radius: 5px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.ye-fmenu-item:hover { background: var(--ye-surface-2); }
/* 모드 막대를 감췄을 때 상태 표시는 툴바 끝 */
.ye-toolbar .ye-status { margin-left: auto; padding-left: 8px; }
/* 표 도구(1.9.0) — 손잡이 · 칸 범위 · 오른쪽 마우스 메뉴 */
.ye-rich td p, .ye-rich th p, .ye-preview td p, .ye-preview th p { margin: 0; }
.ye-rich table[style*="table-layout"] td, .ye-rich table[style*="table-layout"] th { overflow-wrap: anywhere; }
/* 테두리 없는 표도 편집 중에는 칸이 보이게(Word 의 눈금선처럼 — 결과물에는 없음) */
.ye-rich td, .ye-rich th { outline: 1px dashed rgba(127,127,127,.18); outline-offset: -1px; }
.ye-rich td.ye-cell-sel, .ye-rich th.ye-cell-sel { box-shadow: inset 0 0 0 9999px rgba(47,109,246,.18); }
.ye-rich.ye-col-resize, .ye-rich.ye-col-resize * { cursor: col-resize !important; }
.ye-rich.ye-row-resize, .ye-rich.ye-row-resize * { cursor: row-resize !important; }
.ye-tblsel { position: absolute; border: 1px dashed var(--ye-accent); box-sizing: border-box; pointer-events: none; z-index: 5; }
.ye-tblsel[hidden] { display: none; }
.ye-tblsel-h {
  position: absolute; width: 10px; height: 10px; pointer-events: auto; touch-action: none;
  background: var(--ye-accent); border: 2px solid #fff; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.15);
}
.ye-tblsel-h.r { right: -7px; top: 50%; margin-top: -7px; cursor: ew-resize; }
.ye-tblsel-h.b { bottom: -7px; left: 50%; margin-left: -7px; cursor: ns-resize; }
.ye-tblsel-h.rb { right: -7px; bottom: -7px; cursor: nwse-resize; }
.ye-tblsel-size {
  position: absolute; right: 0; top: -22px; padding: 1px 6px; border-radius: 4px; font-size: 11px; line-height: 18px;
  background: var(--ye-accent); color: var(--ye-accent-fg); white-space: nowrap;
}
.ye-ctx {
  position: fixed; z-index: 10000; min-width: 190px; padding: 4px; font-size: 13px; color: var(--ye-fg);
  background: var(--ye-bg); border: 1px solid var(--ye-border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.ye-ctx-item {
  display: block; width: 100%; text-align: left; border: 0; background: transparent; color: inherit; font: inherit;
  padding: 5px 10px; border-radius: 5px; cursor: pointer; white-space: nowrap;
}
.ye-ctx-item:hover:not([disabled]) { background: var(--ye-surface-2); }
.ye-ctx-item[disabled] { color: var(--ye-muted); opacity: .55; cursor: default; }
.ye-ctx-sep { height: 1px; margin: 4px 6px; background: var(--ye-border); }
.ye-ctx-row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; padding: 4px 10px; }
.ye-ctx-label { width: 100%; font-size: 12px; color: var(--ye-muted); }
.ye-ctx-chip {
  border: 1px solid var(--ye-border); background: var(--ye-bg); color: inherit; font: inherit; font-size: 12px;
  padding: 2px 10px; border-radius: 5px; cursor: pointer;
}
.ye-ctx-chip:hover { background: var(--ye-surface-2); }
.ye-ctx-sw { width: 18px; height: 18px; border: 1px solid rgba(0,0,0,.18); border-radius: 4px; cursor: pointer; padding: 0; }
.ye-ctx-sw:hover { outline: 2px solid var(--ye-accent); outline-offset: 1px; }
.ye-ctx-sw.none { background: linear-gradient(135deg, #fff 45%, #d93a3a 45%, #d93a3a 55%, #fff 55%); }

/* 호스트 단추(toolbarEnd, 1.10.0) — 첨부 · 저장소 · 음성처럼 편집기 밖 기능. 호스트가 그린 그림 크기 그대로 */
.ye-tool.ye-tool-host svg { display: block; flex: none; }
.ye-tool.ye-tool-host[disabled] { opacity: .4; cursor: default; }

/* 툴바 아이콘(1.11.0) — 디자인 가이드 색(회색 선 · 파랑 강조 · 흰 면 · 옅은 파랑 면)을 변수로. 다크 테마는 위 변수,
   눌린 단추(파랑 바탕)는 글자색 한 색 */
.ye { --ye-icon-line: #41464D; --ye-icon-accent: #2F6BFF; --ye-icon-fill: #FFFFFF; --ye-icon-soft: #D6E2FF; }
.ye-gi [stroke="#41464D"] { stroke: var(--ye-icon-line); }
.ye-gi [fill="#41464D"] { fill: var(--ye-icon-line); }
.ye-gi [stroke="#2F6BFF"] { stroke: var(--ye-icon-accent); }
.ye-gi [fill="#2F6BFF"] { fill: var(--ye-icon-accent); }
.ye-gi [fill="#FFFFFF"] { fill: var(--ye-icon-fill); }
.ye-gi [fill="#D6E2FF"] { fill: var(--ye-icon-soft); }
.ye-tool[aria-pressed="true"] .ye-gi [stroke]:not([stroke="none"]) { stroke: currentColor; }
.ye-tool[aria-pressed="true"] .ye-gi [fill]:not([fill="none"]) { fill: currentColor; }
.ye-tool[aria-pressed="true"] .ye-gi [fill="#FFFFFF"], .ye-tool[aria-pressed="true"] .ye-gi [fill="#D6E2FF"] { fill: none; }
.ye-gi { display: block; }
