/* 한글 문서 스타일 딸깍 — 기본 스타일 (image-editor topbar 톤 일치) */

:root {
  --bg:       #1a1a1a;
  --panel:    #232323;
  --toolbar:  #2a2a2a;
  --border:   #383838;
  --text1:    #ebebee;
  --text2:    #b0b0b7;
  --text3:    #70707a;
  --accent:   #4a9eff;
  --accent2:  #6db1ff;
  --r:        4px;
  --tph:      40px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', sans-serif;
  font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ── Topbar ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--tph);
  background: var(--toolbar); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px; z-index: 100; gap: 8px;
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 5px; flex: 1; min-width: 0; }
.tb-right { justify-content: flex-end; }

.home-link {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 9px; border-radius: 6px;
  color: var(--text2); text-decoration: none;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  background: rgba(74,158,255,0.06);
  border: 1px solid rgba(74,158,255,0.18);
  transition: all 0.15s;
  white-space: nowrap; flex-shrink: 0;
}
.home-link:hover { background: rgba(74,158,255,0.14); border-color: var(--accent); color: var(--accent2); }

.sep { width: 1px; height: 18px; background: var(--border); margin: 0 2px; flex-shrink: 0; }

.logo {
  display: flex; align-items: center; gap: 5px;
  color: var(--accent); font-weight: 700; font-size: 12px;
  white-space: nowrap;
}

.tbtn {
  display: flex; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer;
  color: var(--text2); padding: 4px 7px; border-radius: var(--r);
  font-size: 11.5px; text-decoration: none;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.tbtn:hover { background: #333; color: var(--text1); }

/* ────────────────────────────────────────────────── */
/*  본문 stage (v0.3.0+)                              */
/* ────────────────────────────────────────────────── */
.stage {
  position: absolute; top: var(--tph); left: 0; right: 0; bottom: 0;
  overflow-y: auto;
  padding: 0;
}

/* ── 탭 바 ── */
.tabs {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
  justify-content: center;
}
/* v0.5.6: 탭 = 버튼 형식, 각 탭마다 색깔 (활성 시 채워진 색 / 비활성 시 외곽선 톤) */
.tab {
  background: #1f1f24;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text2);
  padding: 8px 16px;
  font-size: 13px; font-weight: 600;
  border-radius: 999px;
  transition: all .15s;
  white-space: nowrap;
}
.tab:hover:not(:disabled) {
  color: var(--text1);
  background: #2a2a30;
}
.tab:disabled { color: var(--text3); cursor: not-allowed; opacity: 0.55; }

/* 색깔별 탭 — 파랑(스타일 설정) / 초록(매칭 변환) / 보라(프롬프트) */
.tab-style.active {
  color: #fff;
  background: #4a9eff;
  border-color: #4a9eff;
  box-shadow: 0 2px 8px rgba(74,158,255,0.35);
}
.tab-style:hover:not(:disabled):not(.active) {
  border-color: #4a9eff;
  color: #6db1ff;
}
.tab-convert.active {
  color: #052e16;
  background: #4ade80;
  border-color: #4ade80;
  box-shadow: 0 2px 8px rgba(74,222,128,0.35);
}
.tab-convert:hover:not(:disabled):not(.active) {
  border-color: #4ade80;
  color: #4ade80;
}
.tab-prompt.active {
  color: #fff;
  background: #a855f7;
  border-color: #a855f7;
  box-shadow: 0 2px 8px rgba(168,85,247,0.35);
}
.tab-prompt:hover:not(:disabled):not(.active) {
  border-color: #a855f7;
  color: #c084fc;
}
/* v0.8.3: 항목 4 — 표 스타일 설정 탭 (노랑) 다른 탭과 동일 패턴으로 통일 */
.tab-table.active {
  color: #3a2c00;
  background: #ffd166;
  border-color: #ffd166;
  box-shadow: 0 2px 8px rgba(255,209,102,0.35);
}
.tab-table:hover:not(:disabled):not(.active) {
  border-color: #ffd166;
  color: #ffd166;
  background: #2a2a30;
}

.tabs-spacer { display: none; }
.version-badge {
  position: absolute;
  right: 28px;
  top: 18px;
  font-size: 11px; color: var(--accent);
  padding: 4px 10px; border-radius: 999px;
  background: rgba(74,158,255,0.1);
  border: 1px solid rgba(74,158,255,0.2);
}

/* ── 패널 ── */
.panel {
  max-width: 1100px; margin: 0 auto;
  padding: 24px 28px 80px;
  display: flex; flex-direction: column; gap: 20px;
}
/* hidden 속성이 .panel 의 display:flex 에 override 되지 않도록 명시 */
.panel[hidden] { display: none; }

/* ── 단계 카드 ── */
.step {
  background: #1f1f24;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px;
}
.step-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  background: var(--accent); color: #fff;
  border-radius: 50%;
  font-size: 12px; font-weight: 700;
}
.step-title {
  font-size: 15px; font-weight: 700; color: var(--text1);
}

/* ── Step 1 — 업로드 ── */
.upload-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  padding: 32px 20px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: rgba(74,158,255,0.02);
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}
.upload-zone:hover { border-color: var(--accent); background: rgba(74,158,255,0.06); }
.upload-zone.drag-over { border-color: var(--accent); background: rgba(74,158,255,0.12); }
.upload-icon { font-size: 36px; line-height: 1; }
.upload-text { font-size: 14px; color: var(--text1); }
.upload-text b { color: var(--accent); }
.upload-cta { color: var(--accent); text-decoration: underline; }
.upload-hint { font-size: 11.5px; color: var(--text3); max-width: 520px; line-height: 1.5; }

.upload-status {
  margin-top: 12px; font-size: 12px;
  display: none;
}
.upload-status.ok { display: block; color: #4ade80; }
.upload-status.error {
  display: block;
  color: #f87171; padding: 10px 14px;
  background: rgba(248,113,113,0.08);
  border: 1px solid rgba(248,113,113,0.25);
  border-radius: 6px;
}

/* ── Step 2 — 요약 바 ── */
.summary-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.summary-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: #2a2a30; color: var(--text2);
}
.summary-pill b { color: var(--text1); }
.summary-pill.used    { background: rgba(74,222,128,0.1);  color: #4ade80; }
.summary-pill.unused  { background: rgba(251,191,36,0.1);  color: #fbbf24; }
.summary-pill.ext     { background: rgba(248,113,113,0.1); color: #f87171; }

/* ── 선택 컨트롤 ── */
.select-controls {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: #1a1a1f;
  border-radius: 6px;
}
.ctrl-btn {
  background: var(--toolbar); border: 1px solid var(--border);
  color: var(--text2); padding: 5px 11px; border-radius: 4px;
  font-size: 12px; cursor: pointer;
  transition: all .12s;
}
.ctrl-btn:hover { background: #333; color: var(--text1); border-color: var(--text3); }
.ctrl-check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text2);
  margin-left: auto;
  user-select: none; cursor: pointer;
}
.ctrl-check input { margin: 0; accent-color: var(--accent); cursor: pointer; }

/* ── 스타일 그룹 (실사용/미사용/외부) ── */
.style-group {
  margin-bottom: 16px;
}
.style-group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 4px;
  font-size: 12px; font-weight: 700;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.style-group.used .style-group-head     { color: #4ade80; }
.style-group.unused .style-group-head   { color: #fbbf24; }
.style-group.external .style-group-head { color: #f87171; }

.style-row {
  display: grid;
  grid-template-columns: 32px 40px 200px 1fr 70px 90px;
  gap: 10px; align-items: center;
  padding: 7px 8px;
  border-radius: 4px;
  transition: background .1s;
  font-size: 12.5px;
}
.style-row:hover { background: #1a1a1f; }
.style-row.external { opacity: 0.7; }

.sr-check { display: flex; justify-content: center; }
.sr-check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.sr-id {
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 11px; color: var(--text3);
  text-align: right;
}
.sr-name {
  color: var(--text1); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sr-meta {
  color: var(--text2); font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.5;
}
.sr-usage {
  text-align: right;
  color: var(--text2);
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 11.5px;
}
.sr-usage b { color: var(--text1); }
.sr-verdict {
  font-size: 10.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  text-align: center;
}
.sr-verdict.used    { background: rgba(74,222,128,0.12);  color: #4ade80; }
.sr-verdict.rare    { background: rgba(251,191,36,0.12);  color: #fbbf24; }
.sr-verdict.unused  { background: rgba(176,176,183,0.12); color: var(--text3); }
.sr-verdict.ext     { background: rgba(248,113,113,0.14); color: #f87171; }

/* ── 정렬 컬럼 헤더 (v0.3.2) ── */
.style-row.sr-header {
  background: #16161a;
  border-bottom: 1px solid var(--border);
  border-radius: 4px 4px 0 0;
  padding: 8px 8px;
  margin-bottom: 4px;
  position: sticky; top: 0; z-index: 5;
  user-select: none;
}
.style-row.sr-header:hover { background: #16161a; }
.sr-head-cell {
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  text-transform: none;
  letter-spacing: 0.02em;
  display: flex; align-items: center;
}
.sr-head-cell.sortable {
  cursor: pointer;
  transition: color .12s;
}
.sr-head-cell.sortable:hover {
  color: var(--accent);
}
.sr-head-cell .sort-arrow {
  margin-left: 4px;
  font-size: 10px;
  color: var(--text3);
}
.sr-head-cell .sort-arrow.active {
  color: var(--accent);
}
.sr-head-cell.sr-usage,
.sr-head-cell.sr-id {
  justify-content: flex-end;
}
.sr-head-cell.sr-name,
.sr-head-cell.sr-meta,
.sr-head-cell.sr-verdict {
  justify-content: center;
}

/* 폰트 이식성 안내 (표 상단 한 줄) */
.font-notice {
  color: #fbbf24;
  font-size: 12px;
  padding: 8px 14px;
  margin: 0 0 10px;
  background: rgba(251,191,36,0.06);
  border-left: 3px solid #fbbf24;
  border-radius: 2px;
  line-height: 1.55;
}

/* ── 그룹 보기 토글 버튼 (헤더 첫 칸) ── */
.sr-group-toggle {
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.grp-btn {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid transparent;
  color: var(--text3); cursor: pointer;
  font-size: 14px; line-height: 1;
  border-radius: 4px;
  transition: all .12s;
  padding: 0;
}
.grp-btn:hover { color: var(--text1); background: var(--hover, #333); }
.grp-btn.active {
  color: var(--accent);
  background: rgba(74,158,255,0.12);
  border-color: rgba(74,158,255,0.3);
}

/* ── Step 3 — 저장 (v0.4.0 placeholder) ── */
.save-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.save-label {
  font-size: 12px; color: var(--text2);
  min-width: 80px;
}
.text-input {
  flex: 1;
  background: #16161a; border: 1px solid var(--border);
  color: var(--text1); padding: 8px 12px; border-radius: 4px;
  font-size: 13px; outline: none;
  transition: border-color .12s;
}
.text-input:focus { border-color: var(--accent); }

.save-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.btn-primary, .btn-secondary {
  padding: 8px 16px; border-radius: 5px; font-size: 12.5px; font-weight: 600;
  cursor: pointer; transition: all .12s;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--accent); color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent2); }
.btn-secondary {
  background: var(--toolbar); color: var(--text1); border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: #333; border-color: var(--text3); }
.btn-primary:disabled, .btn-secondary:disabled {
  opacity: 0.4; cursor: not-allowed;
}

.save-hint {
  font-size: 11.5px; color: var(--text3); line-height: 1.6;
  padding: 8px 12px;
  background: rgba(74,158,255,0.04);
  border-left: 3px solid var(--accent);
  border-radius: 2px;
}
.save-hint code {
  background: #2a2a30; color: var(--text2);
  padding: 1px 5px; border-radius: 3px;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 11px;
}
.save-hint b { color: var(--text2); font-weight: 600; }

.save-status {
  margin-top: 10px;
  font-size: 12px;
  display: none;
}
.save-status.ok {
  display: block;
  color: #4ade80;
  padding: 8px 12px;
  background: rgba(74,222,128,0.08);
  border-left: 3px solid #4ade80;
  border-radius: 2px;
}
.save-status.error {
  display: block;
  color: #f87171;
  padding: 8px 12px;
  background: rgba(248,113,113,0.08);
  border-left: 3px solid #f87171;
  border-radius: 2px;
}

/* ────────────────────────────────────────────────── */
/*  v0.8.1: 좌·우 2단 분할 — 좌측 저장된 프리셋 / 우측 선택된 스타일  */
/*  문서 스타일 설정 + 표 스타일 설정 탭 모두 동일 패턴            */
/* ────────────────────────────────────────────────── */
.preset-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr);
  gap: 16px;
  /* v0.8.3: 항목 2·10 — 좌·우 세로 정렬 일치. stretch 로 양 컬럼 동일 높이 */
  align-items: stretch;
}
.preset-overview > .step { display: flex; flex-direction: column; }
.preset-overview > .preset-list-step .preset-grid,
.preset-overview > .preset-list-step .table-preset-grid {
  flex: 1; /* step-head 아래 남은 공간 모두 그리드가 차지 → 우측과 height 매칭 */
  min-height: 0;
}
.preset-overview > .preset-selected-step .selected-preset-info {
  flex: 1;
  min-height: 0;
  overflow-y: auto; /* 우측 정보 길어져도 좌측과 동일 높이 유지 */
}
@media (max-width: 900px) {
  .preset-overview { grid-template-columns: 1fr; } /* 좁은 화면에선 세로 */
  .preset-overview > .preset-list-step .preset-grid,
  .preset-overview > .preset-list-step .table-preset-grid { flex: none; }
  .preset-overview > .preset-selected-step .selected-preset-info { flex: none; }
}

.preset-selected-step .step-head { margin-bottom: 10px; }
.preset-selected-step .step-icon { color: #4a9eff; }
.selected-preset-info {
  background: rgba(74,158,255,0.05);
  border: 1px solid rgba(74,158,255,0.18);
  border-radius: 6px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.55;
  min-height: 80px;
}
.selected-preset-info .sp-name {
  font-size: 13px; font-weight: 600; color: var(--text1);
  margin-bottom: 6px;
}
.selected-preset-info .sp-source {
  display: inline-block;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(74,158,255,0.18);
  color: #4a9eff;
  margin-bottom: 6px;
  margin-right: 4px;
}
.selected-preset-info .sp-source.sp-builtin { background: rgba(255,193,7,0.18); color: #ffc107; }
.selected-preset-info .sp-source.sp-upload  { background: rgba(76,175,80,0.18); color: #4caf50; }
.selected-preset-info .sp-source.sp-user    { background: rgba(156,39,176,0.18); color: #ce93d8; }
.selected-preset-info .sp-desc {
  font-size: 11.5px; color: var(--text3);
  margin-bottom: 8px;
}
.selected-preset-info .sp-stat {
  font-size: 11px; color: var(--text3);
  margin-top: 6px;
}
.selected-preset-info .sp-stat b { color: var(--text1); font-weight: 600; }
.selected-preset-info .sp-mini-svg {
  margin: 8px 0;
  width: 100%; height: 88px;
  background: #fff;
  border-radius: 4px;
}

/* ────────────────────────────────────────────────── */
/*  저장된 프리셋 카드 그리드 (v0.4.0)                */
/* ────────────────────────────────────────────────── */
.preset-list-step .step-head { margin-bottom: 12px; }
.step-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  font-size: 15px; line-height: 1;
}
.step-hint {
  margin-left: auto;
  font-size: 11.5px; color: var(--text3); font-weight: 400;
}

.preset-grid {
  display: grid;
  /* v0.8.5: 항목 21 — 명시적 2열 (좌측 컬럼 좁아도 한 줄 2개) */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  /* v0.8.5: 항목 21 — 카드 높이 고정 (180px) * 2행 + gap = ~370. 그리드 max-height 도 동일. */
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}
@media (max-width: 700px) {
  .preset-grid { grid-template-columns: 1fr; }
}
.preset-grid::-webkit-scrollbar { width: 6px; }
.preset-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.preset-grid::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.28); }

.preset-card {
  position: relative;
  background: #1a1a1f;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px 12px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
  display: flex; flex-direction: column; gap: 6px;
  /* v0.8.5: 항목 18·20·21 — 카드 높이 고정 (빌트인/사용자 동일, 클릭 시 크기 안 출렁임) */
  height: 168px;
  overflow: hidden;
}
.preset-card:hover {
  /* v0.8.4: 항목 12 — transform translateY 제거 (스크롤 컨테이너 안에서 위쪽이 부분 잘림). box-shadow 로 부드러운 hover 표현 */
  border-color: var(--accent);
  background: rgba(74,158,255,0.06);
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}
/* v0.8.7: active 강조 톤 약화 + 빌트인/사용자 통일 정책 — 사용자 피드백
   "선택된 프리셋은 기본 프리셋에 걸린 (옅은) 하이라이트 정도로". 빌트인 base 색이 옅은
   파랑이라 다른 카드 선택해도 빌트인이 active 처럼 보이던 문제 동시 해결. 빌트인 카드
   base/hover/active 룰을 모두 제거 → 일반 카드 룰 상속 → 배지로만 구분. */
.preset-card.active {
  border-color: rgba(74,158,255,0.55);
  background: rgba(74,158,255,0.05);
  box-shadow: 0 0 0 1px rgba(74,158,255,0.35) inset;
}

.preset-card-name {
  font-size: 13px; font-weight: 700; color: var(--text1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-right: 24px; /* 삭제 버튼 공간 */
}
.preset-card-meta {
  font-size: 11px; color: var(--text3);
  display: flex; flex-wrap: wrap; gap: 8px;
}
.preset-card-meta b { color: var(--text2); font-weight: 600; }
.preset-card-time {
  margin-top: auto;
  font-size: 10.5px; color: var(--text3);
  font-family: 'SF Mono', Monaco, Consolas, monospace;
}

.preset-card-delete {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55); border: 1px solid transparent;
  color: #ddd; cursor: pointer;
  border-radius: 4px;
  font-size: 12px; line-height: 1;
  transition: opacity .12s, color .12s, background .12s, border-color .12s;
  opacity: 0;
  z-index: 2; /* v0.8.4: 항목 14 — 보라 배지 위로 (배지는 z 기본 0) */
}
.preset-card:hover .preset-card-delete { opacity: 1; }
.preset-card-delete:hover {
  color: #fff;
  background: rgba(248,113,113,0.45);
  border-color: rgba(248,113,113,0.6);
}
/* v0.8.4: 항목 14 — hover 시 보라 배지 fade-out (삭제 버튼이 같은 위치를 점유) */
.preset-card:hover .preset-badge { opacity: 0; }
.preset-badge { transition: opacity .12s; }

.preset-card.loading { opacity: 0.5; pointer-events: none; }

/* v0.8.7: 빌트인 카드 색상 룰 모두 제거 — 일반 카드 룰 상속. "📦 기본" 배지로 시각 구분.
   (이전: 빌트인 base 가 옅은 파랑이라 다른 카드 선택해도 빌트인이 active 처럼 보임) */
.preset-badge {
  position: absolute; top: 8px; right: 8px;
  font-size: 10px; font-weight: 700;
  color: #ffd166;
  background: rgba(255,209,102,0.18);
  padding: 2px 7px; border-radius: 999px;
  white-space: nowrap;
}
/* v0.8.3: 사용자 저장 프리셋 배지 (보라) — 표 카드 .tp-badge-user 와 동일 톤 */
.preset-badge-user {
  color: #ce93d8;
  background: rgba(156,39,176,0.20);
}
.preset-card-desc {
  font-size: 11px; color: var(--text2);
  line-height: 1.5;
  /* v0.8.5: 항목 18 — 2줄까지 표시, 길면 ...으로 생략 (line-clamp) */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 2.6em; /* line-height 1.5 × 2 lines = 3em, 살짝 작게 */
}
.preset-card-desc-empty { opacity: 0.5; font-style: italic; }

/* ────────────────────────────────────────────────── */
/*  2️⃣ 변환 (.md → .hwpx) — v0.5.0                   */
/* ────────────────────────────────────────────────── */

.convert-empty {
  text-align: center;
  padding: 60px 28px;
}
.empty-icon { font-size: 48px; line-height: 1; margin-bottom: 12px; opacity: 0.6; }
.empty-title {
  font-size: 17px; font-weight: 700; color: var(--text1);
  margin-bottom: 8px;
}
.empty-hint {
  font-size: 13px; color: var(--text2); line-height: 1.7;
  max-width: 480px; margin: 0 auto 18px;
}
.empty-hint b { color: var(--accent); font-weight: 600; }

.convert-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  align-items: stretch;
}
@media (max-width: 900px) {
  .convert-grid { grid-template-columns: 1fr; }
}

.convert-left, .convert-right {
  display: flex; flex-direction: column;
  margin: 0;
}
.convert-left .step-head, .convert-right .step-head { margin-bottom: 12px; }

.md-drop-zone {
  position: relative;
  flex: 1;
  display: flex; flex-direction: column;
  border: 2px solid transparent;
  border-radius: 6px;
  transition: border-color .12s;
  min-height: 720px;
}
.md-drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(74,158,255,0.06);
}
.md-textarea {
  width: 100%; min-height: 720px;
  background: #16161a; color: var(--text1);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 12px 14px;
  font-family: 'D2Coding', 'Consolas', 'SF Mono', Monaco, monospace;
  font-size: 13px; line-height: 1.7;
  outline: none; resize: vertical;
  transition: border-color .12s;
  flex: 1;
}
.md-textarea:focus { border-color: var(--accent); }
.md-textarea::selection {
  background: rgba(74,158,255,0.45);
  color: #fff;
}

.convert-meta {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px;
}
.md-stat {
  margin-left: auto;
  font-size: 11.5px; color: var(--text3);
  font-family: 'SF Mono', Monaco, Consolas, monospace;
}

.map-source {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; margin-bottom: 12px;
  background: rgba(74,158,255,0.06);
  border: 1px solid rgba(74,158,255,0.18);
  border-radius: 6px;
  font-size: 11.5px;
}
.map-source-label { color: var(--text3); }
.map-source-name {
  color: var(--accent2); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.map-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.map-empty {
  font-size: 12px; color: var(--text2);
  padding: 16px 14px;
  background: rgba(74,158,255,0.04);
  border-left: 3px solid var(--accent);
  border-radius: 2px;
  line-height: 1.7;
}
.map-empty b { color: var(--accent2); font-weight: 600; }

.map-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 8px; align-items: center;
}
.map-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text2);
  min-width: 0;
  /* button reset */
  background: none; border: 1px solid transparent;
  padding: 5px 8px; border-radius: 5px;
  cursor: pointer;
  text-align: left; font-family: inherit;
  transition: all .12s;
  width: 100%;
}
.map-label:hover {
  background: rgba(74,158,255,0.08);
  border-color: rgba(74,158,255,0.25);
  color: var(--text1);
}
.map-label:hover .map-find {
  opacity: 1;
}
.map-label:active {
  background: rgba(74,158,255,0.16);
}
.map-find {
  margin-left: auto;
  font-size: 11px;
  opacity: 0;
  transition: opacity .12s;
}
.map-nav {
  font-size: 10px;
  color: var(--accent2);
  background: rgba(74,158,255,0.18);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 4px;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
}
@keyframes mapMiss {
  0%   { background: rgba(248,113,113,0.25); border-color: rgba(248,113,113,0.5); }
  100% { background: rgba(74,158,255,0); border-color: transparent; }
}
.map-label.flash-miss {
  animation: mapMiss .6s ease-out;
}
.map-label-text {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.map-icon {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 22px;
  padding: 0 6px;
  background: #2a2a30; color: var(--text1);
  border-radius: 4px;
  font-family: 'Apple SD Gothic Neo', 'Malgun Gothic', 'SF Mono', Monaco, Consolas, sans-serif;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.map-count {
  font-size: 10.5px; color: var(--text3);
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  flex-shrink: 0;
  background: rgba(74,158,255,0.08);
  padding: 1px 6px;
  border-radius: 999px;
}
.map-select {
  background: #16161a; border: 1px solid var(--border);
  color: var(--text1); padding: 6px 8px; border-radius: 4px;
  font-size: 12px; outline: none;
  transition: border-color .12s;
  width: 100%;
}
.map-select:focus { border-color: var(--accent); }

/* v0.6.1: 변환 옵션 영역 — 변환 버튼 위에 체크박스 줄 */
.convert-options {
  display: flex; flex-wrap: wrap; gap: 12px;
  padding: 8px 10px;
  background: var(--bg-soft, #1c2230);
  border: 1px solid var(--border-soft, #2a3140);
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 12px;
}
.convert-options .opt-hint { opacity: 0.65; font-size: 11px; margin-left: 2px; }

/* v0.7.0/v0.8.3: 표 스타일 그래픽 편집기 — v0.8.3 부터 표 스타일 설정 탭에 상주 (details 가 아닌 일반 div) */
.table-styler-host {
  background: var(--bg-soft, #1c2230);
  border: 1px solid var(--border-soft, #2a3140);
  border-radius: 6px;
  padding: 0;
  font-size: 12px;
}
.table-styler-host .ts-body {
  padding: 14px 16px 16px;
  position: relative; /* v0.7.3: popover absolute 의 기준점 */
}
.ts-svg {
  width: 100%; height: 240px;
  background: #fff;
  border-radius: 4px;
  cursor: default;
}
/* v0.7.8: 평시 stroke none — hit-rect 의 검은 테두리가 진짜 선처럼 보이던 혼동 제거 */
.ts-svg .ts-line { stroke: none; cursor: pointer; transition: fill 0.1s, fill-opacity 0.1s; }
/* v0.7.7: hover 강조 — 옅은 회색에서 진한 파랑 fill 로 (sky blue) + outline */
.ts-svg .ts-line:hover {
  fill: #4a9eff !important;
  fill-opacity: 0.45 !important;
  filter: drop-shadow(0 0 3px rgba(74,158,255,0.7));
}
/* v0.7.11: fill 속성 제거 — SVG inline fill 이 적용되도록 (CSS specificity 가
 *   SVG presentation attribute 보다 높아서 외부 CSS .ts-cell { fill: transparent }
 *   가 inline <rect fill="#xxxxxx"/> 를 덮음. 사용자 색 변경이 화면에 안 보이던 버그.
 *   각 cell 의 fill 은 renderTableStylerSvg 가 inline 으로 박음. */
.ts-svg .ts-cell {
  cursor: pointer;
  transition: stroke-width 0.1s;
}
/* v0.7.9: hover 시 fill 덮지 X — stroke 강조만
 * v0.7.10: hover 효과 더 약화 — 점선 stroke 1px (사용자 색 변경 가시성 우선) */
.ts-svg .ts-cell:hover {
  stroke: #4a9eff;
  stroke-width: 1;
  stroke-dasharray: 3 2;
}
.ts-svg .ts-label { font-size: 11px; fill: #666; pointer-events: none; }
.ts-legend {
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.65;
}
.ts-popover {
  position: absolute;
  background: var(--bg, #14181f);
  border: 1px solid var(--border, #2a3140);
  border-radius: 6px;
  padding: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 100;
  min-width: 180px;
}
/* v0.7.4: hidden 속성이 display:flex 덮어쓰지 못해서 닫혀도 안 보이는 문제 fix */
.ts-popover[hidden] { display: none; }
.ts-popover button {
  padding: 5px 10px;
  background: transparent;
  border: 0;
  text-align: left;
  color: inherit;
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
}
.ts-popover button:hover { background: rgba(74,158,255,0.15); }
.ts-popover button.active { background: rgba(74,158,255,0.25); }
.ts-body > .ctrl-btn { margin-top: 8px; }

/* v0.7.7: 음영 팝오버 상단 title (어떤 영역을 편집 중인지 표시) */
.ts-popover-title {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 4px 6px;
  opacity: 0.85;
  border-bottom: 1px solid var(--border, #2a3140);
  margin-bottom: 4px;
}

/* v0.7.6: 헤더 음영 — 프리셋 + 색 자유 선택기 */
.ts-popover-section { display: flex; flex-direction: column; gap: 3px; padding: 2px 0; }
.ts-popover-section + .ts-popover-section {
  border-top: 1px solid var(--border, #2a3140);
  margin-top: 4px; padding-top: 6px;
}
.ts-popover-label {
  font-size: 10.5px; opacity: 0.6;
  padding-left: 4px; letter-spacing: 0.02em;
  text-transform: none;
}
.ts-popover-row { display: flex; flex-direction: column; gap: 1px; }
/* v0.7.8: 색 직접 선택 영역 — picker 와 HEX 박스를 가로 정렬 */
.ts-popover-row.ts-picker-row { flex-direction: row; align-items: center; gap: 0; }
.ts-popover button.ts-fill-btn {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
}
.ts-fill-chip {
  display: inline-block;
  width: 18px; height: 14px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 3px;
  flex-shrink: 0;
}
.ts-color-picker {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  width: 100%;
  position: relative;
}
.ts-color-picker:hover { background: rgba(74,158,255,0.15); }
.ts-color-picker.active { background: rgba(74,158,255,0.25); }
/* native color picker 는 트리거 영역 전체에서 열 수 있도록 input 을 투명 오버레이로 */
.ts-color-picker input[type=color] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  border: 0;
  padding: 0;
  background: transparent;
}
.ts-color-hex {
  font-family: 'D2Coding', 'Consolas', 'Courier New', monospace;
  font-size: 11px;
  opacity: 0.85;
  margin-left: auto;
}

.convert-actions {
  display: flex; justify-content: flex-end;
  margin-bottom: 10px;
}
.convert-actions .btn-primary { padding: 10px 20px; font-size: 13px; }

.convert-status {
  font-size: 12px;
  display: none;
  padding: 8px 12px; border-radius: 2px;
  line-height: 1.55;
}
.convert-status.info  {
  display: block; color: var(--accent2);
  background: rgba(74,158,255,0.06);
  border-left: 3px solid var(--accent);
}
.convert-status.ok    {
  display: block; color: #4ade80;
  background: rgba(74,222,128,0.08);
  border-left: 3px solid #4ade80;
}
.convert-status.error {
  display: block; color: #f87171;
  background: rgba(248,113,113,0.08);
  border-left: 3px solid #f87171;
}

/* v0.8.0: 표 스타일 설정 탭 — 카드 그리드 */
/* v0.8.3 항목 4 fix: 탭 버튼 스타일 통일 룰은 .tab-prompt 옆에서 처리 */

.table-preset-grid {
  display: grid;
  /* v0.8.4: 항목 15 — 명시적 2열 */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 8px;
  /* v0.8.5: 항목 20 — 4개 (2x2) 까지만 표시, 5번째부터 내부 스크롤. 카드 height 180 × 2 + gap 14 = ~374 */
  max-height: 384px;
  overflow-y: auto;
  padding-right: 4px;
}
@media (max-width: 700px) {
  .table-preset-grid { grid-template-columns: 1fr; }
}
.table-preset-grid::-webkit-scrollbar { width: 6px; }
.table-preset-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.table-preset-grid::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.28); }
.tp-card {
  background: var(--bg-soft, #1c2230);
  border: 1px solid var(--border-soft, #2a3140);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
  display: flex;
  flex-direction: column;
  gap: 6px;
  /* v0.8.5: 항목 18·20 — 카드 height 고정 (선택 시 size 안 출렁임). 4개 fit 위해 ~180px */
  height: 180px;
  overflow: hidden;
}
.tp-card:hover {
  border-color: #ffd166;
  box-shadow: 0 0 0 1px rgba(255,209,102,0.2);
}
.tp-card.active {
  border-color: #ffd166;
  box-shadow: 0 0 0 2px rgba(255,209,102,0.35);
  background: rgba(255,209,102,0.04);
}
.tp-thumb {
  width: 100%;
  height: 70px;
  background: #fff;
  border-radius: 4px;
  display: block;
}
.tp-card-body { font-size: 12px; }
.tp-card-title {
  font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
}
.tp-card-desc {
  opacity: 0.7;
  font-size: 11px;
  margin-top: 2px;
  line-height: 1.4;
  /* v0.8.5: 항목 18 — 2줄까지, 길면 ...생략 (table 카드도 동일 정책) */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 2.4em;
}
.tp-badge {
  background: rgba(255,209,102,0.15);
  color: #ffd166;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 500;
  margin-left: 6px;
}
/* v0.8.2: '양식 그대로' 가상 카드 배지 (초록) */
.tp-badge-template {
  background: rgba(76,175,80,0.20);
  color: #66bb6a;
}
/* v0.8.2: 사용자 저장 프리셋 배지 (보라) */
.tp-badge-user {
  background: rgba(156,39,176,0.20);
  color: #ce93d8;
}
/* v0.8.2: '양식 그대로' 카드 좌측 강조 띠 (양식과 100% 매칭 강조) */
.tp-card.tp-from-template {
  border-left: 3px solid rgba(76,175,80,0.6);
}
.tp-card.tp-from-template.active {
  border-left: 3px solid #66bb6a;
}
/* v0.8.2: 카드 삭제 버튼 (사용자 저장만) */
.tp-card { position: relative; }
.tp-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  background: rgba(0,0,0,0.25);
  color: #aaa;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.tp-card:hover .tp-delete { opacity: 1; }
.tp-delete:hover {
  background: rgba(244,67,54,0.25);
  color: #f44336;
}

/* v0.8.2: 표 스타일 설정 탭 — '현재 스타일을 새 프리셋으로 저장' 패널 */
.table-preset-builder { margin-top: 8px; }
.table-preset-builder .tpb-preview {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--bg-soft, #1c2230);
  border: 1px solid var(--border-soft, #2a3140);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}
.table-preset-builder .tpb-mini {
  width: 140px;
  height: 56px;
  background: #fff;
  border-radius: 4px;
  flex-shrink: 0;
}
.table-preset-builder .tpb-summary { font-size: 12px; line-height: 1.7; opacity: 0.92; }
.table-preset-builder .tpb-summary b { color: var(--text, #e3e9f3); font-weight: 600; }
.table-preset-builder .tpb-row { color: var(--text-soft, #b6bdcb); }
.table-preset-builder .tpb-form {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: 8px;
  align-items: center;
}
.table-preset-builder .tpb-name-input,
.table-preset-builder .tpb-desc-input {
  background: var(--bg-deep, #131720);
  border: 1px solid var(--border, #2a3140);
  color: var(--text, #e3e9f3);
  padding: 7px 10px;
  border-radius: 5px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.table-preset-builder .tpb-name-input:focus,
.table-preset-builder .tpb-desc-input:focus { border-color: var(--accent, #6cc9ff); }
.table-preset-builder #btnSaveTablePreset { padding: 7px 14px; font-size: 13px; }
.table-preset-builder .tpb-status { margin-top: 8px; font-size: 12px; min-height: 18px; }
.table-preset-builder .tpb-status.ok { color: #66bb6a; }
.table-preset-builder .tpb-status.error { color: #f44336; }
.table-preset-builder .tpb-hint {
  margin-top: 8px;
  font-size: 11.5px;
  opacity: 0.65;
  line-height: 1.5;
}
.table-preset-builder .tpb-hint b { color: var(--accent, #6cc9ff); font-weight: 600; }
@media (max-width: 700px) {
  .table-preset-builder .tpb-form { grid-template-columns: 1fr; }
  .table-preset-builder .tpb-preview { flex-direction: column; align-items: flex-start; }
  .table-preset-builder .tpb-mini { width: 100%; }
}

/* v0.8.3: 변환 탭 — 표 프리셋 read-only indicator (항목 7) */
.table-preset-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-soft, #1c2230);
  border: 1px solid var(--border-soft, #2a3140);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 8px 0 4px 0;
  font-size: 12.5px;
}
.table-preset-indicator .tpi-icon { font-size: 14px; flex-shrink: 0; }
.table-preset-indicator .tpi-label { color: var(--text-soft, #b6bdcb); font-weight: 500; flex-shrink: 0; }
.table-preset-indicator .tpi-mini {
  display: inline-flex;
  flex-shrink: 0;
}
.table-preset-indicator .tpi-mini svg.tp-thumb {
  width: 56px;
  height: 32px;
  background: #fff;
  border-radius: 3px;
  vertical-align: middle;
}
.table-preset-indicator .tpi-name {
  flex: 1;
  color: var(--text, #e3e9f3);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.table-preset-indicator .tpi-link {
  background: rgba(108,201,255,0.12);
  color: var(--accent, #6cc9ff);
  border: 1px solid rgba(108,201,255,0.30);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11.5px;
  flex-shrink: 0;
  white-space: nowrap;
}
.table-preset-indicator .tpi-link:hover { background: rgba(108,201,255,0.22); }

/* v0.8.2: 우측 '선택된 표 스타일' 패널 출처 색상 확장 */
.selected-preset-info .sp-source.sp-template {
  background: rgba(76,175,80,0.20);
  color: #66bb6a;
}
.selected-preset-info .sp-source.sp-custom {
  background: rgba(108,201,255,0.18);
  color: #6cc9ff;
}
