/* ============================================================
   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=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-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:     #161513;
  --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-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-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;
  /* 🔴 접힘 상태에서는 클리핑을 푼다 — `overflow-y:auto` 는 overflow-x 도 auto 로 계산돼
     56px 사이드바 **밖**에 그리는 툴팁(::after)이 잘린다. opacity 는 1인데 화면엔 안 보여
     "툴팁이 안 뜬다"로 보였다(실측: navOverflowX=auto, navW=55).
     접힘 항목 높이 합은 443px 로 스크롤이 필요 없다(app min-height 640px) — 안전하다.
     ⚠️ nav 항목이 크게 늘면 이 전제가 깨진다. 그때는 툴팁을 body 로 포탈해야 한다. */
  overflow: visible;
}
.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;
}
/* 접힌 사이드바의 아이콘 툴팁 — 페이지 이름(+건수).
   native title 은 쓰지 않는다(겹침·지연). 화살표까지 CSS 로 그려 붙인다. */
.sidebar.collapsed .nav-item[data-tooltip]::after,
.sidebar.collapsed .nav-item[data-tooltip]::before {
  opacity: 0; pointer-events: none;
  transition: opacity 90ms var(--ease-out, ease-out);
}
.sidebar.collapsed .nav-item[data-tooltip]:hover::after,
.sidebar.collapsed .nav-item[data-tooltip]:focus-visible::after,
.sidebar.collapsed .nav-item[data-tooltip]:hover::before,
.sidebar.collapsed .nav-item[data-tooltip]:focus-visible::before { opacity: 1; }

.sidebar.collapsed .nav-item[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%; transform: translateY(-50%);
  /* 반전 배색(--text-primary 배경)은 이 웜 팔레트에서 검은 딱지처럼 튄다.
     surface + border 로 앱의 다른 떠 있는 요소(모달·드롭다운)와 같은 결을 쓴다.
     라이트/다크 모두 토큰이 알아서 뒤집히므로 테마별 분기가 필요 없다. */
  background: var(--bg-surface); color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 5px 10px; border-radius: var(--r-md);
  font-size: 12px; font-weight: 500; letter-spacing: -0.01em;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  z-index: 50;
}
/* 화살표 — 테두리가 있으므로 두 겹(바깥=border색, 안쪽=surface)으로 그린다 */
.sidebar.collapsed .nav-item[data-tooltip]::before {
  content: "";
  position: absolute;
  left: calc(100% + 5px);
  top: 50%; transform: translateY(-50%);
  width: 8px; height: 8px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transform: translateY(-50%) rotate(45deg);
  z-index: 51;
}
/* 현재 페이지는 강조색 테두리 + 라벨색으로 — 채우지 않는다(글자 대비가 깨진다) */
.sidebar.collapsed .nav-item.active[data-tooltip]::after {
  border-color: var(--accent); color: var(--accent);
}
.sidebar.collapsed .nav-item.active[data-tooltip]::before {
  border-left-color: var(--accent); border-bottom-color: var(--accent);
}

/* ============================================================
   info-badge — circular "!" hint with instant CSS hover tooltip.
   Used for rule description / check-type description in prod-tabs.
   Pure CSS hover (babel/runtime independent). cursor:help retained.
============================================================ */
.info-badge {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid var(--text-muted); color: var(--text-muted);
  font-size: 10px; font-weight: 700; line-height: 1;
  cursor: help;
  vertical-align: middle;
  transition: border-color var(--dur-fast), color var(--dur-fast), background var(--dur-fast);
}
.info-badge:hover {
  border-color: var(--accent); color: var(--accent);
  background: var(--accent-softer, color-mix(in srgb, var(--accent) 10%, transparent));
}
/* default placement = BELOW the badge.
   The rule table lives in a .tbl-wrap/.card with overflow-x:auto, which forces
   overflow-y to compute as auto — an upward tip on the first row (under the
   sticky header) would clip. Downward avoids that for every row but the last;
   the native title fallback on the JSX badge covers that edge case. */
.info-badge .info-tip {
  position: absolute;
  left: 50%; top: calc(100% + 7px);
  transform: translateX(-50%);
  min-width: 120px; max-width: 280px; width: max-content;
  background: var(--bg-surface); color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 7px 9px; border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: 11.5px; font-weight: 400; line-height: 1.45;
  white-space: normal; text-align: left;
  letter-spacing: 0;
  z-index: 600;
  visibility: hidden; opacity: 0;
  transition: opacity var(--dur-fast), visibility var(--dur-fast);
  pointer-events: none;
}
/* arrow above the tip pointing up at the badge */
.info-badge .info-tip::after {
  content: "";
  position: absolute;
  bottom: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: var(--border);
}
.info-badge:hover .info-tip,
.info-badge:focus-visible .info-tip {
  visibility: visible; opacity: 1;
}
/* opt-in: place the tip ABOVE the badge (e.g. bottom-of-viewport rows) */
.info-badge.info-badge--above .info-tip {
  top: auto; bottom: calc(100% + 7px);
}
.info-badge.info-badge--above .info-tip::after {
  bottom: auto; top: 100%;
  border-bottom-color: transparent; border-top-color: var(--border);
}
.info-tip .info-tip-title {
  display: block; font-weight: 600; color: var(--text-primary);
  margin-bottom: 2px;
}

/* 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); }
/* 패널 토글과 breadcrumb 사이 구분선 — 토글이 '패널' 것이고 breadcrumb 은 '본문' 것이라 갈라 보인다 */
.app-header .header-divider { width: 1px; height: 18px; background: var(--border); flex: none; }
/* 패널이 보이는 상태면 토글을 살짝 강조 — 지금 상태가 무엇인지 아이콘 모양만으로는 약하다 */
.app-header .btn.icon.on { background: var(--bg-muted); color: var(--text-primary); }
.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; }

/* 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); }

/* ============================================================
   CodeBadge
============================================================ */
/* V247+: CodeBadge 한 줄 표기 (Topology 탭 등 트리에서 자연 정렬).
   긴 code 는 ns 부분 ellipsis. title attr hover 시 전체 확인. */
.cb {
  display: inline-flex; align-items: center; gap: 4px;
  flex-wrap: nowrap;                     /* 한 줄 유지 */
  white-space: nowrap;                   /* 줄바꿈 X */
  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: hidden;
  min-width: 0;
}
.cb:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.cb.copied { background: var(--success-soft); border-color: var(--success); color: var(--success); }
/* ns (namespace prefix) 가 길 때 ellipsis — leaf 와 copy 아이콘은 항상 보임 */
.cb .ns {
  color: var(--text-muted); font-weight: 400;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1 1 auto; min-width: 0;
}
.cb .leaf { white-space: nowrap; flex-shrink: 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; }

/* ============================================================
   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; }

/* ============================================================
   Set list (left column)
============================================================ */
.list-pane {
  border-right: 1px solid var(--border);
  background: var(--bg-primary);
  display: flex; flex-direction: column;
  min-height: 0;
}

/* 사이드 패널 숨김 — 헤더 아이콘으로 토글(전역 설정, localStorage 유지).
   ⚠️ 숨겨도 본문 폭은 그대로 두고 패널만 **오버레이**로 띄운다.
      폭이 바뀌면 표·차트가 매번 리플로우돼 hover 미리보기가 오히려 산만해진다.
   .main 은 grid-template-columns 를 "0 1fr" 로 받으므로 본문이 전폭을 쓴다. */
.main.pane-hidden > .list-pane { display: none; }
.main.pane-hidden { position: relative; }

/* peek(hover 미리보기) — visible 이면 .pane-hidden 이 안 붙고, 대신 오버레이로 렌더된다 */
.main.pane-peek { position: relative; }
.main.pane-peek > .list-pane {
  /* ⚠️ !important 필요 — 8개 페이지가 .list-pane 에 style={{position:"relative"}} 를
     인라인으로 준다(ResizeHandle 의 absolute 기준점 용도). 인라인이 스타일시트를 이기므로
     이게 없으면 오버레이가 흐름에 남아 본문을 아래로 밀어낸다(실측). */
  position: absolute !important; left: 0; top: 0; bottom: 0;
  width: var(--pane-w, 320px);
  z-index: 60;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  animation: pane-slide-in 140ms var(--ease-out, ease-out);
}
@keyframes pane-slide-in {
  from { transform: translateX(-8px); opacity: 0.4; }
  to   { transform: translateX(0);    opacity: 1; }
}
/* 미리보기 중에는 리사이즈 핸들을 숨긴다 — 오버레이 폭을 드래그해봐야 고정본에 안 남는다 */
.main.pane-peek > .list-pane [title*="드래그"] { display: none; }
.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; }

/* 접기 가능한 prefix 그룹 헤더 — 채점 세트 / 스코링 검증 / 레포트 사이드 패널 공통.
   기존 표기(라벨+카운트)는 그대로 두고 앞에 chevron 만 붙인다.
   chevron 은 접힘/펼침 모두 자리를 차지해야 라벨 좌측 정렬이 흔들리지 않는다. */
.list-group-head > svg { flex: none; opacity: 0.55; }
.list-group-head.toggleable { cursor: pointer; user-select: none; border-radius: var(--r-sm); }
.list-group-head.toggleable:hover { background: var(--bg-muted); color: var(--text-primary); }
.list-group-head.toggleable:hover > svg { opacity: 0.9; }
.list-group-head.toggleable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* UxEntityList(레포트)는 .ux-group-head 를 쓰지만 collapse 시 .list-group-head 로 렌더된다.
   .ux-list 안에서도 같은 여백을 갖도록 맞춘다. */
.ux-list .list-group-head { padding: 4px 8px 3px; }

.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; }
/* 아바타 없는 목록 행 — 사이드 패널 3종(채점세트·스코링 검증·레포트).
   그룹 헤더가 prefix 를 이미 보여줘서 행마다 3자 이니셜을 반복하지 않는다.
   .set-row 기본 그리드(28px 1fr auto)의 아바타 칸만 걷어낸다 —
   문항 페이지는 .set-avatar 를 다른 용도(미사용 표시)로 쓰므로 건드리지 않는다. */
.set-row.no-avatar { grid-template-columns: 1fr auto; }

.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; }

/* ============================================================
   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 svg { flex-shrink: 0; margin-top: 1px; }

/* ============================================================
   Table (V242+: tbl-wrap 컨테이너 + 동적 컬럼 + cell wrap/ellipsis)
   - .tbl-wrap: 가로 스크롤 컨테이너 (좁은 화면 대응)
   - .tbl: width:100% min-width 자동, table-layout auto (컬럼 너비 content 기반)
   - .tbl td.wrap: 긴 텍스트 줄바꿈
   - .tbl td.truncate: 한 줄 ellipsis (title attr 권장)
   - .tbl td.nowrap: 줄바꿈 금지
============================================================ */
.tbl-wrap { width: 100%; overflow-x: auto; overflow-y: visible; -webkit-overflow-scrolling: touch; }
/* V242+: .tbl 의 부모 (.card / .card.flush) 자동 가로 스크롤 — wrap div 없는 기존 table 들도 잘림 X. */
.card:has(> .tbl), .card.flush:has(> .tbl), .card:has(> div > .tbl), .card.flush:has(> div > .tbl) {
  overflow-x: auto; overflow-y: visible;
}
.tbl { width: 100%; min-width: max-content; 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;
  /* default: 셀 너비를 내용에 맞게, 긴 텍스트는 줄바꿈 허용 (jsx 에서 .nowrap/.truncate 명시 시 override) */
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.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; z-index: 1;
  white-space: nowrap; /* 헤더는 줄바꿈 X */
}
.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; }
.tbl td.nowrap, .tbl th.nowrap { white-space: nowrap; }
.tbl td.truncate { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl td.wrap { white-space: normal; word-break: break-word; overflow-wrap: anywhere; }
.tbl td.right, .tbl th.right { text-align: right; }
.tbl td.center, .tbl th.center { text-align: center; }

/* ============================================================
   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 .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-label { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 6px; }

/* utility */
.row { display: flex; align-items: center; gap: 8px; }
.spread { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.spacer { flex: 1; }

/* ============================================================
   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;
  }
}
/* ============================================================
   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;
  }
}

/* ============================================================
   ===== ux- shared components (additive) =====
   page-shared.jsx / page-entity-editor.jsx 전용 신규 클래스.
   원칙: 이 블록은 파일 말미 추가만 — 기존 셀렉터 무수정.
   색/간격/라운드/그림자/모션 전부 기존 CSS 변수 경유 (라이트/다크 자동).
============================================================ */

/* --- UxPageHeader — 리스트 페인 상단 헤더 --- */
.ux-page-head {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  min-width: 0;
}
.ux-page-head-row { display: flex; align-items: center; gap: 8px; min-height: 28px; min-width: 0; }
.ux-page-head-title {
  display: flex; align-items: baseline; gap: 6px; flex: 1; min-width: 0;
  font-size: 14.5px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ux-page-head-count { font-family: var(--font-mono); font-size: 11.5px; font-weight: 400; color: var(--text-muted); }

/* --- UxSearchPanel + chips --- */
.ux-search-panel { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ux-chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.ux-chip-disabled { opacity: 0.45; cursor: not-allowed; }

/* --- UxPager — 서버 페이지네이션 --- */
.ux-pager { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.ux-pager-info { font-size: 11px; }
.ux-pager-range { font-family: var(--font-mono); font-size: 11px; min-width: 44px; text-align: center; }

/* --- UxEntityList — 마스터 리스트 (listbox + sticky 그룹 헤더) --- */
.ux-list { display: flex; flex-direction: column; outline: none; min-width: 0; }
.ux-list:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-soft); border-radius: var(--r-sm); }
.ux-list-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; min-width: 0;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background var(--dur-fast) var(--ease-out);
}
.ux-list-row:hover { background: var(--bg-hover); }
.ux-list-row.selected { background: var(--accent-softer); border-left-color: var(--accent); }
.ux-group-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 12px 4px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}
.ux-group-head .count { font-family: var(--font-mono); font-weight: 500; opacity: 0.7; }
.ux-row-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; flex-shrink: 0;
  border-radius: var(--r-sm);
  background: var(--bg-muted); color: var(--text-secondary);
  font-size: 10px; font-weight: 600;
}
.ux-row-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ux-row-title { font-size: 12.5px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ux-row-sub { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ux-row-badges { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; }

/* --- UxDataTable — sticky header + dirty/selected 행 --- */
.ux-table-wrap { min-width: 0; }
.ux-table { font-size: 12.5px; border-collapse: separate; border-spacing: 0; }
.ux-table thead th { background: var(--bg-surface); }
.ux-table.ux-sticky thead th { position: sticky; top: 0; z-index: 3; box-shadow: inset 0 -1px 0 var(--border-strong); }
.ux-table tbody tr { transition: background var(--dur-fast) var(--ease-out); }
.ux-table tbody tr:hover { background: var(--bg-hover); }
.ux-table tbody tr.ux-row-selected { background: var(--accent-softer); }
.ux-table tbody tr.ux-row-dirty { background: var(--warning-soft); }
.ux-table tbody tr.ux-row-dirty:hover { background: var(--warning-soft); }
.ux-table tbody tr.ux-row-dirty td:first-child { box-shadow: inset 2px 0 0 var(--warning); }

/* --- UxFormSection / UxField / UxNumField --- */
.ux-form-section { min-width: 0; }
.ux-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ux-field-label { font-size: 11px; font-weight: 600; letter-spacing: 0.02em; color: var(--text-muted); }
.ux-field-hint { font-size: 10.5px; color: var(--text-placeholder); }
.ux-num { display: inline-flex; align-items: center; gap: 6px; }
.ux-num-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.ux-num-suffix { font-size: 11px; color: var(--text-muted); }
.ux-num input {
  height: 28px; padding: 0 8px;
  width: var(--ux-num-w, 90px);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--bg-surface); color: var(--text-primary);
  font-family: var(--font-mono); font-size: 12px;
  outline: none;
  transition: width var(--dur-med) var(--ease-out), border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.ux-num input:focus { width: max(var(--ux-num-w, 90px), 148px); border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-softer); }
.ux-num input:disabled { background: var(--bg-muted); color: var(--text-muted); cursor: not-allowed; }

/* --- InlineEdit — 클릭 시 옆으로 늘어나는 인라인 편집 ---------------------
   span↔input 스왑 방식은 클릭 순간 폭이 바뀌며 레이아웃이 튀고, 엘리먼트가
   교체되므로 width 트랜지션을 걸 수도 없다. 대신 input 을 항상 렌더하고
   평상시엔 텍스트처럼 보이게 한 뒤 포커스/입력에 맞춰 폭만 늘린다.
   폭은 JS(ieWidth)가 내용 길이로 계산해 --ie-w / --ie-w-focus 로 넘긴다. */
.inline-edit {
  flex: none;
  /* --ie-w 는 '글자 폭' 이다. border-box 면 padding·border 가 그 안에서 먹혀
     값이 잘린다(실제로 50 이 잘렸다) — 여기서만 content-box 로 되돌린다. */
  box-sizing: content-box;
  width: var(--ie-w, 4ch);
  min-width: 0;
  font: inherit;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid transparent;
  border-bottom-color: var(--text-muted);
  border-radius: var(--r-sm);
  padding: 0 4px;
  outline: none;
  cursor: pointer;
  transition: width var(--dur-med) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.inline-edit:hover:not(:focus) { background: var(--bg-muted); border-bottom-color: var(--text-primary); }
.inline-edit:focus {
  width: var(--ie-w-focus, 10ch);
  cursor: text;
  background: var(--bg-surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-softer);
}
.inline-edit.dirty { background: var(--warning-soft); border-bottom-color: var(--warning); }
.inline-edit.num { font-family: var(--font-mono); }
/* 숫자 스피너는 인라인 폭을 잡아먹고 좁은 칸에선 값을 가린다 */
.inline-edit::-webkit-outer-spin-button,
.inline-edit::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.inline-edit[type="number"] { -moz-appearance: textfield; appearance: textfield; }
/* boxed — 항상 편집 가능한 그리드 셀용. 테두리는 유지하고 폭만 확장한다
   (텍스트처럼 보이면 그 칸이 편집 가능하다는 신호가 사라진다). */
.inline-edit.boxed {
  border-color: var(--border);
  background: var(--bg-surface);
  cursor: text;
  padding: 2px 5px;
}
.inline-edit.boxed:hover:not(:focus) { border-color: var(--border-focus); background: var(--bg-surface); }
/* steady — 원래부터 항상 편집 가능하던 칸(직군 규준처럼 flexWrap 안의 좁은 행).
   포커스에 폭을 키우면 없던 재배치가 생긴다. 폭은 내용(--ie-w)만 따라가고,
   포커스는 테두리·링으로만 알린다. 입력 중에는 --ie-w 가 갱신되므로 여전히 늘어난다. */
.inline-edit.steady:focus { width: var(--ie-w); }

/* .inline-grow — 항상 편집 가능한 표 셀(controlled input). InlineEdit 처럼
   내용 폭까지 재지는 않지만, 좁은 기본폭에서 포커스 시 옆으로 넓어진다. */
.inline-grow {
  width: var(--ig-w, 92px);
  transition: width var(--dur-med) var(--ease-out);
}
.inline-grow:focus { width: max(var(--ig-w, 92px), 130px); }

/* --- UxDirtyPill / UxSaveBar --- */
.ux-dirty-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  background: var(--warning-soft); color: var(--warning);
  border-radius: var(--r-pill);
  font-size: 10.5px; font-weight: 600; white-space: nowrap;
}
.ux-dirty-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--warning); }
.ux-save-bar { display: flex; align-items: center; gap: 8px; }

/* --- UxRelatedCard / UxMetadataCard --- */
.ux-related-card { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ux-related-head { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); min-width: 0; }
.ux-related-title { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.ux-related-count {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-muted);
  background: var(--bg-muted); padding: 0 6px; border-radius: var(--r-pill);
}
.ux-related-list { display: flex; flex-direction: column; min-width: 0; }
.ux-related-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: var(--r-sm); font-size: 12px; min-width: 0; }
.ux-related-row.ux-clickable { cursor: pointer; transition: background var(--dur-fast) var(--ease-out); }
.ux-related-row.ux-clickable:hover { background: var(--bg-hover); }
.ux-related-name { color: var(--text-secondary); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ux-related-more { font-size: 11px; color: var(--text-muted); padding: 4px 6px; cursor: pointer; }
.ux-related-more:hover { color: var(--text-primary); }
.ux-related-empty { font-size: 11.5px; color: var(--text-muted); padding: 2px 6px; }
.ux-meta-pre {
  margin: 0; padding: 10px 12px;
  background: var(--bg-muted); border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: 11px; line-height: 1.55;
  color: var(--text-secondary);
  overflow: auto; max-height: 260px;
}
