/* ============================================================
   ACG Scoring Engine — Production tokens & base styles
   Claude-philosophy warm cream palette, Inter / Tiempos-alt / IBM Plex Mono.
   Light + dark via [data-theme] on <html>.
============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Inter+Tight:wght@500;600;700&family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

:root {
  /* — palette (light) — */
  --bg-primary:    #FAF9F5;
  --bg-surface:    #FFFFFF;
  --bg-muted:      #F0EEE6;
  --bg-sunken:     #E8E5DA;
  --bg-hover:      #F5F3EB;
  --bg-overlay:    rgba(31,30,29,0.48);

  --text-primary:  #1F1E1D;
  --text-secondary:#4A4744;
  --text-muted:    #6B6862;
  --text-placeholder:#A39E96;
  --text-onAccent: #FFFFFF;

  --border:        #E5E2D9;
  --border-strong: #CFCABD;
  --border-focus:  #D97757;

  --accent:        #D97757;
  --accent-hover:  #C8633F;
  --accent-soft:   #F4E2D4;
  --accent-softer: #FAEDE3;

  --success:       #3D8168;
  --success-soft:  #E4EFE8;
  --warning:       #C97518;
  --warning-soft:  #F7E7CC;
  --danger:        #B04843;
  --danger-soft:   #F2D9D6;
  --info:          #4F74A4;
  --info-soft:     #DDE6F1;

  /* mode pill hues (desaturated) */
  --rm-apt-bg:     #DEE8F2; --rm-apt-fg: #294A6E; --rm-apt-br: #A6BFD9;
  --rm-lik-bg:     #DEE9DF; --rm-lik-fg: #2B5847; --rm-lik-br: #A7C7B6;
  --rm-ips-bg:     #E7DEF0; --rm-ips-fg: #4A3574; --rm-ips-br: #B9A7D0;
  --rm-both-bg:    #F4E4C9; --rm-both-fg: #7A4A10; --rm-both-br: #D9BE8C;

  /* shadows (layered, soft) */
  --shadow-xs: 0 1px 0 rgba(31,30,29,0.04);
  --shadow-sm: 0 1px 2px rgba(31,30,29,0.06), 0 1px 3px rgba(31,30,29,0.04);
  --shadow-md: 0 4px 6px -1px rgba(31,30,29,0.08), 0 2px 4px -1px rgba(31,30,29,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(31,30,29,0.10), 0 4px 6px -2px rgba(31,30,29,0.05);
  --shadow-xl: 0 20px 25px -5px rgba(31,30,29,0.12), 0 10px 10px -5px rgba(31,30,29,0.04);
  --shadow-drawer: -8px 0 24px -8px rgba(31,30,29,0.10);

  /* radii */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-xl: 12px;
  --r-2xl: 16px;
  --r-pill: 999px;

  /* type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-display: "Inter Tight", "Inter", sans-serif;
  --font-serif: "Fraunces", "Tiempos Text", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur-med: 200ms;
}

/* dark mode token swap */
[data-theme="dark"] {
  --bg-primary:    #1B1A18;
  --bg-surface:    #232220;
  --bg-muted:      #2B2927;
  --bg-sunken:     #16

1513;
  --bg-hover:      #2F2D2A;
  --bg-overlay:    rgba(0,0,0,0.62);

  --text-primary:  #EDEBE4;
  --text-secondary:#BDB8AE;
  --text-muted:    #8A857C;
  --text-placeholder:#6E6A62;

  --border:        #383531;
  --border-strong: #524E47;
  --border-focus:  #E89376;

  --accent:        #E89376;
  --accent-hover:  #F0A388;
  --accent-soft:   #3A2A22;
  --accent-softer: #2E221C;

  --success:       #6AA88E;
  --success-soft:  #24342C;
  --warning:       #E09349;
  --warning-soft:  #3A2C18;
  --danger:        #D47770;
  --danger-soft:   #3A2423;
  --info:          #7FA0CF;
  --info-soft:     #222C3A;

  --rm-apt-bg:     #223042; --rm-apt-fg: #AFC4DC; --rm-apt-br: #3B4E68;
  --rm-lik-bg:     #1F3028; --rm-lik-fg: #A6CBB5; --rm-lik-br: #3E5A4A;
  --rm-ips-bg:     #2B2338; --rm-ips-fg: #C3B2DE; --rm-ips-br: #4B3E60;
  --rm-both-bg:    #3A2D18; --rm-both-fg: #E5C48C; --rm-both-br: #5F4823;
}

/* ============================================================
   Reset + base
============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
/* V168+: 폼 input 들의 다크모드 기본 색상. 명시적 style 의 background 가 있으면
   그게 우선되므로 안전. user-agent 기본값 (흰 배경 / 검정 텍스트) 차단. */
input, textarea, select {
  font: inherit;
  color: var(--text-primary);
  background: var(--bg-surface);
  border-color: var(--border-subtle);
}
input::placeholder, textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}
/* select dropdown option — 다크모드에서 OS native 의 어두운 배경 사용 */
select option {
  background: var(--bg-surface);
  color: var(--text-primary);
}
/* checkbox / radio 는 accent color 만 토큰 적용 (배경/테두리는 native) */
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--accent);
}
a { color: inherit; text-decoration: none; }
hr { border: none; border-top: 1px solid var(--border); margin: 0; }

/* scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid var(--bg-primary); }
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* focus */
:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; border-radius: 3px; }

/* ============================================================
   Typography helpers
============================================================ */
.t-display { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.015em; }
.t-serif { font-family: var(--font-serif); }
.t-mono { font-family: var(--font-mono); }
.t-h1 { font-family: var(--font-display); font-size: 28px; line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; }
.t-h2 { font-family: var(--font-display); font-size: 20px; line-height: 1.3; font-weight: 600; letter-spacing: -0.015em; }
.t-h3 { font-family: var(--font-sans); font-size: 15px; line-height: 1.4; font-weight: 600; letter-spacing: -0.005em; }
.t-body { font-size: 14px; line-height: 1.55; }
.t-small { font-size: 12.5px; line-height: 1.45; color: var(--text-secondary); }
.t-caption { font-size: 11.5px; line-height: 1.4; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; }
.t-muted { color: var(--text-muted); }
.t-mono-sm { font-family: var(--font-mono); font-size: 12px; }

/* ============================================================
   Layout: app shell
============================================================ */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  grid-template-rows: 48px 1fr;
  grid-template-areas: "sidebar header" "sidebar main";
  height: 100vh;
  min-height: 640px;
}
.app.sidebar-collapsed { grid-template-columns: 56px 1fr !important; }
.sidebar { transition: width var(--dur-med) var(--ease-out); }

/* collapsed sidebar styles */
.sidebar.collapsed .sidebar-brand .logo,
.sidebar.collapsed .sidebar-brand .name,
.sidebar.collapsed .nav-group-title,
.sidebar.collapsed .nav-item span:not(.count),
.sidebar.collapsed .nav-item .count { display: none; }
.sidebar.collapsed .sidebar-brand {
  padding: 12px 0;
  justify-content: center;
  gap: 0;
  flex-direction: column;
}
.sidebar.collapsed .sidebar-brand .logo { margin-bottom: 2px; }
.sidebar.collapsed .nav { padding: 10px 8px; align-items: center; }
.sidebar.collapsed .nav-group { width: 100%; margin-top: 8px; }
.sidebar.collapsed .nav-group::before {
  content: ""; display: block; height: 1px; background: var(--border); margin: 6px 4px;
}
.sidebar.collapsed .nav-group:first-child::before { display: none; }
.sidebar.collapsed .nav-item {
  width: 36px; height: 36px; padding: 0; justify-content: center;
  position: relative;
  margin: 1px auto;
}
.sidebar.collapsed .nav-item[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%; transform: translateY(-50%);
  background: var(--text-primary); color: var(--bg-surface);
  padding: 4px 9px; border-radius: var(--r-sm);
  font-size: 12px; white-space: nowrap;
  box-shadow: var(--shadow-md);
  z-index: 50;
  pointer-events: none;
}

/* sidebar toggle button — inside sidebar-brand, right edge */
.sidebar-toggle {
  margin-left: auto;
  width: 26px; height: 26px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  display: inline-flex !important; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
  flex-shrink: 0;
  padding: 0;
}
.sidebar-toggle svg { width: 14px; height: 14px; display: block; }
.sidebar-toggle:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border);
}
.sidebar.collapsed .sidebar-brand .sidebar-toggle { display: inline-flex !important; margin: 0; }

.app-header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  position: relative;
  z-index: 5;
}
.app-header .crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.app-header .crumbs .sep { color: var(--text-placeholder); }
.app-header .crumbs .cur { color: var(--text-primary); font-weight: 500; }

.sidebar {
  grid-area: sidebar;
  background: var(--bg-muted);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  height: 48px;
}
.sidebar-brand .logo {
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 12px;
  font-family: var(--font-display);
}
.sidebar-brand .name { font-weight: 600; letter-spacing: -0.01em; font-size: 13.5px; }

.nav { padding: 10px 10px; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; }
.nav-group { margin-top: 10px; }
.nav-group-title { padding: 6px 10px 4px; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1.2;
  transition: background var(--dur-fast);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--bg-surface); color: var(--text-primary); font-weight: 500; box-shadow: var(--shadow-xs); }
.nav-item svg { color: var(--text-muted); flex-shrink: 0; }
.nav-item.active svg { color: var(--accent); }
.nav-item .count { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.nav-item.active .count { color: var(--text-secondary); }

/* main */
.main {
  grid-area: main;
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 0;
}

/* ============================================================
   Buttons
============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-md);
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
  white-space: nowrap;
  line-height: 1.3;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { background: var(--bg-muted); }
.btn.primary { background: var(--text-primary); color: var(--bg-surface); border-color: var(--text-primary); }
/* light mode: hover bg → 더 어둡게 (#000), 텍스트는 base 색 (밝음) 유지 */
.btn.primary:hover { background: #000; border-color: #000; color: #fff; }
/* dark mode: base 가 (light bg, dark text) → hover 는 더 밝은 쪽으로 (#fff) 이동.
   #000 으로 가면 text 도 dark 라 가독성 깨짐 (이전 버그). */
[data-theme="dark"] .btn.primary:hover { background: #fff; border-color: #fff; color: #000; }
.btn.accent { background: var(--accent); color: var(--text-onAccent); border-color: var(--accent); }
.btn.accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn.ghost:hover { background: var(--bg-muted); color: var(--text-primary); }
.btn.danger { color: var(--danger); border-color: var(--border); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.sm { padding: 3px 9px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn.icon { padding: 5px; width: 28px; height: 28px; }
.btn .kbd { margin-left: 4px; }

/* ============================================================
   Input / search
============================================================ */
.input {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  font-size: 13px;
}
.input:focus-within { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-softer); }
.input input { flex: 1; border: none; outline: none; background: transparent; min-width: 0; }
.input input::placeholder { color: var(--text-placeholder); }
.input svg { color: var(--text-muted); flex-shrink: 0; }

/* Stand-alone input (편집 form 단일 입력 — Light + Dark 자동 정합).
 * .input wrapper 와 별도 — page-assessments/subtests/scales 의 number/text 입력. */
.input-text {
  width: 100%;
  padding: 6px 10px;
  font: inherit;
  font-size: 12.5px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.input-text::placeholder { color: var(--text-placeholder); }
.input-text:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-softer);
}
.input-text:disabled {
  background: var(--bg-muted);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.7;
}
.input-text.mono { font-family: var(--font-mono); font-size: 12px; }

/* ────────────────────────────────────────────────────────────
   Select — V215+: 모든 native <select> 에 baseline styling 적용.
   class="select" 없어도 기본 design 자동 적용. inline style 이 있어도 base
   tokens (color/border/radius) 는 일관 적용 (specific size 등은 override 가능).

   다크모드 native option list 색상도 color-scheme hint 로 OS 에 알림.
   ──────────────────────────────────────────────────────────── */
select {
  color-scheme: light;
  font: inherit;
  font-size: 12.5px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  outline: none;
  cursor: pointer;
  padding: 0 28px 0 10px;
  height: 32px;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
[data-theme="dark"] select {
  color-scheme: dark;
}
select:hover:not(:disabled) {
  border-color: var(--border-strong, var(--border-focus));
}
select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-softer);
}
select:disabled {
  background: var(--bg-muted);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.7;
}
select option {
  background: var(--bg-surface);
  color: var(--text-primary);
  padding: 4px 8px;
  font-family: inherit;
}
select option:disabled {
  color: var(--text-muted);
  font-style: italic;
}

/* .select class — backward compat (full-width) */
.select {
  width: 100%;
}
.select.mono,
select.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  font-family: var(--font-mono); font-size: 10.5px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  line-height: 1;
}

/* segmented control */
.seg {
  display: inline-flex;
  background: var(--bg-muted);
  border-radius: var(--r-md);
  padding: 2px;
  gap: 2px;
}
.seg button {
  padding: 3px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.seg button:hover { color: var(--text-primary); }
.seg button.on { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-xs); }

/* toggle */
.toggle {
  position: relative;
  width: 30px; height: 18px;
  background: var(--bg-sunken);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--dur-fast);
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: var(--bg-surface);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease-out);
}
.toggle.on { background: var(--success); }
.toggle.on::after { transform: translateX(12px); }

/* ============================================================
   Badges / pills / status
============================================================ */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  font-size: 11.5px; font-weight: 500;
  border-radius: var(--r-pill);
  background: var(--bg-muted);
  color: var(--text-secondary);
  border: 1px solid transparent;
  line-height: 1.4;
  white-space: nowrap;
}
.pill.sm { font-size: 11px; padding: 1px 7px; }

.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* response mode pills */
.rm { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--r-sm); font-size: 11px; font-weight: 500; font-family: var(--font-mono); border: 1px solid transparent; line-height: 1.4; }
.rm-APTITUDE { background: var(--rm-apt-bg); color: var(--rm-apt-fg); border-color: var(--rm-apt-br); }
.rm-LIKERT { background: var(--rm-lik-bg); color: var(--rm-lik-fg); border-color: var(--rm-lik-br); }
.rm-IPSATIVE { background: var(--rm-ips-bg); color: var(--rm-ips-fg); border-color: var(--rm-ips-br); }
.rm-BOTH { background: var(--rm-both-bg); color: var(--rm-both-fg); border-color: var(--rm-both-br); }

/* status pills */
.status { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 500; line-height: 1.4; }
.status-DRAFT      { background: var(--bg-muted); color: var(--text-muted); }
.status-PUBLISHED  { background: var(--accent-softer); color: #8A4A2A; }
[data-theme="dark"] .status-PUBLISHED { color: #E89376; }
.status-ARCHIVED   { background: var(--bg-sunken); color: var(--text-muted); text-decoration: line-through; text-decoration-thickness: 1px; }

/* ============================================================
   CodeBadge
============================================================ */
.cb {
  display: inline-flex; align-items: center; gap: 4px;
  flex-wrap: wrap;                       /* 긴 code 도 잘리지 않도록 줄바꿈 허용 */
  white-space: normal !important;        /* 부모 tree-row 의 nowrap 상속 차단 */
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  padding: 1px 6px;
  background: var(--bg-muted);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  line-height: 1.45;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
  max-width: 100%;
  overflow-wrap: anywhere;               /* dot 사이뿐 아니라 어디서든 break 허용 */
  word-break: break-all;                 /* container 자체에 명시 → 자식 모두 break */
  min-width: 0;                          /* flex item 이 content 보다 작게 shrink 가능 */
}
.cb:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.cb.copied { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.cb .ns { color: var(--text-muted); font-weight: 400; word-break: break-all; min-width: 0; }
.cb .copy {
  opacity: 0; color: var(--text-muted); transition: opacity var(--dur-fast);
  display: inline-flex; align-items: center; flex-shrink: 0;
}
.cb:hover .copy { opacity: 1; }
.cb .leaf { word-break: break-all; min-width: 0; }

/* ============================================================
   DriftIndicator
============================================================ */
.di {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  padding: 1px 7px 1px 5px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  line-height: 1.4;
  white-space: nowrap;
}
.di-ok    { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.di-warn  { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.di-drift { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.di svg { width: 10px; height: 10px; }

/* ============================================================
   TopologyTree
============================================================ */
.tree { font-size: 13.5px; }
.tree-row {
  display: grid;
  grid-template-columns: 14px 14px 24px 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 5px 8px;
  border-radius: var(--r-md);
  cursor: pointer;
  position: relative;
  transition: background var(--dur-fast);
  line-height: 1.3;
}
.tree-row:hover { background: var(--bg-hover); }
.tree-row.selected { background: var(--accent-softer); }
.tree-row.selected::before {
  content: ""; position: absolute; left: -1px; top: 4px; bottom: 4px; width: 2px;
  background: var(--accent); border-radius: 2px;
}
.tree-row .drag { color: var(--text-placeholder); cursor: grab; opacity: 0; display: flex; }
.tree-row:hover .drag { opacity: 1; }
.tree-row .caret { color: var(--text-muted); display: inline-flex; width: 14px; }
.tree-row .caret button { width: 14px; height: 14px; display: inline-flex; align-items: center; justify-content: center; border-radius: 3px; }
.tree-row .caret button:hover { background: var(--bg-sunken); }
.tree-row .icon {
  width: 24px; height: 24px;
  border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.tree-row .icon.asm { background: var(--accent-softer); border-color: var(--accent-soft); color: #8A4A2A; }
.tree-row .icon.sub { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 20%, transparent); color: var(--info); }
.tree-row .label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tree-row .name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-row .badges { display: flex; gap: 4px; align-items: center; flex-wrap: nowrap; }
.tree-row .actions { display: flex; gap: 2px; opacity: 0; transition: opacity var(--dur-fast); }
.tree-row:hover .actions, .tree-row.selected .actions { opacity: 1; }
.tree-children { margin-left: 14px; padding-left: 18px; border-left: 1px dashed var(--border); position: relative; }

.tree-add {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px 5px 34px;
  font-size: 12.5px;
  color: var(--text-muted);
  border-radius: var(--r-md);
  cursor: pointer;
  margin-top: 2px;
}
.tree-add:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ============================================================
   Set list (left column)
============================================================ */
.list-pane {
  border-right: 1px solid var(--border);
  background: var(--bg-primary);
  display: flex; flex-direction: column;
  min-height: 0;
}
.list-head {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
}
.list-head-title { display: flex; align-items: center; gap: 8px; }
.list-filters { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  padding: 3px 9px;
  font-size: 11.5px; font-weight: 500;
  border-radius: var(--r-pill);
  background: var(--bg-muted);
  color: var(--text-secondary);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--dur-fast), color var(--dur-fast);
  line-height: 1.3;
  white-space: nowrap;
}
.chip:hover { background: var(--bg-sunken); color: var(--text-primary); }
.chip.on { background: var(--text-primary); color: var(--bg-surface); }
.chip .count { opacity: 0.7; margin-left: 4px; font-family: var(--font-mono); font-size: 10.5px; }

.list-scroll { flex: 1; overflow-y: auto; padding: 6px 6px 12px; }
.list-group { margin-top: 8px; }
.list-group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 3px;
  font-size: 11.5px; font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}
.list-group-head .count { font-family: var(--font-mono); font-weight: 500; letter-spacing: 0; font-size: 11px; text-transform: none; }

.set-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--r-md);
  cursor: pointer;
  margin: 1px 0;
  transition: background var(--dur-fast);
  position: relative;
}
.set-row:hover { background: var(--bg-hover); }
.set-row.selected { background: var(--accent-softer); }
.set-row.selected::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 2px;
  background: var(--accent); border-radius: 2px;
}
.set-avatar {
  width: 28px; height: 28px;
  border-radius: var(--r-md);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 11px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.set-avatar.sk { background: #EFE4D9; color: #7A4A2A; }
.set-avatar.lg { background: #F4D9D5; color: #7A2A28; }
.set-avatar.acg { background: #DEE9DF; color: #2B5847; }
.set-avatar.cj { background: #E7DEF0; color: #4A3574; }
.set-row .meta { min-width: 0; }
.set-row .title { font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-row .sub { font-size: 11.5px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; margin-top: 1px; }
.set-row .sub .dot { color: var(--text-placeholder); }
.set-row .right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }

/* ============================================================
   Detail pane
============================================================ */
.detail-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-primary); }
.detail-head {
  padding: 14px 24px 0;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}
.detail-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* unsaved-changes dot on save button */
.dirty-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
  animation: dirtyPulse 1.6s ease-in-out infinite;
  margin-right: 2px;
}
@keyframes dirtyPulse {
  0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
  50%      { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 12%, transparent); }
}

/* ============================================================
   Loading skeleton (P2-1)
   - opacity-pulse only (no gradient sweep) to keep light-mode soft
   - will-change to hint compositor; respects prefers-reduced-motion
============================================================ */
.skeleton {
  background: var(--bg-muted);
  border-radius: var(--r-sm);
  display: block;
  will-change: opacity;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 0.85; }
}
.skeleton-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
}
.skeleton-row .skeleton-avatar {
  width: 28px; height: 28px; border-radius: var(--r-md);
  flex-shrink: 0;
}
.skeleton-row .skeleton-text { flex: 1; display: flex; flex-direction: column; gap: 6px; }

/* ============================================================
   Progress bar (P2-2)
============================================================ */
.progress-bar {
  position: relative;
  width: 100%;
  height: 8px;
  background: var(--bg-muted);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progress-bar .progress-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--accent);
  border-radius: var(--r-pill);
  transition: width 240ms var(--ease-out);
}
.progress-bar.indeterminate .progress-fill {
  width: 30% !important;
  animation: progress-indet 1.4s ease-in-out infinite;
}
@keyframes progress-indet {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(360%); }
}
.progress-meta {
  display: flex; align-items: center; gap: 8px;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ============================================================
   Empty state (P2-3)
============================================================ */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px 24px;
  gap: 10px;
  color: var(--text-secondary);
  text-align: center;
}
.empty-state .empty-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.empty-state .empty-title { font-weight: 600; font-size: 15px; color: var(--text-primary); }
.empty-state .empty-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 340px;
  line-height: 1.55;
}
.empty-state .empty-actions { margin-top: 8px; display: flex; gap: 8px; }

/* modal open body lock prevents jump */
body.modal-open { overflow: hidden; }

/* modal danger/warn solid buttons */
.btn.danger-solid {
  background: var(--danger); color: #fff; border-color: var(--danger);
}
.btn.danger-solid:hover { background: #9A3C37; border-color: #9A3C37; }
.btn.warn-solid {
  background: var(--warning); color: #fff; border-color: var(--warning);
}
.btn.warn-solid:hover { background: #A85E0F; border-color: #A85E0F; }
.detail-meta-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-muted); }
.detail-meta-row .dot { color: var(--text-placeholder); }

.tabs {
  display: flex;
  gap: 2px;
  margin-top: 14px;
  margin-bottom: -1px;
}
.tab {
  padding: 9px 14px;
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--dur-fast), border-color var(--dur-fast);
  display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--text-primary); border-color: var(--accent); }
.tab .num {
  font-family: var(--font-mono); font-size: 10.5px;
  padding: 0 5px; border-radius: 3px;
  background: var(--bg-muted); color: var(--text-muted);
  font-weight: 500;
}
.tab.active .num { background: var(--accent-softer); color: var(--accent); }

.detail-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: 1fr 380px;
}
.detail-body.no-drawer { grid-template-columns: 1fr; }
.detail-main { padding: 20px 24px 40px; min-width: 0; }
.detail-drawer {
  border-left: 1px solid var(--border);
  background: var(--bg-surface);
  padding: 20px 22px;
  box-shadow: var(--shadow-drawer);
  overflow-y: auto;
  position: sticky; top: 0;
  max-height: 100%;
}

/* ============================================================
   Cards / stat / callouts
============================================================ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 13.5px;
}
.card-head .count { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); font-weight: 500; margin-left: 4px; }

.stat {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px 14px;
}
.stat .label { font-size: 11.5px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
.stat .value { font-family: var(--font-display); font-weight: 600; font-size: 22px; letter-spacing: -0.02em; margin-top: 2px; }
.stat .value.mono { font-family: var(--font-mono); font-weight: 500; font-size: 18px; letter-spacing: 0; }
.stat .sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.callout {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: 12.5px;
  line-height: 1.5;
}
.callout-warn { background: var(--warning-soft); color: #7A4A10; border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent); }
[data-theme="dark"] .callout-warn { color: #E0B77C; }
.callout-info { background: var(--info-soft); color: #2C4467; border: 1px solid color-mix(in srgb, var(--info) 25%, transparent); }
[data-theme="dark"] .callout-info { color: #A8BFDC; }
.callout-success { background: var(--success-soft); color: #2B5847; border: 1px solid color-mix(in srgb, var(--success) 25%, transparent); }
[data-theme="dark"] .callout-success { color: #97BBA5; }
.callout svg { flex-shrink: 0; margin-top: 1px; }

/* ============================================================
   Table
============================================================ */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th {
  font-size: 11.5px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-primary);
  position: sticky; top: 0;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--bg-hover); }
.tbl td.mono { font-family: var(--font-mono); font-size: 12px; }

/* ============================================================
   Pipeline step
============================================================ */
.pstep {
  display: grid;
  grid-template-columns: 20px 28px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 6px;
  transition: box-shadow var(--dur-fast), border-color var(--dur-fast);
}
.pstep:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.pstep .grip { color: var(--text-placeholder); cursor: grab; display: flex; }
.pstep .n {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  width: 24px; height: 24px;
  background: var(--bg-muted); border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
}
.pstep.disabled { opacity: 0.55; }
.pstep .body { min-width: 0; }
.pstep .type { font-family: var(--font-mono); font-size: 13px; font-weight: 500; }
.pstep .cfg { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pstep .right { display: flex; align-items: center; gap: 6px; }

/* ============================================================
   Drawer detail (topology subtest)
============================================================ */
.drawer-eyebrow {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
}
.drawer-title { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -0.015em; margin-top: 4px; }
.drawer-section { margin-top: 16px; }
.drawer-section + .drawer-section { border-top: 1px solid var(--border); padding-top: 14px; }
.drawer-label { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 6px; }
.drawer-value { font-family: var(--font-mono); font-size: 12.5px; }

/* chart axes */
.axis text { font-family: var(--font-mono); font-size: 10px; fill: var(--text-muted); }
.axis line, .axis path { stroke: var(--border); }

/* diff hunk */
.diff-hunk {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--bg-sunken); border-radius: var(--r-sm);
  padding: 8px 10px;
  white-space: pre-wrap;
  line-height: 1.5;
}
.diff-hunk .rem { color: var(--danger); background: var(--danger-soft); padding: 0 2px; border-radius: 2px; }
.diff-hunk .add { color: var(--success); background: var(--success-soft); padding: 0 2px; border-radius: 2px; }

/* utility */
.row { display: flex; align-items: center; gap: 8px; }
.spread { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.hide { display: none !important; }

/* menu popover */
.menu {
  position: absolute;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  min-width: 180px;
  z-index: 40;
}
.menu button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 10px; border-radius: var(--r-sm);
  font-size: 13px; color: var(--text-primary);
  text-align: left;
}
.menu button:hover { background: var(--bg-hover); }
.menu button.danger { color: var(--danger); }
.menu hr { margin: 4px -4px; }

/* ============================================================
   Accessibility — focus visibility (WCAG 2.1 AA)
============================================================ */
*:focus { outline: none; }
*:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: 3px;
}
button:focus-visible,
[role="button"]:focus-visible,
a:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 0;
}
.set-row:focus-visible,
.nav-item:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: -2px;
}
/* skip-to-content link — shows on keyboard focus only */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 200;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
}
.skip-link:focus,
.skip-link:focus-visible {
  left: 8px;
}
/* reduced motion — honor user preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
/* screenreader-only helper */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ============================================================
   Responsive — 1280+ full edit, 1024–1279 tablet read-only
   (prompt §7: "1024 tablet 열람 전용, 1280+ desktop 기본")
============================================================ */
/* Below 1024 — not supported, show banner via JS */
@media (max-width: 1023px) {
  body::before {
    content: "⚠ 최소 1024px 이상에서 사용하세요. 현재는 표시가 제한됩니다.";
    display: block;
    position: fixed; top: 0; left: 0; right: 0;
    background: var(--danger); color: #fff;
    padding: 10px 16px; font-size: 12.5px;
    text-align: center; z-index: 500;
    font-family: var(--font-sans);
  }
  .app { padding-top: 40px; }
}
/* 1024–1279 tablet — read-only mode */
@media (min-width: 1024px) and (max-width: 1279px) {
  html { --readonly-visible: 1; }
  body[data-readonly="1"]::before {
    content: "🔒 열람 전용 모드 · 1280px 이상에서 편집 가능";
    display: block;
    position: fixed; top: 0; left: 0; right: 0;
    background: var(--warning); color: #fff;
    padding: 6px 16px; font-size: 12px;
    text-align: center; z-index: 500;
    font-weight: 500;
    font-family: var(--font-sans);
  }
  body[data-readonly="1"] .app { padding-top: 28px; }
  /* disable edit affordances */
  body[data-readonly="1"] .btn.primary,
  body[data-readonly="1"] .btn.danger-solid,
  body[data-readonly="1"] .btn.warn-solid,
  body[data-readonly="1"] button[data-edit="1"],
  body[data-readonly="1"] .dragdot,
  body[data-readonly="1"] [draggable="true"] {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed !important;
  }
  body[data-readonly="1"] input:not([type="search"]),
  body[data-readonly="1"] textarea,
  body[data-readonly="1"] select {
    pointer-events: none;
    background: var(--bg-muted);
  }
  /* collapse sidebar defaults on tablet */
  .list-pane { min-width: 280px; }
}
/* high contrast fallback for drift-state colors */
@media (prefers-contrast: more) {
  :root {
    --border: #8A857C;
    --border-strong: #4A4744;
    --text-muted: #4A4744;
  }
}
