/* ============================================================
   Live HTML — KRDS 기반 디자인 토큰
   ============================================================ */
:root {
  /* KRDS Primary (Government Blue) */
  --c-primary: #246BEB;
  --c-primary-hover: #1D56BC;
  --c-primary-active: #18408C;
  --c-primary-soft: #ECF2FE;
  /* KRDS Semantic */
  --c-danger: #EB003B;
  --c-danger-soft: #FDEFF3;
  /* KRDS Gray scale */
  --c-text: #1E2124;
  --c-text-sub: #6D7882;
  --c-border: #CDD1D5;
  --c-border-light: #E6E8EA;
  --c-bg: #F4F5F6;
  --c-surface: #FFFFFF;
  --c-canvas: #E8EAED;

  --radius: 8px;          /* KRDS 기본 라운드 */
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.16);

  --header-h: 56px;
  --footer-h: 40px;
  --tabbar-h: 56px;

  --font: "Pretendard", "Pretendard GOV", -apple-system, BlinkMacSystemFont,
          system-ui, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--c-text);
  background: var(--c-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.material-symbols-outlined {
  font-size: 20px;
  font-variation-settings: 'opsz' 20, 'wght' 500;
  user-select: none;
}

/* ============================================================
   버튼 (KRDS Button 스타일)
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, transform .06s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible,
.tool-btn:focus-visible,
.tab-btn:focus-visible,
.mode-btn:focus-visible {
  outline: 3px solid rgba(36,107,235,.4);
  outline-offset: 1px;
}
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--c-primary-hover); }
.btn-primary:active:not(:disabled) { background: var(--c-primary-active); }

.btn-secondary { background: var(--c-surface); color: var(--c-primary); border-color: var(--c-primary); }
.btn-secondary:hover:not(:disabled) { background: var(--c-primary-soft); }

.btn-tertiary { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border); }
.btn-tertiary:hover:not(:disabled) { background: var(--c-bg); }

.btn-icon {
  width: 36px; height: 36px; padding: 0;
  background: transparent; color: var(--c-text-sub);
  border: none; border-radius: var(--radius);
}
.btn-icon:hover:not(:disabled) { background: var(--c-bg); color: var(--c-text); }

.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-sm .material-symbols-outlined { font-size: 18px; }
.btn-lg { height: 48px; padding: 0 20px; font-size: 16px; border-radius: 10px; }
.btn-block { width: 100%; }

/* ============================================================
   헤더
   ============================================================ */
.app-header {
  height: var(--header-h);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border-light);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo {
  position: relative;
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  background: var(--c-primary); color: #fff;
  border-radius: 9px;
}
.brand-logo .material-symbols-outlined { font-size: 21px; }
.live-dot {
  position: absolute;
  top: -3px; right: -3px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #FF5C7A;
  border: 2px solid var(--c-surface);
  animation: livePulse 2s ease-out infinite;
}
@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,92,122,.55); }
  70%  { box-shadow: 0 0 0 7px rgba(255,92,122,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,92,122,0); }
}
.brand-name { font-size: 18px; font-weight: 800; margin: 0; letter-spacing: -.02em; white-space: nowrap; }
.brand-name em { font-style: normal; color: var(--c-primary); }

.header-actions { display: flex; align-items: center; gap: 8px; }
.history-group {
  display: flex; gap: 2px; margin-right: 4px;
  padding-right: 10px; border-right: 1px solid var(--c-border-light);
}

/* ============================================================
   메인 레이아웃
   ============================================================ */
.app-main {
  flex: 1;
  display: flex;
  min-height: 0;
}
.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--c-surface);
}
.code-pane { flex: 0 0 38%; border-right: 1px solid var(--c-border-light); }
.preview-pane { flex: 1; background: var(--c-canvas); }

.gutter {
  flex: none;
  width: 6px;
  cursor: col-resize;
  background: transparent;
  margin-left: -6px;
  z-index: 10;
}
.gutter:hover, .gutter.dragging { background: rgba(36,107,235,.25); }

.pane-toolbar {
  flex: none;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border-light);
}
.pane-title {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 700; color: var(--c-text-sub);
  white-space: nowrap; min-width: 0; overflow: hidden;
}
.pane-title .material-symbols-outlined { font-size: 19px; flex: none; }
.pane-title .pt-text { overflow: hidden; text-overflow: ellipsis; }
.pane-tools { display: flex; align-items: center; gap: 6px; flex: none; }

/* ---- 코드 입력창 (줄 번호 포함) ---- */
.code-editor {
  flex: 1;
  display: flex;
  min-height: 0;
  background: var(--c-surface);
}
.line-numbers {
  flex: none;
  min-width: 46px;
  padding: 14px 10px 14px 6px;
  text-align: right;
  font-family: "SF Mono", "JetBrains Mono", Consolas, "D2Coding", monospace;
  font-size: 13px;
  line-height: 1.65;
  color: #9DA5AE;
  background: #F8F9FA;
  border-right: 1px solid var(--c-border-light);
  overflow: hidden;
  user-select: none;
  white-space: pre;
}
#codeInput {
  flex: 1;
  min-width: 0;
  border: none;
  resize: none;
  padding: 14px 16px;
  font-family: "SF Mono", "JetBrains Mono", Consolas, "D2Coding", monospace;
  font-size: 13px;
  line-height: 1.65;
  color: var(--c-text);
  background: var(--c-surface);
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}
#codeInput:focus { outline: none; }
#codeInput::placeholder { color: #9DA5AE; }
.code-statusbar {
  flex: none;
  display: flex;
  justify-content: space-between;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--c-text-sub);
  border-top: 1px solid var(--c-border-light);
  background: var(--c-surface);
}

/* ---- 미리보기 ---- */
.mode-toggle {
  display: flex;
  background: var(--c-bg);
  border-radius: var(--radius);
  padding: 3px;
}
.mode-btn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 30px; padding: 0 12px;
  border: none; border-radius: 6px;
  background: transparent;
  font-family: inherit; font-size: 13px; font-weight: 700;
  color: var(--c-text-sub);
  cursor: pointer;
  white-space: nowrap; flex: none;
}
.mode-btn .material-symbols-outlined { font-size: 17px; }
.mode-btn.active { background: var(--c-surface); color: var(--c-primary); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.zoom-select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--c-text);
  cursor: pointer;
}

.preview-viewport {
  flex: 1;
  overflow: auto;
  padding: 20px;
  position: relative;
  overscroll-behavior: contain;
}
.preview-canvas {
  position: relative;
  margin: 0 auto;
  width: fit-content;
  border-radius: 4px;
  box-shadow: var(--shadow);
  background: #fff;
}
#preview {
  position: absolute;
  top: 0; left: 0;
  border: none;
  background: #fff;
  transform-origin: top left;
  display: block;
}
body.has-content .preview-canvas { min-width: 40px; min-height: 40px; }
body:not(.has-content) .preview-canvas { display: none; }

/* ---- 편집 도구 바 ---- */
.edit-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border-light);
  overflow-x: auto;
  scrollbar-width: none;
}
.edit-toolbar::-webkit-scrollbar { display: none; }
.edit-toolbar[hidden] { display: none; }

.sel-chip {
  flex: none;
  padding: 4px 10px;
  background: var(--c-primary-soft);
  color: var(--c-primary);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  font-family: monospace;
}
.tool-group {
  display: flex;
  gap: 2px;
  padding: 0 6px;
  border-right: 1px solid var(--c-border-light);
}
.tool-group:last-of-type { border-right: none; }
.tool-btn {
  position: relative;
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border: none; border-radius: var(--radius);
  background: transparent;
  color: var(--c-text);
  cursor: pointer;
}
.tool-btn:hover { background: var(--c-bg); }
.tool-btn:active { background: var(--c-primary-soft); }
.tool-btn.danger { color: var(--c-danger); }
.tool-btn.danger:hover { background: var(--c-danger-soft); }
.tool-btn.close { margin-left: auto; color: var(--c-text-sub); }
.color-btn input[type="color"] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}

/* 글꼴 선택 버튼 + 크기 입력 */
.font-btn {
  width: auto;
  min-width: 96px;
  max-width: 150px;
  padding: 0 6px 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  border: 1px solid var(--c-border);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
}
.font-btn #fontName {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.font-btn .material-symbols-outlined { font-size: 18px; color: var(--c-text-sub); }
.size-input {
  width: 52px;
  height: 32px;
  margin: 0 2px;
  padding: 0 4px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  color: var(--c-text);
  background: var(--c-surface);
}
.size-input:focus { outline: 2px solid rgba(36,107,235,.4); border-color: var(--c-primary); }

/* 글꼴 선택 패널 */
.preview-pane { position: relative; }
.font-panel {
  position: absolute;
  top: 96px;
  left: 10px;
  z-index: 50;
  width: min(320px, calc(100% - 20px));
  max-height: min(420px, 60vh);
  display: flex;
  flex-direction: column;
  background: var(--c-surface);
  border: 1px solid var(--c-border-light);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn .15s ease-out;
}
.font-panel[hidden] { display: none; }
.font-search-wrap {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-border-light);
  color: var(--c-text-sub);
}
.font-search-wrap input {
  flex: 1;
  border: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--c-text);
}
.font-search-wrap input:focus { outline: none; }
.font-list { flex: 1; overflow-y: auto; padding: 6px; }
.font-group-title {
  padding: 10px 10px 4px;
  font-size: 12px;
  font-weight: 800;
  color: var(--c-text-sub);
}
.font-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.font-item:hover { background: var(--c-bg); }
.font-item.active { background: var(--c-primary-soft); }
.font-item .fi-preview {
  font-size: 17px;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.font-item .fi-label {
  flex: none;
  font-size: 11px;
  color: var(--c-text-sub);
}
.font-empty { padding: 18px; text-align: center; font-size: 13px; color: var(--c-text-sub); }

/* 글자 효과 패널 */
.effect-panel { width: min(300px, calc(100% - 20px)); padding-bottom: 12px; }
.effect-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 6px 12px;
}
.effect-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px 8px;
  border: 1px solid var(--c-border-light);
  border-radius: 10px;
  background: var(--c-surface);
  font-family: inherit;
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.effect-item:hover { border-color: var(--c-primary); background: var(--c-primary-soft); }
.effect-item .fx { font-size: 20px; font-weight: 800; color: var(--c-text); }
.effect-item small { font-size: 11px; font-weight: 700; color: var(--c-text-sub); }
.effect-color {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 12px 0;
  padding: 8px 12px;
  border: 1px solid var(--c-border-light);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--c-text-sub);
  cursor: pointer;
}
.effect-color input { width: 36px; height: 28px; border: none; padding: 0; background: none; cursor: pointer; }

/* 배경(채우기) 색 패널 */
.color-panel { width: min(300px, calc(100% - 20px)); padding-bottom: 12px; }
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  padding: 4px 12px 6px;
}
.swatch {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid rgba(0,0,0,.14);
  border-radius: 7px;
  cursor: pointer;
  padding: 0;
  transition: transform .08s, box-shadow .12s;
}
.swatch:hover { transform: scale(1.12); box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.swatch.none {
  background:
    linear-gradient(to top right, transparent 44%, #EB003B 46%, #EB003B 54%, transparent 56%),
    #fff;
}
.swatch-empty {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--c-text-sub);
  padding: 4px 2px 6px;
}

/* ---- 빈 상태 ---- */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 24px;
}
body.has-content .empty-state { display: none; }
.empty-icon {
  width: 72px; height: 72px;
  display: grid; place-items: center;
  background: var(--c-primary-soft);
  color: var(--c-primary);
  border-radius: 24px;
  margin-bottom: 8px;
}
.empty-icon .material-symbols-outlined { font-size: 40px; }
.empty-state h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.empty-state p { margin: 0 0 16px; color: var(--c-text-sub); font-size: 15px; line-height: 1.6; }
.empty-actions { display: flex; flex-direction: column; gap: 10px; width: min(320px, 100%); }
.empty-actions .btn { width: 100%; }

/* ---- 편집 힌트 ---- */
.edit-hint {
  position: sticky;
  bottom: 8px;
  width: fit-content;
  max-width: calc(100% - 16px);
  margin: 12px auto 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: rgba(30,33,36,.85);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  backdrop-filter: blur(6px);
  pointer-events: none;
  z-index: 5;
}
.edit-hint .material-symbols-outlined { font-size: 18px; }
.edit-hint[hidden] { display: none; }

/* ============================================================
   삽입 버튼(FAB) + 삽입 패널
   ============================================================ */
.insert-fab {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border: none;
  border-radius: 50%;
  background: var(--c-primary);
  color: #fff;
  box-shadow: 0 4px 16px rgba(36,107,235,.4);
  cursor: pointer;
  transition: background-color .15s, transform .1s;
}
.insert-fab:hover { background: var(--c-primary-hover); }
.insert-fab:active { transform: scale(.93); }
.insert-fab .material-symbols-outlined { font-size: 28px; }
body:not(.has-content) .insert-fab,
body.mode-view .insert-fab { display: none; }

.insert-panel {
  position: absolute;
  right: 16px;
  bottom: 78px;
  z-index: 45;
  width: min(340px, calc(100% - 32px));
  max-height: min(440px, 62vh);
  display: flex;
  flex-direction: column;
  background: var(--c-surface);
  border: 1px solid var(--c-border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn .15s ease-out;
}
.insert-panel[hidden] { display: none; }
.insert-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px 6px 16px;
  font-size: 15px;
}
.insert-body { flex: 1; overflow-y: auto; padding: 0 12px 14px; }
.insert-group-title {
  padding: 12px 4px 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--c-text-sub);
}
.insert-row { display: flex; flex-wrap: wrap; gap: 8px; }
.ins-btn {
  flex: 1 1 calc(25% - 8px);
  min-width: 64px;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 6px;
  border: 1px solid var(--c-border-light);
  border-radius: 10px;
  background: var(--c-surface);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text);
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.ins-btn:hover { border-color: var(--c-primary); background: var(--c-primary-soft); }
.ins-btn.wide { flex: 1 1 100%; flex-direction: row; min-height: 44px; font-size: 13px; }
.ins-h1 { font-size: 17px; font-weight: 800; }
.ins-h2 { font-size: 14px; font-weight: 700; }
.ins-p  { font-size: 12px; font-weight: 500; }
.ins-box {
  font-size: 11px; font-weight: 700;
  background: var(--c-primary); color: #fff;
  padding: 5px 9px; border-radius: 6px;
}
.shape { display: block; }
.shape.rect     { width: 26px; height: 26px; background: var(--c-primary); }
.shape.rounded  { width: 26px; height: 26px; background: var(--c-primary); border-radius: 7px; }
.shape.circle   { width: 26px; height: 26px; background: var(--c-primary); border-radius: 50%; }
.shape.triangle { width: 28px; height: 26px; background: var(--c-primary); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.shape.line     { width: 30px; height: 4px;  background: var(--c-primary); border-radius: 2px; margin: 11px 0; }
.emoji-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}
.emoji-tabs::-webkit-scrollbar { display: none; }
.emoji-tab {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--c-border-light);
  border-radius: 999px;
  background: var(--c-surface);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--c-text-sub);
  cursor: pointer;
  white-space: nowrap;
}
.emoji-tab.active {
  background: var(--c-primary-soft);
  border-color: var(--c-primary);
  color: var(--c-primary);
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 2px;
}
.emoji-grid button {
  height: 40px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}
.emoji-grid button:hover { background: var(--c-bg); }

/* ============================================================
   모바일 탭바
   ============================================================ */
.tabbar {
  display: none;
  flex: none;
  height: var(--tabbar-h);
  background: var(--c-surface);
  border-top: 1px solid var(--c-border-light);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--c-text-sub);
  cursor: pointer;
}
.tab-btn .material-symbols-outlined { font-size: 23px; }
.tab-btn.active { color: var(--c-primary); }

/* ============================================================
   푸터
   ============================================================ */
.app-footer {
  flex: none;
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border-light);
}
.app-footer a {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-sub);
  text-decoration: none;
  padding: 4px 12px;
  border-radius: 999px;
  transition: color .15s, background-color .15s;
}
.app-footer a:hover { color: var(--c-primary); background: var(--c-primary-soft); }

/* ============================================================
   모달
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(30,33,36,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(440px, 100%);
  max-height: min(640px, 90vh);
  display: flex;
  flex-direction: column;
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn .18s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.modal-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px 20px;
}
.modal-head h3 {
  margin: 0;
  display: flex; align-items: center; gap: 8px;
  font-size: 18px; font-weight: 800;
}
.modal-body { padding: 8px 20px 20px; overflow-y: auto; }

.dl-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--c-border-light);
  border-radius: 12px;
  background: var(--c-surface);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.dl-option:hover { border-color: var(--c-primary); background: var(--c-primary-soft); }
.dl-option + .dl-option { margin-top: 8px; }
.dl-ic {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  background: var(--c-primary-soft);
  color: var(--c-primary);
  border-radius: 12px;
}
.dl-ic .material-symbols-outlined { font-size: 26px; }
.dl-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.dl-text strong { font-size: 15px; }
.dl-text small { font-size: 13px; color: var(--c-text-sub); }
.dl-option .arrow { color: var(--c-border); }

.dl-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 18px 0 10px;
  font-size: 13px; font-weight: 700; color: var(--c-text-sub);
}
.dl-divider::before, .dl-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--c-border-light);
}

.dl-modes { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.dl-mode {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--c-border-light);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.dl-mode:has(input:checked) { border-color: var(--c-primary); background: var(--c-primary-soft); }
.dl-mode input { width: 18px; height: 18px; accent-color: var(--c-primary); cursor: pointer; flex: none; }
.dl-mode > .material-symbols-outlined { color: var(--c-primary); flex: none; }
.dl-mode-text { display: flex; flex-direction: column; gap: 1px; }
.dl-mode-text strong { font-size: 14px; }
.dl-mode-text small { font-size: 12px; color: var(--c-text-sub); }

.png-pages-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--c-text-sub);
}
.png-pages { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; max-height: 200px; overflow-y: auto; }
.png-page {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--c-border-light);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px; font-weight: 600;
  transition: border-color .15s, background-color .15s;
}
.png-page:has(input:checked) { border-color: var(--c-primary); background: var(--c-primary-soft); }
.png-page input { width: 18px; height: 18px; accent-color: var(--c-primary); cursor: pointer; }
.png-page .dim { margin-left: auto; font-size: 12px; color: var(--c-text-sub); font-weight: 500; }
.png-empty { font-size: 14px; color: var(--c-text-sub); text-align: center; padding: 12px; }

/* ---- PNG 크기 선택 ---- */
.png-size-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.png-size-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; color: var(--c-text-sub);
}
.png-size-label .material-symbols-outlined { font-size: 18px; }
.png-size-row select { flex: 1; max-width: 220px; }

/* ---- 템플릿 ---- */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.tpl-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--c-border-light);
  border-radius: 12px;
  background: var(--c-surface);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background-color .15s, transform .08s;
}
.tpl-card:hover { border-color: var(--c-primary); background: var(--c-primary-soft); }
.tpl-card:active { transform: scale(.98); }
.tpl-ic { font-size: 30px; line-height: 1.2; }
.tpl-card strong { font-size: 14px; color: var(--c-text); }
.tpl-card small { font-size: 12px; color: var(--c-text-sub); line-height: 1.45; }
.tpl-size {
  font-size: 11px; font-weight: 700;
  color: var(--c-primary);
  background: var(--c-primary-soft);
  padding: 2px 8px; border-radius: 99px;
}

/* ---- 도움말 ---- */
.help-body { display: flex; flex-direction: column; gap: 14px; }
.help-step { display: flex; gap: 12px; align-items: flex-start; }
.help-num {
  flex: none;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: var(--c-primary);
  color: #fff;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 800;
}
.help-step strong { display: block; font-size: 15px; margin-bottom: 2px; }
.help-step p { margin: 0; font-size: 14px; color: var(--c-text-sub); line-height: 1.55; }

/* ============================================================
   관리자 대시보드 (내 디자인)
   ============================================================ */
.admin-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--c-bg);
  display: flex;
  flex-direction: column;
}
.admin-overlay[hidden] { display: none; }
.admin-head {
  flex: none;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 16px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border-light);
}
.admin-head h2 {
  display: flex; align-items: center; gap: 8px;
  margin: 0; font-size: 17px; font-weight: 800;
  white-space: nowrap;
}
.admin-badge {
  font-size: 11px; font-weight: 800;
  color: #fff; background: var(--c-danger);
  padding: 2px 8px; border-radius: 999px;
}
.admin-tools { display: flex; align-items: center; gap: 8px; }

.cloud-panel {
  flex: none;
  max-height: 60vh;
  overflow-y: auto;
  padding: 14px 16px;
  background: var(--c-primary-soft);
  border-bottom: 1px solid var(--c-border-light);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cloud-panel[hidden] { display: none; }
.cloud-panel code { background: #fff; padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* 연결 상태 배너 */
.cloud-status {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px; font-weight: 700;
  background: #fff;
  color: var(--c-text-sub);
}
.cloud-status .material-symbols-outlined { font-size: 20px; }
.cloud-status.ok { color: #1F8A4C; }
.cloud-status.ok .material-symbols-outlined { color: #1F8A4C; }
.cloud-status.err { color: var(--c-danger); }
.cloud-status.err .material-symbols-outlined { color: var(--c-danger); }

/* 헤더 클라우드 버튼의 연결 점 */
#adminCloudBtn { position: relative; }
.cloud-dot {
  position: absolute; top: 4px; right: 4px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #1F8A4C;
}
.cloud-dot[hidden] { display: none; }

.cloud-field { display: flex; flex-direction: column; gap: 5px; }
.cloud-label { font-size: 12px; font-weight: 800; color: var(--c-text-sub); }
.cloud-field input {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  background: #fff;
}
.cloud-field input:focus { outline: 2px solid rgba(36,107,235,.4); border-color: var(--c-primary); }
.cloud-saved {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; color: #1F8A4C;
}
.cloud-saved[hidden] { display: none; }
.cloud-saved .material-symbols-outlined { font-size: 16px; }

.cloud-toggle {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--c-border-light);
  border-radius: 10px;
  cursor: pointer;
}
.cloud-toggle input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--c-primary); flex: none; cursor: pointer; }
.cloud-toggle strong { display: block; font-size: 14px; }
.cloud-toggle small { font-size: 12px; color: var(--c-text-sub); }

.cloud-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cloud-actions .btn { flex: 1; min-width: 150px; }

.cloud-help { font-size: 13px; color: var(--c-text); }
.cloud-help summary { cursor: pointer; font-weight: 700; color: var(--c-primary); padding: 4px 0; }
.cloud-help ol { margin: 8px 0; padding-left: 20px; line-height: 1.7; }
.cloud-help li { margin-bottom: 4px; }
.cloud-warn { margin: 6px 0 0; font-size: 12px; color: var(--c-danger); font-weight: 700; }

.admin-body { flex: 1; overflow-y: auto; padding: 16px; }
.design-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
.design-card {
  display: flex;
  flex-direction: column;
  background: var(--c-surface);
  border: 1px solid var(--c-border-light);
  border-radius: 12px;
  overflow: hidden;
  transition: box-shadow .15s, border-color .15s;
}
.design-card:hover { border-color: var(--c-primary); box-shadow: var(--shadow); }

/* 새 디자인 만들기 카드 (런치패드) */
.new-card {
  border: 2px dashed var(--c-border);
  background: var(--c-surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 160px;
  color: var(--c-primary);
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  transition: border-color .15s, background-color .15s;
}
.new-card:hover { border-color: var(--c-primary); background: var(--c-primary-soft); }
.new-card .new-ic {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  background: var(--c-primary-soft);
  border-radius: 50%;
}
.new-card .new-ic .material-symbols-outlined { font-size: 30px; }
.design-list.list-view .new-card { flex-direction: row; min-height: 60px; justify-content: flex-start; padding: 0 16px; gap: 12px; }
.design-list.list-view .new-card .new-ic { width: 38px; height: 38px; }
.design-list.list-view .new-card .new-ic .material-symbols-outlined { font-size: 24px; }

/* 카드 본문(썸네일+정보)을 클릭하면 열림 */
.design-open { cursor: pointer; display: contents; }
.design-thumb {
  aspect-ratio: 4 / 3;
  background: var(--c-canvas);
  display: grid;
  place-items: center;
  cursor: pointer;
  overflow: hidden;
}
.design-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.design-thumb > .material-symbols-outlined { font-size: 42px; color: var(--c-border); }
.design-info { padding: 10px 12px 2px; min-width: 0; }
.design-name {
  font-size: 14px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.design-date { font-size: 12px; color: var(--c-text-sub); margin-top: 2px; }
.design-actions { display: flex; gap: 2px; padding: 6px 8px 8px; }
.design-actions .tool-btn { width: 34px; height: 34px; }
.design-actions .tool-btn .material-symbols-outlined { font-size: 19px; }

/* 리스트형 보기 */
.design-list.list-view { display: flex; flex-direction: column; gap: 8px; }
.design-list.list-view .design-card { flex-direction: row; align-items: center; }
.design-list.list-view .design-thumb { aspect-ratio: auto; width: 96px; height: 64px; flex: none; }
.design-list.list-view .design-info { flex: 1; padding: 0 12px; }
.design-list.list-view .design-actions { padding: 0 8px; }

.admin-empty {
  text-align: center;
  padding: 64px 20px;
  color: var(--c-text-sub);
  font-size: 14px;
  line-height: 1.7;
}
.admin-empty .material-symbols-outlined { font-size: 52px; color: var(--c-border); }
.admin-empty[hidden] { display: none; }

/* 헤더의 관리자 버튼 / 편집 중인 디자인 표시 */
#btnMyDesigns.active {
  background: var(--c-primary-soft);
  border-color: var(--c-primary);
  color: var(--c-primary);
}
.design-card.current {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 2px rgba(36,107,235,.22);
}
.current-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  background: var(--c-primary);
  border-radius: 999px;
  vertical-align: 2px;
}

@media (max-width: 600px) {
  .admin-tools .btn-label { display: none; }
  .design-list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
}

/* ============================================================
   토스트 / 드롭 오버레이
   ============================================================ */
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(var(--footer-h) + 20px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 18px;
  background: rgba(30,33,36,.92);
  color: #fff;
  font-size: 14px; font-weight: 600;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .22s cubic-bezier(.2,.9,.3,1.2);
}
.toast .material-symbols-outlined { font-size: 19px; color: #6FA4F4; }
.toast.error .material-symbols-outlined { color: #FF7B9B; }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .25s; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(.95); }
  to   { opacity: 1; transform: none; }
}

.drop-overlay {
  position: fixed; inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(36,107,235,.92);
  color: #fff;
  z-index: 300;
  pointer-events: none;
}
.drop-overlay[hidden] { display: none; }
.drop-overlay .material-symbols-outlined { font-size: 64px; }
.drop-overlay p { font-size: 20px; font-weight: 800; margin: 0; }

/* ============================================================
   반응형 (모바일)
   ============================================================ */
@media (max-width: 767px) {
  .app-header { padding: 0 10px; gap: 6px; }
  .brand-name { font-size: 16px; }
  .header-actions { gap: 4px; }
  .header-actions .btn { padding: 0 12px; }
  .history-group { padding-right: 6px; margin-right: 0; }

  .app-main { position: relative; }
  .gutter { display: none; }
  .code-pane, .preview-pane { flex: 1 1 100%; border-right: none; }
  body.view-preview .code-pane { display: none; }
  body.view-code .preview-pane { display: none; }

  .tabbar { display: flex; }
  .app-footer { height: 34px; }
  .app-footer a { font-size: 12px; }

  .pane-toolbar { padding: 0 8px; gap: 6px; }
  .preview-viewport { padding: 12px; }
  .toast-wrap { bottom: calc(var(--tabbar-h) + 44px); }
  .insert-fab { right: 12px; bottom: 12px; width: 48px; height: 48px; }
  .insert-panel { right: 12px; bottom: 68px; }
  /* 관리자 버튼이 보일 때는 공간 확보를 위해 아이콘만 표시 */
  .admin-only .btn-label { display: none; }
  body.admin-unlocked .brand-name { display: none; }
}

/* 아주 좁은 화면: 패널 제목 글자를 숨겨 도구가 깨지지 않게 */
@media (max-width: 480px) {
  .pane-title .pt-text { display: none; }
  .mode-btn { padding: 0 10px; }
  .zoom-select { max-width: 92px; }
  .brand { gap: 7px; }
  .brand-name { font-size: 15px; }
}

/* 초소형 화면에서만 코드 도구 글자를 숨김 */
@media (max-width: 380px) {
  .pane-tools .btn-sm .btn-label { display: none; }
}

/* 터치 기기: 어린이·어르신도 누르기 쉽게 버튼을 크게 */
@media (pointer: coarse) {
  .tool-btn { width: 42px; height: 42px; }
  .size-input { height: 36px; }
  .emoji-grid button { height: 44px; font-size: 24px; }
  .emoji-tab { height: 34px; font-size: 13px; }
  .btn-sm { height: 36px; }
  .tab-btn .material-symbols-outlined { font-size: 25px; }
}
