/* ============================================================
   GCLEF Studio — 부분 텍스처 교체 목업
   디자인 토큰은 Genver Docs 디자인 시스템을 따른다.
   ============================================================ */

:root {
  /* Surfaces */
  --bg-app: #fbfbfc;
  --bg-panel: #ffffff;
  --bg-sidebar: #f8f8fa;
  --bg-subtle: #f3f3f6;
  --bg-hover: #eeeef2;
  --bg-active: #e7e7ed;
  --bg-sunken: #eaeaec;

  /* Text */
  --text-1: #18181b;
  --text-2: #5b5b66;
  --text-3: #8a8a95;
  --text-inv: #ffffff;

  /* Borders */
  --border-1: #ededf1;
  --border-2: #e0e0e6;
  --border-3: #c9c9d2;

  /* Accent */
  --accent: #5b5bd6;
  --accent-hover: #4e4ec4;
  --accent-press: #4444b0;
  --accent-subtle: #f1f1fe;
  --accent-border: #d7d7f8;
  --accent-text: #4a4ab5;

  /* Semantic */
  --success: #167c3c;
  --success-subtle: #e9f6ed;
  --warning: #9a5700;
  --warning-subtle: #fdf2e4;
  --danger: #c22b2b;
  --danger-subtle: #fdecec;
  --danger-border: #f5c9c9;

  /* Type scale */
  --fs-11: 11px;
  --fs-12: 12px;
  --fs-13: 13px;
  --fs-14: 14px;
  --fs-15: 15px;
  --fs-17: 17px;

  /* Radius */
  --r-4: 4px;
  --r-6: 6px;
  --r-8: 8px;
  --r-10: 10px;
  --r-14: 14px;

  /* Elevation */
  --sh-1: 0 1px 2px rgba(20, 20, 35, 0.05);
  --sh-2: 0 4px 12px rgba(20, 20, 35, 0.07), 0 0 0 1px rgba(20, 20, 35, 0.04);
  --sh-3: 0 16px 48px rgba(20, 20, 35, 0.16), 0 0 0 1px rgba(20, 20, 35, 0.06);
  --sh-paper: 0 1px 2px rgba(20, 20, 35, 0.06), 0 10px 30px rgba(20, 20, 35, 0.07);

  --ring: 0 0 0 3px rgba(91, 91, 214, 0.16);

  /* Layout */
  --menu-w: 216px;
  --steps-w: 248px;
  --insp-w: 340px;
  --split-w: 1px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: "Pretendard Variable", Pretendard, "IBM Plex Sans KR", -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: var(--fs-13);
  line-height: 1.5;
  color: var(--text-1);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: rgba(91, 91, 214, 0.18); }

* { scrollbar-width: thin; scrollbar-color: var(--border-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: transparent;
  border: 3px solid transparent;
  border-radius: 8px;
  background-clip: padding-box;
}
*:hover::-webkit-scrollbar-thumb { background: var(--border-3); background-clip: padding-box; }

/* ============================================================
   Shell
   ============================================================ */

.app {
  display: grid;
  grid-template-columns:
    var(--menu-w) var(--split-w)
    var(--steps-w) var(--split-w)
    minmax(360px, 1fr) var(--split-w)
    var(--insp-w);
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.rule { width: var(--split-w); background: var(--border-1); }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-6);
  background: var(--bg-panel);
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-12);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn:hover { background: var(--bg-subtle); border-color: var(--border-3); }
.btn:active { background: var(--bg-active); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { cursor: not-allowed; color: var(--text-3); }
.btn:disabled:hover { background: var(--bg-panel); border-color: var(--border-2); }

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--text-inv);
  box-shadow: var(--sh-1);
}
.btn.primary:hover { background: var(--accent-hover); color: var(--text-inv); }
.btn.primary:active { background: var(--accent-press); }
.btn.primary:disabled,
.btn.primary:disabled:hover {
  background: var(--bg-subtle);
  border-color: var(--border-2);
  color: var(--text-3);
  box-shadow: none;
}

.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text-1); }

.btn.icon { width: 28px; padding: 0; }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn.sm { height: 24px; padding: 0 8px; font-size: var(--fs-11); }
.btn.block { width: 100%; }

/* ============================================================
   Menu (left rail)
   ============================================================ */

.menu {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 10px;
  background: var(--bg-sidebar);
  overflow: auto;
}

.brand { display: flex; align-items: center; gap: 9px; padding: 4px 6px 14px; }
.brand .logo {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 7px;
  background: linear-gradient(150deg, var(--accent), #7b6cf0);
  color: #fff;
  font-size: var(--fs-13);
  font-weight: 700;
  letter-spacing: -0.02em;
  box-shadow: var(--sh-1);
}
.brand .txt { min-width: 0; display: flex; flex-direction: column; }
.brand .mark {
  font-size: var(--fs-13);
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.brand .sub { font-size: var(--fs-11); color: var(--text-3); line-height: 1.3; }

.nav-label {
  padding: 12px 8px 4px;
  font-size: var(--fs-11);
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-6);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-13);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-1); }
.nav-item.active { background: var(--accent-subtle); color: var(--accent-text); font-weight: 600; }
.nav-item:focus-visible { outline: none; box-shadow: var(--ring); }
.nav-item .ico { display: grid; place-items: center; width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.nav-item .ico svg { width: 16px; height: 16px; }
.nav-item .tail { margin-left: auto; font-size: var(--fs-11); color: var(--text-3); font-weight: 500; }

.menu-foot { margin-top: auto; padding: 10px 8px 2px; border-top: 1px solid var(--border-1); }
.model-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 7px 8px;
  border-radius: var(--r-6);
  background: var(--bg-panel);
  border: 1px solid var(--border-1);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.model-chip:hover { border-color: var(--border-2); background: var(--bg-subtle); }
.model-chip .dot {
  width: 6px; height: 6px; flex-shrink: 0; border-radius: 50%;
  background: var(--text-3); box-shadow: 0 0 0 3px var(--bg-subtle);
}
.model-chip strong {
  min-width: 0; font-size: var(--fs-11); font-weight: 600; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.model-chip[data-state="on"] .dot { background: var(--success); box-shadow: 0 0 0 3px var(--success-subtle); }
.model-chip[data-state="on"] strong { color: var(--text-1); }
.model-chip[data-state="off"] .dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-subtle); }
.model-chip[data-state="local"] .dot { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-subtle); }

/* ============================================================
   Panel primitives
   ============================================================ */

.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-panel); }
.pane.sunken { background: var(--bg-app); }

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  height: 44px;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--border-1);
}
.pane-head h2 { font-size: var(--fs-12); font-weight: 600; color: var(--text-2); letter-spacing: 0.01em; }
.pane-body { flex: 1; min-height: 0; overflow: auto; }

.badge {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-2);
  font-size: var(--fs-11);
  font-weight: 600;
  white-space: nowrap;
}
.badge.ok { background: var(--success-subtle); color: var(--success); }
.badge.warn { background: var(--warning-subtle); color: var(--warning); }
.badge.bad { background: var(--danger-subtle); color: var(--danger); }
.badge.accent { background: var(--accent-subtle); color: var(--accent-text); }

.dim { font-size: var(--fs-11); color: var(--text-3); }

/* ============================================================
   Steps rail
   ============================================================ */

.steps { padding: 8px 8px 16px; }

.step {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 9px;
  width: 100%;
  padding: 8px 8px 9px;
  border: 0;
  border-radius: var(--r-8);
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}
.step:hover { background: var(--bg-hover); }
.step:focus-visible { outline: none; box-shadow: var(--ring); }
.step.active { background: var(--accent-subtle); }

.step .num {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: var(--r-6);
  background: var(--bg-subtle);
  border: 1px solid var(--border-2);
  color: var(--text-3);
  font-size: var(--fs-11);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.step .num svg { width: 12px; height: 12px; }
.step.active .num { background: var(--accent); border-color: transparent; color: #fff; }
.step.done .num { background: var(--success-subtle); border-color: transparent; color: var(--success); }

.step .name { font-size: var(--fs-13); font-weight: 500; color: var(--text-2); line-height: 1.35; }
.step.active .name { color: var(--accent-text); font-weight: 650; }
.step.done .name { color: var(--text-1); }
.step .stage { display: block; margin-top: 1px; font-size: var(--fs-11); color: var(--text-3); line-height: 1.35; }

.steps-foot {
  padding: 12px 14px 14px;
  margin: 4px 8px 0;
  border-top: 1px solid var(--border-1);
}
.steps-foot .t { font-size: var(--fs-11); font-weight: 600; color: var(--text-3); letter-spacing: 0.03em; }
.steps-foot p { margin-top: 6px; font-size: var(--fs-11); color: var(--text-3); line-height: 1.5; }

/* ============================================================
   Stage
   ============================================================ */

.stage-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border-1);
  background: var(--bg-panel);
}
.stage-head .title { font-size: var(--fs-13); font-weight: 650; letter-spacing: -0.01em; }
.stage-head .sub { font-size: var(--fs-11); color: var(--text-3); }
.stage-head .sp { flex: 1; }

.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--r-8); background: var(--bg-subtle); }
.seg button {
  height: 24px;
  padding: 0 9px;
  border: 0;
  border-radius: var(--r-6);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-11);
  font-weight: 550;
  cursor: pointer;
}
.seg button:hover { color: var(--text-1); }
.seg button.active { background: var(--bg-panel); color: var(--text-1); box-shadow: var(--sh-1); }

.stage-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 24px;
  background: var(--bg-app);
}

.stage-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  height: 34px;
  padding: 0 14px;
  border-top: 1px solid var(--border-1);
  background: var(--bg-sidebar);
  font-size: var(--fs-11);
  color: var(--text-3);
}
.stage-foot .k { color: var(--text-2); font-weight: 600; }
.stage-foot .sp { flex: 1; }

/* Canvas surface */
.canvas {
  position: relative;
  display: block;
  margin: 0 auto;
  max-width: 100%;
  border-radius: var(--r-10);
  background: var(--bg-panel);
  box-shadow: var(--sh-paper);
  overflow: hidden;
}
.canvas img { display: block; width: 100%; height: auto; }
.canvas.tall { max-width: 560px; }

.canvas-cap {
  margin: 12px auto 0;
  max-width: 620px;
  text-align: center;
  font-size: var(--fs-11);
  color: var(--text-3);
  line-height: 1.6;
}

/* Mask + grid overlays */
.ov { position: absolute; inset: 0; pointer-events: none; }
.ov.mask svg { width: 100%; height: 100%; display: block; }
.ov.mask .fillpath { fill: rgba(194, 43, 43, 0.14); stroke: #c22b2b; stroke-width: 0.5; stroke-dasharray: 2 1.4; }
.ov.mask.soft .fillpath { fill: rgba(91, 91, 214, 0.16); stroke: var(--accent); }

.ov.grid {
  background-image:
    linear-gradient(to right, rgba(91, 91, 214, 0.28) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(91, 91, 214, 0.28) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
}
.ov.grid::after {
  content: attr(data-label);
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 3px 7px;
  border-radius: var(--r-4);
  background: rgba(24, 24, 27, 0.78);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Compare slider */
.compare { position: relative; }
.compare .after { position: absolute; inset: 0; overflow: hidden; width: var(--pos, 50%); }
.compare .after img { position: absolute; top: 0; left: 0; height: 100%; width: auto; max-width: none; }
.compare .after { border-right: 2px solid var(--accent); }
.compare .handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos, 50%);
  width: 26px;
  transform: translateX(-13px);
  cursor: col-resize;
}
.compare .handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 26px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: var(--sh-2);
}
.compare .tag {
  position: absolute;
  top: 10px;
  padding: 3px 8px;
  border-radius: var(--r-4);
  background: rgba(24, 24, 27, 0.72);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
}
.compare .tag.l { left: 10px; }
.compare .tag.r { right: 10px; }

/* Upload dropzone */
.drop {
  display: grid;
  place-items: center;
  gap: 10px;
  max-width: 520px;
  margin: 40px auto;
  padding: 44px 28px;
  border: 1.5px dashed var(--border-3);
  border-radius: var(--r-14);
  background: var(--bg-panel);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-subtle); }
.drop .ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-10); background: var(--bg-subtle); color: var(--text-3); }
.drop .ic svg { width: 20px; height: 20px; }
.drop h3 { font-size: var(--fs-14); font-weight: 650; }
.drop p { font-size: var(--fs-12); color: var(--text-3); line-height: 1.6; }

/* Element grid */
.el-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  max-width: 900px;
  margin: 0 auto;
}
.el-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 1px solid var(--border-2);
  border-radius: var(--r-10);
  background: var(--bg-panel);
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.el-card:hover { border-color: var(--border-3); box-shadow: var(--sh-2); }
.el-card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.el-card .thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 168px;
  height: 168px;
  min-height: 0;
  overflow: hidden;
  padding: 12px;
  background: var(--bg-subtle);
  background-image:
    linear-gradient(45deg, rgba(0,0,0,.028) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.028) 75%),
    linear-gradient(45deg, rgba(0,0,0,.028) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.028) 75%);
  background-size: 14px 14px;
  background-position: 0 0, 7px 7px;
}
.el-card .thumb img { max-width: 100%; max-height: 144px; width: auto; object-fit: contain; }
.el-card .meta { flex: 1 1 auto; padding: 9px 11px 11px; border-top: 1px solid var(--border-1); background: var(--bg-panel); }
.el-card .meta b { display: block; font-size: var(--fs-12); font-weight: 600; }
.el-card .meta span { display: block; margin-top: 2px; font-size: var(--fs-11); color: var(--text-3); }
.el-card .pick {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-panel);
  border: 1px solid var(--border-2);
  color: transparent;
}
.el-card .pick svg { width: 12px; height: 12px; }
.el-card.sel .pick { background: var(--accent); border-color: transparent; color: #fff; }

/* Colorway grid */
.cw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  max-width: 940px;
  margin: 0 auto;
}
.cw {
  border: 1px solid var(--border-2);
  border-radius: var(--r-10);
  background: var(--bg-panel);
  overflow: hidden;
}
.cw img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.cw .meta { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-top: 1px solid var(--border-1); }
.cw .meta b { font-size: var(--fs-12); font-weight: 600; }
.cw .meta .dim { margin-left: auto; }

/* Busy state */
.busy-wrap { max-width: 520px; margin: 60px auto; text-align: center; }
.busy-wrap h3 { font-size: var(--fs-14); font-weight: 650; }
.busy-wrap p { margin-top: 6px; font-size: var(--fs-12); color: var(--text-3); }
.bar { height: 4px; margin-top: 18px; border-radius: 999px; background: var(--bg-sunken); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width 0.3s ease; }
.busy-log { margin-top: 16px; text-align: left; font-size: var(--fs-11); color: var(--text-3); line-height: 1.9; }
.busy-log li { list-style: none; display: flex; gap: 8px; }
.busy-log li b { color: var(--text-2); font-weight: 600; }
.busy-log li.done b { color: var(--success); }

/* ============================================================
   Inspector
   ============================================================ */

.insp { background: var(--bg-sidebar); border-left: 0; }
.insp .pane-body { padding: 0 0 24px; }

.sec { padding: 14px 14px 16px; border-bottom: 1px solid var(--border-1); }
.sec > .t {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: var(--fs-11);
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-3);
}
.sec > .t .badge { margin-left: auto; }
.sec p.note { font-size: var(--fs-11); color: var(--text-3); line-height: 1.6; }

.field { margin-bottom: 10px; }
.field:last-child { margin-bottom: 0; }
.field > label { display: block; margin-bottom: 5px; font-size: var(--fs-12); font-weight: 550; color: var(--text-2); }
.field .hint { margin-top: 5px; font-size: var(--fs-11); color: var(--text-3); line-height: 1.55; }

.input, .select, textarea.input {
  width: 100%;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-6);
  background: var(--bg-panel);
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-12);
}
textarea.input { height: auto; padding: 7px 9px; resize: vertical; line-height: 1.55; }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input::placeholder { color: var(--text-3); }
.input:disabled, .select:disabled { background: var(--bg-subtle); color: var(--text-3); cursor: not-allowed; }

.range { display: flex; align-items: center; gap: 10px; }
.range input[type="range"] {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 999px;
  background: var(--bg-sunken);
  cursor: pointer;
}
.range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: var(--sh-1);
}
.range input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
}
.range input[type="range"]:disabled { cursor: not-allowed; opacity: 0.5; }
.range .val {
  min-width: 68px;
  text-align: right;
  font-size: var(--fs-12);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
}

.switch { display: flex; align-items: center; gap: 9px; padding: 6px 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  position: relative;
  width: 30px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--bg-sunken);
  transition: background 0.14s ease;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--sh-1);
  transition: transform 0.14s ease;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(12px); }
.switch .lbl { font-size: var(--fs-12); font-weight: 500; color: var(--text-2); }
.switch .lbl small { display: block; font-size: var(--fs-11); font-weight: 400; color: var(--text-3); }

/* Key-value readout */
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; }
.kv dt { font-size: var(--fs-11); color: var(--text-3); }
.kv dd { font-size: var(--fs-11); font-weight: 600; color: var(--text-1); font-variant-numeric: tabular-nums; text-align: right; }
.kv dd.ok { color: var(--success); }
.kv dd.warn { color: var(--warning); }
.kv dd.bad { color: var(--danger); }

/* Source-of-truth callout for calibration */
.src {
  display: flex;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--r-8);
  background: var(--bg-panel);
  border: 1px solid var(--border-1);
}
.src .ic { flex-shrink: 0; width: 14px; height: 14px; margin-top: 2px; color: var(--accent); }
.src .ic svg { width: 14px; height: 14px; }
.src b { display: block; font-size: var(--fs-12); font-weight: 600; }
.src span { display: block; margin-top: 2px; font-size: var(--fs-11); color: var(--text-3); line-height: 1.5; }

.callout {
  display: flex;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--r-8);
  background: var(--warning-subtle);
  color: #7a4600;
  font-size: var(--fs-11);
  line-height: 1.6;
}
.callout.info { background: var(--accent-subtle); color: var(--accent-text); }
.callout b { font-weight: 650; }

.insp-foot { padding: 14px; }

/* ============================================================
   Modal
   ============================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(24, 24, 32, 0.34);
}
.modal-backdrop.open { display: flex; }

.modal {
  display: flex;
  flex-direction: column;
  width: min(680px, 100%);
  max-height: min(88vh, 860px);
  overflow: hidden;
  border-radius: var(--r-14);
  background: var(--bg-panel);
  box-shadow: var(--sh-3);
  animation: pop 0.16s cubic-bezier(0.2, 0, 0.2, 1);
}
@keyframes pop {
  from { opacity: 0; transform: translateY(6px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-1);
}
.modal-head h3 { font-size: var(--fs-14); font-weight: 650; letter-spacing: -0.01em; }
.modal-head .sub { display: block; margin-top: 2px; font-size: var(--fs-11); font-weight: 400; color: var(--text-3); }

.modal-body { flex: 1; min-height: 0; padding: 4px 18px 18px; overflow: auto; }

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  padding: 12px 18px;
  border-top: 1px solid var(--border-1);
  background: var(--bg-sidebar);
}
.modal-foot .btn { height: 30px; padding: 0 14px; }
.modal-foot .sp { flex: 1; }

/* Settings groups */
.set-group { padding: 16px 0; border-bottom: 1px solid var(--border-1); }
.set-group:last-child { border-bottom: 0; }
.set-group > .gt { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.set-group > .gt h4 { font-size: var(--fs-13); font-weight: 650; }
.set-group > .gd { margin-bottom: 12px; font-size: var(--fs-11); color: var(--text-3); line-height: 1.6; }

.key-row { display: flex; gap: 6px; align-items: center; }
.key-row .input { flex: 1; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: var(--fs-12); letter-spacing: 0.02em; }
.key-row .btn { flex-shrink: 0; height: 30px; }

.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.stat-line { display: flex; align-items: center; gap: 7px; margin-top: 8px; font-size: var(--fs-11); color: var(--text-3); }
.stat-line .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.stat-line[data-state="ok"] .dot { background: var(--success); }
.stat-line[data-state="ok"] { color: var(--success); }
.stat-line[data-state="bad"] .dot { background: var(--danger); }
.stat-line[data-state="bad"] { color: var(--danger); }
.stat-line[data-state="busy"] .dot { background: var(--warning); }

/* ============================================================
   Toast
   ============================================================ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 90;
  transform: translate(-50%, 12px);
  padding: 9px 14px;
  border-radius: var(--r-8);
  background: #22222a;
  color: #fff;
  font-size: var(--fs-12);
  font-weight: 500;
  box-shadow: var(--sh-3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================
   Responsive fallback
   ============================================================ */

@media (max-width: 1180px) {
  .app { grid-template-columns: var(--menu-w) var(--split-w) var(--steps-w) var(--split-w) minmax(320px, 1fr); }
  .app > .rule.r3, .app > .insp { display: none; }
}
