/*
 * EduTalk 어드민 웹 — TailAdmin 기반 디자인 시스템 (자가포함, 빌드 단계 없음).
 *
 * spec/service/backend.md "디자인 정책":
 *  - 타이포(D-2): Pretendard 단일 패밀리, fallback = Pretendard → system-ui → sans-serif.
 *    식별자(deviceId·에러코드)만 모노스페이스.
 *  - 화면 레이아웃(D-3): 데스크톱 우선 + 모바일 반응형(사이드바 collapse).
 *
 * TailAdmin 표준 셸(좌측 사이드바 + 상단 헤더 + 콘텐츠) / 데이터 테이블 / 설정 폼 /
 * 토글 스위치 / 배지 / 토스트 / 확인 모달의 구조·비주얼을 Tailwind CDN 없이 직접 작성.
 * (동일 오리진 정적 서빙 제약상 외부 CDN 의존을 피하고 자가포함으로 구성)
 */

/* Pretendard 웹폰트 — 실패 시 system-ui로 graceful fallback(D-2). */
@font-face {
  font-family: 'Pretendard';
  font-weight: 45 920;
  font-display: swap;
  src: local('Pretendard Variable'), local('Pretendard');
}

:root {
  --brand: #465fff;
  --brand-600: #3641f5;
  --brand-50: #ecf3ff;
  --gray-25: #fcfcfd;
  --gray-50: #f9fafb;
  --gray-100: #f2f4f7;
  --gray-200: #e4e7ec;
  --gray-300: #d0d5dd;
  --gray-400: #98a2b3;
  --gray-500: #667085;
  --gray-600: #475467;
  --gray-700: #344054;
  --gray-800: #1d2939;
  --gray-900: #101828;
  --success-50: #ecfdf3;
  --success-500: #12b76a;
  --success-700: #027a48;
  --warning-50: #fffaeb;
  --warning-500: #f79009;
  --warning-700: #b54708;
  --error-50: #fef3f2;
  --error-500: #f04438;
  --error-700: #b42318;
  --radius: 12px;
  --sidebar-w: 260px;
  --shadow-card: 0 1px 3px rgba(16, 24, 40, 0.1), 0 1px 2px rgba(16, 24, 40, 0.06);
  --font-sans: 'Pretendard', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SFMono-Regular', ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  color: var(--gray-700);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

code, .mono { font-family: var(--font-mono); }

button { font-family: inherit; }

/* ── 인증 레이아웃(중앙 로그인 카드, 사이드바 없음) ── */
.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand-50), var(--gray-50));
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  padding: 40px 32px;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.auth-brand .logo {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.auth-card h1 { font-size: 22px; margin: 0 0 4px; color: var(--gray-900); }
.auth-card .subtitle { color: var(--gray-500); margin: 0 0 24px; font-size: 13px; }

/* ── 콘솔 셸(사이드바 + 헤더 + 콘텐츠) ── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  transition: transform 0.2s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
}
.sidebar-brand .logo {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.sidebar-brand .name { font-weight: 700; color: var(--gray-900); font-size: 16px; }
.nav { padding: 16px 12px; flex: 1; overflow-y: auto; }
/* 섹션 라벨: 흰 사이드바 위 대비 ≥4.5:1 충족 위해 gray-500(#667085, ~4.97:1) 사용
   — gray-400(#98a2b3)은 2.57:1로 WCAG 2.1 AA 미달(axe color-contrast). text 보조 토큰 범위. */
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-500); padding: 8px 12px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none; background: none;
  border-radius: 8px;
  color: var(--gray-600);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  text-align: left;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--gray-50); color: var(--gray-900); }
.nav-item.active { background: var(--brand-50); color: var(--brand-600); }
.nav-item .ico { width: 20px; height: 20px; display: inline-flex; flex-shrink: 0; }
.nav-item .ico svg { width: 20px; height: 20px; }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .page-title { font-size: 18px; font-weight: 600; color: var(--gray-900); }
/* 헤더 브레드크럼: 흰 헤더 위 대비 ≥4.5:1 충족 위해 gray-500(~4.97:1) 사용(gray-400은 2.57:1 미달). */
.topbar .breadcrumb { font-size: 12px; color: var(--gray-500); }
.topbar .title-wrap { flex: 1; min-width: 0; }
.hamburger { display: none; background: none; border: none; cursor: pointer; padding: 6px; }
.content { padding: 24px; max-width: 1280px; width: 100%; }

.sidebar-backdrop { display: none; }

/* ── 카드 ── */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 20px 24px;
  margin-bottom: 20px;
}
.card-title { font-size: 16px; font-weight: 600; color: var(--gray-900); margin: 0 0 16px; }
.card-subtitle { color: var(--gray-500); font-size: 13px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-header .card-title { margin: 0; }

/* ── 지표 카드(대시보드) ── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.metric {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 20px;
}
.metric .label { color: var(--gray-500); font-size: 13px; margin-bottom: 8px; }
.metric .value { font-size: 28px; font-weight: 700; color: var(--gray-900); }

/* ── 인라인 스탯(대화 지속시간 평균 등 단일 지표 강조) ── */
.inline-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  background: var(--gray-50, #f9fafb);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
}
.inline-stat-label { color: var(--gray-500); font-size: 13px; }
.inline-stat-value { font-size: 24px; font-weight: 700; color: var(--gray-900); }

/* ── 폼 ── */
.form-group { margin-bottom: 16px; }
.form-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.form-row > label { min-width: 160px; font-weight: 500; color: var(--gray-700); font-size: 13px; }
label.lbl { display: block; font-weight: 500; color: var(--gray-700); font-size: 13px; margin-bottom: 6px; }

/* 동종 필드 다열 그리드(ops-config 자동복귀 3필드·비중복 윈도우 2필드) — md+ 다열, < md 1열 스택
   (ops-config ui.md 가정: 동종 병렬 배치가 비교 스캔에 유리, 좁은 폭 1열). 각 셀은 .form-group. */
.form-grid-3, .form-grid-2 { display: grid; gap: 16px; }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid-3 .form-group, .form-grid-2 .form-group { margin-bottom: 0; }
.form-grid-3 input.inline, .form-grid-2 input.inline { width: 100%; }
@media (max-width: 767px) {
  .form-grid-3, .form-grid-2 { grid-template-columns: 1fr; }
}
/* ops-config 레이아웃 A/B 폼 행(화면명 label + Select 세로 스택) */
.layout-row { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.layout-row > label { min-width: 160px; font-weight: 500; color: var(--gray-700); font-size: 13px; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="time"], select, textarea {
  width: 100%;
  max-width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  color: var(--gray-800);
  background: #fff;
  font-family: inherit;
}
input.inline, select.inline { width: auto; min-width: 120px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-50);
}
input.invalid, select.invalid { border-color: var(--error-500); }
.field-error { color: var(--error-700); font-size: 12px; margin-top: 4px; }

/* ── 버튼 시스템(item #9) ──
 * 통일 기준 = [의미(variant) × 크기(size)] 2축. 모든 버튼은 명시적 variant를 가진다(무변형 .btn 금지).
 *  variant(의미):
 *   - .btn-primary       : 맥락의 주(主) 긍정 액션(조회·저장·생성·로그인). 브랜드 채움.
 *   - .btn-secondary     : 중립/취소/이동(취소·수정·다시 시도·이전/다음). 흰 배경+회색 외곽선.
 *   - .btn-danger        : 인라인/행(行) 파괴 액션(목록·행의 삭제·비활성화). 흰 배경+빨강 외곽선(저자극).
 *   - .btn-danger-solid  : 확인 다이얼로그의 주 파괴 액션(빨강 채움, 고강조 — primary와 강조 동급).
 *  size(맥락):
 *   - 기본(미지정)        : 폼/툴바의 주 액션(조회·저장·생성·모달 확인/취소).
 *   - .btn-sm            : 카드 헤더 보조 액션·페이지네이션.
 *   - .btn-xs            : 테이블 행 내 액션(행별 수정/삭제).
 *  같은 역할은 어디서나 같은 variant·size를 쓴다(역할↔표현 1:1). */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--gray-100);
  color: var(--gray-700);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-600); }
.btn-secondary { background: #fff; border-color: var(--gray-300); color: var(--gray-700); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-50); }
.btn-danger { background: #fff; border-color: var(--error-500); color: var(--error-700); }
.btn-danger:hover:not(:disabled) { background: var(--error-50); }
.btn-danger-solid { background: var(--error-500); border-color: var(--error-500); color: #fff; }
.btn-danger-solid:hover:not(:disabled) { background: var(--error-700); border-color: var(--error-700); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 테이블 ── */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--gray-700); }
table.data th .sort-ind { font-size: 10px; margin-left: 4px; color: var(--brand); }
table.data td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
  color: var(--gray-700);
  vertical-align: middle;
}
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--gray-25); }
table.data tr.inactive td { color: var(--gray-400); }
/* 통계 숫자 표(정밀 수치 등) — 그룹별 표의 열 너비를 고정해 일관되게 정렬하고 숫자를 우측정렬한다 (item44).
   auto-layout일 때 그룹(콘텐츠/레벨/아바타별)마다 내용에 따라 열 너비가 제각각이던 문제 해소. */
table.data.nums { table-layout: fixed; }
table.data.nums th:first-child,
table.data.nums td:first-child { width: 46%; }
table.data.nums th:not(:first-child),
table.data.nums td:not(:first-child) { text-align: right; white-space: nowrap; }

/* ── 배지 ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--gray-100);
  color: var(--gray-600);
}
.badge-success { background: var(--success-50); color: var(--success-700); }
.badge-error { background: var(--error-50); color: var(--error-700); }
.badge-warning { background: var(--warning-50); color: var(--warning-700); }
.badge-neutral { background: var(--gray-100); color: var(--gray-600); }
.badge-brand { background: var(--brand-50); color: var(--brand-600); }

/* ── 토글 스위치 ── */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--gray-300);
  border-radius: 999px;
  transition: 0.2s;
}
.switch .slider:before {
  content: '';
  position: absolute;
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider:before { transform: translateX(20px); }
.switch input:disabled + .slider { opacity: 0.5; cursor: not-allowed; }

/* 체크박스 그룹(노출 설정 등) */
.check-group { display: flex; flex-wrap: wrap; gap: 16px; }
.check-item { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.check-item input { width: 16px; height: 16px; }

/* ── 분포 차트(막대) ── */
.chart-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.bar-row .bar-key { width: 110px; flex-shrink: 0; color: var(--gray-600); }
.bar-row .bar-track { flex: 1; height: 22px; background: var(--gray-100); border-radius: 6px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: var(--brand); border-radius: 6px; min-width: 2px; transition: width 0.3s; }
.bar-row .bar-val { width: 80px; text-align: right; flex-shrink: 0; font-weight: 500; color: var(--gray-700); }

/* ── 차트 다양화: 자체 SVG 렌더(외부 CDN 의존 없음, 0.5.0 ⑤-10) ──
 * 도넛/파이(구성비) · 라인/영역(시계열 추세) · 스택 막대(별등급 분포)를 인라인 SVG로 그린다. */
.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut-figure { width: 120px; flex-shrink: 0; }
.donut-svg { width: 120px; height: 120px; display: block; }
.donut-svg .donut-center { font-size: 7px; font-weight: 700; fill: var(--gray-900); }
.chart-legend { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 140px; }
.chart-legend.chart-legend-row { flex-direction: row; flex-wrap: wrap; gap: 16px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--gray-600); }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; display: inline-block; }
.legend-key { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-val { font-weight: 600; color: var(--gray-800); white-space: nowrap; }
.line-figure { width: 100%; overflow-x: auto; }
.line-svg { width: 100%; min-width: 480px; height: auto; display: block; }
.line-svg .axis-label { font-size: 11px; fill: var(--gray-400); }
.stack-row { display: flex; align-items: center; gap: 12px; font-size: 13px; margin-bottom: 10px; }
.stack-row .bar-key { width: 90px; flex-shrink: 0; color: var(--gray-600); }
.stack-bar-wrap { flex: 1; }
.stack-bar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; background: var(--gray-100); }
.stack-seg { height: 100%; min-width: 2px; }
.stack-legend { display: flex; gap: 16px; margin-bottom: 12px; }

/* ── 일괄 입력(bulk import) 모달 (0.5.0 ⑤-9) ── */
.modal-form input[type='file'] {
  font-size: 13px;
  width: 100%;
  padding: 8px;
  border: 1px dashed var(--gray-300);
  border-radius: 8px;
  background: var(--gray-25);
}

/* ── 상태/빈/로딩 ── */
.empty-state, .loading-state, .error-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
  font-size: 14px;
}
.error-state { color: var(--error-700); }
.skeleton {
  height: 16px;
  background: linear-gradient(90deg, var(--gray-100), var(--gray-200), var(--gray-100));
  background-size: 200% 100%;
  border-radius: 6px;
  animation: shimmer 1.2s infinite;
  margin: 8px 0;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}

/* ── 토스트 ── */
.toast-region {
  position: fixed;
  top: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 100;
  max-width: 380px;
}
.toast {
  background: var(--gray-900);
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.18);
  display: flex; align-items: flex-start; gap: 10px;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.success { background: var(--success-700); }
.toast.error { background: var(--error-700); }
.toast.warning { background: var(--warning-700); }
/* 중립 토스트(no-op 가드 등 — 성공/실패 아님). 기본 gray-900보다 한 단계 밝은 중립 톤. */
.toast.neutral { background: var(--gray-700); }
.toast .toast-ico { font-weight: 700; }

/* ── 모달(확인 다이얼로그) ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 90;
  padding: 24px;
}
.modal {
  background: #fff;
  border-radius: 14px;
  max-width: 440px;
  width: 100%;
  padding: 28px;
  box-shadow: 0 20px 48px rgba(16, 24, 40, 0.24);
}
.modal h3 { margin: 0 0 8px; font-size: 18px; color: var(--gray-900); }
.modal p { margin: 0 0 24px; color: var(--gray-600); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ── 고정 대화 라인 관리 패널(0.12.0 R2) ──
 * 자체 오버레이(document.body 직속). 라인 생성/수정 폼·삭제 확인(공용 modal-host, z-index
 * 90)이 이 패널 위에 겹쳐 뜨도록 낮은 z-index(80)를 준다. */
.lines-backdrop { z-index: 80; }
.modal.modal-wide { max-width: 860px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 4px; }

/* ── 모달 폼(생성/수정) ── */
.modal.modal-form { max-width: 600px; max-height: 88vh; display: flex; flex-direction: column; }
.modal-form > h3 { flex-shrink: 0; }
.modal-form .modal-form-body { overflow-y: auto; margin-bottom: 20px; padding-right: 4px; }
.modal-form .modal-actions { flex-shrink: 0; }
.readonly-field {
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: var(--gray-50);
  color: var(--gray-500);
  font-size: 14px;
}
/* ── 행별 작업 버튼 / 섹션 툴바 ── */
.row-actions { display: flex; gap: 6px; flex-wrap: nowrap; }
.btn-xs { padding: 4px 10px; font-size: 12px; }
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}

/* ── 알림 박스(인라인 안내) ── */
.alert {
  display: flex; gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-info { background: var(--brand-50); color: var(--brand-600); }
.alert-warning { background: var(--warning-50); color: var(--warning-700); }
.alert-error { background: var(--error-50); color: var(--error-700); }

/* 유틸 */
.muted { color: var(--gray-500); font-size: 13px; }
.mb-0 { margin-bottom: 0; }
.mt-16 { margin-top: 16px; }
.flex { display: flex; }
.flex-gap { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.section-divider { height: 1px; background: var(--gray-200); margin: 20px 0; }
.meta-row { display: flex; gap: 24px; flex-wrap: wrap; font-size: 13px; color: var(--gray-500); }
.meta-row b { color: var(--gray-800); font-weight: 600; }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.pagination { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 16px; font-size: 13px; color: var(--gray-600); }

/* ── 커스텀 드롭다운(디자인 시스템 — 네이티브 <select> 대체, item #8) ──
 * 네이티브 select의 OS 렌더 팝업/화살표를 디자인 시스템과 어울리는 트리거+메뉴로 대체한다.
 * .cs 루트가 네이티브 select 호환 인터페이스(.value get/set, 'change' 이벤트)를 노출한다. */
.cs { position: relative; display: block; width: 100%; max-width: 100%; }
.cs-inline { display: inline-block; width: auto; min-width: 150px; }
.cs-trigger {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  background: #fff;
  color: var(--gray-800);
  font-size: 14px; font-family: inherit;
  cursor: pointer; text-align: left;
}
.cs-trigger:hover { border-color: var(--gray-400); }
.cs.open > .cs-trigger, .cs-trigger:focus-visible {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50);
}
.cs-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-label.cs-placeholder { color: var(--gray-400); }
.cs-caret { display: inline-flex; color: var(--gray-400); flex-shrink: 0; transition: transform 0.15s ease; }
.cs.open .cs-caret { transform: rotate(180deg); }
.cs-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.16);
  padding: 4px;
  max-height: 280px; overflow-y: auto;
  display: none;
}
.cs.open .cs-menu { display: block; }
.cs-option {
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 14px; color: var(--gray-700);
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.cs-option:hover { background: var(--gray-50); }
.cs-option.selected { background: var(--brand-50); color: var(--brand-600); font-weight: 500; }
.cs-option.selected::after { content: '✓'; color: var(--brand); font-size: 12px; }
.cs.invalid > .cs-trigger { border-color: var(--error-500); }
.cs.cs-disabled { opacity: 0.55; pointer-events: none; }

/* ── 그림 힌트 이미지 URL + 미리보기(item #6) ── */
.img-hint-preview {
  margin-top: 8px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: var(--gray-50);
  padding: 8px;
  display: flex; align-items: center; justify-content: center;
  min-height: 96px;
}
.img-hint-preview img { max-width: 100%; max-height: 160px; border-radius: 6px; display: block; }
.img-hint-preview .img-hint-empty { color: var(--gray-400); font-size: 13px; }
.img-hint-thumb { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; border: 1px solid var(--gray-200); background: var(--gray-50); }

/* ── 레벨별 정책 그리드(전 레벨 한눈에 편집, item #11) ── */
/* 콘텐츠 폭이 표(min-width 920px)보다 좁아지면(사이드바 표시 중간 폭 등) 가로 스크롤한다. 드롭다운은
   position:fixed(customSelect)로 뷰포트에 띄워 overflow에 잘리지 않는다 — 우측 열 드롭다운 클리핑 수정. */
.lp-grid-wrap { overflow-x: auto; }
table.lp-grid { width: 100%; border-collapse: collapse; min-width: 920px; }
table.lp-grid th, table.lp-grid td {
  padding: 10px 12px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; text-align: left;
}
table.lp-grid thead th {
  font-size: 12px; font-weight: 600; color: var(--gray-500);
  background: var(--gray-50); border-bottom: 1px solid var(--gray-200); white-space: nowrap;
}
table.lp-grid td.lp-level-cell { font-weight: 600; color: var(--gray-800); white-space: nowrap; }
table.lp-grid tbody tr:hover td { background: var(--gray-25); }
table.lp-grid input[type="text"], table.lp-grid input[type="number"] { min-width: 72px; }
.lp-words { display: flex; align-items: center; gap: 6px; }
.lp-words input { width: 72px; }
.lp-words .lp-dash { color: var(--gray-400); }

/* ── 활동별 엔진 매트릭스(0.12.0 R3 — KF-11) ──
 * 3행(활동) × 4열(활동/STT/LLM/TTS). STT 열만 편집 컨트롤(Select), LLM/TTS는 읽기 전용
 * 텍스트. 좁은 폭에서는 부모 .table-wrap의 overflow-x로 가로 스크롤(ui.md 가정 — 행·열
 * 대응 관계 보존). */
table.data.engine-matrix { min-width: 720px; }
table.data.engine-matrix td { vertical-align: top; }
table.data.engine-matrix td.engine-activity { font-weight: 600; color: var(--gray-800); white-space: nowrap; }
table.data.engine-matrix .cs-inline { min-width: 240px; max-width: 100%; }

/* ── 아바타·음성 카탈로그 authoring(0.14.0) ──
 * 허용 아바타 블록(토글 + 관측 표시 정보) + 켰을 때만 펼쳐지는 아바타별 음성 매핑 패널.
 * 재확인 필요(NEEDS_RECHECK) 항목은 경고 배지 행으로 별도 노출한다. 원천 키(opaque)는
 * 모노스페이스로 줄바꿈 허용해 좁은 폭에서도 넘치지 않게 한다. */
.avc-avatar {
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.avc-avatar.on { border-color: var(--brand); background: var(--gray-25); }
.avc-avatar-head { display: flex; align-items: flex-start; gap: 14px; }
.avc-avatar-info { flex: 1; min-width: 0; }
.avc-avatar-name { font-weight: 600; color: var(--gray-900); font-size: 15px; }
.avc-key { font-size: 12px; color: var(--gray-500); word-break: break-all; margin-top: 2px; }
.avc-meta-line { font-size: 13px; color: var(--gray-500); margin-top: 4px; }
.avc-thumb {
  width: 40px; height: 40px; border-radius: 8px; object-fit: cover;
  flex-shrink: 0; border: 1px solid var(--gray-200); background: var(--gray-100);
}
.avc-voice-panel { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--gray-200); }
.avc-voice-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.avc-voice-title { font-weight: 600; color: var(--gray-700); font-size: 13px; }
.avc-vcount { font-size: 12px; color: var(--gray-500); }
.avc-voice-group { gap: 10px 20px; }
.avc-voice-item { align-items: baseline; gap: 8px; }
.avc-voice-name { color: var(--gray-800); }
.avc-orphan-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--gray-100); flex-wrap: wrap;
}
.avc-orphan-row:last-child { border-bottom: none; }
.avc-orphan-body { flex: 1; min-width: 0; font-size: 14px; color: var(--gray-700); }

/* ── 반응형(D-3: 모바일 사이드바 collapse) ── */
@media (max-width: 1023px) {
  .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0,0,0,0.1); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .sidebar-backdrop.open {
    display: block;
    position: fixed; inset: 0;
    background: rgba(16,24,40,0.4);
    z-index: 35;
  }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .form-row > label { min-width: 100%; }
  .lp-grid-wrap { overflow-x: auto; }
}
@media (max-width: 560px) {
  .metric-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}
