/* needforai app.css — docs/UI.md 규칙 구현 */

/* ===== 1. 디자인 토큰 ===== */
:root {
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --bg-hover: #f4f4f5;
  --border: #ececec;
  --border-strong: #dcdcdc;
  --text: #1a1a1a;
  --text-muted: #8a8a8e;
  --accent: #111111;
  --accent-contrast: #ffffff;
  --avatar: #e6447e;
  --focus: #111111;
  --danger: #c0392b;

  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "맑은 고딕", "Malgun Gothic", sans-serif;

  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-pill: 999px;

  --shadow-card: 0 1px 2px rgba(0,0,0,.04);
  --shadow-pop: 0 8px 30px rgba(0,0,0,.08);

  --sidebar-w: 250px;

  /* 모바일 드로어 레이어 (토스트 50 < 드로어 < 모달 60) */
  --z-drawer: 55;
  --z-drawer-backdrop: 54;
}

/* ===== body / 기본 ===== */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: var(--accent-contrast);
  font-weight: 800; font-size: 15px; flex: none;
}
.logo-mark-lg { width: 44px; height: 44px; border-radius: 12px; font-size: 24px; }

/* ===== 레이아웃 ===== */
.app { display: flex; min-height: 100vh; min-height: 100svh; }
.content { flex: 1; min-width: 0; padding: 34px 52px; }
.row-between { display: flex; align-items: center; justify-content: space-between; }

.page-title { font-size: 30px; font-weight: 800; margin: 0 0 6px; }
/* 위치 표시(브레드크럼): 상위 링크·구분자·폴더 아이콘을 제목보다 작게, 세로 가운데 정렬 */
.crumb-back { color: var(--text-muted); text-decoration: none; font-weight: 600; font-size: 0.55em; vertical-align: middle; }
.crumb-back:hover { color: var(--text); text-decoration: underline; }
.crumb-sep { color: var(--border-strong); margin: 0 8px; font-weight: 400; font-size: 0.55em; vertical-align: middle; }
.crumb-folder { color: var(--text-muted); font-size: 0.72em; margin-right: 8px; vertical-align: middle; }
.page-desc { color: var(--text-muted); margin: 0 0 24px; font-size: 15px; }
.section-title { font-size: 16px; font-weight: 700; margin: 0; }

.card {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 18px 20px; background: var(--bg); box-shadow: var(--shadow-card);
  margin-bottom: 18px;
}

/* ===== 사이드바 ===== */
.sidebar {
  width: var(--sidebar-w); flex: none;
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  position: sticky; top: 0; height: 100vh; height: 100svh;
  display: flex; flex-direction: column;
}
.side-logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; padding: 4px 8px 14px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-md);
  color: var(--text); font-size: 15px; line-height: 1.2;
}
.nav-item i { width: 20px; text-align: center; color: var(--text); font-size: 16px; }
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active { background: #f0f0f1; font-weight: 600; }
.nav-item.active i { color: var(--accent); }

/* +버튼을 흐름에서 빼내 절대배치 → nav-item 폭/하이라이트가 다른 항목과 동일 */
.nav-row { position: relative; }
/* 오른쪽 +버튼(절대배치, 6~30px) 자리를 비워 개수 배지와 겹치지 않게 */
.nav-row .nav-item { flex: 1; padding-right: 28px; }
.nav-add {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: none; background: none; color: var(--text-muted);
  width: 24px; height: 24px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .1s;
}
.nav-row:hover .nav-add { opacity: 1; }
/* +버튼은 행 위에 겹쳐 있어 배경을 주면 이중 박스로 보임 → 색 변화만으로 피드백 */
.nav-add:hover { color: var(--text); }

.nav-sub { display: flex; flex-direction: column; }
.nav-sub a {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px 7px 40px; font-size: 13px; color: var(--text-muted);
  border-radius: var(--r-md);
}
.nav-sub a i { font-size: 12px; }
.nav-sub a:hover { background: var(--bg-hover); color: var(--text); }
.nav-sub a.active { color: var(--text); font-weight: 600; background: #f0f0f1; }

.nav-divider { height: 1px; background: var(--border); margin: 10px 8px; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .02em; color: var(--text-muted); padding: 8px 10px 4px; }

.side-bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 4px; }
.side-user img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.avatar-fallback {
  width: 32px; height: 32px; border-radius: 50%; background: var(--avatar);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; text-transform: uppercase; flex: none;
}
.side-user-meta { display: flex; flex-direction: column; line-height: 1.3; }
.side-user-meta strong { font-size: 14px; font-weight: 600; }
.plan-badge {
  align-self: flex-start; font-size: 10px; text-transform: uppercase;
  background: var(--bg-hover); color: var(--text-muted);
  padding: 1px 6px; border-radius: var(--r-sm); margin-top: 2px;
}
.btn-logout {
  width: 100%; margin-top: 10px; padding: 8px;
  border: 1px solid var(--border-strong); background: var(--bg);
  border-radius: var(--r-md); font-size: 13px; color: var(--text-muted);
}
.btn-logout:hover { background: var(--bg-hover); color: var(--text); }

/* ===== 게이트 ===== */
.gate { min-height: 100vh; min-height: 100svh; display: flex; align-items: center; justify-content: center; background: var(--bg-subtle); }
.gate-card {
  width: 340px; background: var(--bg); padding: 32px; border-radius: 14px;
  box-shadow: var(--shadow-pop); text-align: center;
}
.gate-logo { display: flex; justify-content: center; margin-bottom: 16px; }
.gate-card h2 { margin: 0 0 6px; font-size: 20px; font-weight: 800; }
.gate-card p { color: var(--text-muted); font-size: 14px; margin: 0 0 20px; }
.gate-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px; border: 1px solid var(--border-strong);
  border-radius: var(--r-md); font-size: 15px; font-weight: 600; background: var(--bg);
}
.gate-btn:hover { background: var(--bg-hover); }
.gate-back { display: inline-block; margin-top: 16px; color: var(--text-muted); font-size: 13px; }

/* ===== 버튼 ===== */
.btn {
  padding: 9px 14px; border: 1px solid var(--border-strong); background: var(--bg);
  border-radius: var(--r-md); font-size: 14px; color: var(--text);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.btn.primary:hover { opacity: .9; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn i { font-size: 14px; }
.toolbar { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 14px; }

/* ===== 입력 요소 ===== */
.text-input, input[type="text"], input[type="email"], input[type="search"], textarea, select {
  padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  font-family: inherit; font-size: 15px; background: var(--bg); color: var(--text); width: 100%;
}
select {
  cursor: pointer; width: auto; min-width: 120px;
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8a8e' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.tpl-row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.tpl-select { width: auto; }
.text-input:focus, input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(17,17,17,.08);
}
::placeholder { color: var(--text-muted); }
textarea.note-body { min-height: 160px; resize: vertical; }

/* ===== 리스트 ===== */
.list { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg-subtle); }
.list-item.row-click { cursor: pointer; }   /* 행 전체 클릭 이동(Home 최근 처리·재연결 로그) */

/* 경고 배너(자동수집 재연결 필요 등) */
.alert-banner {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  background: #fff7f4; border: 1px solid #f0c7bd;
  border-radius: var(--r-lg); padding: 14px 16px; margin-bottom: 18px;
}
.alert-banner > i { color: var(--danger); font-size: 20px; flex: none; }
.alert-banner .alert-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 180px; }
.alert-banner .alert-body b { font-size: 14px; }
.alert-banner .alert-body span { color: var(--text-muted); font-size: 13px; }
.alert-banner .btn { flex: none; }

/* ===== 오디오 플레이어 ===== */
.audio-player { display: flex; flex-direction: column; gap: 14px; }
.ap-time { font-size: 13px; color: var(--text-muted); text-align: center; font-variant-numeric: tabular-nums; }
.wave { display: flex; align-items: center; gap: 2px; height: 64px; cursor: pointer; padding: 0 2px; }
.wave-bar { flex: 1; min-width: 2px; background: var(--border-strong); border-radius: 2px; transition: background .05s; }
.wave-bar.on { background: var(--accent); }
.ap-controls { display: flex; align-items: center; justify-content: center; gap: 14px; }
.ap-btn {
  border: none; background: none; color: var(--text); cursor: pointer;
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; position: relative;
  font-size: 18px;
}
.ap-btn:hover { background: var(--bg-hover); }
.ap-btn span { position: absolute; font-size: 9px; font-weight: 700; bottom: 8px; }
.ap-btn.ap-play { background: var(--accent); color: var(--accent-contrast); }
.ap-btn.ap-play:hover { opacity: .9; }
.ap-rate { width: auto; min-width: 68px; padding: 6px 26px 6px 10px; font-size: 13px; }
.ap-trim { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.ap-trim-label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.ap-range { font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; min-width: 96px; text-align: center; }
.ap-err { color: var(--danger); font-size: 13px; text-align: center; }
.note-source .ns-play { margin-left: 12px; padding: 3px 10px; }
.list-item .name { flex: 1; font-size: 15px; }
.file-note-title { color: var(--text-muted); font-weight: 400; margin-left: 6px; }
.file-note-title.file-error { color: var(--danger); }
.list-item .meta { color: var(--text-muted); font-size: 13px; }
.empty { text-align: center; color: var(--text-muted); padding: 56px 20px; }

/* 로그 행: 영역 뱃지 + 동작/대상 + 시간 + 상태 */
.log-item .log-area { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 10px; border-radius: var(--r-pill); background: var(--bg-hover); color: var(--text-muted); white-space: nowrap; min-width: 78px; justify-content: center; }
.log-item .log-detail { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.empty .big { font-size: 34px; margin-bottom: 8px; }

/* ===== 검색 페이지 (좌 채팅 / 우 결과) ===== */
.search-page { display: flex; gap: 20px; height: calc(100vh - 190px); height: calc(100svh - 190px); min-height: 420px; margin-top: 10px; }
.search-chat { width: 380px; flex-shrink: 0; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--bg); }
.search-thread { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.sb { max-width: 90%; padding: 10px 13px; border-radius: var(--r-lg); font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.sb-me { align-self: flex-end; background: var(--accent); color: var(--accent-contrast); }
.sb-ai { align-self: flex-start; background: var(--bg-hover); color: var(--text); }
.sb-err { background: #fdece9; color: var(--danger); }
.search-typing { color: var(--text-muted); }
.search-degraded { color: var(--danger); font-size: 12px; }
.search-input-row { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.search-input-row .text-input { flex: 1; }
.search-results { flex: 1; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; }
.sr-head { font-weight: 700; color: var(--text-muted); font-size: 13px; margin-bottom: 12px; }
.sr-card { border: 1px solid var(--border); border-radius: var(--r-md); padding: 13px 15px; margin-bottom: 10px; cursor: pointer; }
.sr-card:hover { background: var(--bg-subtle); border-color: var(--border-strong); }
.sr-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.sr-reason { color: #2b6cb0; font-size: 13px; margin-bottom: 4px; }
.sr-summary { color: var(--text-muted); font-size: 13px; line-height: 1.5; }

/* ===== 상태 배지 ===== */
.status { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: var(--r-pill); white-space: nowrap; }
.status.processing { background: #fff4e5; color: #b26a00; }
.status.done { background: #e7f6ec; color: #1b7f3b; }
.status.failed { background: #fdeaea; color: #c0392b; }

/* ===== 드롭존 ===== */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--r-lg);
  padding: 36px; text-align: center; color: var(--text-muted); cursor: pointer; margin-bottom: 20px;
}
.dropzone.drag { border-color: var(--accent); background: var(--bg-subtle); }
.dropzone .hint { font-size: 12px; margin-top: 6px; color: var(--text-muted); }
.dropzone i { font-size: 20px; margin-bottom: 8px; display: block; }

/* ===== 사용량 바 ===== */
.usage-bar-track { height: 8px; background: #eee; border-radius: var(--r-pill); overflow: hidden; margin-top: 10px; }
.usage-bar-fill { height: 100%; background: var(--accent); }
.plan-card-foot { margin-top: 10px; align-items: center; }
.plan-card-foot .meta { color: var(--text-muted); font-size: 13px; }
.plan-warn { margin-top: 8px; color: var(--danger); font-size: 13px; }

/* ===== 노트 상세 ===== */
.note-section-title { font-size: 13px; color: var(--text-muted); margin: 20px 0 6px; font-weight: 600; }
.tag { display: inline-block; background: var(--bg-hover); color: var(--text-muted); font-size: 12px; padding: 3px 9px; border-radius: var(--r-pill); margin: 2px 4px 2px 0; }
.transcript-box { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px; font-size: 13px; color: #444; white-space: pre-wrap; max-height: 300px; overflow: auto; }

/* ===== 토스트 ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; padding: 10px 16px;
  border-radius: var(--r-md); box-shadow: var(--shadow-pop); font-size: 13px; z-index: 50;
}

/* ===== 음성 추가 버튼 + 드롭다운 ===== */
.add-wrap { position: relative; padding: 0 2px 10px; }
.btn-add {
  width: 100%; padding: 10px; border: 1px solid var(--border-strong);
  background: var(--bg); border-radius: var(--r-md); font-weight: 600; font-size: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--text);
}
.btn-add:hover { background: var(--bg-hover); }
.dropdown {
  position: absolute; left: 2px; right: 2px; top: 46px; z-index: 40;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); padding: 6px;
}
.dropdown-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); font-size: 14px; cursor: pointer; }
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item.disabled { opacity: .5; cursor: default; }
.dropdown-item .soon { margin-left: auto; font-size: 11px; color: var(--text-muted); }
.dropdown-item i { width: 18px; text-align: center; color: var(--text-muted); }

/* 사이드바 개수/단축키 */
.nav-count { margin-left: auto; font-size: 12px; color: var(--text-muted); }
.nav-item .kbd { margin-left: auto; font-size: 11px; color: var(--text-muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; }
#navSearch { cursor: pointer; }

/* 하단 사용량 */
.side-usage { font-size: 12px; color: var(--text-muted); padding: 6px 6px 2px; }

/* ===== 모달 / 오버레이 ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh; z-index: 60;
}
.modal { width: 560px; max-width: 92vw; background: var(--bg); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; }
.modal-x { border: none; background: none; color: var(--text-muted); font-size: 16px; }
.modal-x:hover { color: var(--text); }
.modal-body { padding: 18px; }
.import-status { margin-top: 12px; font-size: 13px; color: var(--text-muted); }

/* ===== 커맨드 팔레트 ===== */
.modal.palette { width: 620px; }
.palette-search { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.palette-search i { color: var(--text-muted); }
.palette-search input { border: none; outline: none; font-size: 16px; width: 100%; background: transparent; }
.palette-search input:focus { box-shadow: none; }
.palette-list { max-height: 52vh; overflow: auto; padding: 6px; }
.palette-group { font-size: 12px; color: var(--text-muted); padding: 8px 12px 4px; }
.palette-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 12px; border-radius: var(--r-md); cursor: pointer; }
.palette-item .p-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .p-date { font-size: 12px; color: var(--text-muted); }
.palette-item.sel, .palette-item:hover { background: var(--bg-hover); }
.palette-empty { padding: 24px; text-align: center; color: var(--text-muted); }
.palette-hint { font-size: 12px; color: var(--text-muted); padding: 9px 14px; border-top: 1px solid var(--border); }

/* ===== 생성 방식 모달 ===== */
.gen-opt { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 8px; cursor: pointer; }
.gen-opt .meta { color: var(--text-muted); font-size: 12px; }
#generateTemplate, #importTemplate { width: 100%; }

/* ===== 연결 안내 박스 ===== */
.conn-help { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; margin-top: 12px; font-size: 13px; color: var(--text-muted); }
.conn-help b { color: var(--text); }
.conn-help ol { margin: 6px 0 0; padding-left: 18px; }
.conn-help a { color: #2b6cb0; text-decoration: underline; }
.conn-help-bot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.conn-help-bot .conn-req { flex-basis: 100%; color: var(--danger); font-size: 12px; font-weight: 600; }
.conn-field { margin-top: 10px; }
.conn-field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.conn-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 8px; }
.set-section + .set-section { border-top: 1px solid var(--border); margin-top: 24px; padding-top: 8px; }
.conn-item .c-name { flex: 1; font-weight: 600; }
.conn-badge { font-size: 11px; background: var(--bg-hover); color: var(--text-muted); padding: 2px 8px; border-radius: var(--r-pill); }

/* ===== 노트 워크스페이스 (노트 보기) ===== */
.note-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.note-head h2 { font-size: 22px; font-weight: 800; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-actions { display: flex; gap: 8px; flex: none; }
.note-body-wrap { display: flex; gap: 20px; align-items: flex-start; }
.note-list-pane { width: 240px; flex: none; border-right: 1px solid var(--border); padding-right: 12px; max-height: calc(100vh - 170px); max-height: calc(100svh - 170px); overflow: auto; }
.note-list-pane .nl-new { width: 100%; margin-bottom: 8px; }
.nl-rulebar { margin-bottom: 8px; }
.nl-rulebar .btn { width: 100%; justify-content: center; }
.nl-rule-on { color: #1b7f3b; }
.nl-item { padding: 9px 10px; border-radius: var(--r-md); cursor: pointer; }
.nl-item:hover { background: var(--bg-hover); }
.nl-item.active { background: #f0f0f1; font-weight: 600; }
.nl-item .nl-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nl-item .nl-date { font-size: 12px; color: var(--text-muted); }

/* 노트 원문: 고객 가독성 위해 본문·제목·강조 크게, line-height 여유 */
.note-doc { flex: 1; max-width: 820px; font-size: 17px; line-height: 2.0; color: var(--text); }
.note-doc h2 { font-size: 24px; font-weight: 800; line-height: 1.5; margin: 28px 0 12px; }
.note-doc h3 { font-size: 24px; font-weight: 700; line-height: 1.5; margin: 24px 0 10px; }
.note-doc h2:first-child, .note-doc h3:first-child { margin-top: 0; }
.note-doc p { margin: 12px 0; }
.note-doc ul { padding-left: 20px; margin: 10px 0; }
.note-doc li { margin: 7px 0; }
.note-doc strong { font-weight: 800; font-size: 1.12em; }
.note-doc .note-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 4px; }
.note-doc .empty { padding: 40px; }
.note-source { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--r-md); padding: 8px 12px; margin-bottom: 16px; cursor: pointer; }
.note-source:hover { background: var(--bg-hover); }
.note-source b { color: var(--text); font-weight: 600; }
.note-source .ns-go { margin-left: auto; color: var(--accent); }
.note-edit-title { font-size: 22px; font-weight: 800; margin-bottom: 12px; }
.note-doc textarea.note-body { min-height: 55vh; font-size: 15px; line-height: 1.7; }

@media (max-width: 860px) {
  .note-body-wrap { flex-direction: column; }
  .note-list-pane { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 220px; padding-right: 0; }
}

/* ===== 반응형 — 모바일 드로어 (docs/UI.md '반응형' 절) ===== */
/* 모바일 전용 상단바(☰ + 로고). 데스크톱에선 숨김 */
.mobile-topbar {
  display: none;
  position: sticky; top: 0; height: 52px;
  align-items: center; gap: 10px; padding: 0 14px;
  background: var(--bg); border-bottom: 1px solid var(--border);
  z-index: 30;
}
.mobile-topbar .topbar-menu {
  border: none; background: none; color: var(--text);
  width: 36px; height: 36px; margin-left: -8px;
  border-radius: var(--r-md); font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
.mobile-topbar .topbar-menu:hover { background: var(--bg-hover); }
.mobile-topbar .topbar-logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; }

.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: var(--z-drawer-backdrop);
}

@media (max-width: 720px) {
  .app { display: block; }               /* 사이드바가 흐름에서 빠지므로 본문이 전체 폭 사용 */
  .mobile-topbar { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; height: 100svh;
    width: var(--sidebar-w); background: var(--bg);
    z-index: var(--z-drawer);
    transform: translateX(-105%); transition: transform .2s ease;
    overflow-y: auto;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow-pop); }
  .content { padding: 20px 16px; overflow-x: hidden; }

  /* 툴바(제목+버튼)·목록 행: 좁은 폭에서 줄바꿈 허용 */
  .toolbar { flex-wrap: wrap; }
  .list-item { flex-wrap: wrap; row-gap: 6px; }
  .list-item .name { flex-basis: 100%; }   /* 1줄: 파일명(+노트제목/사유), 2줄: 메타·버튼 */

  /* 설정 — 연결 행: 입력칸은 전체 폭으로 내려가고 나머지는 줄바꿈 */
  .conn-item { flex-wrap: wrap; }
  .conn-item .text-input, .conn-item input, .conn-item select { flex-basis: 100%; }

  /* 노트 상세 — 상단 액션(폴더·전사원문·공유·편집·삭제): 제목 아래 줄로 내리고 줄바꿈 */
  .note-head { flex-wrap: wrap; }
  .note-head h2 { flex-basis: 100%; white-space: normal; }   /* 제목은 전체 폭 + 줄바꿈 허용 */
  .note-actions { flex-wrap: wrap; width: 100%; }
  .note-actions select { max-width: 150px; }                 /* 폴더 select 가 폭 독식하지 않게 */
  .note-source { flex-wrap: wrap; row-gap: 2px; }            /* 원본 파일 카드: 글자 세로쪼개짐 방지 */

  /* 검색 — 좌(채팅)/우(결과) 2패널 → 상하 스택 */
  .search-page { flex-direction: column; height: auto; }
  .search-chat { width: 100%; height: 55vh; min-height: 320px; }
  .search-results { min-height: 200px; max-height: 45vh; }
}
