/* hwp2md V3 — 변환 화면. 매일 쓰는 작업 화면이라 모션은 상태 설명에만 쓴다. */

.page-app .site-header__inner { max-width: 1440px; }
.app { max-width: 1440px; margin: 0 auto; padding: 32px 24px 96px; display: flex; flex-direction: column; gap: 16px; }

.app-head { text-align: center; padding: 16px 0 12px; }
.app-head h1 { font-size: clamp(26px, 3vw, 34px); font-weight: 780; letter-spacing: -0.03em; }
.app-head p { margin-top: 6px; color: var(--text-muted); }

/* ---------- mode switch ---------- */
.mode { display: flex; align-items: center; gap: 10px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 14px; font-weight: 500; color: var(--text-muted); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track {
  position: relative; width: 36px; height: 20px; border-radius: var(--radius-pill); flex: none;
  background: var(--border-strong); transition: background var(--t-normal) var(--ease-std);
}
.switch__track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.2); transition: transform 0.28s var(--ease-out);
}
.switch input:checked + .switch__track { background: var(--accent-primary); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.switch:hover .switch__label { color: var(--text-primary); }

#mode-status {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-pill); background: var(--surface-main);
  font-size: 13px; font-weight: 500; color: var(--text-muted); white-space: nowrap;
  transition: color var(--t-normal) var(--ease-std), border-color var(--t-normal) var(--ease-std);
}
#mode-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--status-success); flex: none; }
#mode-status[data-state="loading"]::before { background: var(--accent-primary); animation: pulse 0.9s ease-in-out infinite alternate; }
#mode-status[data-state="browser"] { color: var(--accent-text); border-color: color-mix(in srgb, var(--accent-primary) 45%, transparent); }
#mode-status[data-state="browser"]::before { background: var(--accent-primary); }
#mode-status[data-state="error"] { color: var(--status-error); border-color: color-mix(in srgb, var(--status-error) 45%, transparent); }
#mode-status[data-state="error"]::before { background: var(--status-error); }
@keyframes pulse { from { opacity: 0.25; transform: scale(0.8); } to { opacity: 1; transform: scale(1.1); } }

/* ---------- error (높이 0 → 자연 높이 전환) ---------- */
.error-wrap { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.32s var(--ease-out); }
.error-wrap:has(#error:not([hidden])) { grid-template-rows: 1fr; }
.error-wrap > #error { min-height: 0; }
#error {
  display: flex; align-items: center; gap: 10px; overflow: hidden;
  padding: 12px 12px 12px 16px; border-radius: var(--radius-md);
  background: var(--status-error-soft); color: var(--status-error); border: 1px solid color-mix(in srgb, var(--status-error) 35%, transparent);
  font-weight: 500; font-size: 15px;
}
#error[hidden] { display: flex; visibility: hidden; padding-block: 0; border-width: 0; }
.error__icon { width: 20px; height: 20px; flex: none; }
#error-text { flex: 1; }
.error__close { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: var(--radius-sm); background: none; color: inherit; }
.error__close:hover { background: color-mix(in srgb, var(--status-error) 12%, transparent); }
.error__close svg { width: 16px; height: 16px; }

/* ---------- 건너뛴 요소 경고 ---------- */
#skipped[hidden] { display: none; }
#skipped {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
  padding: 10px 16px; border-radius: var(--radius-md);
  background: var(--status-warning-soft); color: var(--status-warning);
  border: 1px solid color-mix(in srgb, var(--status-warning) 35%, transparent);
  font-weight: 500; font-size: 14px;
}
#skipped a { color: inherit; font-weight: 600; text-underline-offset: 3px; }

/* ---------- 바닥 고지 ---------- */
.app-foot { margin-top: 8px; text-align: center; font-size: 13px; color: var(--text-muted); }
.app-foot p + p { margin-top: 4px; }
.app-foot a { color: inherit; text-underline-offset: 3px; }
.app-foot a:hover { color: var(--text-primary); }

/* ---------- drop zone ---------- */
#drop-zone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 196px; padding: 28px 20px; border-radius: 14px; text-align: center; cursor: pointer;
  background: var(--surface-main); outline: none;
  transition: background 0.22s var(--ease-std), box-shadow 0.22s var(--ease-std);
}
.drop-zone__frame { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.drop-zone__frame rect {
  width: calc(100% - 2px); height: calc(100% - 2px); fill: none;
  stroke: var(--border-strong); stroke-width: 1.5; stroke-dasharray: 7 6;
  transition: stroke 0.2s var(--ease-std);
}
#drop-zone:hover .drop-zone__frame rect, #drop-zone:focus-visible .drop-zone__frame rect { stroke: var(--accent-primary); }
#drop-zone:focus-visible { box-shadow: var(--shadow-drag); }
#drop-zone.dragover { background: var(--accent-soft); box-shadow: var(--shadow-drag); }
#drop-zone.dragover .drop-zone__frame rect { stroke: var(--accent-primary); animation: march 0.6s linear infinite; }
@keyframes march { to { stroke-dashoffset: -13; } }

.drop-zone__icon {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 10px;
  color: var(--accent-text); background: var(--accent-soft);
  transition: transform 0.32s var(--ease-out), background 0.2s var(--ease-std);
}
.drop-zone__icon svg { width: 22px; height: 22px; }
#drop-zone:hover .drop-zone__icon { transform: translateY(-2px); }
#drop-zone.dragover .drop-zone__icon { transform: translateY(-4px) scale(1.06); background: var(--surface-main); }
.drop-zone__title { position: relative; display: grid; font-weight: 650; font-size: 16px; }
.drop-zone__title > span { grid-area: 1 / 1; transition: opacity 0.18s var(--ease-std), transform 0.25s var(--ease-out); }
.t-drag { opacity: 0; transform: translateY(6px); color: var(--accent-text); }
#drop-zone.dragover .t-idle { opacity: 0; transform: translateY(-6px); }
#drop-zone.dragover .t-drag { opacity: 1; transform: none; }
.drop-zone__hint { font-size: 13px; color: var(--text-muted); }
.drop-zone__sample {
  margin-top: 12px; border: 0; background: none; padding: 4px 8px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; color: var(--accent-text); text-decoration: underline; text-underline-offset: 0.25em; text-decoration-thickness: 1px;
}
.drop-zone__sample:hover { background: var(--accent-soft); }

/* 결과가 있으면 드롭 영역을 낮춰 결과에 자리를 내준다 */
body[data-state="done"] #drop-zone, body[data-state="converting"] #drop-zone { min-height: 112px; padding-block: 18px; }
body[data-state="done"] .drop-zone__icon, body[data-state="converting"] .drop-zone__icon { width: 36px; height: 36px; margin-bottom: 4px; }
body[data-state="done"] .drop-zone__sample, body[data-state="converting"] .drop-zone__sample { display: none; }

/* ---------- status bar ---------- */
.status-bar {
  position: relative; display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap;
  min-height: 60px; padding: 10px 12px 10px 16px; border-radius: var(--radius-lg);
  background: var(--surface-main); border: 1px solid var(--border-subtle); overflow: hidden;
}
.file-chip {
  display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%;
  min-height: 38px; padding: 6px 12px; border-radius: var(--radius-sm); background: var(--surface-secondary); border: 1px solid var(--border-subtle);
}
.file-chip[hidden] { display: none; }
.file-chip__icon { width: 16px; height: 16px; color: var(--accent-text); flex: none; }
#file-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.file-chip__size { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
#file-badge:empty { display: none; }
.status-text { font-size: 14px; color: var(--text-muted); }
body[data-state="converting"] .status-text, body[data-state="done"] .status-text, body[data-state="error"] .status-text { display: none; }
#result-meta { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
#result-meta b { color: var(--text-primary); font-weight: 650; }
.busy { display: none; font-size: 13px; color: var(--accent-text); font-weight: 500; }
body[data-state="converting"] .busy { display: inline; }
#download { margin-left: auto; }

.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; overflow: hidden; opacity: 0; transition: opacity 0.3s var(--ease-std); }
.progress__bar { position: absolute; inset: 0; background: var(--accent-primary); transform-origin: left; transform: scaleX(0); }
body[data-state="converting"] .progress { opacity: 1; }
body[data-state="converting"] .progress__bar { animation: indeterminate 1.1s var(--ease-std) infinite; }
@keyframes indeterminate {
  0% { transform: translateX(-40%) scaleX(0.4); }
  100% { transform: translateX(110%) scaleX(0.6); }
}

/* ---------- panes ---------- */
.pane-tabs { display: none; }
.panes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.pane {
  display: flex; flex-direction: column; min-width: 0; height: min(72vh, 860px); min-height: 420px;
  border-radius: var(--radius-lg); background: var(--surface-main); border: 1px solid var(--border-subtle); overflow: hidden;
}
.pane__head {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 10px 6px 16px;
  border-bottom: 1px solid var(--border-subtle); background: var(--surface-secondary);
}
.pane__title { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; color: var(--text-muted); }
.pane__title svg { width: 16px; height: 16px; }
.pane__meta { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pane__head .btn { margin-left: auto; }
.pane__body { position: relative; flex: 1; min-height: 0; overflow: auto; }

#copy { position: relative; }
#copy .i-done { display: none; color: var(--status-success); }
#copy.is-done .i-copy { display: none; }
#copy.is-done .i-done { display: block; }

.empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 12px;
  padding: clamp(48px, 12vh, 112px) 24px 24px; text-align: center; color: var(--text-muted); font-size: 14px;
}
.empty svg { width: 34px; height: 34px; color: var(--border-strong); }
body[data-state="done"] .empty--raw { display: none; }

/* 원문: 줄 번호는 CSS 카운터라 #raw 의 textContent 는 Markdown 과 정확히 같다 */
#raw {
  margin: 0; padding: 16px 0; min-height: 100%; background: var(--code-bg);
  font-family: var(--font-mono); font-size: 13px; line-height: 1.7; color: var(--text-primary);
  counter-reset: ln; tab-size: 4;
}
#raw:empty { display: none; }
#raw .l { display: block; position: relative; padding: 0 20px 0 64px; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.7em; counter-increment: ln; }
#raw .l::before {
  content: counter(ln); position: absolute; left: 0; width: 44px; padding-right: 10px; text-align: right;
  color: var(--text-subtle); border-right: 1px solid var(--border-subtle); user-select: none; font-variant-numeric: tabular-nums;
}
#raw .l:hover { background: var(--surface-hover); }
#raw .k { color: var(--badge-md); font-weight: 600; }

/* 미리보기 본문 */
#preview { padding: 28px 32px 40px; min-height: 100%; }
.markdown-body { font-size: 15px; line-height: 1.75; color: var(--text-primary); }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { margin: 1.6em 0 0.55em; line-height: 1.3; letter-spacing: -0.02em; }
.markdown-body h1 { font-size: 1.65em; font-weight: 780; padding-bottom: 0.4em; border-bottom: 1px solid var(--border-subtle); }
.markdown-body h2 { font-size: 1.32em; font-weight: 720; }
.markdown-body h3 { font-size: 1.12em; font-weight: 700; }
.markdown-body p { margin: 0.7em 0; max-width: 72ch; }
.markdown-body img { max-width: 100%; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--border-subtle); }
.markdown-body table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 1.1em 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border-strong); padding: 7px 12px; vertical-align: top; text-align: left; }
.markdown-body th { background: var(--surface-secondary); font-weight: 650; }
.markdown-body tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-secondary) 45%, transparent); }
.markdown-body code { font-family: var(--font-mono); font-size: 0.88em; padding: 0.12em 0.4em; border-radius: var(--radius-xs); background: var(--surface-secondary); }
.markdown-body blockquote { margin: 1em 0; padding: 0 1em; border-left: 1px solid var(--border-strong); color: var(--text-muted); }
.markdown-body a { color: var(--accent-text); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 60; transform: translate(-50%, 16px);
  padding: 10px 16px; border-radius: var(--radius-pill); font-size: 14px; font-weight: 600;
  background: var(--text-primary); color: var(--surface-main); box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity 0.22s var(--ease-std), transform 0.32s var(--ease-out);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 899px) {
  .app { padding: 20px 16px 120px; }
  .mode .switch__label { display: none; }
  .pane-tabs {
    display: grid; grid-template-columns: 1fr 1fr; padding: 4px; gap: 4px;
    border-radius: var(--radius-md); background: var(--surface-secondary); border: 1px solid var(--border-subtle);
  }
  .pane-tabs button {
    height: 36px; border: 0; border-radius: var(--radius-sm); background: none; font-size: 14px; font-weight: 600; color: var(--text-muted);
  }
  .pane-tabs button[aria-selected="true"] { background: var(--surface-main); color: var(--text-primary); box-shadow: var(--shadow-sm); }
  .panes { grid-template-columns: minmax(0, 1fr); }
  .pane[hidden] { display: none; }
  .pane { height: 64vh; min-height: 360px; }
  #preview { padding: 20px; }
  #download { margin-left: 0; }
}
@media (max-width: 520px) {
  #mode-status { max-width: 132px; overflow: hidden; text-overflow: ellipsis; display: inline-block; line-height: 28px; }
  #mode-status::before { display: inline-block; margin-right: 6px; vertical-align: middle; }
  .brand__ver { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .error-wrap, #drop-zone, .drop-zone__icon, .toast, .switch__track::after { transition: none; }
  #drop-zone.dragover .drop-zone__frame rect { animation: none; }
  body[data-state="converting"] .progress__bar { animation: none; transform: scaleX(1); opacity: 0.6; }
  #mode-status[data-state="loading"]::before { animation: none; }
  .toast { transform: translate(-50%, 0); }
}
