/* 평가 콘솔 스타일 — 외부 폰트·CDN 없음. 시스템 폰트만 사용한다. */

:root {
  --bg: #0f1216;
  --bg-panel: #171b21;
  --bg-panel-2: #1d222a;
  --bg-input: #11151a;
  --line: #2a313b;
  --line-soft: #222831;
  --fg: #e6eaf0;
  --fg-dim: #9aa5b4;
  --fg-mute: #6b7684;
  --accent: #4c8dff;
  --accent-dim: #2b5cab;
  --ok: #35c48a;
  --warn: #e0a338;
  --danger: #e5544b;
  --gold: #d8b34a;
  --radius: 8px;
  --mono: ui-monospace, "Cascadia Mono", "Consolas", "D2Coding", monospace;
  --sans: "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

/* 100dvh tracks the *visible* viewport on mobile — 100vh sits under the iOS
   address bar and clips the bottom of the app. Desktop resolves both the same. */
#app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* Hamburger: desktop never sees it; the mobile block below turns it on. */
.nav-toggle { display: none; }
.nav-backdrop { display: none; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: var(--bg-panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 6px 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: var(--radius);
  background: linear-gradient(140deg, var(--accent), #7b5cff);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: .5px;
}
.brand strong { display: block; font-size: 14px; }
.brand small { color: var(--fg-mute); font-size: 11px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px;
  color: var(--fg-dim); text-decoration: none; font-size: 13.5px;
}
.nav a:hover { background: var(--bg-panel-2); color: var(--fg); }
.nav a.active { background: var(--accent-dim); color: #fff; }
.nav .ico { width: 16px; text-align: center; opacity: .85; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.health {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; padding: 7px 9px; border-radius: 6px;
  background: var(--bg-panel-2); border: 1px solid var(--line-soft);
}
.health .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fg-mute); }
.health-ok .dot { background: var(--ok); }
.health-bad .dot { background: var(--danger); }
.health-bad { color: #f2b7b3; }

/* ---------- main ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; flex: 0 0 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; border-bottom: 1px solid var(--line);
  background: var(--bg-panel);
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; }
.view-actions { display: flex; gap: 8px; align-items: center; }
.view { flex: 1; overflow: auto; padding: 20px 24px 48px; }

/* ---------- layout helpers ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.split-wide-left { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.spacer { flex: 1; }

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}
.panel > h2 {
  margin: 0 0 12px; font-size: 13px; font-weight: 600;
  color: var(--fg-dim); text-transform: none; letter-spacing: .2px;
  display: flex; align-items: center; gap: 8px;
}
.panel-tight { padding: 12px; }

/* ---------- text ---------- */
.muted { color: var(--fg-dim); }
.tiny { font-size: 11.5px; }
.mono { font-family: var(--mono); font-size: 12px; }
h3 { font-size: 13px; margin: 0 0 8px; }
a { color: var(--accent); }

.metric-big { font-size: 26px; font-weight: 600; line-height: 1.2; }
.metric-label { font-size: 11.5px; color: var(--fg-mute); }

/* ---------- gauges ---------- */
.gauge { margin-bottom: 14px; }
.gauge:last-child { margin-bottom: 0; }
.gauge-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 5px; }
.gauge-head b { font-weight: 600; }
.bar {
  height: 10px; border-radius: 5px; background: var(--bg-input);
  overflow: hidden; border: 1px solid var(--line-soft); position: relative;
}
.bar > span { display: block; height: 100%; background: var(--accent); transition: width .35s ease; }
.bar.lv-ok > span { background: var(--ok); }
.bar.lv-warn > span { background: var(--warn); }
.bar.lv-crit > span { background: var(--danger); }
.bar-thin { height: 6px; }
.bar-tall { height: 16px; border-radius: 6px; }
.bar-marker {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--fg); opacity: .55;
}

/* ---------- tables ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; font-weight: 600; font-size: 11.5px; color: var(--fg-mute);
  padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr.clickable { cursor: pointer; }
table.tbl tbody tr.clickable:hover { background: var(--bg-panel-2); }
table.tbl tbody tr.selected { background: var(--accent-dim); }
.num { text-align: right; font-family: var(--mono); font-size: 12px; }
table.tbl tr.license-review td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.table-wrap { overflow-x: auto; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 2px 7px; border-radius: 999px;
  font-size: 11px; line-height: 1.6; border: 1px solid transparent; white-space: nowrap;
}
.badge-ok { background: rgba(53,196,138,.14); color: #6fe0b0; border-color: rgba(53,196,138,.35); }
.badge-warn { background: rgba(224,163,56,.16); color: #f0c470; border-color: rgba(224,163,56,.4); }
.badge-danger { background: rgba(229,84,75,.16); color: #f3948d; border-color: rgba(229,84,75,.4); }
.badge-info { background: rgba(76,141,255,.14); color: #8db6ff; border-color: rgba(76,141,255,.35); }
.badge-mute { background: var(--bg-panel-2); color: var(--fg-mute); border-color: var(--line); }

/* ---------- buttons / inputs ---------- */
button, .btn {
  font-family: inherit; font-size: 13px;
  background: var(--bg-panel-2); color: var(--fg);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 12px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: #3b4553; background: #232a33; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: #3d7ceb; border-color: #3d7ceb; }
button.danger { background: rgba(229,84,75,.15); border-color: rgba(229,84,75,.5); color: #f3948d; }
button.ok { background: rgba(53,196,138,.15); border-color: rgba(53,196,138,.5); color: #6fe0b0; }
button.gold { background: rgba(216,179,74,.15); border-color: rgba(216,179,74,.5); color: #e6c96f; }
button.small { padding: 3px 8px; font-size: 12px; }
button.ghost { background: transparent; }

input, select, textarea {
  font-family: inherit; font-size: 13px;
  background: var(--bg-input); color: var(--fg);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { font-family: var(--mono); font-size: 12px; line-height: 1.55; resize: vertical; width: 100%; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--fg-dim); }
label.inline { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--fg-dim); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; }
legend { font-size: 12px; color: var(--fg-mute); padding: 0 6px; }

/* ---------- states ---------- */
.loading, .empty, .error-box {
  padding: 26px; text-align: center; color: var(--fg-mute);
  border: 1px dashed var(--line); border-radius: var(--radius); font-size: 13px;
}
.empty strong { display: block; color: var(--fg-dim); margin-bottom: 4px; font-size: 13.5px; }
.error-box { border-color: rgba(229,84,75,.5); color: #f3948d; border-style: solid; background: rgba(229,84,75,.07); }

.notice {
  border-radius: var(--radius); padding: 10px 13px; font-size: 12.5px;
  border: 1px solid var(--line); background: var(--bg-panel-2); margin-bottom: 14px;
}
.notice-warn { border-color: rgba(224,163,56,.5); background: rgba(224,163,56,.09); color: #f0c470; }
.notice-danger { border-color: rgba(229,84,75,.5); background: rgba(229,84,75,.09); color: #f3948d; }
.notice-info { border-color: rgba(76,141,255,.45); background: rgba(76,141,255,.08); color: #a8c5ff; }
.notice b { font-weight: 600; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  padding: 9px 14px; border-radius: 6px; font-size: 13px; max-width: 380px;
  background: var(--bg-panel-2); border: 1px solid var(--line); box-shadow: 0 6px 22px rgba(0,0,0,.45);
}
.toast-ok { border-color: rgba(53,196,138,.5); color: #6fe0b0; }
.toast-error { border-color: rgba(229,84,75,.55); color: #f3948d; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(6,8,11,.72);
  display: grid; place-items: center; z-index: 50; padding: 30px;
}
.modal {
  background: var(--bg-panel); border: 1px solid var(--line); border-radius: 10px;
  width: min(1080px, 100%); max-height: 88vh; display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 14px; }
.modal-body { padding: 18px; overflow: auto; }

/* ---------- misc components ---------- */
.kv { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 5px 12px; font-size: 12.5px; }
.kv dt { color: var(--fg-mute); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12px; word-break: break-all; }

pre.block {
  background: var(--bg-input); border: 1px solid var(--line-soft); border-radius: 6px;
  padding: 11px; font-family: var(--mono); font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; max-height: 340px; overflow: auto; margin: 0;
}
pre.block.thinking { color: var(--fg-mute); font-style: italic; }

.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.thumb {
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
  background: var(--bg-input); cursor: pointer;
}
.thumb.selected { border-color: var(--accent); }
.thumb img { width: 100%; display: block; background: #fff; }
.thumb .cap { padding: 5px 7px; font-size: 11px; color: var(--fg-mute); }

.preview-img {
  width: 100%; background: #fff; border-radius: 6px; border: 1px solid var(--line);
  display: block; cursor: zoom-in;
}
.preview-img.zoomed { cursor: zoom-out; max-width: none; width: auto; }
.preview-scroll { overflow: auto; max-height: 68vh; border-radius: 6px; }

.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 10px; font-size: 12.5px; }

.log {
  background: var(--bg-input); border: 1px solid var(--line-soft); border-radius: 6px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.6;
  height: 300px; overflow: auto; padding: 9px;
}
.log div { white-space: pre-wrap; word-break: break-all; }
.log .t-unit_completed { color: #6fe0b0; }
.log .t-unit_failed, .log .t-run_failed { color: #f3948d; }
.log .t-unit_skipped { color: var(--fg-mute); }
.log .t-run_started, .log .t-run_completed { color: #8db6ff; }
.log .t-run_stopped { color: #f0c470; }

/* matrix */
.matrix td.cell { text-align: center; cursor: pointer; font-family: var(--mono); font-size: 12px; padding: 0; }
.matrix td.cell > div { padding: 9px 6px; border-radius: 4px; margin: 2px; }
.matrix td.cell small { display: block; font-size: 10px; opacity: .75; }
.matrix td.na { text-align: center; color: var(--fg-mute); }

/* golden strata bar chart */
.chart-rows { display: flex; flex-direction: column; gap: 7px; }
.chart-row { display: grid; grid-template-columns: 160px minmax(0, 1fr) 44px; gap: 10px; align-items: center; font-size: 12px; }
.chart-row .label { color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-row .val { text-align: right; font-family: var(--mono); font-size: 11.5px; color: var(--fg-dim); }

.progress-item { padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.progress-item:last-child { border-bottom: none; }
.progress-item.below-min { background: rgba(229,84,75,.06); border-radius: 6px; padding-left: 8px; padding-right: 8px; }

/* keyboard hint */
kbd {
  font-family: var(--mono); font-size: 11px; padding: 1px 5px; border-radius: 4px;
  background: var(--bg-input); border: 1px solid var(--line); border-bottom-width: 2px; color: var(--fg-dim);
}
.shortcut-bar { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--fg-mute); }

.pairwise { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pairwise .side { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.pairwise .side h3 { display: flex; justify-content: space-between; align-items: center; }
.pairwise .side.picked { border-color: var(--accent); }

.review-fields { display: flex; flex-direction: column; gap: 10px; }
.review-fields label.field textarea { min-height: 62px; }

/* ---------- 모델 수평 비교 (행=문항 / 열=모델) ---------- */
.req-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.req-card {
  text-align: left; padding: 10px 12px; border-radius: var(--radius);
  background: var(--bg-panel-2); border: 1px solid var(--line); display: flex;
  flex-direction: column; gap: 3px;
}
.req-card.active { border-color: var(--accent); background: rgba(76,141,255,.10); }
.req-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.req-card-name { font-size: 12.5px; color: var(--fg-dim); }

.cmp-model-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 6px; }
.model-pick { padding: 5px 8px; border: 1px solid var(--line-soft); border-radius: 6px; background: var(--bg-input); }
.model-pick.unusable { opacity: .5; }

/* 표는 자체 스크롤 박스 안에서만 움직인다 — 헤더와 첫 열을 붙잡아 두기 위해서다. */
.cmp-scroll { overflow: auto; max-height: 72vh; border: 1px solid var(--line); border-radius: var(--radius); }
table.cmp-tbl { border-collapse: separate; border-spacing: 0; min-width: 100%; }
table.cmp-tbl thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--bg-panel-2); border-bottom: 1px solid var(--line); padding: 8px 10px;
  vertical-align: top; white-space: normal;
}
table.cmp-tbl th.cmp-unit-col {
  position: sticky; left: 0; z-index: 2;
  background: var(--bg-panel-2); min-width: 190px; max-width: 190px;
  text-align: left; vertical-align: top; padding: 8px 10px;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line-soft);
}
table.cmp-tbl thead th.cmp-unit-col { z-index: 4; }
.cmp-model-col { min-width: 240px; }
.cmp-model-head { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--fg); }
.cmp-key {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 4px;
  background: var(--bg-input); border: 1px solid var(--line); font-family: var(--mono); font-size: 11px;
}

tr.cmp-row td { border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr.cmp-row.active th.cmp-unit-col { box-shadow: inset 3px 0 0 var(--accent); }
tr.cmp-row.active td { background: rgba(76,141,255,.05); }
tr.cmp-row.incomplete th.cmp-unit-col { box-shadow: inset 3px 0 0 var(--warn); }
tr.cmp-row.incomplete td { background: rgba(224,163,56,.05); }
.unit-label { font-size: 11.5px; word-break: break-all; }
.unit-verdict { margin-top: 5px; }
.cmp-thumb {
  width: 100%; margin-top: 6px; border-radius: 4px; border: 1px solid var(--line);
  background: #fff; cursor: zoom-in; display: block;
}

td.cmp-cell { padding: 8px 10px; cursor: pointer; }
td.cmp-cell.sz-top { box-shadow: inset 0 -2px 0 rgba(53,196,138,.55); }
td.cmp-cell.sz-low { box-shadow: inset 0 -2px 0 rgba(224,163,56,.6); }
td.cmp-cell.cmp-divergent { box-shadow: inset 0 -2px 0 rgba(224,163,56,.6); }
td.cmp-cell.cmp-missing { background: repeating-linear-gradient(45deg, transparent, transparent 6px, rgba(255,255,255,.02) 6px, rgba(255,255,255,.02) 12px); cursor: default; }
.cell-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cell-sum { font-size: 14px; font-weight: 600; margin: 4px 0 2px; word-break: break-word; }
.cell-size { display: flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 11.5px; color: var(--fg-dim); }
.sz-bar { flex: 1; height: 5px; border-radius: 3px; background: var(--bg-input); border: 1px solid var(--line-soft); overflow: hidden; }
.sz-bar i { display: block; height: 100%; background: var(--accent); }
.cell-flags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px; }
.cell-rate { display: flex; gap: 4px; margin-top: 7px; }
.cell-rate .rate { padding: 2px 7px; font-size: 11px; }
.cell-rate .rate.active.rate-good { background: rgba(53,196,138,.2); border-color: rgba(53,196,138,.6); color: #6fe0b0; }
.cell-rate .rate.active.rate-ok { background: rgba(76,141,255,.18); border-color: rgba(76,141,255,.55); color: #8db6ff; }
.cell-rate .rate.active.rate-bad { background: rgba(229,84,75,.18); border-color: rgba(229,84,75,.55); color: #f3948d; }
.best-pick { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--fg-dim); cursor: pointer; }
.cell-detail { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 7px; }
.cell-detail-tbl td { padding: 3px 6px; border-bottom: 1px solid var(--line-soft); word-break: break-word; }

.win-bar, .rate-bar { height: 6px; border-radius: 3px; background: var(--bg-input); border: 1px solid var(--line-soft); overflow: hidden; display: flex; min-width: 90px; }
.win-bar i { display: block; height: 100%; background: var(--ok); }
.rate-bar i.g { background: var(--ok); }
.rate-bar i.o { background: var(--accent); }
.rate-bar i.b { background: var(--danger); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent;
  border-radius: 0; color: var(--fg-mute); padding: 7px 12px;
}
.tabs button.active { color: var(--fg); border-bottom-color: var(--accent); }

/* ---------- 사용 가이드 ---------- */
.nav-guide { margin-top: 10px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.nav-kbd {
  margin-left: auto; font-family: var(--mono); font-size: 10.5px; padding: 0 5px;
  border-radius: 4px; background: var(--bg-input); border: 1px solid var(--line); color: var(--fg-mute);
}

.guide { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; align-items: start; }
.guide-side {
  position: sticky; top: 0; align-self: start;
  max-height: calc(100vh - 96px); overflow: auto;
  border-right: 1px solid var(--line-soft); padding-right: 12px;
}
.guide-side-head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.guide-side-head .tiny { font-family: var(--mono); word-break: break-all; }

.guide-toc { display: flex; flex-direction: column; gap: 1px; }
.toc-link {
  text-align: left; background: none; border: none; border-left: 2px solid transparent;
  border-radius: 0; color: var(--fg-dim); font-size: 12.5px; padding: 4px 8px;
  line-height: 1.35; white-space: normal;
}
.toc-link:hover:not(:disabled) { background: var(--bg-panel-2); color: var(--fg); border-color: var(--line); }
.toc-link.active { color: #fff; border-left-color: var(--accent); background: rgba(76,141,255,.10); }
.toc-l1 { font-weight: 600; color: var(--fg); }
.toc-l2 { padding-left: 12px; }
.toc-l3 { padding-left: 24px; font-size: 12px; color: var(--fg-mute); }

.guide-links { margin-top: 20px; border-top: 1px solid var(--line-soft); padding-top: 14px; }
.guide-links h3 { color: var(--fg-mute); font-size: 11.5px; }
.doc-link {
  display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left;
  background: var(--bg-panel); border: 1px solid var(--line-soft); border-radius: 6px;
  padding: 7px 9px; margin-bottom: 5px;
}
.doc-link .doc-title { font-size: 12.5px; color: var(--fg); }
.doc-link .mono { word-break: break-all; }
.doc-link.unavailable { opacity: .45; }

.guide-main { min-width: 0; }
.guide-search {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  background: var(--bg); padding: 0 0 12px;
}
.guide-search input { flex: 1; max-width: 460px; }

/* 본문 — 읽기 좋은 폭과 줄간격 */
.md { max-width: 78ch; font-size: 14px; line-height: 1.75; padding-bottom: 60px; }
.md > :first-child { margin-top: 0; }
.md p { margin: 0 0 14px; }
.md .md-h1 { font-size: 24px; margin: 0 0 14px; font-weight: 650; letter-spacing: -.2px; }
.md .md-h2 {
  font-size: 19px; margin: 34px 0 12px; font-weight: 640;
  padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.md .md-h3 { font-size: 15.5px; margin: 26px 0 10px; font-weight: 600; color: var(--fg); }
.md .md-h4 { font-size: 13.5px; margin: 20px 0 8px; font-weight: 600; color: var(--fg-dim); }
.md .md-rule { border: none; border-top: 1px solid var(--line-soft); margin: 26px 0; }

.md .md-list { margin: 0 0 14px; padding-left: 22px; }
.md .md-list li { margin-bottom: 6px; }
.md .md-list .md-list { margin: 6px 0 0; }

.md code {
  font-family: var(--mono); font-size: 12.5px; padding: 1px 5px; border-radius: 4px;
  background: var(--bg-input); border: 1px solid var(--line-soft); color: #cfd8e6;
}
.md pre.md-code {
  background: var(--bg-input); border: 1px solid var(--line-soft); border-radius: 6px;
  padding: 12px 14px; overflow-x: auto; margin: 0 0 16px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
}
.md pre.md-code code { background: none; border: none; padding: 0; font-size: inherit; }

.md .md-quote {
  margin: 0 0 16px; padding: 10px 14px; border-left: 3px solid var(--accent-dim);
  background: rgba(76,141,255,.06); border-radius: 0 6px 6px 0; color: var(--fg-dim);
}
.md .md-quote > :last-child { margin-bottom: 0; }
.md .md-quote strong { color: var(--fg); }

.md .md-table-wrap { overflow-x: auto; margin: 0 0 18px; border: 1px solid var(--line); border-radius: var(--radius); }
.md table.md-table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 1.6; }
.md table.md-table th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--fg-dim);
  background: var(--bg-panel-2); padding: 8px 11px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.md table.md-table td { padding: 8px 11px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.md table.md-table tr:last-child td { border-bottom: none; }
.md table.md-table tbody tr:hover { background: var(--bg-panel); }

.md mark.md-hit { background: rgba(224,163,56,.35); color: var(--fg); border-radius: 3px; padding: 0 1px; }
.md mark.md-hit.current { background: var(--warn); color: #1a1206; }

@media (max-width: 1100px) {
  .guide { grid-template-columns: minmax(0, 1fr); }
  .guide-side { position: static; max-height: none; border-right: none; padding-right: 0; }
}

/* ---- GPU 대기열 ---- */
.q-sep { width: 1px; height: 14px; background: var(--line); }
.q-running {
  border: 1px solid rgba(76,141,255,.35); background: rgba(76,141,255,.06);
  border-radius: var(--radius); padding: 12px;
}
.q-idle {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; color: var(--fg-dim);
}
.q-hist td { vertical-align: top; }
.q-hist-actions { white-space: nowrap; text-align: right; }
.q-hist-note td { border-top: none; padding-top: 0; }
.q-error {
  margin: 0; padding: 8px 10px; border-radius: 6px; background: var(--bg-input);
  border: 1px solid rgba(229,84,75,.4); color: #f3948d;
  font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; word-break: break-all;
  max-height: 180px; overflow: auto;
}

/* ---- 프롬프트 레지스트리 ---- */
details.prompt-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-panel-2); }
details.prompt-panel > summary {
  cursor: pointer; padding: 9px 12px; font-size: 12.5px; color: var(--fg-dim);
  display: flex; align-items: center; gap: 8px; list-style: none; user-select: none;
}
details.prompt-panel > summary::-webkit-details-marker { display: none; }
details.prompt-panel > summary::before { content: "▸"; color: var(--fg-mute); font-size: 11px; }
details.prompt-panel[open] > summary::before { content: "▾"; }
details.prompt-panel[open] > summary { border-bottom: 1px solid var(--line-soft); }
.prompt-panel-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.prompt-preview-label {
  font-size: 11px; color: var(--fg-mute); text-transform: uppercase; letter-spacing: .4px;
  margin: 4px 0 3px; display: flex; align-items: center; gap: 8px;
}
pre.prompt-block {
  background: var(--bg-input); border: 1px solid var(--line-soft); border-radius: 6px;
  padding: 10px; font-family: var(--mono); font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; margin: 0;
}
.prompt-edit textarea { min-height: 140px; }
.prompt-edit textarea.prompt-system { min-height: 70px; }

.pv-list-actions { display: flex; gap: 6px; flex-wrap: wrap; }
tr.pv-row.selected-a td, tr.pv-row.selected-b td { background: rgba(76,141,255,.07); }

/* 줄 단위 diff — 추가는 초록, 삭제는 빨강 */
.diff-block {
  background: var(--bg-input); border: 1px solid var(--line-soft); border-radius: 6px;
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  max-height: 420px; overflow: auto; margin: 0; padding: 6px 0;
}
.diff-block .dl { padding: 0 10px; white-space: pre-wrap; word-break: break-word; }
.diff-block .dl.add { background: rgba(53,196,138,.13); color: #8ae7bd; }
.diff-block .dl.del { background: rgba(229,84,75,.13); color: #f3a49d; text-decoration: line-through; text-decoration-color: rgba(229,84,75,.5); }
.diff-block .dl.ctx { color: var(--fg-dim); }
.diff-block .dl .dsign { display: inline-block; width: 16px; color: var(--fg-mute); }
.diff-block .dl.add .dsign { color: #6fe0b0; }
.diff-block .dl.del .dsign { color: #f3948d; }

/* 비교 축 전환 */
.axis-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.axis-toggle button { border: none; border-radius: 0; background: var(--bg-input); color: var(--fg-dim); padding: 6px 14px; }
.axis-toggle button.active { background: var(--accent-dim); color: #fff; }
.cmp-prompt-line { font-size: 11px; color: var(--fg-mute); font-family: var(--mono); margin-top: 2px; }

/* ---- 로그인 ---- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 60vh; }
.login-card {
  display: flex; flex-direction: column; gap: 12px; width: min(340px, 92vw);
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-panel); padding: 26px 24px 22px;
}
.login-card h2 { margin: 0; font-size: 17px; }
.login-card input[type="password"] {
  font-size: 16px; /* iOS: smaller inputs trigger auto-zoom on focus */
  padding: 10px 12px;
}
.login-status { margin: 0; font-size: 12.5px; }
.login-status.error { color: #f3948d; }
.login-status.warn { color: var(--warn); }
.login-status.muted { color: var(--fg-mute); }
.logout-btn { width: 100%; font-size: 12px; }

/* =====================================================================
   모바일 골격 (EXT-8) — 데스크탑(>900px)은 이 블록의 영향을 받지 않는다.
   사이드바는 오프캔버스 서랍이 되고, 본문이 화면 전체를 쓴다.
   ===================================================================== */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 70;
    width: min(260px, 78vw);
    transform: translateX(-100%);
    transition: transform .18s ease-out;
    box-shadow: 4px 0 24px rgba(0, 0, 0, .5);
  }
  body.nav-open .sidebar { transform: none; }

  .nav-backdrop {
    position: fixed; inset: 0; z-index: 65;
    background: rgba(0, 0, 0, .45);
  }
  body.nav-open .nav-backdrop { display: block; }

  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 44px; min-height: 44px;
    font-size: 18px; line-height: 1;
    background: transparent; border: none; color: var(--fg-dim);
    padding: 0; margin-right: 2px;
  }
  .nav-toggle:hover { color: var(--fg); background: transparent; }

  /* Touch targets: menu rows and buttons grow to a finger-sized minimum. */
  .nav a { padding: 12px 10px; min-height: 44px; }
  .topbar { padding: 0 10px; gap: 6px; }
  .topbar h1 { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .view { padding: 14px 12px 72px; }
  .toasts { left: 12px; right: 12px; bottom: 12px; align-items: stretch; }

  /* -- 화면별 규칙 (EXT-9) -- */

  /* Two-pane layouts stack; the left pane (usually the list) comes first. */
  .split, .split-wide-left { grid-template-columns: minmax(0, 1fr); }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Any wide table becomes its own horizontal scroller. Page-level horizontal
     scroll is what must never happen; inside a table it is expected. */
  table.tbl { display: block; overflow-x: auto; }
  table.tbl thead, table.tbl tbody { min-width: max-content; }

  /* 비교 표: 자체 스크롤 컨테이너(.cmp-scroll)는 유지하고 열만 좁힌다.
     첫 열(문항)은 원래 sticky — 모바일에서도 기준점으로 남는다. */
  .cmp-model-col { min-width: 185px; }
  .cmp-scroll { max-height: 65dvh; }

  /* 원본 미리보기: 화면 절반을 넘지 않아야 아래 정보·이력에 닿을 수 있다. */
  .preview-scroll { max-height: 48dvh; }
}

@media (max-width: 600px) {
  /* iOS zooms into any focused control under 16px — keep them at 16px on
     phones and leave desktop density untouched. */
  input, select, textarea { font-size: 16px; }
  button, .btn { min-height: 40px; }
  button.small, .btn.small { min-height: 36px; }
  .view-actions { flex-wrap: wrap; justify-content: flex-end; }

  /* 폰에서는 모든 격자가 한 열: 실행 폼·대시보드 타일·결과 요약 전부. */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: 12px; }
  label.field select, label.field input { width: 100%; }
}

/* ---- 검수 모바일 (EXT-10) ---- */
/* 데스크탑: 탭·액션바는 존재하지 않는 것처럼. */
.rv-tabs { display: none; }
.rv-actionbar { display: none; }

@media (max-width: 900px) {
  .rv-tabs {
    display: flex; gap: 6px; margin-bottom: 10px;
    position: sticky; top: 0; z-index: 30;
    background: var(--bg); padding: 4px 0;
  }
  .rv-tabs button { flex: 1; min-height: 40px; }
  .rv-tabs button.active { background: var(--accent-dim); border-color: var(--accent-dim); color: #fff; }

  /* 한 번에 한 면만: data-pane 이 가리키지 않는 쪽을 숨긴다. */
  .rv-split[data-pane="source"] .rv-pane-output { display: none; }
  .rv-split[data-pane="output"] .rv-pane-source { display: none; }

  .rv-actionbar {
    display: flex; gap: 8px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: var(--bg-panel); border-top: 1px solid var(--line);
  }
  .rv-actionbar button { flex: 1; min-height: 44px; font-size: 14px; }
  .rv-actionbar .gold { flex: 1; }

  /* 액션바가 본문 끝을 가리지 않도록 여백을 남긴다. */
  .view { padding-bottom: 96px; }

  /* 요구3 페어와이즈: 좌우 → 상하, 판정 버튼은 하단 고정. */
  .pairwise { grid-template-columns: minmax(0, 1fr); }
  .pw-actions {
    position: sticky; bottom: 0; z-index: 30;
    background: var(--bg-panel); border-top: 1px solid var(--line);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    margin: 0 -12px;
  }
  .pw-actions button { flex: 1; min-height: 44px; }
}

/* ---- 작업실 (WS 트랙) ---- */
.ws-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 14px; margin-bottom: 12px; flex-wrap: wrap;
}
.ws-widgets { display: flex; gap: 10px; flex-wrap: wrap; }
.ws-widget {
  display: flex; flex-direction: column; gap: 2px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-panel); padding: 8px 12px; min-width: 110px;
}
.ws-widget b { font-size: 13.5px; }
.ws-widget-link { cursor: pointer; }
.ws-widget-link:hover { border-color: var(--accent-dim); }
.ws-tabs { margin-bottom: 14px; }

@media (max-width: 600px) {
  .ws-head { flex-direction: column; align-items: stretch; }
  .ws-widget { flex: 1; min-width: 0; }
}

/* ---- 작업실 실행 탭: 모델 복수 선택 ---- */
.rt-models { display: flex; flex-direction: column; gap: 6px; }
.rt-model {
  display: flex; align-items: center; gap: 9px;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px; cursor: pointer; font-size: 13px;
}
.rt-model:hover { border-color: #3b4553; }
.rt-model.checked { border-color: var(--accent-dim); background: rgba(76,141,255,.07); }

/* ---- 작업실 드릴인 검수 ---- */
.ws-drill {
  margin-top: 16px; border: 1px solid var(--accent-dim);
  border-radius: var(--radius); background: var(--bg-panel);
}
.ws-drill-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.ws-drill > div:last-child { padding: 14px; }

/* ---- 대시보드 골든 요약 (MB-2: 좁은 화면 겹침 교정) ---- */
.golden-grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.golden-card {
  display: flex; flex-direction: column; gap: 3px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-panel-2); padding: 10px 12px;
  text-decoration: none; color: inherit; min-width: 0;
}
.golden-card:hover { border-color: var(--accent-dim); }
.golden-card .metric-label { white-space: normal; line-height: 1.35; }
.golden-card .badge { align-self: flex-start; }

/* ---- 모바일 가독성 (MB-2) ---- */
@media (max-width: 600px) {
  /* 표: 손가락과 눈이 쉴 자리 — 행 높이·줄간격을 넉넉히 */
  table.tbl td { padding: 10px 10px; line-height: 1.55; }
  table.tbl th { padding: 9px 10px; }

  /* 날짜·시각·ID 류가 여러 줄로 꺾이면 읽기 힘들다 — 한 덩어리 유지
     (표 자체가 가로 스크롤 컨테이너라 nowrap 이 넘쳐도 안전) */
  table.tbl td.tiny, table.tbl td.mono, table.tbl td .tiny.muted { white-space: nowrap; }

  /* 상태·실패 배지가 숫자 위로 겹치지 않게 간격 */
  table.tbl td .badge { margin: 2px 2px 2px 0; }

  .golden-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ---- 모델 프로필 (주장 섹션 — 실측 표와 시각 구분) ---- */
.model-profile {
  margin-top: 14px; padding: 12px;
  border: 1px dashed rgba(224,163,56,.45); border-radius: var(--radius);
  background: rgba(224,163,56,.05);
}
