/* =========================================================
   Daeryun Songmu · Toss-inspired Design System
   ========================================================= */

/* ─── Top progress bar (페이지 이동 로딩) ─── */
.top-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: #3182F6;
  z-index: 9999;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1), opacity 200ms;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(49, 130, 246, 0.45);
}
.top-progress[hidden] { display: none; }

/* ─── Native-app 같은 페이지 전환 (cross-fade) ───
   Same-origin MPA 페이지 이동 시 흰 화면 깜빡임 대신 부드러운 페이드.
   Chrome 115+, Safari 18+, Android Chrome 모두 지원. 미지원 브라우저는 무시. */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 120ms;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none; }
}

:root {
  /* Motion tokens (Toss feel) */
  --ease-out-toss: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out-toss: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-1: 120ms;
  --dur-2: 220ms;
  --dur-3: 360ms;
  --dur-4: 520ms;

  /* Brand */
  --primary: #3182F6;
  --primary-strong: #1B64DA;
  --primary-soft: #E8F3FF;

  /* Neutrals (Toss palette) */
  --bg: #F9FAFB;
  --surface: #FFFFFF;
  --surface-2: #F2F4F6;
  --border: #F2F4F6;
  --border-strong: #E5E8EB;

  /* Text */
  --text: #191F28;
  --text-secondary: #4E5968;
  --text-muted: #8B95A1;
  --text-disabled: #B0B8C1;

  /* Semantic */
  --success: #05C26A;
  --success-soft: #E7F8EE;
  --warning: #FF9A32;
  --warning-soft: #FFF4E5;
  --danger: #F04452;
  --danger-soft: #FEECEE;

  /* Elevation (Toss keeps it FLAT) */
  --shadow-1: none;
  --shadow-2: 0 2px 8px rgba(10, 20, 35, 0.04);
  --shadow-3: 0 10px 30px rgba(10, 20, 35, 0.08);

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* Layout */
  --header-h: 56px;
  --bottom-nav-h: 64px;
  --sidebar-w: 240px;
  --content-max: 1280px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; min-width: 0; }
html { max-width: 100vw; }
body { overflow-x: clip; }
body {
  font-family: 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont,
               'SF Pro Text', 'Segoe UI', 'Noto Sans KR', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum";
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }

/* =========================================================
   App Shell
   ========================================================= */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}
.app.no-chrome { grid-template-columns: 1fr; }
/* 로그인처럼 사이드바가 없는 화면은 콘텐츠를 뷰포트 정중앙에 둔다 */
.app.no-chrome .main {
  padding: 24px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Desktop sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.sidebar .brand {
  padding: 4px 12px 20px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.sidebar .brand .brand-logo {
  display: block;
  /* 락업이 4.44:1 이라 폭(184px)에 맞추면 세로가 너무 작아진다. 높이로 맞춘다.
     34px → 폭 151px, SKYZAI 잉크 21.9px — 글자 크기를 옛 로고(22.5px)에 맞춘 값이다.
     40px 로 두면 폭이 178px 이 되어 사이드바에서 지나치게 커 보인다. brand/README.md 참고 */
  height: 34px;
  width: auto;
}
.sidebar .brand small {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 6px;
}
.sidebar .nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* 그룹 라벨이 붙어 세로가 길어졌다. 낮은 창에서는 nav 만 스크롤하고
     브랜드·footer 는 제자리에 남긴다 (footer 의 margin-top:auto 유지). */
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar .nav-group::-webkit-scrollbar { width: 6px; }
.sidebar .nav-group::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
/* 대메뉴 묶음 */
.sidebar .nav-sec { display: flex; flex-direction: column; gap: 2px; }
.sidebar .nav-sec + .nav-sec { margin-top: 14px; }
.sidebar .nav-sec-label {
  padding: 0 12px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
/* `.nav-sec + .nav-sec` 보다 약하면 margin 이 안 먹는다 — 클래스를 겹쳐 특정도를 맞춘다 */
.sidebar .nav-sec.nav-sec-tail {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.12s;
}
.sidebar .nav-item:hover { background: var(--surface-2); color: var(--text); }
.sidebar .nav-item.active { background: var(--primary-soft); color: var(--primary-strong); font-weight: 600; }
.sidebar .nav-item .ico { flex-shrink: 0; }

/* Notification badge (sidebar + mobile bottom nav) */
.notif-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #e5484d;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
}
.notif-badge[hidden] { display: none; }
.sidebar .nav-item .notif-badge { margin-left: auto; }
.mobile-bottom-nav a { position: relative; }
.mobile-bottom-nav a .notif-badge {
  position: absolute;
  top: 6px;
  left: calc(50% + 2px);    /* 아이콘 우측상단에 살짝 겹치는 위치 */
  right: auto;
  transform: none;
  min-width: 16px;
  height: 16px;
  font-size: 10px;
  border: 2px solid var(--surface);
}

/* ─── Toast (실시간 알림) ─── */
.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 380px;
  width: calc(100% - 32px);
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(10, 20, 35, 0.12), 0 2px 8px rgba(10, 20, 35, 0.06);
  cursor: pointer;
  animation: toast-in 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast.is-removing { animation: toast-out 220ms ease-in forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(20px); }
}
.toast-icon {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.toast-icon .ico { width: 18px; height: 18px; }
.toast-body { flex: 1; min-width: 0; }
.toast-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.toast-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.toast-close {
  flex-shrink: 0;
  width: 24px; height: 24px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px; line-height: 1;
  cursor: pointer;
  border-radius: 6px;
}
.toast-close:hover { background: var(--surface-2); color: var(--text); }

@media (max-width: 768px) {
  .toast-stack {
    top: calc(var(--header-h) + 8px);
    left: 12px; right: 12px;
    max-width: none;
    width: auto;
  }
}

/* Notifications page — push 토글 */
.push-card { padding: 16px 18px; margin-bottom: 12px; }
.push-row {
  display: flex; align-items: center; gap: 12px;
}
.push-info { flex: 1; min-width: 0; }
.push-title {
  font-size: 14px; font-weight: 700; color: var(--text);
  letter-spacing: -0.01em; margin-bottom: 4px;
}
.push-desc {
  font-size: 12px; color: var(--text-muted); line-height: 1.5;
}
.push-error {
  margin-top: 12px;
  padding: 10px 12px;
  background: #FEE2E2;
  color: #B91C1C;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  word-break: break-word;
}
.push-error[hidden] { display: none; }
.push-test-row {
  margin-top: 10px;
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.push-test-row[hidden] { display: none; }
.push-test-result {
  font-size: 12px;
  color: var(--text-muted);
}
.push-test-result.success { color: #047857; font-weight: 600; }
.push-test-result.fail    { color: #B91C1C; font-weight: 600; }
.push-diag {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.push-diag b {
  color: var(--text-secondary);
  font-weight: 700;
  margin-right: 4px;
}

@media (max-width: 600px) {
  .push-row { flex-direction: column; align-items: stretch; }
  .push-info { margin-bottom: 4px; }
  .push-row .btn { width: 100%; }
}

/* Notifications page — Toss-style */
.notif-list { display: flex; flex-direction: column; gap: 10px; }

.notif-item {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 16px 16px 16px 18px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  transition: transform 60ms var(--ease-out-toss), background 120ms;
}
.notif-item:active { transform: scale(0.99); background: var(--surface-2); }
.notif-item:hover { background: var(--surface-2); }

/* 메인 영역 (아이콘 + 본문) — 카드 내 in-app 이동 링크 */
.notif-main {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  color: inherit;
  text-decoration: none;
}

/* "바로가기" 외부 링크 버튼 — 대륜탑(aegis) 새 탭 */
.notif-open-ext {
  flex-shrink: 0;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  border: 1px solid var(--border);
  transition: background 120ms, color 120ms, border-color 120ms;
  white-space: nowrap;
}
.notif-open-ext:hover {
  background: #E8F3FF;
  color: var(--primary);
  border-color: var(--primary);
}
.notif-open-ext .ico { width: 12px; height: 12px; }

/* 모바일: 텍스트 숨기고 아이콘만 표시 (원형 버튼) */
@media (max-width: 600px) {
  .notif-open-ext { padding: 8px; gap: 0; border-radius: 50%; }
  .notif-open-ext-label { display: none; }
  .notif-open-ext .ico { width: 14px; height: 14px; }
}

/* unread: 좌측 작은 점으로 표시 (배경/테두리 변경 X — 토스 패턴) */
.notif-item.unread::before {
  content: "";
  position: absolute;
  top: 22px; left: 6px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--primary);
}
.notif-item.unread .notif-title { font-weight: 700; }

.notif-item .notif-ico {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  color: var(--text-muted);
}
.notif-item .notif-ico .ico { width: 20px; height: 20px; }

/* 분석 모드별 아이콘 색상 (kind 는 analysis_done / analysis_error 만 있어 mode chip 으로 추가 구분) */
.notif-item.kind-analysis_error .notif-ico { background: #FEE2E2; color: #B91C1C; }
.notif-item.kind-analysis_done .notif-ico { background: #E8F3FF; color: var(--primary); }
.notif-item.mode-strategy   .notif-ico { background: #FFF4E5; color: #B45309; }
.notif-item.mode-precedent  .notif-ico { background: #ECFDF5; color: #047857; }
.notif-item.mode-evidence   .notif-ico { background: #F3E8FF; color: #7C3AED; }
.notif-item.mode-full       .notif-ico { background: #E8F3FF; color: var(--primary); }
.notif-item.mode-management .notif-ico { background: #CCFBF1; color: #0F766E; }

.notif-item .notif-body { flex: 1; min-width: 0; }

.notif-item .notif-head {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 2px;
  flex-wrap: wrap;
}
.notif-item .notif-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.35;
}
.notif-item .notif-mode-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-secondary);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.notif-item.mode-strategy   .notif-mode-chip { background: #FFF4E5; color: #B45309; }
.notif-item.mode-precedent  .notif-mode-chip { background: #ECFDF5; color: #047857; }
.notif-item.mode-evidence   .notif-mode-chip { background: #F3E8FF; color: #7C3AED; }
.notif-item.mode-full       .notif-mode-chip { background: #E8F3FF; color: var(--primary-strong); }
.notif-item.mode-management .notif-mode-chip { background: #CCFBF1; color: #0F766E; }
.notif-item.mode-change     .notif-mode-chip { background: #FEF3C7; color: #92400E; }

.notif-item .notif-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 6px;
  word-break: break-word;
}
.notif-item .notif-time {
  font-size: 12px;
  color: var(--text-disabled);
  font-variant-numeric: tabular-nums;
}

.notif-empty {
  text-align: center; padding: 60px 16px; color: var(--text-muted);
  font-size: 14px;
}

/* 페이지 타이틀 옆 액션 */
.notif-title-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
}

/* 알림 분류 탭 — 토스 segmented control */
.notif-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 12px 0 16px;
  background: var(--surface-2);
  border-radius: 12px;
}
.notif-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.notif-tab:hover { color: var(--text); }
.notif-tab.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.notif-tab-count {
  display: inline-block;
  min-width: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 18px;
  text-align: center;
}
.notif-tab.is-active .notif-tab-count {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

@media (max-width: 480px) {
  .notif-tab { padding: 8px 10px; font-size: 12.5px; }
  .notif-tab-count { font-size: 10.5px; }
}
.btn-text {
  font-size: 13px; font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 120ms, color 120ms;
}
.btn-text:hover { background: var(--surface-2); color: var(--text); }
.btn-text:active { background: var(--border); }
.btn-text:disabled { opacity: 0.4; cursor: default; }

/* "분석중" chip — used on case list rows + detail page header */
.analyzing-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--primary-soft, #eff6ff);
  color: var(--primary-strong, #1d4ed8);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  border: 1px solid color-mix(in srgb, var(--primary-strong, #1d4ed8) 25%, transparent);
}
.analyzing-chip[hidden] { display: none; }
.spinner-sm {
  display: inline-block;
  width: 9px; height: 9px;
  border: 1.5px solid color-mix(in srgb, currentColor 35%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.sidebar .footer {
  margin-top: auto;
  padding: 12px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.sidebar .footer .who { font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; font-size: 13px; }
.sidebar .footer a { color: var(--text-muted); font-size: 12px; }
/* 사이드바 footer 의 버튼형 링크 (설정 등) — 옆의 <a> 와 톤을 맞춤 */
.sidebar .footer .footer-link {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; width: fit-content;
  background: none; border: 0; padding: 0;
  font-family: inherit; font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}
.sidebar .footer .footer-link:hover { color: var(--text-secondary); }

/* Main content */
.main {
  padding: 28px 32px 64px;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

/* Mobile top header */
.mobile-header { display: none; }
.mobile-bottom-nav { display: none; }

/* =========================================================
   Page header
   ========================================================= */
.page-title {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.035em;
  margin-bottom: 10px;
  line-height: 1.25;
}
.fav-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 999px;
  background: transparent;
  color: #B0B8C1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.fav-btn:hover { background: var(--surface-2); color: #F6A323; }
.fav-btn.is-fav { color: #F6A323; }
.fav-btn.is-fav:hover { transform: scale(1.05); }
.fav-btn:disabled { opacity: 0.5; cursor: default; }
.fav-btn .ico { width: 22px; height: 22px; }
.fav-btn-sm {
  width: 28px; height: 28px;
}
.fav-btn-sm .ico { width: 18px; height: 18px; }
.page-subtitle {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 28px;
  letter-spacing: -0.01em;
}
.page-subtitle strong { color: var(--text-secondary); font-weight: 600; }
.page-subtitle code {
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--text-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.page-subtitle-meta { color: var(--text-muted); font-weight: 500; }
.page-subtitle-meta::before { content: ' · '; }

/* =========================================================
   Action tile grid (Toss home menu style)
   ========================================================= */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.tile-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 768px) {
  .tile-grid { grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .tile-grid.cols-3 { grid-template-columns: repeat(3, 1fr); gap: 8px; }
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 8px;
  background: transparent;
  border-radius: 16px;
  border: none;
  cursor: pointer;
  transition: background 0.12s, transform 0.08s;
  text-align: center;
}
.tile { border: 1px solid transparent; transition: border-color 0.15s, background 0.15s; }
.tile:hover { background: var(--primary-soft); border-color: rgba(49, 130, 246, 0.18); }
.tile:active { transform: scale(0.95); }
.tile:focus-visible { outline: none; border-color: var(--primary); }
.tile .tile-ico {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tile .tile-ico svg { width: 24px; height: 24px; }
.tile .tile-ico.blue   { background: var(--primary-soft);  color: var(--primary-strong); }
.tile .tile-ico.green  { background: var(--success-soft);  color: var(--success); }
.tile .tile-ico.orange { background: var(--warning-soft);  color: var(--warning); }
.tile .tile-ico.red    { background: var(--danger-soft);   color: var(--danger); }
.tile .tile-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.35;
  word-break: keep-all;
  overflow-wrap: normal;
}

/* Section header */
.section-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
}
.section-bar .section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
}
.section-bar .section-title .ico { color: var(--primary); }

/* =========================================================
   Card (Toss: flat, spacious, no borders)
   ========================================================= */
.card {
  background: var(--surface);
  border-radius: 20px;
  padding: 28px;
  margin-bottom: 16px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.card.flush { padding: 0; }
.card.accent {
  background: var(--primary-soft);
}
.card h2 {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.025em;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.card h2 .count {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-strong);
  background: var(--primary-soft);
  padding: 3px 10px;
  border-radius: var(--r-pill);
  letter-spacing: 0;
}
.card h2 .ico { color: var(--primary); }
.card h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 18px 0 10px;
  letter-spacing: -0.01em;
}
.card h3:first-child { margin-top: 0; }

/* =========================================================
   Grid
   ========================================================= */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* =========================================================
   Stat (Toss hero amount)
   ========================================================= */
.stat {
  background: var(--surface);
  border-radius: 20px;
  padding: 28px;
  position: relative;
  overflow: hidden;
}
.stat .label {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}
.stat .num {
  font-size: 36px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.035em;
  line-height: 1.1;
}
.stat .num .unit { font-size: 18px; color: var(--text-muted); font-weight: 700; margin-left: 2px; letter-spacing: -0.02em; }
.stat.primary {
  background: var(--primary);
  color: white;
}
.stat.primary .label { color: rgba(255, 255, 255, 0.9); }
.stat.primary .num { color: white; }
.stat.primary .num .unit { color: rgba(255, 255, 255, 0.85); }

/* =========================================================
   Table
   ========================================================= */
table { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: auto; }
.card table { word-break: break-word; }
table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  border-bottom: 1px solid var(--border-strong);
  background: transparent;
}
table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  vertical-align: middle;
}
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: var(--surface-2); }
.kv-table th {
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
  font-weight: 500;
  width: 110px;
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.kv-table td { color: var(--text); font-weight: 500; font-size: 13px; }

/* =========================================================
   Button (Toss: one primary, rest ghost/text)
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 22px;
  border-radius: 14px;
  background: var(--primary);
  color: white !important;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.015em;
  transition: transform 0.08s ease, background 0.12s, opacity 0.12s;
  min-height: 48px;
}
.btn:hover { background: var(--primary-strong); }
.btn:active { transform: scale(0.97); }
.btn.secondary {
  background: var(--primary-soft);
  color: var(--primary-strong) !important;
}
.btn.secondary:hover { background: #DCEAFF; }
.btn.ghost {
  background: transparent;
  color: var(--primary) !important;
  min-height: unset;
  padding: 10px 14px;
  font-weight: 700;
}
.btn.ghost:hover { background: var(--primary-soft); }
.btn.accent { background: var(--primary); }
.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  min-height: 36px;
  border-radius: 10px;
  font-weight: 600;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, transform 0.08s;
  border: none;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.chip:hover { background: var(--border-strong); }
.chip:active { transform: scale(0.97); }
.chip.active { background: var(--text); color: white; }
.chip.active:hover { background: var(--text); }
.card.accent .chip {
  background: var(--surface);
  color: var(--primary-strong);
  box-shadow: 0 1px 3px rgba(10, 20, 35, 0.08);
}
.card.accent .chip:hover { background: white; box-shadow: 0 2px 8px rgba(10, 20, 35, 0.12); }
.chip-row { overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip-row::-webkit-scrollbar { display: none; }

/* =========================================================
   Inputs
   ========================================================= */
input[type="text"], input[type="tel"], input[type="password"], input[type="email"],
select, textarea {
  width: 100%;
  padding: 16px 18px;
  border: none;
  background: var(--surface-2);
  border-radius: 14px;
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
  transition: background 0.12s, box-shadow 0.12s;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); font-weight: 500; }
input:focus, select:focus, textarea:focus {
  outline: none;
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--primary);
}
label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 0 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-bar:hover { border-color: #D5DBE2; }
.search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(49, 130, 246, 0.12);
}
.search-bar input {
  border: none;
  background: transparent;
  padding: 14px 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}
.search-bar input:focus { box-shadow: none; outline: none; }
.search-bar input::placeholder { color: var(--text-muted); font-weight: 500; }
.search-bar .ico { color: var(--text-secondary); flex-shrink: 0; }
.search-bar:focus-within .ico { color: var(--primary); }

/* =========================================================
   Tag / Badge
   ========================================================= */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}
.tag.primary { background: var(--primary-soft); color: var(--primary-strong); }
.tag.success { background: var(--success-soft); color: var(--success); }
.tag.warn    { background: var(--warning-soft); color: var(--warning); }
.tag.danger  { background: var(--danger-soft); color: var(--danger); }

/* =========================================================
   Alerts
   ========================================================= */
.alert {
  padding: 14px 16px;
  border-radius: var(--r-md);
  font-size: 14px;
  margin-bottom: 16px;
  font-weight: 500;
}
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.info  { background: var(--primary-soft); color: var(--primary-strong); }
.alert.warn  { background: var(--warning-soft); color: var(--warning); }

/* =========================================================
   Role card (landing)
   ========================================================= */
.role-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 32px;
  box-shadow: var(--shadow-1);
  transition: transform 0.15s, box-shadow 0.15s;
}
.role-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.role-card .icon-wrap {
  width: 52px; height: 52px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.role-card h3 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 6px; }
.role-card p { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; line-height: 1.6; }
.landing-subtitle { color: var(--text-secondary); font-size: 14px; font-weight: 500; }

/* 로그인 폼 카드는 클릭 대상이 아니므로 hover 리프트를 쓰지 않는다 */
.landing-page .role-card:hover { transform: none; box-shadow: var(--shadow-1); }

/* =========================================================
   AI output
   ========================================================= */
.btn-full-analyze {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 100%;
  margin-top: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
  border: 0;
  border-radius: var(--r-md);
  color: #fff;
  cursor: pointer;
  transition: transform 0.05s, box-shadow 0.15s, filter 0.15s;
  box-shadow: 0 4px 12px rgba(49, 130, 246, 0.24);
}
.btn-full-analyze:hover { filter: brightness(1.04); box-shadow: 0 6px 16px rgba(49, 130, 246, 0.32); }
.btn-full-analyze:active { transform: scale(0.99); }
.btn-full-analyze-main {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 15px; font-weight: 700;
  letter-spacing: -0.01em;
}
.btn-full-analyze-main .ico { color: #fff; }
.btn-full-analyze-sub {
  font-size: 11.5px; font-weight: 500;
  color: rgba(255, 255, 255, 0.82);
}
@media (max-width: 480px) {
  .btn-full-analyze { padding: 13px 16px; }
  .btn-full-analyze-sub { display: none; }
}

.btn-draft {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 100%;
  margin-top: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border: 0;
  box-shadow: inset 0 0 0 1.5px var(--primary);
  border-radius: var(--r-md);
  color: var(--primary-strong);
  text-decoration: none;
  cursor: pointer;
  line-height: normal;
  transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
}
.btn-draft:hover {
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1.5px var(--primary), 0 4px 12px rgba(49, 130, 246, 0.16);
}
.btn-draft:active { transform: scale(0.99); }
.btn-draft-main {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 15px; font-weight: 700;
  letter-spacing: -0.01em;
}
.btn-draft-main .ico { color: var(--primary); }
.btn-draft-sub {
  font-size: 11.5px; font-weight: 500;
  color: var(--text-muted);
}
@media (max-width: 480px) {
  .btn-draft { padding: 13px 16px; }
  .btn-draft-sub { display: none; }
}

.ai-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-secondary);
  margin-top: 12px;
}
.ai-files {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--primary-soft);
  border-radius: var(--r-md);
}
.ai-files-head {
  font-size: 12px; font-weight: 600;
  color: var(--primary-strong);
  margin-bottom: 8px;
}
.ai-files-head b { font-weight: 700; }
.file-chips {
  display: flex; flex-direction: column; gap: 6px;
}
.file-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.05s, background 0.15s;
  min-width: 0;
}
a.file-chip:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
a.file-chip:active { transform: scale(0.99); }
.file-chip-folder {
  flex-shrink: 0;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 3px 8px;
  border-radius: var(--r-pill);
  white-space: nowrap;
}
.file-chip-name {
  flex: 1; min-width: 0;
  font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-chip-ext {
  flex-shrink: 0;
  font-size: 10px; font-weight: 700;
  color: var(--primary-strong);
  background: var(--primary-soft);
  padding: 2px 7px;
  border-radius: var(--r-pill);
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.ai-files-reason {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(49, 130, 246, 0.15);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.ai-output-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 14px 0 8px;
}
.ai-output-title {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.ai-output-title .ico { color: var(--primary); }
.btn-copy {
  padding: 6px 14px;
  font-size: 12px; font-weight: 600;
  color: var(--primary-strong);
  background: var(--primary-soft);
  border: 0;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-copy:hover { background: #D6E9FF; }
.btn-copy:active { background: #BFDCFF; }

.ai-output-actions {
  display: flex; gap: 6px;
}
.btn-ghost-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px;
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-ghost-pill:hover {
  color: var(--primary-strong);
  border-color: var(--primary);
  background: var(--primary-soft);
}
.btn-ghost-pill .ico { width: 13px; height: 13px; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: transparent; border: 0;
  border-radius: var(--r-pill);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }

.ai-output {
  background: var(--surface);
  color: var(--text);
  padding: 20px 22px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  max-height: 560px;
  overflow: auto;
}
/* 사건 상세 카드·인라인용 높이 제한. 모달은 패널·본문 쪽이 스크롤하므로 내부 560px 박스 제거 */
.ai-modal-body .ai-output {
  max-height: none;
  overflow: visible;
}
#ai-hist-body .ai-output,
#ai-history-modal-body .ai-output {
  max-height: none;
  overflow: visible;
}

/* ─── Markdown typography (Toss) ─── */
.markdown-body {
  font-size: 14px;
  line-height: 1.75;
  letter-spacing: -0.01em;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
}
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body > *:last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 20px 0 10px;
}
.markdown-body h1 { font-size: 20px; }
.markdown-body h2 {
  font-size: 17px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-strong);
}
.markdown-body h3 { font-size: 15px; color: var(--primary-strong); }
.markdown-body h4 { font-size: 14px; color: var(--text-secondary); }
@media (max-width: 600px) {
  .markdown-body h1 { font-size: 16px; }
  .markdown-body h2 { font-size: 14px; padding-bottom: 4px; }
  .markdown-body h3 { font-size: 13px; }
  .markdown-body h4 { font-size: 13px; }
  .markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
    margin: 14px 0 8px;
    word-break: keep-all;
  }
}
.markdown-body p { margin: 8px 0; }
.markdown-body strong { font-weight: 700; color: var(--text); }
.markdown-body em { font-style: normal; color: var(--primary-strong); }
.markdown-body ul, .markdown-body ol { padding-left: 22px; margin: 8px 0; }
.markdown-body li { margin: 4px 0; }
.markdown-body li::marker { color: var(--primary); }
.markdown-body hr {
  border: 0; border-top: 1px solid var(--border-strong);
  margin: 18px 0;
}
.markdown-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  padding: 2px 6px;
  background: var(--surface-2);
  border-radius: 6px;
  color: var(--primary-strong);
}
.markdown-body pre {
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 10px 0;
}
.markdown-body pre code { padding: 0; background: transparent; color: var(--text); }
.markdown-body blockquote {
  margin: 10px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--primary);
  background: var(--primary-soft);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--text-secondary);
}
.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
  font-size: 13px;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border-strong);
  padding: 8px 12px;
  text-align: left;
}
.markdown-body th { background: var(--surface-2); font-weight: 600; }
.markdown-body a { color: var(--primary); font-weight: 500; }
.markdown-body a:hover { text-decoration: underline; }

/* ─── AI Modal ─── */
.ai-modal {
  position: fixed; inset: 0;
  background: rgba(10, 20, 35, 0.5);
  display: none;
  align-items: center; justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: ai-modal-fade 0.15s ease-out;
}
.ai-modal.is-open { display: flex; }
@keyframes ai-modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.ai-modal-panel {
  background: var(--surface);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: min(1200px, 92vw);
  /* 화면을 다 채우지 않고, 본문은 아래 .ai-modal-body에서 스크롤 */
  max-height: min(960px, calc(100vh - 20px));
  min-height: 0;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-3);
  animation: ai-modal-slide 0.18s ease-out;
}
@keyframes ai-modal-slide {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.ai-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-strong);
}
.ai-modal-title {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700;
  color: var(--text);
}
.ai-modal-title .ico { color: var(--primary); }
.ai-modal-actions { display: flex; align-items: center; gap: 6px; }
.ai-modal-body {
  padding: 24px 28px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}
@media (max-width: 600px) {
  .ai-modal { padding: 0; }
  .ai-modal-panel {
    max-height: 100vh;
    max-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }
  .ai-modal-body { padding: 18px 18px 40px; }
}
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn .spinner {
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  margin-right: 8px;
}
.btn.is-loading {
  opacity: 0.92;
  cursor: wait;
  pointer-events: none;
}

/* ─── Case detail collapse ─── */
#case-detail-cards.is-collapsed { display: none; }

/* ─── Analyze button active state ─── */
.tile.is-active {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.tile.is-active .tile-label { color: var(--primary-strong); }
.btn-full-analyze.is-active {
  background: linear-gradient(135deg, var(--primary-strong) 0%, #1348b8 100%);
  outline: 3px solid white;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(49, 130, 246, 0.35);
}

/* ─── Analysis Accordion ─── */
.analysis-accordion-list {
  margin: -24px -28px;
}
.analysis-accordion {
  border-bottom: 1px solid var(--border);
}
.analysis-accordion:last-child { border-bottom: none; }
.analysis-accordion summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background var(--dur-1);
}
.analysis-accordion summary::-webkit-details-marker { display: none; }
.analysis-accordion summary::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform var(--dur-2) var(--ease-out-toss);
  flex-shrink: 0;
}
.analysis-accordion[open] summary::before {
  transform: rotate(45deg);
}
.analysis-accordion[open] summary {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.analysis-accordion summary:hover { background: var(--surface-2); }

/* mode chip: 분석 종류 시각화 */
.analysis-mode-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.2px;
  background: var(--surface-2);
  color: var(--text);
  flex-shrink: 0;
}
.analysis-mode-chip.mode-strategy   { background: rgba(49, 130, 246, .12); color: #1d4ed8; }
.analysis-mode-chip.mode-precedent  { background: rgba(139, 92, 246, .12); color: #6d28d9; }
.analysis-mode-chip.mode-evidence   { background: rgba(249, 115, 22, .12); color: #c2410c; }
.analysis-mode-chip.mode-full       { background: rgba(16, 185, 129, .12); color: #047857; }
.analysis-mode-chip.mode-management { background: rgba(20, 184, 166, .12); color: #0f766e; }

/* 메타: 날짜 · 사용자 (우측 정렬) */
.analysis-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 0;
  flex-shrink: 1;
}
.analysis-meta .analysis-date {
  font-variant-numeric: tabular-nums;
}
.analysis-meta .analysis-author {
  font-weight: 500;
  color: var(--text-secondary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.analysis-meta .analysis-author.is-auto {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(20, 184, 166, .10);
  color: #0f766e;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 11px;
}

.analysis-accordion-body {
  padding: 16px 20px 20px;
  background: var(--bg);
}

@media (max-width: 600px) {
  .analysis-accordion summary { padding: 12px 16px; gap: 8px; }
  .analysis-meta { gap: 6px; font-size: 11px; }
  .analysis-meta .analysis-author { max-width: 80px; }
}
.analysis-attached {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.analysis-attached span {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  padding: 1px 7px;
  border-radius: 4px;
  margin-right: 4px;
  margin-bottom: 4px;
}
@media (max-width: 600px) {
  .analysis-accordion-list { margin: -18px -18px; }
}

/* =========================================================
   Full-analysis tabs
   ========================================================= */
.full-analysis-tabs {
  margin-top: 12px;
}
.full-tab-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 0;
  border-bottom: 2px solid var(--border);
}
.full-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  cursor: pointer;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.full-tab-btn .tab-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.full-tab-btn:hover { background: var(--surface-2); color: var(--text); }

.full-tab-btn.strategy.is-active  { color: var(--primary-strong);  border-bottom-color: var(--primary-strong);  background: var(--primary-soft); }
.full-tab-btn.precedent.is-active { color: var(--success);          border-bottom-color: var(--success);         background: var(--success-soft); }
.full-tab-btn.evidence.is-active  { color: var(--warning);          border-bottom-color: var(--warning);         background: var(--warning-soft); }

.full-tab-btn.strategy  .tab-dot  { background: var(--primary-strong); }
.full-tab-btn.precedent .tab-dot  { background: var(--success); }
.full-tab-btn.evidence  .tab-dot  { background: var(--warning); }

.full-tab-pane { display: none; }
.full-tab-pane.is-active { display: block; }

.full-tab-body {
  padding: 20px 0 4px;
}
.full-tab-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 13px;
}

/* =========================================================
   Bar chart
   ========================================================= */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row {
  display: grid;
  grid-template-columns: 140px 1fr 60px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}
.bar-row .bar-wrap {
  background: var(--surface-2);
  border-radius: var(--r-pill);
  height: 10px;
  overflow: hidden;
}
.bar-row .bar {
  height: 100%;
  width: var(--bw, 0%);
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-strong) 100%);
  border-radius: var(--r-pill);
}
.bar-row .val {
  text-align: right;
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* =========================================================
   Timeline (schedules)
   ========================================================= */
.timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 6px 0;
}
.timeline-item {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 16px;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  align-items: center;
}
.timeline-item.upcoming { background: var(--primary-soft); }
.timeline-item.important { background: var(--warning-soft); }
.timeline-item .date-box {
  text-align: center;
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 6px 0;
  box-shadow: var(--shadow-1);
}
.timeline-item .date-box .d { font-size: 20px; font-weight: 700; color: var(--text); line-height: 1.1; }
.timeline-item .date-box .m { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.timeline-item .body .t {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.timeline-item .body .meta { font-size: 12px; color: var(--text-muted); }
.timeline-item .body .result {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  padding-top: 6px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* =========================================================
   Progress feed
   ========================================================= */
.feed { display: flex; flex-direction: column; }
.feed-day { padding: 14px 0; border-bottom: 1px solid var(--border); }
.feed-day:last-child { border-bottom: none; }
.feed-day .date {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.feed-day .entry {
  padding: 10px 0 10px 14px;
  border-left: 2px solid var(--border-strong);
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
}
.feed-day .entry + .entry { margin-top: 4px; }
.feed-day .entry .author { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

/* =========================================================
   Memo (Toss message/notification list style)
   ========================================================= */
.memo-list { display: flex; flex-direction: column; }
.memo {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 14px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
}
.memo:first-child { padding-top: 4px; }
.memo:last-child { border-bottom: none; padding-bottom: 4px; }

.memo .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  text-transform: uppercase;
}
.memo.pinned .avatar {
  background: var(--text);
  color: white;
}

.memo .body { min-width: 0; }
.memo .head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.memo .head .name {
  font-weight: 700;
  color: var(--text);
  font-size: 15px;
  letter-spacing: -0.015em;
}
.memo .head .date {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.memo .head .pin-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-strong);
}
.memo .head .pin-tag .ico { width: 12px; height: 12px; }
.memo .title-line {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-strong);
  background: var(--primary-soft);
  padding: 3px 10px;
  border-radius: var(--r-pill);
  display: inline-block;
  margin-bottom: 8px;
}
.memo .content {
  white-space: pre-wrap;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.65;
}

/* =========================================================
   Closing / Payments
   ========================================================= */
.money-hero {
  background: var(--primary-soft);
  border-radius: 18px;
  padding: 24px;
  margin-bottom: 20px;
}
.money-hero .label {
  font-size: 13px;
  color: var(--primary-strong);
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.money-hero .amount {
  font-size: 34px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.04em;
  line-height: 1.1;
}
.money-hero .amount .unit { font-size: 20px; color: var(--text-secondary); margin-left: 2px; font-weight: 700; }
.money-hero .sub {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid rgba(27, 100, 218, 0.12);
}
.money-hero .sub span { font-weight: 600; }
.money-hero .sub span strong { color: var(--text); font-weight: 800; margin-left: 4px; letter-spacing: -0.01em; }

.payment-row {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.payment-row:last-child { border-bottom: none; }
.payment-row .date { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.payment-row .method { color: var(--text); }
.payment-row .method .sub { font-size: 12px; color: var(--text-muted); }
.payment-row .amount { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

/* =========================================================
   Client / Party / Agency cards
   ========================================================= */
.mini-card {
  padding: 14px 0;
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.mini-card:last-child { border-bottom: none; padding-bottom: 4px; }
.mini-card:first-of-type { padding-top: 4px; }
.mini-card .name {
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.mini-card .meta { color: var(--text-secondary); font-size: 13px; line-height: 1.7; }
.mini-card .meta > div { margin-top: 2px; }
.mini-card .meta .row { display: flex; gap: 8px; align-items: center; color: var(--text-secondary); }
.mini-card .meta .ico { color: var(--text-muted); }

/* =========================================================
   Icons
   ========================================================= */
.ico { width: 18px; height: 18px; display: inline-block; vertical-align: -3px; flex-shrink: 0; }
.ico-sm { width: 14px; height: 14px; }
.ico-lg { width: 24px; height: 24px; }

/* =========================================================
   Pagination
   ========================================================= */
.pagination {
  display: flex;
  justify-content: center;
  gap: 2px;
  flex-wrap: wrap;
  margin-top: 24px;
}
.pagination .btn-sm {
  min-width: 40px;
  background: transparent;
  color: var(--text-secondary) !important;
  font-weight: 600;
  min-height: 40px;
  border-radius: 10px;
}
.pagination .btn-sm:hover { background: var(--surface-2); }
.pagination .btn-sm.secondary { background: transparent; color: var(--text-secondary) !important; }
.pagination .btn-sm:not(.secondary):not([href]) {
  background: var(--text);
  color: white !important;
}

/* =========================================================
   Filter form (responsive)
   ========================================================= */
.filter-form {
  display: grid;
  grid-template-columns: 1fr 180px auto;
  gap: 12px;
  align-items: end;
}
@media (max-width: 768px) {
  /* 압축: [검색 input | 유형 select] 한 줄, 별도 검색 버튼 제거(엔터로 제출), label 시각적 숨김 */
  .filter-form {
    grid-template-columns: 1fr 104px;
    gap: 8px;
    align-items: center;
  }
  .filter-form > div { min-width: 0; }
  .filter-form button[type="submit"] { display: none; }
  .filter-form label {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .filter-form .search-bar { padding: 0 12px; }
  .filter-form .search-bar input { padding: 12px 0; }
  .filter-form select { padding: 13px 10px; }
}

/* =========================================================
   Case list (responsive: table on desktop, cards on mobile)
   ========================================================= */
.case-list { display: flex; flex-direction: column; }
.case-list .head, .case-list .row {
  display: grid;
  grid-template-columns: minmax(0, 2.4fr) 180px 120px 140px 110px 64px 56px 20px;
  gap: 12px;
  align-items: center;
  padding: 14px 12px;
  font-size: 14px;
}
.case-list .head {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-strong);
  padding-top: 4px;
  padding-bottom: 10px;
}
/* 본문 분석/채팅 아이콘과 같은 세로축에 오도록 헤더 정렬 통일 */
.case-list .head > div:nth-child(6),
.case-list .head > div:nth-child(7) {
  text-align: center;
}
.case-list .head > div:nth-child(8) {
  text-align: right;
}
.case-list .row {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.case-list .row:last-child { border-bottom: none; }
.case-list .row:hover { background: var(--surface-2); }
.case-list .row .title { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 사건명 본문 — 폭이 부족할 때만 ellipsis (서버측 글자수 컷 없음) */
.case-list .row .title .case-title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 유형 — 대분류 배지 + 소분류 텍스트를 두 줄에서 한 줄로 */
.case-list .row .category {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.case-list .row .category > .tag { flex: 0 0 auto; }
.case-list .row .case-category-sub {
  min-width: 0;
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 종결 표시 — 상단 필터가 '전체'·'즐겨찾기' 일 때만 노출되는 중립 배지 */
.case-list .row .title .case-status-tag {
  flex: 0 0 auto;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}
.case-list .row .muted-cell { color: var(--text-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-list .row .analysis-cell {
  text-align: center;
  cursor: default;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  min-width: 0;
  gap: 6px;
}
.mgmt-auto-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #CCFBF1;
  color: #0F766E;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: -0.2px;
  vertical-align: middle;
}
.mgmt-auto-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #14B8A6;
  box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.18);
}
/* 사건 목록 안에서는 색은 유지하고 크기만 축소 — 상태 신호는 남기되 행 높이를 키우지 않음 */
.case-list .row .title .mgmt-auto-badge {
  flex: 0 0 auto;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}
.case-list .row .analysis-eye-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  line-height: 0;
  transition: color 0.12s ease, background 0.12s ease, transform 0.08s ease;
}
.case-list .row .analysis-eye-btn:hover {
  color: var(--text-secondary);
  background: var(--surface-2);
}
.case-list .row .analysis-eye-btn:active {
  transform: scale(0.95);
}
.case-list .row .analysis-eye-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.case-list .row .analysis-eye-btn .ico {
  width: 18px;
  height: 18px;
  display: block;
  vertical-align: unset;
}
.case-list .row .analysis-eye-btn svg {
  display: block;
  /* stroke 아이콘 시각적 중심 보정 */
  transform: translateY(0.5px);
}
.case-list .row .analysis-link { min-width: 32px; padding: 6px 8px; }
.case-list .row .chev { color: var(--text-muted); text-align: right; }

/* 사건별 AI 채팅 진입 (서면 작성) */
.case-list .row .chat-cell {
  cursor: default;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  min-width: 0;
}
.case-chat-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  line-height: 0;
  transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.case-chat-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-soft);
}
.case-chat-btn:active { transform: scale(0.95); }
.case-chat-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.case-chat-btn .ico { width: 17px; height: 17px; display: block; vertical-align: unset; }
.case-chat-btn-label { display: none; }

@media (max-width: 768px) {
  .case-list .head { display: none; }

  /* 각 사건을 독립된 카드로 분리 — 탭 영역과 그룹핑을 시각화 */
  .case-list .row {
    display: block;
    padding: 14px 14px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    position: relative;
  }
  .case-list .row:last-child { margin-bottom: 0; border-bottom: 1px solid var(--border); }
  .case-list .row:active { background: var(--surface-2); }
  .case-list .row:hover { background: var(--surface); }
  .case-list .row > * { display: block; }

  /* 제목 행: 즐겨찾기 + 사건명 + AI관리/종결/분석중 마커 */
  .case-list .row .title {
    display: flex !important;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.4;
    white-space: normal;
    margin-bottom: 8px;
  }
  .case-list .row .title .case-title-text {
    flex: 1 1 auto;
    min-width: 0;
    word-break: keep-all;
  }
  /* 즐겨찾기 별: 모바일에서 탭 영역 확대 */
  .case-list .row .fav-btn-sm {
    width: 32px !important;
    height: 32px !important;
    margin: -4px 0;
    flex-shrink: 0;
  }
  .case-list .row .fav-btn-sm .ico {
    width: 20px !important;
    height: 20px !important;
  }

  /* 카테고리 행 */
  .case-list .row .category { margin-bottom: 8px; }

  /* 메타 정보: 줄단위 키-값 grid (라벨 폭 고정) */
  .case-list .row .muted-cell {
    display: grid !important;
    grid-template-columns: 56px 1fr;
    gap: 8px;
    align-items: baseline;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0 0 4px 0;
    white-space: normal;
  }
  .case-list .row .muted-cell:last-of-type { margin-bottom: 0; }
  .case-list .row .muted-cell::before {
    content: attr(data-label);
    color: var(--text-disabled);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0;
    margin-right: 0;
  }

  /* 사건명 한 줄 유지 — 폭 부족 시 wrap 대신 ellipsis */
  .case-list .row .title {
    min-height: 24px;
    flex-wrap: nowrap;
    overflow: hidden;
    min-width: 0;
  }
  .case-list .row .title .case-title-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .case-list .row .analysis-cell { display: none; }
  .case-list .row .chev { display: none; }

  /* 채팅 진입은 모바일에서도 유지 — 카드 하단 전체폭 액션 버튼 */
  .case-list .row .chat-cell {
    display: block;
    margin-top: 10px;
  }
  .case-chat-btn {
    width: 100%;
    height: 38px;
    line-height: normal;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    border-color: var(--border);
  }
  .case-chat-btn-label { display: inline; }

  /* 사건 목록 outer card 의 좌우 padding 약간 줄여 inner 카드 좌우 여백 확보 */
  .card:has(> .case-list) {
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* =========================================================
   File tree
   ========================================================= */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  font-size: 13px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.breadcrumb a { color: var(--primary); font-weight: 600; }
.breadcrumb .sep { color: var(--text-disabled); }

#file-table {
  table-layout: auto;
}
#file-table .show-mobile { display: none; }
#file-table td, #file-table th { word-break: keep-all; overflow-wrap: normal; }
#file-table td:first-child { word-break: break-word; overflow-wrap: anywhere; }

@media (max-width: 768px) {
  /* Card-like list on mobile */
  #file-table, #file-table thead, #file-table tbody, #file-table tr, #file-table td { display: block; width: 100%; }
  #file-table thead { display: none; }
  #file-table tr {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    position: relative;
    min-height: 54px;
  }
  #file-table tr:last-child { border-bottom: none; }
  #file-table td {
    padding: 0;
    border: none;
    text-align: left !important;
    white-space: normal;
  }
  #file-table td.name-cell {
    font-size: 14px;
    font-weight: 600;
    padding-right: 80px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #file-table td.name-cell > a,
  #file-table td.name-cell > span {
    display: inline !important;
    white-space: nowrap;
  }
  #file-table td.name-cell svg { vertical-align: -3px; margin-right: 6px; }
  #file-table td.meta-cell {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
  }
  #file-table td.action-cell {
    position: absolute;
    top: 10px;
    right: 0;
    width: auto !important;
  }
  #file-table td.hide-mobile, #file-table th.hide-mobile, #file-table .hide-mobile { display: none !important; }
  #file-table .show-mobile { display: inline; }
  #file-table .back-row td {
    font-size: 13px;
    color: var(--text-muted);
    padding: 10px 0;
  }
}

/* =========================================================
   Mobile (≤768px): native-app shell
   ========================================================= */
@media (max-width: 768px) {
  body { background: var(--bg); overscroll-behavior-y: none; }

  /* 모바일 — mobile-header(56 + safe-area-top) + main(나머지) 두 row 명시.
     iOS notch / Dynamic Island 영역까지 헤더가 확장되도록 safe-area-inset-top 포함. */
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: calc(var(--header-h, 56px) + env(safe-area-inset-top, 0px)) 1fr;
  }
  .sidebar { display: none; }

  .mobile-header {
    display: flex;
    align-items: center;
    height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 12px 0;
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 4px;
  }
  .mobile-header .back {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px;
    color: var(--text);
  }
  .mobile-header .back:active { background: var(--surface-2); }
  .mobile-header .back.manual-text {
    width: auto;
    height: 34px;
    padding: 0 14px;
    margin-right: 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-strong);
    background: var(--primary-soft);
    border-radius: 999px;
    letter-spacing: -0.01em;
  }
  .mobile-header .back.manual-text:active { background: #D9E8FB; }
  .mobile-header .title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.025em;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-header .right { display: flex; gap: 4px; }
  .mobile-header .mobile-logout,
  .mobile-header .mobile-settings {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
  }
  .mobile-header .mobile-settings {
    background: none; border: 0; padding: 0; cursor: pointer;
  }
  .mobile-header .mobile-logout:active,
  .mobile-header .mobile-settings:active { background: var(--surface-2); color: var(--text); }
  .mobile-header .mobile-logout .ico,
  .mobile-header .mobile-settings .ico { width: 20px; height: 20px; }

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    /* border-box 환경에서 padding-bottom 이 콘텐츠 영역을 침범하지 않도록
       safe-area 만큼 height 도 함께 늘림 (PWA / home indicator 영역 대응) */
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .mobile-bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-disabled);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: -0.01em;
  }
  .mobile-bottom-nav a.active { color: var(--text); }
  .mobile-bottom-nav a.active .ico { color: var(--text); }
  .mobile-bottom-nav a:active { opacity: 0.6; }

  /* 모달 열림 시 모바일 헤더/하단 네비 숨김 — 백드롭 너머로 비치는 UI 정리 */
  body:has(.ai-modal.is-open) .mobile-bottom-nav,
  body:has(.ai-modal.is-open) .mobile-header { display: none; }

  .main {
    padding: 20px 20px calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 24px);
  }

  .app.no-chrome .main { padding: 20px; }

  .page-title { font-size: 26px; letter-spacing: -0.03em; }
  .page-subtitle { font-size: 14px; }
  .page-subtitle-meta { display: block; margin-top: 6px; }
  .page-subtitle-meta::before { content: ''; }
  .card { padding: 20px; border-radius: 16px; margin-bottom: 12px; }
  .card h2 { font-size: 17px; margin-bottom: 14px; letter-spacing: -0.02em; }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  .stat .num { font-size: 26px; }

  table { font-size: 13px; }
  table th, table td { padding: 10px 8px; }

  .timeline-item { grid-template-columns: 56px 1fr; padding: 12px; }

  .payment-row { grid-template-columns: 80px 1fr auto; }

  .bar-row { grid-template-columns: 90px 1fr 50px; font-size: 12px; }

  .btn { font-size: 14px; padding: 12px 16px; }

  input, select, textarea { font-size: 16px; } /* prevent iOS zoom */
}

/* =========================================================
   Scrollbar (webkit)
   ========================================================= */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* =========================================================
   Utilities
   ========================================================= */
.muted { color: var(--text-muted); }
.empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 12px;
}
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm { gap: 8px; }
.gap-md { gap: 12px; }
.wrap { flex-wrap: wrap; }
.text-right { text-align: right; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mb-none { margin-bottom: 0; }

/* =========================================================
   Motion layer (Toss-inspired animations)
   ========================================================= */

/* Smooth scroll like native apps */
html { scroll-behavior: smooth; }

/* Re-tune existing transitions with Toss easing */
.sidebar .nav-item {
  transition: background var(--dur-2) var(--ease-out-toss),
              color var(--dur-2) var(--ease-out-toss),
              transform var(--dur-1) var(--ease-out-toss);
}
.sidebar .nav-item:active { transform: scale(0.98); }

.tile {
  transition: background var(--dur-2) var(--ease-out-toss),
              border-color var(--dur-2) var(--ease-out-toss),
              transform var(--dur-1) var(--ease-out-toss),
              box-shadow var(--dur-2) var(--ease-out-toss);
}
.tile:hover { transform: translateY(-1px); }
.tile:active { transform: scale(0.94); transition-duration: 80ms; }

.btn {
  transition: background var(--dur-2) var(--ease-out-toss),
              transform var(--dur-1) var(--ease-out-toss),
              box-shadow var(--dur-2) var(--ease-out-toss),
              opacity var(--dur-2) var(--ease-out-toss);
}
.btn:active { transform: scale(0.96); transition-duration: 80ms; }

.chip { transition: background var(--dur-2) var(--ease-out-toss),
                     color var(--dur-2) var(--ease-out-toss),
                     transform var(--dur-1) var(--ease-out-toss); }
.chip:active { transform: scale(0.94); transition-duration: 80ms; }

.role-card { transition: transform var(--dur-3) var(--ease-out-toss),
                         box-shadow var(--dur-3) var(--ease-out-toss); }
.role-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-3); }

.case-list .row { transition: background var(--dur-2) var(--ease-out-toss),
                              transform var(--dur-1) var(--ease-out-toss); }
.case-list .row:active { transform: scale(0.995); }
/* 분석기록 칸만 누를 때는 행 전체 눌림·스케일 없이 버튼만 반응 */
.case-list .row:has(.analysis-cell button:active) { transform: none; }
.case-list .row:has(.analysis-cell:hover) { background: transparent; }

/* Memo / list row press feedback on mobile */
@media (max-width: 768px) {
  .memo, .mini-card { transition: background var(--dur-2) var(--ease-out-toss),
                                   transform var(--dur-1) var(--ease-out-toss); }
  .memo:active, .mini-card:active { transform: scale(0.995); }
}

/* ─── Page entrance: staggered fade-up ─── */
@keyframes toss-fade-up {
  from { opacity: 0; transform: translate3d(0, 14px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}
.anim-in {
  opacity: 0;
  animation: toss-fade-up var(--dur-4) var(--ease-out-toss) forwards;
  animation-delay: calc(var(--i, 0) * 55ms);
  will-change: transform, opacity;
}

/* ─── Main content reveal on every navigation ─── */
@keyframes toss-main-enter {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.main { animation: toss-main-enter 320ms var(--ease-out-toss) both; }

/* ─── Mobile header/bottom nav slide-in on load ─── */
@keyframes toss-slide-down {
  from { opacity: 0; transform: translate3d(0, -6px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes toss-slide-up {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}
.mobile-header { animation: toss-slide-down 320ms var(--ease-out-toss) both; }
.mobile-bottom-nav { animation: toss-slide-up 360ms var(--ease-out-toss) both; }

/* Bottom nav active indicator (animated pill) */
.mobile-bottom-nav a {
  position: relative;
  /* home indicator(safe-area)가 padding-bottom 으로 빠지면서 콘텐츠가 박스 전체 기준
     위쪽으로 치우쳐 보이던 문제 보정 — safe-area 절반만큼 콘텐츠 아래로 이동 */
  transform: translateY(calc(env(safe-area-inset-bottom, 0px) * 0.5));
  transition: color var(--dur-2) var(--ease-out-toss);
}
.mobile-bottom-nav a .ico {
  transition: transform var(--dur-3) var(--ease-spring),
              color var(--dur-2) var(--ease-out-toss);
}
.mobile-bottom-nav a.active .ico { transform: translateY(-2px) scale(1.08); }
.mobile-bottom-nav a::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 50%;
  width: 28px; height: 3px;
  border-radius: 999px;
  background: var(--text);
  transform: translateX(-50%) scaleX(0);
  transform-origin: center;
  transition: transform var(--dur-3) var(--ease-spring), opacity var(--dur-2);
  opacity: 0;
}
.mobile-bottom-nav a.active::before { transform: translateX(-50%) scaleX(1); opacity: 1; }
.mobile-bottom-nav a:active { transform: scale(0.96); }

/* Sidebar active indicator bar */
.sidebar .nav-item { position: relative; }
.sidebar .nav-item::before {
  content: "";
  position: absolute;
  left: 4px; top: 50%;
  width: 3px; height: 0;
  background: var(--primary);
  border-radius: 2px;
  transform: translateY(-50%);
  transition: height var(--dur-3) var(--ease-spring);
}
.sidebar .nav-item.active::before { height: 18px; }

/* ─── Tile icon subtle lift ─── */
.tile .tile-ico { transition: transform var(--dur-3) var(--ease-spring); }
.tile:hover .tile-ico { transform: translateY(-2px) scale(1.04); }
.tile:active .tile-ico { transform: scale(0.96); transition-duration: 80ms; }

/* ─── Favorite pop ─── */
@keyframes toss-fav-pop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.35) rotate(-8deg); }
  70%  { transform: scale(0.92) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}
.fav-btn.is-popping { animation: toss-fav-pop 420ms var(--ease-spring); }

/* ─── Modal / Bottom sheet ─── */
.ai-modal { animation: toss-fade 200ms var(--ease-out-toss); }
@keyframes toss-fade { from { opacity: 0; } to { opacity: 1; } }
.ai-modal-panel {
  animation: toss-modal-pop 280ms var(--ease-spring);
}
@keyframes toss-modal-pop {
  from { transform: translateY(16px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
@media (max-width: 600px) {
  .ai-modal { align-items: flex-end; }
  .ai-modal-panel {
    border-radius: 20px 20px 0 0 !important;
    max-height: 92vh !important;
    max-height: 92dvh !important;
    height: auto !important;
    animation: toss-sheet-up 340ms var(--ease-out-toss);
  }
  @keyframes toss-sheet-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  /* Drag handle */
  .ai-modal-panel::before {
    content: "";
    display: block;
    width: 36px; height: 4px;
    border-radius: 999px;
    background: var(--border-strong);
    margin: 8px auto 2px;
    flex-shrink: 0;
  }
}

/* ─── Skeleton shimmer ─── */
@keyframes toss-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg,
              var(--surface-2) 0%,
              #EDF0F3 50%,
              var(--surface-2) 100%);
  background-size: 800px 100%;
  animation: toss-shimmer 1.4s linear infinite;
  border-radius: var(--r-sm);
  color: transparent !important;
  pointer-events: none;
}

/* ─── Count-up: mono-spaced for smooth tick ─── */
.stat .num, .money-hero .amount { font-variant-numeric: tabular-nums; }

/* ─── Input focus micro bounce ─── */
input[type="text"], input[type="tel"], input[type="password"], input[type="email"],
select, textarea {
  transition: background var(--dur-2) var(--ease-out-toss),
              box-shadow var(--dur-2) var(--ease-out-toss),
              transform var(--dur-1) var(--ease-out-toss);
}
input:focus, select:focus, textarea:focus { transform: translateY(-1px); }

/* ─── Spinner smoother ─── */
.spinner { animation: spin 0.85s var(--ease-in-out-toss) infinite; }

/* ─── Past-analysis indicator (replaces model badge) ─── */
.hist-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px 6px 12px;
  min-width: 160px;
  background: var(--primary-soft);
  color: var(--primary-strong) !important;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  border: none;
  border-radius: var(--r-pill);
  text-decoration: none !important;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--dur-2) var(--ease-out-toss),
              transform var(--dur-1) var(--ease-out-toss);
  animation: hist-fade-in 420ms var(--ease-out-toss);
}
.hist-indicator:hover { background: #DCEAFF; }
.hist-indicator:active { transform: scale(0.96); }
.hist-indicator strong { font-weight: 800; }
.hist-indicator .ico { width: 12px; height: 12px; color: var(--primary-strong); }
.hist-indicator .hist-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--primary);
  position: relative;
  flex-shrink: 0;
}
.hist-indicator .hist-dot::after {
  content: "";
  position: absolute; inset: -3px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.45;
  animation: hist-pulse 1.6s var(--ease-out-toss) infinite;
}
@keyframes hist-pulse {
  0%   { transform: scale(0.7); opacity: 0.5; }
  70%  { transform: scale(1.8); opacity: 0; }
  100% { transform: scale(1.8); opacity: 0; }
}
@keyframes hist-fade-in {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Smooth anchor scroll offset on mobile (so sticky header doesn't cover) */
#ai-history { scroll-margin-top: 72px; }

/* ─── 분석 모드 진행 chip (각 타일 / 종합 버튼 안) ─── */
.tile { position: relative; }
.btn-full-analyze { position: relative; }

.mode-chip {
  position: absolute;
  top: 6px;
  right: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  z-index: 1;
}
.mode-chip[hidden] { display: none; }
.mode-chip:hover { filter: brightness(0.97); }

.mode-chip-running {
  background: var(--primary-soft);
  color: var(--primary-strong);
  border-color: color-mix(in srgb, var(--primary-strong, #1d4ed8) 25%, transparent);
}
.mode-chip-done {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}
.mode-chip-done.is-viewing {
  background: #15803d;
  color: #fff;
  border-color: #15803d;
}
.mode-chip-error {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

/* 종합 버튼은 흰 글자 위에 chip 이 잘 보이도록 강한 배경 */
.btn-full-analyze .mode-chip {
  background: rgba(255,255,255,0.95);
  color: var(--primary-strong);
  border-color: rgba(255,255,255,0.9);
}
.btn-full-analyze .mode-chip-done { background: #dcfce7; color: #15803d; border-color: #86efac; }
.btn-full-analyze .mode-chip-done.is-viewing { background: #15803d; color: #fff; border-color: #15803d; }
.btn-full-analyze .mode-chip-error { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }

/* 좁은 확인 모달 패널 */
.ai-modal-panel-sm {
  max-width: 460px !important;
  width: calc(100vw - 32px) !important;
  max-height: 90vh !important;
  max-height: 90dvh !important;
}

/* 모바일에서 chip 폰트 살짝 크게 (탭하기 쉽게) */
@media (max-width: 768px) {
  .mode-chip { font-size: 11px; padding: 4px 9px; top: 5px; right: 5px; }
  .ai-modal-panel-sm { width: calc(100vw - 16px) !important; }
}

/* ─── 모바일 랜딩(로그인) 화면: 스크롤 없는 단일 뷰포트 레이아웃 ─── */
@media (max-width: 768px) {
  .landing-page { max-width: 420px !important; }
}
@media (max-width: 480px) {
  .landing-hero { margin-bottom: 20px !important; }
  .landing-subtitle { font-size: 12px !important; }
  .landing-footer { margin-top: 20px !important; font-size: 11px !important; }
  .landing-page .role-card { padding: 20px !important; }
  .landing-page .role-card label { font-size: 12px !important; margin-bottom: 4px !important; }
  .landing-page .role-card input[type="text"],
  .landing-page .role-card input[type="password"] { padding: 11px 14px !important; font-size: 14px !important; border-radius: 10px !important; }
  .landing-page .role-card .btn { padding: 12px 16px !important; font-size: 14px !important; }
}

/* ─── Accessibility: respect reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .anim-in { opacity: 1 !important; transform: none !important; }
}

/* =========================================================
   AI 사건 관리 결과 (사건 상세 + 분석기록 모달 공통)
   ========================================================= */
.mgmt-section { margin-bottom: 16px; }
.mgmt-section-last,
.mgmt-section:last-child { margin-bottom: 0; }
.mgmt-section-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: -0.2px;
}
.mgmt-summary-box {
  padding: 14px 16px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  line-height: 1.7;
  font-size: 14px;
  color: var(--text);
}
.mgmt-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px 0;
}
.mgmt-card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mgmt-action-card,
.mgmt-risk-card {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.mgmt-risk-card { border-left: 3px solid #f59e0b; }
.mgmt-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.mgmt-card-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  word-break: keep-all;
}
.mgmt-card-detail {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  word-break: keep-all;
}
.mgmt-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}
.mgmt-missing-list {
  margin: 0;
  padding-left: 20px;
}
.mgmt-missing-list li {
  margin-bottom: 4px;
  line-height: 1.6;
  font-size: 13px;
  word-break: keep-all;
}
.mgmt-missing-reason { color: var(--text-muted); }
.mgmt-pri-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -0.2px;
  flex-shrink: 0;
}
.mgmt-pri-chip.high { background: #fee2e2; color: #b91c1c; }
.mgmt-pri-chip.med  { background: #fef3c7; color: #92400e; }
.mgmt-pri-chip.low  { background: #e5e7eb; color: #374151; }

/* 모바일 보정 — 사건 상세 카드 + 모달 공통 */
@media (max-width: 600px) {
  .mgmt-summary-box { padding: 12px 14px; font-size: 13px; line-height: 1.65; }
  .mgmt-action-card,
  .mgmt-risk-card { padding: 10px 12px; }
  .mgmt-card-title { font-size: 13px; }
  .mgmt-card-detail { font-size: 12.5px; }
  .mgmt-card-meta { font-size: 11px; }
  .mgmt-missing-list { padding-left: 18px; }
  .mgmt-missing-list li { font-size: 12.5px; }
  .mgmt-section { margin-bottom: 14px; }
  .mgmt-section-title { font-size: 12px; margin-bottom: 6px; }
}

/* AI 사건 관리 카드 자체 (사건 상세) — 모바일 헤더/버튼 보정 */
@media (max-width: 600px) {
  #mgmt-card .section-bar {
    flex-wrap: wrap;
    align-items: flex-start;
    margin-bottom: 12px;
  }
  #mgmt-card .section-title {
    flex-wrap: wrap;
    font-size: 16px;
    gap: 6px;
  }
  #mgmt-card #mgmt-last-meta {
    flex-basis: 100%;
    margin-top: 2px;
    font-size: 11px;
  }
  #mgmt-card .btn-full-analyze {
    padding: 12px 14px;
  }
}

/* AI 사건 관리 — 토스 스타일 체크박스 */
.mgmt-card-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.mgmt-card-body {
  flex: 1;
  min-width: 0;
}
.mgmt-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  padding-top: 2px;
}
.mgmt-check input[type="checkbox"] {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}
.mgmt-check-box {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid #d0d4dc;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1);
  flex-shrink: 0;
}
.mgmt-check-ico {
  width: 14px;
  height: 14px;
  display: block;
}
.mgmt-check:hover .mgmt-check-box {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.mgmt-check.is-checked .mgmt-check-box,
.mgmt-check input:checked + .mgmt-check-box {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.mgmt-check input:focus-visible + .mgmt-check-box {
  box-shadow: 0 0 0 3px rgba(49, 130, 246, 0.18);
}
.mgmt-checked-meta {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
  letter-spacing: -0.2px;
  font-variant-numeric: tabular-nums;
}

/* 체크된 카드의 시각 — 옅은 톤 + 텍스트 약하게 */
.mgmt-checkable.is-checked {
  background: var(--surface-2);
}
.mgmt-checkable.is-checked .mgmt-card-title,
.mgmt-checkable.is-checked .mgmt-card-detail,
.mgmt-checkable.is-checked .mgmt-missing-body strong,
.mgmt-checkable.is-checked .mgmt-missing-reason {
  color: var(--text-muted);
}
.mgmt-checkable.is-checked .mgmt-card-title,
.mgmt-checkable.is-checked .mgmt-missing-body strong {
  text-decoration: line-through;
  text-decoration-color: rgba(0,0,0,0.25);
}
.mgmt-checkable.is-busy { opacity: 0.6; pointer-events: none; }

/* 누락 자료 li 도 row 정렬 */
.mgmt-missing-list li.mgmt-checkable {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 8px;
  margin-left: -8px;
  border-radius: 8px;
  list-style: none;
}
.mgmt-missing-list li.mgmt-checkable::marker { content: ''; }
.mgmt-missing-body { flex: 1; min-width: 0; }
ul.mgmt-missing-list:has(li.mgmt-checkable) { padding-left: 0; }

@media (max-width: 600px) {
  .mgmt-card-row { gap: 10px; }
  .mgmt-check-box { width: 20px; height: 20px; }
  .mgmt-check-meta { font-size: 10px; }
}

/* AI 사건 관리 — 분석 기록 chips */
.mgmt-history-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  margin-bottom: 4px;
}
.mgmt-history-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.mgmt-history-chip:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}
.mgmt-history-chip.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
}
.mgmt-history-chip-auto {
  display: inline-block;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(20, 184, 166, .14);
  color: #0f766e;
  letter-spacing: -0.2px;
}
.mgmt-history-chip.is-active .mgmt-history-chip-auto {
  background: rgba(255, 255, 255, .25);
  color: #fff;
}

@media (max-width: 600px) {
  .mgmt-history-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .mgmt-history-tabs::-webkit-scrollbar { height: 4px; }
  .mgmt-history-tabs::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
  .mgmt-history-chip { flex: 0 0 auto; }
}

/* ════════════════════════════════════════════════════════════════
 * 일일 업무 브리핑 모달 (토스 스타일)
 * ════════════════════════════════════════════════════════════════ */
.briefing-panel {
  max-width: min(640px, 92vw);
  max-height: min(820px, calc(100vh - 32px));
}

.briefing-body {
  padding: 0;
}

.briefing-headline {
  padding: 20px 24px 18px;
  background: linear-gradient(180deg, rgba(49,130,246,0.06), rgba(49,130,246,0));
  border-bottom: 1px solid var(--border);
}
.briefing-date {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.2px;
  margin-bottom: 4px;
}
.briefing-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
  line-height: 1.45;
}

.briefing-section {
  padding: 18px 24px 6px;
  border-bottom: 1px solid var(--border);
}
.briefing-section:last-of-type {
  border-bottom: none;
}
.briefing-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}
.briefing-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.briefing-dot-blue { background: #3182F6; }
.briefing-dot-amber { background: #F59E0B; }
.briefing-dot-rose { background: #F43F5E; }
.briefing-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 24px;
  text-align: center;
}

.briefing-empty {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--surface-2);
  border-radius: 12px;
  margin-bottom: 12px;
}

.briefing-list {
  list-style: none;
  margin: 0 0 12px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.briefing-item {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: background 120ms var(--ease-out-toss, ease-out), border-color 120ms;
}
.briefing-item:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.briefing-item-stack {
  flex-direction: column;
  gap: 4px;
}
.briefing-time {
  flex-shrink: 0;
  width: 56px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
  padding-top: 1px;
}
.briefing-time-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 78px;
}
.briefing-time-date {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}
.briefing-d {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  color: #B91C1C;
  background: rgba(244, 63, 94, 0.10);
  padding: 1px 7px;
  border-radius: 999px;
  letter-spacing: -0.2px;
}
.briefing-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.briefing-chip {
  display: inline-block;
  align-self: flex-start;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  letter-spacing: -0.2px;
}
.briefing-chip-court {
  background: rgba(244, 63, 94, 0.10);
  color: #B91C1C;
}
.briefing-chip-consult {
  background: rgba(49, 130, 246, 0.10);
  color: #1D4ED8;
}
.briefing-chip-done {
  background: rgba(107, 114, 128, 0.12);
  color: #4B5563;
}
.briefing-item.is-past {
  background: var(--surface-2, rgba(0,0,0,0.02));
  opacity: 0.62;
}
.briefing-item.is-past .briefing-item-title {
  text-decoration: line-through;
  text-decoration-color: rgba(0,0,0,0.25);
  text-decoration-thickness: 1px;
}
.briefing-item-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
  line-height: 1.45;
  word-break: keep-all;
}
.briefing-link {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px dashed var(--border-strong);
  transition: color 120ms;
}
.briefing-link:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.briefing-meta {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: -0.2px;
}
.briefing-detail {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.55;
  letter-spacing: -0.2px;
}

.briefing-focus {
  margin: 12px 24px 24px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(49,130,246,0.08), rgba(49,130,246,0.02));
  border: 1px solid rgba(49,130,246,0.15);
  border-radius: 14px;
}
.briefing-focus-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.2px;
  margin-bottom: 4px;
  text-transform: uppercase;
}
.briefing-focus-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.briefing-loading {
  padding: 60px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.briefing-spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.briefing-loading-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: -0.2px;
}
.briefing-error {
  padding: 24px;
  background: rgba(244, 63, 94, 0.06);
  border: 1px solid rgba(244, 63, 94, 0.18);
  border-radius: 14px;
  margin: 18px 24px;
}
.briefing-error strong {
  display: block;
  font-size: 14px;
  color: #B91C1C;
  margin-bottom: 4px;
}
.briefing-error-detail {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* 헤더의 "오늘의 업무" 트리거 — 사이드바 nav-item 옆 작은 아이콘 버튼 */
.briefing-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  letter-spacing: -0.2px;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.briefing-trigger:hover {
  background: rgba(49,130,246,0.06);
  color: var(--primary);
  border-color: rgba(49,130,246,0.25);
}
.briefing-trigger .ico { width: 14px; height: 14px; color: var(--primary); }

/* 모바일 헤더의 sparkle 아이콘 버튼 */
.mobile-briefing-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--text);
  cursor: pointer;
  border-radius: 10px;
  transition: background 120ms;
}
.mobile-briefing-btn:hover { background: var(--surface-2); }
.mobile-briefing-btn .ico { width: 18px; height: 18px; color: var(--primary); }

@media (max-width: 600px) {
  .briefing-panel {
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
  }
  .briefing-headline { padding: 18px 18px 16px; }
  .briefing-section { padding: 16px 18px 4px; }
  .briefing-focus { margin: 12px 18px 24px; }
  .briefing-time { width: 48px; font-size: 12px; }
  .briefing-time-stack { width: 70px; }
}

.briefing-date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.briefing-branch-tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -0.2px;
  background: rgba(20, 184, 166, 0.12);
  color: #0F766E;
  white-space: nowrap;
  cursor: default;
}
.briefing-branch-tag-soft {
  background: var(--surface-2);
  color: var(--text-secondary);
}

.briefing-chip-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.briefing-chip-branch {
  display: inline-block;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  letter-spacing: -0.2px;
  background: rgba(20, 184, 166, 0.10);
  color: #0F766E;
}

/* 일일 브리핑 — 단계별 로딩 진행 */
.briefing-loading-hint {
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: -0.2px;
  margin-top: -4px;
}
.briefing-loading-steps {
  list-style: none;
  padding: 0;
  margin: 12px 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(280px, 90%);
  text-align: left;
}
.briefing-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  letter-spacing: -0.2px;
  transition: background 200ms var(--ease-out-toss, ease-out),
              color 200ms,
              border-color 200ms;
}
.briefing-step-marker {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  position: relative;
  transition: background 200ms, border-color 200ms;
}
.briefing-step.is-active {
  background: rgba(49, 130, 246, 0.06);
  color: var(--primary);
  border-color: rgba(49, 130, 246, 0.25);
}
.briefing-step.is-active .briefing-step-marker {
  border-color: var(--primary);
  background: var(--primary);
  animation: briefing-step-pulse 1.2s ease-in-out infinite;
}
@keyframes briefing-step-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(49, 130, 246, 0.4); }
  50%      { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(49, 130, 246, 0); }
}
.briefing-step.is-done {
  color: #0F766E;
  background: rgba(20, 184, 166, 0.06);
  border-color: rgba(20, 184, 166, 0.18);
}
.briefing-step.is-done .briefing-step-marker {
  background: #14B8A6;
  border-color: #14B8A6;
}
.briefing-step.is-done .briefing-step-marker::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0;
  width: 4px;
  height: 8px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(45deg);
}

/* 일일 브리핑 — 분석 이후 새 일정 알림 배너 (헤드라인 바로 아래) */
.briefing-stale {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 24px 16px;
  padding: 12px 14px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.22);
  border-radius: 14px;
}
.briefing-stale-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #92400E;
  letter-spacing: -0.2px;
  flex: 1;
  min-width: 0;
}
.briefing-stale-text strong {
  font-weight: 700;
  color: #78350F;
}
.briefing-stale-text .ico {
  flex-shrink: 0;
  color: #F59E0B;
  width: 16px;
  height: 16px;
}
.briefing-stale-btn {
  flex-shrink: 0;
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: #F59E0B;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: -0.2px;
  transition: background 120ms var(--ease-out-toss, ease-out), transform 120ms;
}
.briefing-stale-btn:hover { background: #D97706; }
.briefing-stale-btn:active { transform: scale(0.96); }
@media (max-width: 600px) {
  .briefing-stale { margin: 0 18px 14px; flex-wrap: wrap; }
  .briefing-stale-btn { width: 100%; padding: 9px 14px; }
}

/* "오늘의 업무" 트리거 — 분석 이후 새 일정 등록됨 표시 점 배지 */
[data-briefing-open] { position: relative; }
[data-briefing-open].briefing-has-update::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #F59E0B;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
  animation: briefing-badge-pulse 1.6s ease-in-out infinite;
}
@keyframes briefing-badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
  50%      { box-shadow: 0 0 0 5px rgba(245, 158, 11, 0); }
}
/* 사이드바 nav-item 은 좌측 정렬이라 dot 위치 조정 */
.sidebar [data-briefing-open].briefing-has-update::after {
  top: 8px;
  right: 10px;
}

/* ════════════════════════════════════════════════════════════════
 * 서면·리서치 채팅 페이지
 * ════════════════════════════════════════════════════════════════ */
.chat-page {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 0px);
  height: 100dvh;
  background: var(--surface);
  overflow: hidden;
}
.main:has(.chat-page) { padding: 0; min-height: 0; overflow: hidden; }

/* 좌측 세션 목록 */
.chat-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
  min-height: 0;
}
.chat-sidebar-header {
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--border);
}
.chat-new-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.2px;
  cursor: pointer;
  transition: background 120ms var(--ease-out-toss, ease-out), border-color 120ms;
}
.chat-new-btn:hover {
  background: rgba(49, 130, 246, 0.06);
  color: var(--primary);
  border-color: rgba(49, 130, 246, 0.25);
}
.chat-new-btn .ico { width: 14px; height: 14px; }

.chat-session-list {
  list-style: none;
  margin: 0; padding: 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.chat-session-empty {
  padding: 24px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.6;
}
.chat-session-item {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-bottom: 4px;
  border-radius: 10px;
  transition: background 120ms;
}
.chat-session-item:hover { background: var(--surface); }
.chat-session-item.is-active { background: var(--surface); }
.chat-session-open {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  min-width: 0;
}
.chat-session-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}
.chat-session-item.is-active .chat-session-title { color: var(--primary); }
.chat-session-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: 11px;
  color: var(--text-secondary);
}
.chat-session-count {
  background: var(--surface-2);
  padding: 0 6px;
  border-radius: 999px;
  font-weight: 600;
}
.chat-session-item.is-active .chat-session-count { background: rgba(49,130,246,0.15); color: var(--primary); }
.chat-session-del {
  width: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 0 10px 10px 0;
  opacity: 0;
  transition: opacity 120ms, color 120ms, background 120ms;
}
.chat-session-item:hover .chat-session-del { opacity: 1; }
.chat-session-del:hover { color: #DC2626; background: rgba(244,63,94,0.06); }
.chat-session-del .ico { width: 14px; height: 14px; }

/* 우측 메인 채팅 영역 */
.chat-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
}
.chat-main-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.chat-mobile-back {
  display: none;
  width: 32px; height: 32px;
  align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--text); cursor: pointer;
  border-radius: 8px;
}
.chat-mobile-back:hover { background: var(--surface-2); }
.chat-mobile-back .ico { width: 18px; height: 18px; }
.chat-current-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-empty {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 20px;
  text-align: center;
}
.chat-empty-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(49,130,246,0.08);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
}
.chat-empty-icon .ico { width: 28px; height: 28px; }
.chat-empty-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
}
.chat-empty-hint {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 360px;
  line-height: 1.6;
}
.chat-empty-suggestions {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.chat-suggest-btn {
  padding: 9px 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: -0.2px;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.chat-suggest-btn:hover {
  background: rgba(49,130,246,0.06);
  color: var(--primary);
  border-color: rgba(49,130,246,0.25);
}

/* 메시지 버블 */
.chat-msg { display: flex; flex-direction: column; max-width: 100%; gap: 6px; }
.chat-msg-user { align-items: flex-end; }
.chat-msg-assistant { align-items: flex-start; }
.chat-msg-bubble {
  max-width: min(860px, 90%);
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: -0.2px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.chat-msg-user .chat-msg-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg-assistant .chat-msg-bubble {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-msg-bubble p { margin: 0 0 6px; }
.chat-msg-bubble p:last-child { margin-bottom: 0; }
/* 스트리밍 중에는 본문이 '확정된 앞부분'과 '아직 자라는 끝부분' 두 상자로 나뉜다.
   그래서 문단 하나가 확정될 때마다 :last-child 가 바뀌며 아래 여백이 사라졌고,
   그때마다 읽던 글이 위로 튀었다. 자라는 동안에는 여백을 고정해 둔다. */
.chat-msg-streaming .chat-msg-bubble p:last-child { margin-bottom: 6px; }
.chat-msg-bubble a { color: var(--primary); text-decoration: underline; }
.chat-msg-user .chat-msg-bubble a { color: #fff; }
/* 번호·글머리표는 목록 상자 '바깥' 에 그려진다. margin 으로만 밀어 두면 표식이
   놓이는 자리가 말풍선의 안쪽 여백이라, 번호가 길수록 가장자리로 삐져나왔다.
   padding 으로 자리를 확보하면 표식이 상자 안에 남는다. */
.chat-msg-bubble ul, .chat-msg-bubble ol { margin: 4px 0 6px; padding-left: 22px; }
.chat-msg-bubble li { margin: 2px 0; }
.chat-msg-bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  padding: 1px 5px;
  background: rgba(0,0,0,0.05);
  border-radius: 4px;
}

/* 근거 칩 — 인용된 문장 바로 뒤에 붙는다. 클릭하면 원본 PDF 의 해당 쪽이 열린다.
   본문 줄높이를 밀지 않도록 세로 여백 대신 line-height 로 높이를 맞춘다. */
/* 근거 칩은 화면에만 있는 것이고 서면의 일부가 아니다.
   user-select 를 풀어 두었을 때는 답변을 드래그해 한글에 붙이면
   "1 26.06.18. 수신 준비서면(...).pdf, 2쪽" 이 문장 한가운데 끼어 들어갔다.
   실제로 그 상태의 준비서면이 검토까지 올라간 적이 있다(2026-08-17).
   선택에서 빼면 클릭으로 원문을 여는 기능은 그대로 두면서 복사만 깨끗해진다. */
.chat-cite {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  -webkit-user-select: none;
  user-select: none;
  margin: 0 2px;
  padding: 0 7px 0 4px;
  max-width: 100%;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 999px;
  background: var(--surface-2, #f7fafc);
  color: var(--text-muted, #4a5568) !important;
  font-size: 11px;
  line-height: 18px;
  font-weight: 600;
  text-decoration: none !important;
  vertical-align: baseline;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 열 수 있는 근거만 반응한다.
   종전에는 span(열 곳이 없는 판례·법령)도 hover 하면 파랗게 변해서, 눌러도
   아무 일이 없는 칩이 눌리는 것처럼 보였다. 원문이 있는 것과 없는 것을
   손끝에서 가르는 신호가 이 hover 하나다. */
a.chat-cite {
  cursor: pointer;
}
a.chat-cite:hover {
  border-color: var(--primary);
  color: var(--primary) !important;
  background: #fff;
}
span.chat-cite {
  cursor: default;
}
.chat-cite-num {
  flex: none;
  min-width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 9px;
  line-height: 14px;
  text-align: center;
}
/* 근거 층위 배지 — 사건기록 / 판례 / 법령 / 서면 양식.
   같은 답변 안에서 사건기록 인용과 판례 인용이 섞이므로, 무엇을 근거로 한
   문장인지 칩만 보고 갈라져야 한다. */
.chat-cite-tier {
  flex: none;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--surface-3, #edf2f7);
  color: var(--text-muted, #4a5568);
  font-size: 9px;
  line-height: 14px;
  font-weight: 700;
}
/* 판례·법령 인용은 아직 원문을 열 라우트가 없어 링크가 아니다(<span>).
   눌릴 것처럼 보이지 않게 커서와 hover 를 죽인다. */
.chat-cite-ref {
  cursor: default;
  border-style: dashed;
}
.chat-cite-ref:hover {
  border-color: var(--border, #e2e8f0);
  color: var(--text-muted, #4a5568) !important;
  background: var(--surface-2, #f7fafc);
}
/* 좌표는 맞지만 자료 이름이 이 문장의 것이라는 보장이 없는 인용.
   한 자료에 판례가 여럿 실려 있는 경우다 — 눈에 걸려야 변호사가 원문을 확인한다. */
.chat-cite-doubt {
  background: #fffaf0;
  color: #b7791f;
}
.chat-msg-user .chat-msg-bubble code { background: rgba(255,255,255,0.18); }
.chat-msg-bubble pre {
  margin: 6px 0;
  padding: 10px 12px;
  background: rgba(0,0,0,0.04);
  border-radius: 8px;
  overflow-x: auto;
}
.chat-msg-bubble table {
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 12px;
  display: block;
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.chat-msg-bubble th, .chat-msg-bubble td {
  border: 1px solid var(--border-strong);
  padding: 4px 8px;
  text-align: left;
  white-space: nowrap;
}

/* 응답 대기 (typing dots) */
.chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}
.chat-typing span {
  width: 6px; height: 6px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: chat-typing-bounce 1.2s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes chat-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ── 진행 패널 (서면 작성은 p90 156초. 그동안 무엇을 하는 중인지 보여준다) ── */
.chat-progress {
  margin: 0 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  overflow: hidden;
}
.chat-progress-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  color: var(--text-secondary);
  text-align: left;
}
.chat-progress-spinner {
  flex: none;
  width: 12px; height: 12px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: chat-progress-spin 0.8s linear infinite;
}
@keyframes chat-progress-spin { to { transform: rotate(360deg); } }
.chat-progress.is-finished .chat-progress-spinner {
  animation: none;
  border-color: var(--success);
}
.chat-progress-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.chat-progress-time {
  flex: none;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.chat-progress-caret {
  flex: none;
  color: var(--text-muted);
  transition: transform var(--dur-2) var(--ease-out-toss);
}
.chat-progress.is-collapsed .chat-progress-caret { transform: rotate(-90deg); }
.chat-progress.is-collapsed .chat-progress-body { display: none; }

/* 진행 상세 — 단계 문구가 몇 분씩 그대로인 구간에 "지금 적고 있는 것" 이 흐른다.
   단계 이름보다 한 단 낮게 보여야 무엇이 제목이고 무엇이 진행인지 헷갈리지 않는다. */
.chat-progress-detail {
  padding: 0 10px 8px 30px;      /* 스피너(12) + gap(8) + 좌패딩(10) 만큼 들여 쓴다 */
  margin-top: -2px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;          /* 쟁점 한 줄이 길다. 두 줄에서 자른다 */
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.chat-progress-detail[hidden] { display: none; }

/* REQUEST_ 왕복이 반복되면 단계가 10개를 넘을 수 있다. 진행 패널이 화면을
   잡아먹지 않도록 높이를 묶는다 (완료되면 어차피 한 줄로 접힌다). */
.chat-progress-body {
  max-height: 200px;
  padding: 0 10px 8px;
  overflow-y: auto;
}
.chat-progress-steps { margin: 0; padding: 0; list-style: none; }
.chat-progress-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 12.5px;
  color: var(--text-muted);
}
.chat-progress-step.is-running { color: var(--text-secondary); }
.chat-progress-mark {
  flex: none;
  width: 6px; height: 6px;
  margin: 0 3px;
  border-radius: 50%;
  background: var(--text-disabled);
}
.chat-progress-step.is-running .chat-progress-mark {
  background: var(--primary);
  animation: chat-progress-pulse 1.4s ease-in-out infinite;
}
.chat-progress-step.is-done .chat-progress-mark { background: var(--success); }
@keyframes chat-progress-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.45; transform: scale(0.8); }
}
.chat-progress-step-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-progress-step-time {
  flex: none;
  color: var(--text-disabled);
  font-variant-numeric: tabular-nums;
}

.chat-progress-reasoning { margin-top: 6px; }
.chat-progress-reasoning > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  list-style: none;
}
.chat-progress-reasoning > summary::-webkit-details-marker { display: none; }
.chat-progress-reasoning > summary::before {
  content: '▸ ';
  color: var(--text-disabled);
}
.chat-progress-reasoning[open] > summary::before { content: '▾ '; }
.chat-progress-reasoning-body {
  max-height: 160px;
  margin-top: 6px;
  padding: 8px 10px;
  overflow-y: auto;
  border-radius: 8px;
  background: var(--surface);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

/* 생성이 중간에 끊긴 답변 — 왜 여기서 끝났는지 알리고 재시도 경로를 준다 */
.chat-msg-aborted {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--text-secondary);
}
.chat-retry-btn {
  margin-left: auto;
  padding: 5px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}
.chat-retry-btn:hover { background: var(--primary-soft); }

.chat-loading {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 13px;
}
.chat-spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* 입력 바 */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  resize: none;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  letter-spacing: -0.2px;
  outline: none;
  max-height: 180px;
  transition: border-color 120ms;
}
.chat-input:focus { border-color: var(--primary); }
.chat-input:disabled { opacity: 0.6; cursor: not-allowed; }
.chat-send-btn {
  width: 44px; height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: 14px;
  cursor: pointer;
  transition: background 120ms, transform 120ms;
  flex-shrink: 0;
}
.chat-send-btn:hover:not(:disabled) { background: var(--primary-strong); }
.chat-send-btn:active:not(:disabled) { transform: scale(0.95); }
.chat-send-btn:disabled { background: var(--border-strong); cursor: not-allowed; }
.chat-send-btn .ico { width: 18px; height: 18px; }

/* 모바일 — 사이드바를 슬라이드 패널처럼 */
@media (max-width: 720px) {
  /* chat 페이지 전용 — mobile-header(56 + safe-area-top) 아래부터 mobile-bottom-nav(64 + safe-area-bottom) 위까지 정확히 채움. */
  .main:has(.chat-page) {
    height: calc(100dvh - 56px - env(safe-area-inset-top, 0px));
    min-height: calc(100dvh - 56px - env(safe-area-inset-top, 0px));
    max-height: calc(100dvh - 56px - env(safe-area-inset-top, 0px));
  }
  .chat-page {
    grid-template-columns: 1fr;
    height: calc(100dvh - 56px - 64px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
  .chat-sidebar {
    position: fixed;
    /* mobile-header / bottom-nav 사이를 정확히 채우도록 safe-area 포함. */
    top: calc(56px + env(safe-area-inset-top, 0px));
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    left: 0; right: 0;
    z-index: 50;
    width: 100%;
    border-right: none;
    transform: translateX(0);
    transition: transform 220ms var(--ease-out-toss, ease-out);
  }
  .chat-sidebar.is-hidden-mobile {
    transform: translateX(-100%);
    pointer-events: none;
  }
  .chat-mobile-back { display: inline-flex; }
  .chat-thread { padding: 16px 14px 8px; }
  .chat-input-bar {
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
  }
  .chat-empty-title { font-size: 16px; }

  /* 모바일에서 메시지 버블 폭을 충분히 — 테이블 가로 스크롤 안전성 */
  .chat-msg-bubble { max-width: 92%; }
}

/* 서면·리서치 — 응답 안의 추천 질문 칩 (assistant 버블 아래) */
.chat-suggest-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(720px, 84%);
  margin-left: 38px;
}
.chat-suggest-chip {
  padding: 7px 13px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 16px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: -0.2px;
  line-height: 1.3;
  transition: background 120ms var(--ease-out-toss, ease-out), color 120ms, border-color 120ms;
  white-space: normal;
  text-align: left;
}
.chat-suggest-chip:hover {
  background: rgba(49,130,246,0.06);
  color: var(--primary);
  border-color: rgba(49,130,246,0.25);
}

/* =========================================================
   기일 캘린더 (/calendar) — 월 그리드 + 선택일 패널
   ========================================================= */
.cal-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.cal-toolbar-left { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.cal-title {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  white-space: nowrap;
}
.cal-count { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.cal-toolbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.cal-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.cal-arrow:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.cal-arrow:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.cal-arrow .ico { width: 16px; height: 16px; display: block; }
/* i-chevron-left 스프라이트가 없어 우측 화살표를 반전해 사용 */
.cal-arrow-flip { transform: scaleX(-1); }

.cal-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}
.cal-main { margin: 0; padding: 0; overflow: hidden; }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--border-strong);
}
.cal-weekdays > div {
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}
.cal-weekdays .is-sun { color: var(--danger); }
.cal-weekdays .is-sat { color: var(--primary); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: minmax(104px, auto);
}
.cal-loading { grid-column: 1 / -1; padding: 60px 0; text-align: center; color: var(--text-muted); font-size: 14px; }

.cal-day {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-width: 0;
  padding: 6px 6px 8px;
  border: none;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 100ms ease;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day:nth-child(n+36) { border-bottom: none; }
.cal-day:hover { background: var(--surface-2); }
.cal-day:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-day.is-other { background: var(--bg); }
.cal-day.is-other .cal-day-num { color: var(--text-disabled); }
.cal-day.is-selected { background: var(--primary-soft); }
.cal-day.is-selected:hover { background: var(--primary-soft); }

.cal-day-num {
  align-self: flex-start;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 22px;
  text-align: center;
}
.cal-day.is-sun .cal-day-num { color: var(--danger); }
.cal-day.is-sat .cal-day-num { color: var(--primary); }
/* 오늘 — 구글 캘린더처럼 파란 원 */
.cal-day.is-today .cal-day-num { background: var(--primary); color: #fff; }

/* 모바일 전용 점 표시 */
.cal-day-dot { display: none; }

.cal-chips { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-chip {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 11px;
  line-height: 1.35;
}
.cal-chip.is-closed { background: var(--surface-2); color: var(--text-muted); }
.cal-chip-time { flex: 0 0 auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-chip-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-chip-more { padding: 0 5px; font-size: 11px; font-weight: 600; color: var(--text-muted); }

/* ── 선택일 패널 ── */
.cal-side { margin: 0; padding: 0; position: sticky; top: 20px; }
.cal-side-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.cal-side-date { font-size: 15px; font-weight: 700; }
.cal-side-sub { font-size: 12px; font-weight: 600; color: var(--primary); }
.cal-side-list { max-height: calc(100vh - 220px); overflow-y: auto; }
.cal-side-empty { padding: 32px 16px; text-align: center; font-size: 13px; color: var(--text-muted); }

.cal-event {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: inherit;
  transition: background 100ms ease;
}
.cal-event:last-child { border-bottom: none; }
.cal-event:hover { background: var(--surface-2); }
.cal-event-time {
  flex: 0 0 auto;
  width: 40px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.6;
}
.cal-event-body { flex: 1 1 auto; min-width: 0; }
.cal-event-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cal-event-head > .tag { flex: 0 0 auto; padding: 2px 8px; font-size: 11px; }
.cal-event-title {
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-event-sub  { margin-top: 3px; font-size: 12px; color: var(--text-secondary); }
.cal-event-meta { margin-top: 2px; font-size: 11px; color: var(--text-muted); }
.cal-event-arrow { flex: 0 0 auto; color: var(--text-muted); margin-top: 4px; }

@media (max-width: 1100px) {
  .cal-body { grid-template-columns: minmax(0, 1fr); }
  .cal-side { position: static; }
  .cal-side-list { max-height: none; }
}

@media (max-width: 768px) {
  .cal-toolbar { align-items: center; margin-bottom: 12px; }
  .cal-title { font-size: 20px; }
  .cal-count { display: none; }

  /* 모바일 — 셀에 칩 대신 점만, 상세는 아래 패널에서 */
  .cal-grid { grid-auto-rows: minmax(46px, auto); }
  .cal-day {
    align-items: center;
    justify-content: flex-start;
    gap: 3px;
    padding: 5px 2px;
  }
  .cal-day-num { align-self: center; }
  .cal-chips { display: none; }
  .cal-day.has-events .cal-day-dot {
    display: block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary);
  }
  .cal-day.has-events.is-today .cal-day-dot { background: var(--primary-strong); }
  .cal-day:nth-child(n+36) { border-bottom: 1px solid var(--border); }
}

/* 캘린더 — 종결 포함 토글 / 종일 항목 */
.cal-closed-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.cal-closed-toggle input { width: 14px; height: 14px; accent-color: var(--primary); cursor: pointer; }
.cal-chip.is-allday { background: var(--surface-2); color: var(--text-secondary); }
.cal-chip.is-allday.is-closed { color: var(--text-muted); }
.cal-event-time.is-allday { font-size: 11px; font-weight: 600; color: var(--text-muted); }

/* ═══════ 설정 모달 ═══════ */
.set-body { padding: 4px 20px 8px; }
.set-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.set-section:last-child { border-bottom: 0; }
.set-label {
  display: block;
  font-size: 14px; font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.set-desc {
  display: block;
  margin-top: 4px;
  font-size: 12.5px; line-height: 1.6;
  color: var(--text-muted);
}
.set-section > select,
.set-section > textarea { margin-top: 10px; width: 100%; }
.set-section > textarea { resize: vertical; line-height: 1.6; }
.set-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
}
.set-note:empty { display: none; }
.set-counter {
  margin-top: 6px;
  text-align: right;
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* 토글 스위치 */
.set-switch-row {
  display: flex; align-items: flex-start; gap: 14px;
  cursor: pointer;
}
.set-switch-row > span:first-child { flex: 1; min-width: 0; }
.set-switch { position: relative; flex-shrink: 0; margin-top: 2px; }
.set-switch input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  margin: 0; opacity: 0; cursor: pointer;
  /* 트랙(형제 span)이 뒤에 오므로 z-index 없이는 input 위에 깔려
     스위치를 직접 클릭할 수 없다. */
  z-index: 1;
}
.set-switch-track {
  display: block;
  width: 44px; height: 26px;
  border-radius: 999px;
  background: var(--border);
  transition: background 160ms var(--ease-out-toss, ease-out);
}
.set-switch-track::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 160ms var(--ease-out-toss, ease-out);
}
.set-switch input:checked ~ .set-switch-track { background: var(--primary); }
.set-switch input:checked ~ .set-switch-track::after { transform: translateX(18px); }
.set-switch input:focus-visible ~ .set-switch-track {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* footer */
.set-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface, #fff);
}
.set-status {
  flex: 1; min-width: 0;
  font-size: 12.5px; font-weight: 600;
  color: var(--text-muted);
}
.set-status.is-ok  { color: var(--success); }
.set-status.is-err { color: var(--danger); }

/* 인라인 패널 (내 정보 페이지) — 모달 셸 대신 카드 안에 그대로 얹는다 */
.set-panel-inline .set-body { padding: 0; }
.set-panel-inline .set-section:first-child { padding-top: 4px; }
.set-panel-inline .set-actions {
  display: flex; align-items: center; gap: 8px;
  margin-top: 4px; padding-top: 14px;
  border-top: 1px solid var(--border);
}


/* ═══════════════════════════════════════════════
   의견 나눔 (피드백 · 토론의 장)
   ═══════════════════════════════════════════════ */
.fb-title-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.fb-title-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.fb-title-actions .btn { display: inline-flex; align-items: center; gap: 6px; }

.fb-back-link {
  display: inline-flex; align-items: center; gap: 5px;
  margin-bottom: 12px;
  font-size: 13px; font-weight: 600;
  color: var(--text-muted); text-decoration: none;
}
.fb-back-link:hover { color: var(--text-secondary); }

/* ─── 필터 바 */
.fb-filters {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0 14px;
}
.fb-filters .chip-row { flex: 1; min-width: 0; }
.fb-filters .chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.fb-filters .chip.is-on { background: var(--text); color: #fff; }
.fb-filters .chip.is-on:hover { background: var(--text); }
.fb-chip-n {
  font-size: 11px; font-weight: 700;
  opacity: 0.55;
}
.fb-chip-mine { margin-left: 4px; }
.fb-sort select {
  height: 34px; padding: 0 30px 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2 3.5L5 6.5L8 3.5' fill='none' stroke='%238B95A1' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center;
  font-size: 12.5px; font-weight: 600; color: var(--text-secondary);
  appearance: none; -webkit-appearance: none;
  cursor: pointer;
}

/* ─── 목록 */
.fb-list { display: flex; flex-direction: column; gap: 10px; }
.fb-item {
  display: flex; gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: background var(--dur-2) var(--ease-out-toss),
              box-shadow var(--dur-2) var(--ease-out-toss);
}
.fb-item:hover { background: var(--surface-2); box-shadow: var(--shadow-2); }
.fb-item-body { flex: 1; min-width: 0; }
.fb-item-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.fb-item-title {
  display: block;
  font-size: 15px; font-weight: 700; line-height: 1.45;
  color: var(--text); text-decoration: none;
  letter-spacing: -0.02em;
  word-break: break-word;
}
.fb-item-title:hover { color: var(--primary-strong); }
.fb-item-excerpt {
  margin: 6px 0 0;
  font-size: 13px; line-height: 1.65;
  color: var(--text-secondary);
  word-break: break-word;
}
.fb-item-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px;
  font-size: 12px; font-weight: 500; color: var(--text-muted);
}
.fb-item-comments { display: inline-flex; align-items: center; gap: 4px; }

/* ─── 공감 버튼 */
.fb-vote {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  flex-shrink: 0;
  width: 48px; min-height: 48px; padding: 6px 0;
  background: var(--surface-2);
  border: 1px solid transparent; border-radius: var(--r-md);
  font-size: 13px; font-weight: 700; color: var(--text-muted);
  cursor: pointer;
  transition: background var(--dur-2) var(--ease-out-toss),
              color var(--dur-2) var(--ease-out-toss),
              transform var(--dur-1) var(--ease-out-toss);
}
.fb-vote:hover { background: var(--border-strong); color: var(--text-secondary); }
.fb-vote:active { transform: scale(0.94); }
.fb-vote.is-on {
  background: var(--primary-soft);
  border-color: #BFDCFF;
  color: var(--primary-strong);
}
.fb-vote:disabled { opacity: 0.5; cursor: default; }
.fb-vote-lg {
  flex-direction: row; width: auto; min-height: 0;
  padding: 9px 16px; gap: 7px;
  border-radius: var(--r-pill);
  font-size: 13px;
}

/* ─── 분류 칩 / 상태 배지 */
.fb-cat-chip {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  font-size: 11.5px; font-weight: 700;
  background: var(--surface-2); color: var(--text-secondary);
}
.fb-cat-chip.cat-bug      { background: var(--danger-soft);  color: #C13540; }
.fb-cat-chip.cat-idea     { background: var(--primary-soft); color: var(--primary-strong); }
.fb-cat-chip.cat-question { background: var(--warning-soft); color: #B45309; }
.fb-cat-chip.cat-praise   { background: var(--success-soft); color: #047857; }

.fb-status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 700;
  background: var(--surface-2); color: var(--text-muted);
}
.fb-status-badge::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor;
}
.fb-status-badge.s-reviewing { background: var(--warning-soft); color: #B45309; }
.fb-status-badge.s-planned   { background: var(--primary-soft); color: var(--primary-strong); }
.fb-status-badge.s-done      { background: var(--success-soft); color: #047857; }
.fb-status-badge.s-wontfix   { background: var(--surface-2);    color: var(--text-disabled); }

.fb-mine-badge {
  padding: 3px 7px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  font-size: 11px; font-weight: 700; color: var(--text-muted);
}

.fb-empty {
  padding: 44px 20px;
  text-align: center;
  font-size: 13.5px; color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg);
}

/* ─── 글쓰기 폼 */
.fb-form { padding: 16px 20px 18px; }
.fb-field-label {
  display: block;
  margin: 16px 0 8px;
  font-size: 13px; font-weight: 700; color: var(--text);
}
.fb-field-label:first-child { margin-top: 0; }
.fb-counter { float: right; font-weight: 600; color: var(--text-disabled); font-size: 11.5px; }
.fb-cat-pick { margin-bottom: 4px; }
.fb-input, .fb-textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface);
  font-family: inherit; font-size: 14px; line-height: 1.6; color: var(--text);
  transition: border-color var(--dur-2) var(--ease-out-toss);
}
.fb-textarea { resize: vertical; }
.fb-input:focus, .fb-textarea:focus {
  outline: none; border-color: var(--primary);
}
.fb-input::placeholder, .fb-textarea::placeholder { color: var(--text-disabled); }

.fb-anon {
  display: flex; align-items: flex-start; gap: 8px;
  margin-top: 14px;
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  cursor: pointer;
}
.fb-anon input { margin-top: 2px; accent-color: var(--primary); }
.fb-anon em { font-style: normal; font-weight: 500; color: var(--text-muted); }

.fb-form-foot {
  display: flex; align-items: center; gap: 10px;
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.fb-form-btns { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ─── 상세 */
.fb-detail { margin-bottom: 14px; }
.fb-detail-title {
  margin: 10px 0 0;
  font-size: 21px; font-weight: 800; line-height: 1.4;
  letter-spacing: -0.03em; color: var(--text);
  word-break: break-word;
}
.fb-detail-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px;
  font-size: 12.5px; font-weight: 500; color: var(--text-muted);
}
.fb-detail-page code {
  padding: 1px 5px;
  background: var(--surface-2); border-radius: 4px;
  font-size: 11.5px;
}
.fb-detail-content {
  margin-top: 18px; padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 14.5px; line-height: 1.8; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}
.fb-detail-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 22px; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.fb-status-pick {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--text-muted);
}
.fb-status-pick select {
  height: 34px; padding: 0 30px 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2 3.5L5 6.5L8 3.5' fill='none' stroke='%238B95A1' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center;
  font-size: 12.5px; font-weight: 600; color: var(--text);
  appearance: none; -webkit-appearance: none; cursor: pointer;
}
.fb-delete { margin-left: auto; color: var(--text-muted); }
.fb-delete:hover { color: var(--danger); }

/* ─── 댓글 */
.fb-comments { display: flex; flex-direction: column; gap: 2px; }
.fb-comment {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.fb-comment:last-child { border-bottom: 0; }
.fb-comment.is-staff {
  margin: 6px 0;
  padding: 14px 16px;
  background: var(--primary-soft);
  border: 0; border-radius: var(--r-md);
}
.fb-comment-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.fb-comment-author { font-size: 13px; font-weight: 700; color: var(--text); }
.fb-staff-badge {
  padding: 2px 7px;
  background: var(--primary); color: #fff;
  border-radius: var(--r-sm);
  font-size: 10.5px; font-weight: 700;
}
.fb-comment-time { font-size: 11.5px; font-weight: 500; color: var(--text-muted); }
.fb-comment-del {
  margin-left: auto;
  padding: 2px 6px;
  background: none; border: 0;
  font-size: 11.5px; font-weight: 600; color: var(--text-disabled);
  cursor: pointer;
}
.fb-comment-del:hover { color: var(--danger); }
.fb-comment-body {
  font-size: 13.5px; line-height: 1.75; color: var(--text-secondary);
  word-break: break-word;
}
.fb-comment-empty {
  padding: 24px 0;
  text-align: center; font-size: 13px; color: var(--text-muted);
}
.fb-comment-write {
  margin-top: 16px; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.fb-comment-write-foot {
  display: flex; align-items: center; gap: 10px;
  margin-top: 10px;
}

/* ─── AI 답변 평가 (운영자 화면) */
.fb-rating-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin: 16px 0 14px;
}
.fb-rating-stat {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  text-align: center;
}
.fb-rating-stat-n {
  font-size: 26px; font-weight: 800; letter-spacing: -0.04em; color: var(--text);
}
.fb-rating-pct { font-size: 15px; font-weight: 700; margin-left: 1px; }
.fb-rating-stat-l { margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.fb-rating-stat.up   .fb-rating-stat-n { color: var(--success); }
.fb-rating-stat.down .fb-rating-stat-n { color: var(--danger); }

.fb-rating-list { display: flex; flex-direction: column; gap: 12px; }
.fb-rating-item {
  padding: 14px 16px;
  background: var(--surface-2); border-radius: var(--r-md);
}
.fb-rating-item-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.fb-rating-who { font-size: 12.5px; font-weight: 700; color: var(--text); }
.fb-rating-time { font-size: 11.5px; color: var(--text-muted); }
.fb-reason-chip {
  padding: 2px 7px;
  background: var(--danger-soft); color: #C13540;
  border-radius: var(--r-sm);
  font-size: 11px; font-weight: 700;
}
.fb-rating-comment {
  margin-bottom: 8px;
  font-size: 13px; line-height: 1.7; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}
.fb-rating-answer {
  padding: 10px 12px;
  background: var(--surface); border-radius: var(--r-sm);
  font-size: 12px; line-height: 1.7; color: var(--text-muted);
  white-space: pre-wrap; word-break: break-word;
}

/* ─── 채팅 답변 평가 버튼 */
.chat-rate-btn.is-up.is-on   { background: var(--success-soft); color: #047857; border-color: #A7E8C6; }
.chat-rate-btn.is-down.is-on { background: var(--danger-soft);  color: #C13540; border-color: #F7BFC4; }
.chat-rate-thanks {
  font-size: 11.5px; font-weight: 600; color: var(--text-muted);
  align-self: center;
}

/* 아쉬움 사유 입력 패널 — 답변 아래에 접혀 나온다 */
.chat-rate-panel {
  margin-top: 8px; padding: 12px 14px;
  background: var(--surface-2); border-radius: var(--r-md);
}
.chat-rate-panel-title {
  font-size: 12.5px; font-weight: 700; color: var(--text);
  margin-bottom: 9px;
}
.chat-rate-reasons { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chat-rate-reason {
  padding: 5px 10px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--dur-1) var(--ease-out-toss);
}
.chat-rate-reason:hover { background: var(--primary-soft); }
.chat-rate-reason.is-on {
  background: var(--text); border-color: var(--text); color: #fff;
}
.chat-rate-panel textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface);
  font-family: inherit; font-size: 12.5px; line-height: 1.6; color: var(--text);
  resize: vertical;
}
.chat-rate-panel textarea:focus { outline: none; border-color: var(--primary); }
.chat-rate-panel-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  margin-top: 9px;
}

@media (max-width: 600px) {
  .fb-title-row { flex-direction: column; align-items: stretch; }
  .fb-title-actions { justify-content: flex-end; }
  .fb-filters { flex-direction: column; align-items: stretch; gap: 8px; }
  .fb-sort select { width: 100%; }
  .fb-item { padding: 14px 15px; gap: 11px; }
  .fb-vote { width: 42px; min-height: 42px; }
  .fb-detail-title { font-size: 18.5px; }
  .fb-rating-stats { grid-template-columns: 1fr; }
  .fb-form-foot { flex-direction: column; align-items: stretch; }
  .fb-form-btns { justify-content: flex-end; }
}

/* ─── 첨부: 업로드 영역 */
.fb-drop {
  display: flex; align-items: center; justify-content: center;
  padding: 18px 16px;
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--dur-2) var(--ease-out-toss),
              background var(--dur-2) var(--ease-out-toss);
}
.fb-drop:hover, .fb-drop:focus-visible { border-color: var(--primary); background: var(--primary-soft); }
.fb-drop.is-over { border-color: var(--primary); background: var(--primary-soft); }
.fb-drop-hint {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  text-align: center;
  font-size: 12.5px; line-height: 1.6; color: var(--text-secondary);
}
.fb-drop-hint svg { color: var(--text-muted); }
.fb-drop-hint b { font-weight: 700; color: var(--text); }
.fb-drop-hint small { font-size: 11.5px; color: var(--text-disabled); }

.fb-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.fb-thumbs:empty { display: none; }
.fb-thumb {
  position: relative;
  width: 84px; height: 84px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  overflow: hidden; background: var(--surface-2);
}
.fb-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fb-thumb-loading { display: flex; align-items: center; justify-content: center; height: 100%; }
.fb-thumb-del {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 22, 33, 0.72); color: #fff;
  border: 0; border-radius: 50%;
  font-size: 15px; line-height: 1; cursor: pointer;
}
.fb-thumb-del:hover { background: rgba(15, 22, 33, 0.92); }

/* ─── 첨부: 링크 입력 */
.fb-links { display: flex; flex-direction: column; gap: 8px; }
.fb-links:empty { display: none; }
.fb-link-row { display: flex; gap: 6px; align-items: center; }
.fb-link-row .fb-link-url { flex: 1.6; min-width: 0; }
.fb-link-row .fb-link-title { flex: 1; min-width: 0; }
.fb-link-row .fb-input { padding: 9px 11px; font-size: 13px; }
.fb-link-del {
  flex-shrink: 0;
  width: 30px; height: 30px;
  background: none; border: 0; border-radius: var(--r-sm);
  font-size: 18px; line-height: 1; color: var(--text-disabled);
  cursor: pointer;
}
.fb-link-del:hover { background: var(--surface-2); color: var(--danger); }
.fb-link-add {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 8px; padding: 7px 12px;
  background: var(--surface-2); border: 0; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 600; color: var(--text-secondary);
  cursor: pointer;
}
.fb-link-add:hover { background: var(--border-strong); color: var(--text); }
.fb-link-add:disabled { opacity: 0.45; cursor: default; }

/* ─── 목록 썸네일 */
.fb-item-thumb {
  position: relative; display: inline-block;
  margin-top: 10px;
  width: 96px; height: 68px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  overflow: hidden;
}
.fb-item-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fb-item-thumb-more {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 22, 33, 0.5); color: #fff;
  font-size: 13px; font-weight: 700;
}

/* ─── 상세: 이미지 · 링크 */
.fb-detail-images {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 18px;
}
.fb-detail-image {
  padding: 0; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface-2); overflow: hidden; cursor: zoom-in;
  max-width: 220px;
  transition: transform var(--dur-2) var(--ease-out-toss),
              box-shadow var(--dur-2) var(--ease-out-toss);
}
.fb-detail-image:hover { transform: translateY(-2px); box-shadow: var(--shadow-3); }
.fb-detail-image img { display: block; max-width: 100%; height: auto; }

.fb-detail-links { display: flex; flex-direction: column; gap: 7px; margin-top: 16px; }
.fb-link-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px;
  background: var(--surface-2); border-radius: var(--r-md);
  text-decoration: none; color: var(--text);
  transition: background var(--dur-2) var(--ease-out-toss);
}
.fb-link-item:hover { background: var(--border-strong); }
.fb-link-item > .ico { flex-shrink: 0; color: var(--primary); }
.fb-link-item-body { flex: 1; min-width: 0; }
.fb-link-item-title {
  display: block;
  font-size: 13.5px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fb-link-item-url {
  display: block; margin-top: 2px;
  font-size: 11.5px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fb-link-item-ext { flex-shrink: 0; color: var(--text-disabled); }

/* ─── 이미지 확대 보기 */
.fb-zoom {
  position: fixed; inset: 0; z-index: 1300;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 15, 22, 0.9);
  animation: toss-fade 180ms var(--ease-out-toss);
  padding: 56px 20px;
}
.fb-zoom-img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  border-radius: var(--r-sm);
  cursor: default;
}
.fb-zoom-close {
  position: absolute; top: 14px; right: 16px;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.14); color: #fff;
  border: 0; border-radius: 50%;
  font-size: 24px; line-height: 1; cursor: pointer;
}
.fb-zoom-close:hover { background: rgba(255, 255, 255, 0.26); }
.fb-zoom-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.14); color: #fff;
  border: 0; border-radius: 50%;
  font-size: 26px; line-height: 1; cursor: pointer;
}
.fb-zoom-nav:hover { background: rgba(255, 255, 255, 0.26); }
.fb-zoom-nav[hidden] { display: none; }
.fb-zoom-nav.prev { left: 16px; }
.fb-zoom-nav.next { right: 16px; }
.fb-zoom-name {
  position: absolute; bottom: 18px; left: 0; right: 0;
  text-align: center;
  font-size: 12.5px; font-weight: 600; color: rgba(255, 255, 255, 0.78);
}

@media (max-width: 600px) {
  .fb-link-row { flex-wrap: wrap; }
  .fb-link-row .fb-link-url, .fb-link-row .fb-link-title { flex: 1 1 100%; }
  .fb-link-del { margin-left: auto; }
  .fb-detail-image { max-width: 100%; }
  .fb-zoom { padding: 52px 8px; }
  .fb-zoom-nav { width: 38px; height: 38px; }
}

/* ─── 글쓰기 폼 다듬기
   첨부 UI 가 들어오며 폼이 길어져 등록 버튼이 스크롤 아래로 묻혔다.
   버튼 줄을 패널 바닥에 붙여 스크롤 위치와 상관없이 늘 보이게 한다. */
.fb-form-foot {
  position: sticky; bottom: -18px; z-index: 2;
  margin: 20px -20px -18px;
  padding: 14px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border-strong);
}
/* '상태' 두 글자가 세로로 쪼개지던 것 */
.fb-status-pick label { white-space: nowrap; }

/* =========================================================
   어드민 콘솔 (/admin) — twdong · drkkyubrother 전용
   ========================================================= */
.sidebar .footer .footer-link.is-on { color: var(--primary); font-weight: 600; }

.adm-tabs { margin: 4px 0 20px; }
.adm-n {
  display: inline-block; margin-left: 4px; padding: 0 6px;
  border-radius: 8px; background: var(--surface-2);
  font-size: 11px; font-weight: 700; color: var(--text-muted);
}
.chip.active .adm-n { background: rgba(255, 255, 255, 0.22); color: white; }

.adm-stats {
  display: grid; gap: 12px; margin-bottom: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.adm-sub { font-size: 12px; color: var(--text-muted); }
.stat .adm-sub { margin-top: 6px; }
.stat.primary .adm-sub { color: rgba(255, 255, 255, 0.85); }

.adm-live {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px; padding: 10px 14px;
  border-radius: 12px; background: var(--primary-soft);
  color: var(--primary-strong); font-size: 13px; font-weight: 600;
}
.adm-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--primary);
  animation: adm-pulse 1.4s ease-in-out infinite;
}
@keyframes adm-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.adm-grid { display: grid; gap: 16px; grid-template-columns: 1.3fr 1fr; align-items: start; }
@media (max-width: 900px) { .adm-grid { grid-template-columns: 1fr; } }

/* 일별 막대 */
.adm-bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 8px; }
.adm-bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.adm-bar {
  min-height: 3px; border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, var(--primary) 0%, #6BA7FA 100%);
  transition: opacity var(--dur-1);
}
.adm-bar-col:hover .adm-bar { opacity: 0.75; }
.adm-bar-label {
  margin-top: 6px; font-size: 10px; color: var(--text-muted);
  text-align: center; white-space: nowrap;
}

/* 모델 분포 */
.adm-models { display: flex; flex-direction: column; gap: 14px; }
.adm-model-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.adm-model-name { font-size: 13px; font-weight: 600; color: var(--text); }
.adm-model-n { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.adm-track { height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.adm-fill { height: 100%; border-radius: 4px; background: var(--primary); }
.adm-model-note { margin-top: 5px; font-size: 11px; color: var(--text-muted); }
.adm-caveat {
  margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-muted); line-height: 1.6;
}
.adm-caveat strong { color: var(--text-secondary); }

/* 표 */
.adm-table-wrap { overflow-x: auto; }
.adm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.adm-table th {
  padding: 12px 14px; text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  letter-spacing: 0.02em; border-bottom: 1px solid var(--border-strong);
}
.adm-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.adm-table tr:last-child td { border-bottom: 0; }
.adm-table tbody tr:hover { background: var(--surface-2); }
.adm-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.adm-table-sm { font-size: 12px; }
.adm-table-sm th, .adm-table-sm td { padding: 8px 10px; }
.adm-who { font-weight: 600; color: var(--text); }
.adm-row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.adm-tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-secondary);
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.adm-tag-dim { color: var(--text-muted); font-weight: 500; }
.adm-tag-soft { background: var(--primary-soft); color: var(--primary-strong); margin-left: 4px; }
.adm-tag-live { background: var(--primary); color: white; margin-left: 6px; }

/* 대화 목록 */
/* 전역 select 가 width:100% 라 flex 로 두면 줄이 쪼개진다 — grid 로 칸을 고정 */
.adm-chat-filters {
  display: grid; gap: 8px; margin-bottom: 14px;
  grid-template-columns: 1fr 220px auto;
}
@media (max-width: 700px) { .adm-chat-filters { grid-template-columns: 1fr; } }
.adm-chat-filters input[type="search"],
.adm-chat-filters select {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  font-size: 14px; background: var(--surface); font-weight: 500;
}
.adm-chat-filters .btn { padding: 10px 20px; font-size: 14px; }
.adm-chat-list { display: flex; flex-direction: column; gap: 8px; }
.adm-chat-row {
  display: flex; gap: 16px; align-items: flex-start; width: 100%;
  padding: 14px 16px; text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; cursor: pointer;
  transition: border-color var(--dur-1), transform var(--dur-1);
}
.adm-chat-row:hover { border-color: var(--border-strong); }
.adm-chat-row:active { transform: scale(0.995); }
.adm-chat-main { flex: 1; min-width: 0; }
.adm-chat-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.adm-chat-preview {
  font-size: 12.5px; color: var(--text-muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.adm-chat-meta { flex-shrink: 0; text-align: right; font-size: 12px; }
.adm-chat-meta .adm-who { font-size: 12.5px; }
.adm-pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; font-size: 12px; color: var(--text-muted); }

/* 모달 상세 */
.adm-detail-meta { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.adm-k { display: inline-block; min-width: 130px; color: var(--text-muted); font-size: 12px; }
.adm-h3 { margin: 20px 0 8px; font-size: 13px; font-weight: 700; color: var(--text); }
.adm-pre {
  margin: 0; padding: 12px 14px; border-radius: 10px;
  background: var(--surface-2); font-size: 12.5px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word; font-family: inherit; color: var(--text-secondary);
}
.adm-uploads { margin: 12px 0 0; font-size: 12px; color: var(--text-muted); }
.adm-msgs { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.adm-msg { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.adm-msg-user { background: var(--primary-soft); }
.adm-msg-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.adm-msg-role { font-size: 12px; font-weight: 700; color: var(--text-secondary); }
.adm-msg-user .adm-msg-role { color: var(--primary-strong); }
.adm-msg-body {
  font-size: 13px; line-height: 1.75; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
  max-height: 420px; overflow-y: auto;
}
