:root {
  --bg: #f6f7f9; --panel: #fff; --ink: #1a1c22; --muted: #6b7280;
  --line: #e5e7eb; --accent: #4f46e5; --accent-ink: #fff;
  --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#0f1115; --panel:#171a21; --ink:#e7e9ee; --muted:#9aa2b1;
    --line:#262b36; --accent:#7c6cf0; --accent-ink:#fff; }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background: var(--bg); color: var(--ink); }
#topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.spacer { flex: 1; }
.icon-btn { display: none; background: none; border: 0; font-size: 20px; color: var(--ink); }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--muted); }
main { max-width: 1080px; margin: 0 auto; padding: 20px 16px 80px; }
.loading { color: var(--muted); padding: 40px; text-align: center; }
h1 { font-size: 22px; } h2 { font-size: 17px; margin: 18px 0 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
button, .btn { cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 8px 14px; border-radius: 9px; font-size: 14px; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.ghost { background: none; }
button:disabled { opacity: .5; cursor: default; }
input, textarea, select { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--ink); font-size: 14px; font-family: inherit; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
textarea { min-height: 90px; resize: vertical; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tag { display: inline-block; padding: 4px 10px; margin: 3px; border-radius: 999px; border: 1px solid var(--line);
  font-size: 13px; cursor: pointer; user-select: none; }
.tag.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; font-size: 14px; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.pill.ok { background: rgba(22,163,74,.15); color: var(--ok); }
.pill.warn { background: rgba(217,119,6,.15); color: var(--warn); }
.pill.bad { background: rgba(220,38,38,.15); color: var(--bad); }
.muted { color: var(--muted); font-size: 13px; }
.reader { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px;
  line-height: 1.9; font-size: 16px; white-space: pre-wrap; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .3s; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
pre.log { background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 10px; overflow-x: auto; font-size: 12px; max-height: 240px; }
#mobilenav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--panel);
  border-top: 1px solid var(--line); padding: 8px env(safe-area-inset-right) calc(8px + env(safe-area-inset-bottom)) env(safe-area-inset-left); }
#mobilenav a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: 12px; }
/* 편집기 3분할 */
.editor, .viewer { display: grid; grid-template-columns: 260px 1fr; gap: 14px; align-items: start; }
.ed-list, .vtree { max-height: 72vh; overflow-y: auto; position: sticky; top: 64px; }
.ed-main .row { margin-bottom: 8px; }
/* 뷰어 트리 */
.tvol { font-weight: 700; margin: 10px 0 4px; }
.tchap { font-size: 13px; color: var(--muted); margin: 6px 0 2px; }
.tnode { padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.tnode:hover { background: var(--bg); }
.tnode.on { background: var(--accent); color: var(--accent-ink); }
.tnode.muted { cursor: default; }
/* 품질 히트맵 */
.hmcell { text-align: center; font-weight: 600; }
.hmcell.ok { background: rgba(22,163,74,.14); }
.hmcell.warn { background: rgba(217,119,6,.18); }
.hmcell.bad { background: rgba(220,38,38,.2); }
/* diff */
.diff-add { color: var(--ok); background: rgba(22,163,74,.08); white-space: pre-wrap; }
.diff-del { color: var(--bad); background: rgba(220,38,38,.08); white-space: pre-wrap; }
/* 모바일 드로어: 탭을 세로 오버레이로 */
@media (max-width: 640px) {
  .icon-btn { display: block; }
  #mobilenav { display: flex !important; }
  main { padding-bottom: 90px; }
  .editor, .viewer { grid-template-columns: 1fr; }
  .ed-list, .vtree { position: static; max-height: 40vh; }
  .tabs { position: relative; }
  body.drawer-open .tabs { position: fixed; inset: 52px 0 auto 0; z-index: 20; flex-direction: column;
    background: var(--panel); border-bottom: 1px solid var(--line); max-height: 70vh; overflow-y: auto; padding: 8px; }
}
