/* ── reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f9f9f8;
  --surface: #ffffff;
  --border: #e8e8e5;
  --text: #1a1a1a;
  --text2: #6b6b6b;
  --text3: #b0b0b0;
  --primary: #5b5bd6;
  --primary-light: #e8e8ff;
  --danger: #e5484d;
  --success: #30a46c;
  --callout-bar: #c8c8f0;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 2px 8px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
}

body { font-family: 'Noto Sans KR', sans-serif; color: var(--text); background: var(--bg); font-size: 14px; }

/* ════════════════════════════════════════
   홈
════════════════════════════════════════ */
.home-body { min-height: 100vh; }

.home-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 72px 40px 120px;
}

/* 헤더 */
.home-header { margin-bottom: 48px; }
.home-title { font-size: 1.9rem; font-weight: 700; letter-spacing: -.5px; color: var(--text); }
.home-sub { color: var(--text2); margin-top: 4px; font-size: .88rem; }

/* 섹션 라벨 */
.section-label {
  font-size: .7rem; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text3);
  margin-bottom: 6px; padding-left: 2px;
}

/* ── 파일 트리 ── */
.file-tree { display: flex; flex-direction: column; gap: 1px; }

/* 빈 상태 */
.tree-empty {
  padding: 8px 4px;
  font-size: .85rem; color: var(--text3);
}
.tree-empty-child {
  font-size: .8rem; color: var(--text3);
  padding-top: 2px; padding-bottom: 6px;
  font-style: italic;
}

/* 공통 행 */
.tree-row {
  display: flex; align-items: center;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  transition: background .1s, border-color .15s;
  min-height: 34px;
  padding: 2px 0;
}
.tree-row:hover { background: rgba(0,0,0,.035); }
.tree-row:hover .tree-more { opacity: 1; }

/* 들여쓰기 */
.tree-indent { flex-shrink: 0; }

/* ▼ 화살표 버튼 */
.tree-toggle-btn {
  width: 28px; height: 28px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  border-radius: 5px; transition: background .12s;
  padding: 0; margin: 0 2px;
}
.tree-toggle-btn:hover { background: rgba(0,0,0,.07); }

.toggle-arrow {
  width: 12px; height: 12px;
  stroke: var(--text3);
  transition: transform .2s cubic-bezier(.4,0,.2,1), stroke .15s;
  /* 기본: > (오른쪽) = -90도 */
  transform: rotate(-90deg);
}
/* 열렸을 때: ∨ (아래) = 0도 */
.tree-toggle-btn.open .toggle-arrow {
  transform: rotate(0deg);
  stroke: var(--primary);
}

/* 책 행 토글 자리 (빈 공간) */
.tree-toggle-spacer {
  width: 14px; height: 28px; flex-shrink: 0; margin: 0 2px;
}

/* 라벨 공통 */
.tree-label {
  flex: 1; display: flex; align-items: center;
  font-size: .92rem; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 0 6px 0 4px;
  user-select: none; min-height: 28px;
}

/* 태그 라벨 */
.tag-label {
  font-weight: 500; cursor: pointer;
  gap: 0;
}

/* 책 라벨 */
.book-label {
  text-decoration: none; cursor: pointer;
  font-weight: 400; color: var(--text2);
  padding-left: 8px;
}
.book-label:hover { color: var(--text); }

/* 책 앞 점 — 제거됨 */

/* 태그 행 열림 강조 */

/* ⋮ 버튼 */
.tree-more {
  width: 26px; height: 26px; border-radius: 5px;
  background: none; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); flex-shrink: 0; margin-right: 6px;
  opacity: 0; transition: opacity .12s, background .12s;
  font-size: .7rem; letter-spacing: .05em; line-height: 1;
}
.tree-more:hover { background: rgba(0,0,0,.07); color: var(--text2); }

/* 자식 컨테이너 */
.tree-children { display: none; flex-direction: column; gap: 1px; }
.tree-children.open { display: flex; }

/* 책 추가 인라인 행 */
.add-book-row {
  cursor: pointer; min-height: 28px;
  border-left: 2px solid transparent !important;
}
.add-book-label {
  font-size: .82rem; color: var(--text3);
  transition: color .12s;
}
.add-book-row:hover .add-book-label { color: var(--text2); }

/* ── 메모리 리스트 ── */
.memory-list { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.memory-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--border);
  transition: border-color .12s;
}
.memory-item:hover { border-color: #bbb; }
.memory-item-text {
  flex: 1; font-size: .82rem; color: var(--text2);
  word-break: break-word; line-height: 1.45;
}
.memory-item-del {
  background: none; border: none; cursor: pointer;
  font-size: .9rem; color: var(--text3); padding: 0 2px;
  line-height: 1; border-radius: 4px; transition: all .12s;
  flex-shrink: 0;
}
.memory-item-del:hover { background: #ffe0e0; color: var(--danger); }

/* ── 하단 추가 행 ── */
.bottom-actions {
  display: flex; gap: 4px;
  margin-top: 4px; padding-left: 2px;
}
.inline-row-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: var(--radius-sm);
  background: none; border: none; cursor: pointer;
  font-size: .85rem; font-family: inherit; color: var(--text3);
  transition: background .1s, color .1s;
}
.inline-row-btn:hover { background: rgba(0,0,0,.04); color: var(--text2); }
.inline-row-icon { font-size: .8rem; }

/* ════════════════════════════════════════
   팝업
════════════════════════════════════════ */
.popup-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.28); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .15s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.popup-box {
  background: var(--surface); border-radius: 10px;
  box-shadow: var(--shadow-lg);
  width: 400px; max-width: calc(100vw - 32px);
  animation: popIn .18s cubic-bezier(.34,1.56,.64,1);
  overflow: hidden;
}
@keyframes popIn {
  from { transform: scale(.94) translateY(8px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);   opacity: 1; }
}

.popup-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 10px;
}
.popup-title { font-size: .88rem; font-weight: 600; }
.popup-close {
  background: none; border: none; cursor: pointer;
  font-size: .9rem; color: var(--text2); padding: 3px 7px;
  border-radius: 4px; transition: background .12s;
}
.popup-close:hover { background: var(--bg); }

.popup-body { padding: 0 18px 14px; display: flex; flex-direction: column; }
.popup-label {
  font-size: .7rem; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text2); margin-bottom: 6px;
}
.popup-input {
  width: 100%; padding: 8px 10px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: .9rem; font-family: inherit; color: var(--text);
  outline: none; background: var(--surface); transition: border-color .15s;
}
.popup-input:focus { border-color: var(--primary); }
.popup-input::placeholder { color: var(--text3); }
.popup-input.error { border-color: var(--danger); }

.popup-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 18px 16px; border-top: 1px solid var(--border);
}
.popup-btn-cancel {
  padding: 7px 14px; border-radius: var(--radius-sm);
  background: none; border: 1px solid var(--border);
  font-size: .85rem; font-family: inherit; color: var(--text2);
  cursor: pointer; transition: all .12s;
}
.popup-btn-cancel:hover { background: var(--bg); color: var(--text); }
.popup-btn-ok {
  padding: 7px 16px; border-radius: var(--radius-sm);
  background: var(--primary); border: none;
  font-size: .85rem; font-weight: 600; font-family: inherit; color: #fff;
  cursor: pointer; transition: background .12s;
}
.popup-btn-ok:hover { background: #4a4ac4; }
.popup-btn-ok:disabled { opacity: .5; cursor: not-allowed; }

/* 드롭존 */
.drop-zone {
  border: 1.5px dashed var(--border); border-radius: var(--radius);
  background: var(--bg); cursor: pointer; transition: all .15s;
  min-height: 86px; display: flex; align-items: center; justify-content: center;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--primary); background: var(--primary-light); }
.drop-inner {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 16px; text-align: center; pointer-events: none;
}
.drop-icon { font-size: 1.6rem; margin-bottom: 2px; }
.drop-inner span { font-size: .85rem; color: var(--text2); }
.drop-inner b { color: var(--primary); font-weight: 500; }
.drop-inner small { font-size: .75rem; color: var(--text3); }

.drop-selected {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; width: 100%;
}
.drop-file-icon { font-size: 1.1rem; flex-shrink: 0; }
.drop-file-name {
  flex: 1; font-size: .85rem; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drop-file-remove {
  background: none; border: none; cursor: pointer;
  font-size: .8rem; color: var(--text3); padding: 3px 6px;
  border-radius: 4px; transition: all .12s;
}
.drop-file-remove:hover { background: #ffe0e0; color: var(--danger); }

/* 업로드 프로그레스 */
.upload-progress {
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
}
.upload-bar {
  flex: 1; height: 4px; background: var(--border);
  border-radius: 2px; overflow: hidden;
}
.upload-fill {
  height: 100%; width: 0%;
  background: var(--primary); border-radius: 2px; transition: width .25s;
}
.upload-progress span { font-size: .75rem; color: var(--text2); white-space: nowrap; }

/* ── 컨텍스트 메뉴 ── */
.ctx-menu {
  position: fixed; z-index: 200;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 4px; min-width: 148px;
  animation: fadeIn .1s;
}
.ctx-menu button {
  display: flex; align-items: center; gap: 7px;
  width: 100%; padding: 7px 10px; border-radius: var(--radius-sm);
  background: none; border: none; font-size: .85rem; font-family: inherit;
  color: var(--text); cursor: pointer; transition: background .1s; text-align: left;
}
.ctx-menu button:hover { background: var(--bg); }
.ctx-sep { height: 1px; background: var(--border); margin: 3px 0; }
.ctx-danger { color: var(--danger) !important; }
.ctx-danger:hover { background: #fff0f0 !important; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60%  { transform: translateX(-4px); }
  40%,80%  { transform: translateX(4px); }
}

/* ════════════════════════════════════════
   뷰어
════════════════════════════════════════ */
.viewer-body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }

.viewer-nav {
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px; height: 48px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0; z-index: 10;
}
.nav-back {
  display: flex; align-items: center; gap: 5px;
  color: var(--text2); text-decoration: none; font-size: .85rem;
  padding: 6px 12px; border-radius: 20px; transition: all .12s;
}
.nav-back:hover { background: var(--bg); color: var(--text); }
.nav-back svg { width: 13px; height: 13px; stroke: currentColor; }
.nav-title { flex: 1; overflow: hidden; }
.nav-file { font-size: .9rem; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-page-ctrl { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.nav-page-ctrl button {
  width: 28px; height: 28px; border-radius: 14px;
  background: var(--bg); border: 1px solid var(--border);
  cursor: pointer; font-size: 14px; color: var(--text2);
  display: flex; align-items: center; justify-content: center; transition: all .12s;
}
.nav-page-ctrl button:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.nav-page-ctrl button:disabled { opacity: .35; cursor: not-allowed; }
#pageInfo { font-size: .78rem; color: var(--text2); min-width: 52px; text-align: center; }

.viewer-layout { flex: 1; display: flex; overflow: hidden; }

.pdf-panel {
  flex: 1; min-width: 300px; overflow: auto;
  background: #404040;
  display: flex; flex-direction: column;
  align-items: center;
  position: relative;
}

/* 페이지 래퍼 — 2페이지 나란히 */
.pdf-pages-wrap {
  flex: 1; display: flex; flex-direction: row;
  align-items: center; justify-content: center;
  gap: 4px; padding: 12px;
  overflow: auto; width: 100%;
  position: relative;
}

/* PDF 페이지 컨테이너 */
.pdf-page-container {
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 2px 16px rgba(0,0,0,.5);
  border-radius: 1px;
  background: #fff;
}

.pdf-page-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* PDF 텍스트 레이어 */
.textLayer {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  opacity: 1;
  line-height: 1;
  text-size-adjust: none;
  forced-color-adjust: none;
}

.textLayer span,
.textLayer br {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}

.textLayer span.markedContent {
  top: 0;
  height: 0;
}

.textLayer .highlight {
  margin: -1px;
  padding: 1px;
  background-color: rgba(180, 0, 170, 0.2);
  border-radius: 4px;
}

.textLayer .highlight.appended {
  position: initial;
}

.textLayer .highlight.begin {
  border-radius: 4px 0 0 4px;
}

.textLayer .highlight.end {
  border-radius: 0 4px 4px 0;
}

.textLayer .highlight.middle {
  border-radius: 0;
}

.textLayer .highlight.selected {
  background-color: rgba(0, 100, 0, 0.2);
}

.textLayer ::selection {
  background: rgba(0, 100, 255, 0.3);
}

.textLayer br::selection {
  background: transparent;
}

.textLayer .endOfContent {
  display: block;
  position: absolute;
  left: 0;
  top: 100%;
  right: 0;
  bottom: 0;
  z-index: -1;
  cursor: default;
  user-select: none;
}

.textLayer .endOfContent.active {
  top: 0;
}

/* 페이지 컨트롤 — PDF 아래 */
.pdf-controls {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0 12px; flex-shrink: 0;
}
.pdf-controls-left { margin-right: auto; }
.pdf-controls button {
  width: 32px; height: 32px; border-radius: 16px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.pdf-controls button svg { width: 14px; height: 14px; stroke: #fff; }
.pdf-controls button:hover { background: rgba(255,255,255,.22); }
.pdf-controls button:disabled { opacity: .3; cursor: not-allowed; }
#pageInfo { font-size: .8rem; color: rgba(255,255,255,.7); min-width: 80px; text-align: center; }

.pdf-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; gap: 10px; padding: 60px 0;
}
.spinner {
  width: 32px; height: 32px; border: 2.5px solid rgba(255,255,255,.25);
  border-top-color: #fff; border-radius: 50%; 
  animation: smoothSpin 1s linear infinite;
  will-change: transform;
}
@keyframes smoothSpin { 
  from { transform: rotate(0deg); } 
  to { transform: rotate(360deg); } 
}

.panel-divider {
  width: 4px; background: var(--border); cursor: col-resize; flex-shrink: 0; transition: background .15s;
}
.panel-divider:hover { background: var(--primary); }

/* 채팅 패널 */
.chat-panel {
  width: 380px; min-width: 280px; max-width: 560px;
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border); flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.chat-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, 
    rgba(34, 197, 94, 0.12), 
    rgba(251, 146, 60, 0.12), 
    rgba(239, 68, 68, 0.10),
    rgba(251, 146, 60, 0.12),
    rgba(34, 197, 94, 0.12));
  background-size: 400% 400%;
  opacity: 0;
  transition: opacity .5s;
  pointer-events: none;
  z-index: 0;
}
.chat-panel.voice-active::before {
  opacity: 1;
  animation: colorfulWave 2.5s ease-in-out infinite;
}
@keyframes colorfulWave {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}.chat-panel > * {
  position: relative;
  z-index: 1;
}

/* 음성 듣기 상태 오버레이 */
.voice-listening-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  flex-direction: column;
  gap: 12px;
}
.voice-listening-overlay.show {
  display: flex;
}
.voice-overlay-close {
  position: absolute;
  top: 14px; right: 14px;
  background: none; border: none; cursor: pointer;
  font-size: 1rem; color: var(--text3);
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all .12s;
}
.voice-overlay-close:hover { background: var(--bg); color: var(--text); }
.chat-header {
  display: none;
}
.chat-header-title { font-size: .88rem; font-weight: 600; color: var(--text); }

/* 탭 */
.chat-tabs {
  display: flex; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  position: relative; z-index: 1;
}
.chat-tab {
  padding: 12px 16px; background: none; border: none;
  font-size: .85rem; font-family: inherit; color: var(--text3);
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: all .15s; font-weight: 500;
}
.chat-tab:hover { color: var(--text2); }
.chat-tab.active { color: var(--text); border-bottom-color: var(--text); }

/* 탭 패널 */
.tab-panel {
  flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative;
}

/* 히스토리 화면 */
.history-screen {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  position: relative;
}
.history-list { flex: 1; overflow-y: auto; padding: 8px; }
.history-item {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  transition: background .12s; margin-bottom: 2px;
}
.history-item:hover { background: var(--bg); }
.history-item.active { background: var(--primary-light); }
.history-item-title {
  flex: 1; font-size: .85rem; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item-del {
  background: none; border: none; cursor: pointer;
  color: var(--text3); font-size: .75rem; padding: 2px 6px;
  border-radius: 4px; opacity: 0; transition: all .12s;
}
.history-item:hover .history-item-del { opacity: 1; }
.history-item-del:hover { background: #ffe0e0; color: var(--danger); }
.history-fab {
  position: absolute; bottom: 16px; right: 16px;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--text); border: none; color: #fff;
  font-size: 1.4rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.18); transition: opacity .12s;
}
.history-fab:hover { opacity: .8; }

/* 채팅 화면 */
.chat-screen {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}

/* AI 스튜디오 */
.studio-content {
  flex: 1; overflow-y: auto; padding: 16px;
}
.studio-section {
  margin-bottom: 24px;
}
.studio-section-title {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.studio-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 200px; gap: 10px;
}
.studio-empty-icon { font-size: 2rem; }
.studio-empty-text { font-size: .85rem; color: var(--text3); }
.studio-exam-list { display: flex; flex-direction: column; gap: 10px; }
.studio-exam-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 14px 16px; cursor: pointer;
  transition: all .15s;
}
.studio-exam-card:hover { border-color: #c0c0c0; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.studio-exam-title { font-size: .9rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.studio-exam-meta {
  display: flex; align-items: center; justify-content: space-between;
}
.studio-exam-count { font-size: .75rem; color: var(--text3); }
.studio-exam-del {
  background: none; border: none; cursor: pointer;
  font-size: .75rem; color: var(--text3); padding: 3px 8px;
  border-radius: 8px; transition: all .12s;
}
.studio-exam-del:hover { background: #ffe0e0; color: var(--danger); }
.exam-quick-btn {
  padding: 6px 14px; border-radius: 20px;
  background: var(--text); border: none;
  font-size: .78rem; font-weight: 500; font-family: inherit; color: #fff;
  cursor: pointer; transition: opacity .12s; white-space: nowrap;
}
.exam-quick-btn:hover { opacity: .8; }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* AI 텍스트 — 말풍선 없이 */
.ai-message-plain {
  font-size: .88rem; line-height: 1.7; color: var(--text2);
  padding: 0 2px;
}
.ai-message-plain code {
  background: var(--bg); padding: 1px 5px;
  border-radius: 3px; font-size: .82em;
}

/* ── 마크다운 렌더링 스타일 ── */
.md-h1, .md-h2, .md-h3, .md-h4, .md-h5, .md-h6 {
  color: var(--text); font-weight: 700; line-height: 1.3;
  margin: .9em 0 .3em;
}
.md-h1 { font-size: 1.15rem; }
.md-h2 { font-size: 1.05rem; }
.md-h3 { font-size: .97rem; }
.md-h4, .md-h5, .md-h6 { font-size: .9rem; }

.md-p { margin: .25em 0; }
.md-gap { height: .5em; }

.md-ul, .md-ol {
  margin: .3em 0 .3em 1.2em;
  padding: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.md-li { line-height: 1.6; }

.md-bq {
  border-left: 3px solid var(--callout-bar);
  margin: .4em 0; padding: .3em .8em;
  color: var(--text2); background: var(--bg);
  border-radius: 0 4px 4px 0;
  font-style: italic;
}

.md-hr {
  border: none; border-top: 1px solid var(--border);
  margin: .6em 0;
}

.md-pre {
  background: #1e1e2e; border-radius: 6px;
  padding: .7em 1em; margin: .5em 0;
  overflow-x: auto;
}
.md-code {
  font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
  font-size: .8rem; color: #cdd6f4; line-height: 1.6;
  white-space: pre;
}
.md-inline-code {
  background: var(--bg); padding: 1px 5px;
  border-radius: 3px; font-size: .82em;
  font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
  color: var(--text);
}
.md-link {
  color: var(--primary); text-decoration: underline;
  text-underline-offset: 2px;
}
.md-link:hover { opacity: .75; }

/* 사용자 말풍선 */
.user-bubble { display: flex; justify-content: flex-end; }
.user-bubble-content {
  max-width: 78%; padding: 9px 13px;
  background: var(--text); color: #fff;
  border-radius: 14px 14px 3px 14px;
  font-size: .88rem; line-height: 1.6;
}

/* 타이핑 */
.typing-indicator { display: inline-flex; gap: 3px; align-items: center; }
.typing-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text3); animation: typing 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typing { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }

.chat-input-area { padding: 10px; flex-shrink: 0; }
.chat-input-wrap {
  display: flex; gap: 6px; align-items: center;
  background: var(--bg); border-radius: 24px;
  border: 1.5px solid var(--border); padding: 6px 6px 6px 16px; transition: all .3s;
}
.chat-input-wrap:focus-within { border-color: var(--text); }
#chatInput {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: .85rem; font-family: inherit; color: var(--text);
  resize: none; max-height: 100px; line-height: 1.5;
  padding: 4px 0;
}
#chatInput::placeholder { color: var(--text3); }
.send-btn {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--text); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .3s;
  position: relative;
}
.send-btn:hover { opacity: .75; }
.send-btn:disabled { opacity: .3; cursor: not-allowed; }
.send-btn svg { width: 14px; height: 14px; stroke: #fff; transition: all .3s; }

/* 시험지 생성 상태 표시 */
.exam-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: .82rem;
  color: var(--text2);
  margin: 4px 0;
}
.exam-status-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: smoothSpin 1s linear infinite;
  will-change: transform;
}
@keyframes smoothSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ── 교육과정 검색(RAG) 진행 패널 ── */
.rag-panel {
  margin: 2px 0 6px;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  font-size: .78rem;
  animation: ragFade .25s ease;
}
@keyframes ragFade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
.rag-head {
  display: flex; align-items: center; gap: 7px;
  font-weight: 600; color: var(--text2);
}
.rag-spinner {
  width: 11px; height: 11px; flex-shrink: 0;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: smoothSpin .9s linear infinite;
}
.rag-check {
  width: 14px; height: 14px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff;
  border-radius: 50%; font-size: .62rem; font-weight: 700;
}
.rag-list { margin-top: 7px; display: flex; flex-direction: column; gap: 5px; }
.rag-item {
  display: flex; gap: 7px; align-items: flex-start;
  animation: ragFade .25s ease;
}
.rag-doc { flex-shrink: 0; font-size: .82rem; line-height: 1.4; }
.rag-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.rag-file {
  color: var(--text); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.rag-q { color: var(--text3); font-size: .72rem; }
.rag-snip {
  color: var(--text3); font-size: .7rem; line-height: 1.35;
  opacity: .8; margin-top: 1px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 시험지 카드 (채팅 메시지 안에) */
.exam-card-inline {
  background: #fff;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  padding: 16px 18px;
  margin: 8px 0;
  cursor: pointer;
  transition: all .15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  display: block;
  width: 100%;
  max-width: 100%;
}
.exam-card-inline:hover {
  border-color: #c0c0c0;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.ppt-card:hover {
  border-color: #fcd5c0;
  box-shadow: 0 2px 8px rgba(224,90,43,.1);
}
.exam-card-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.exam-card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
}
.exam-card-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: .72rem;
  font-weight: 600;
  background: var(--bg);
  color: var(--text2);
  border: 1px solid var(--border);
  align-self: flex-start;
}

/* 시험지 모달 — 전체화면 */
.fullscreen-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: var(--surface);
  display: flex; flex-direction: column;
  animation: fadeIn .18s;
}
.fullscreen-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 0 0 24px; height: 56px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
.fullscreen-title {
  font-size: 1rem; font-weight: 600; color: var(--text);
}
.fullscreen-actions {
  display: flex; align-items: center; gap: 8px;
  padding-right: 16px;
}
.fullscreen-close {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .12s; flex-shrink: 0;
}
.fullscreen-close:hover { background: #ffe0e0; border-color: var(--danger); }
.fullscreen-close svg { width: 14px; height: 14px; stroke: var(--text2); }
.fullscreen-close:hover svg { stroke: var(--danger); }
.fullscreen-body {
  flex: 1; overflow-y: auto; padding: 32px;
  max-width: 760px; width: 100%; margin: 0 auto;
}

.exam-question {
  margin-bottom: 36px;
}
.exam-question:last-of-type {
  margin-bottom: 0;
}
.question-num { 
  display: none;
}
.question-text { 
  font-size: .92rem; 
  font-weight: 500; 
  margin-bottom: 16px; 
  line-height: 1.6; 
  color: var(--text);
}
/* 해설 영역 */
.question-explanation {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 8px;
  border-left: 3px solid var(--border);
  display: none;
}
.question-explanation.show {
  display: block;
}
.question-explanation.correct {
  background: #f0faf5;
  border-left-color: var(--success);
}
.question-explanation.wrong {
  background: #fff0f0;
  border-left-color: var(--danger);
}
.explanation-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text3);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.explanation-text {
  font-size: .85rem;
  line-height: 1.6;
  color: var(--text2);
}
.correct-answer-text {
  font-size: .82rem;
  color: var(--danger);
  margin-top: 8px;
  font-weight: 500;
}

/* 점수 카드 */
.score-summary {
  background: linear-gradient(135deg, var(--text), #4a4a4a);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  color: #fff;
  margin-bottom: 24px;
  display: none;
}
.score-summary.show {
  display: block;
}
.score-big {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 8px;
}
.score-label {
  font-size: .9rem;
  opacity: .85;
}
.options-list { 
  display: flex; 
  flex-direction: column; 
  gap: 8px; 
  margin-bottom: 4px;
}
.option-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 13px; border-radius: 20px;
  border: 1.5px solid var(--border); cursor: pointer;
  transition: all .12s; background: var(--surface); font-size: .85rem;
}
.option-item:hover { border-color: var(--primary); background: var(--primary-light); }
.option-item.selected { border-color: var(--primary); background: var(--primary-light); }
.option-item.correct { border-color: var(--success); background: #f0faf5; }
.option-item.wrong { border-color: var(--danger); background: #fff0f0; }
.option-radio {
  width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--border);
  flex-shrink: 0; transition: all .12s; display: flex; align-items: center; justify-content: center;
}
.option-item.selected .option-radio { border-color: var(--primary); background: var(--primary); }
.option-item.selected .option-radio::after { content: ''; width: 5px; height: 5px; border-radius: 50%; background: #fff; }
.option-text { font-size: .85rem; }
.short-answer-input {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: 20px;
  font-size: .88rem; font-family: inherit; outline: none; transition: border-color .15s;
}
.short-answer-input:focus { border-color: var(--primary); }
.short-answer-input.correct { border-color: var(--success); background: #f0faf5; }
.short-answer-input.wrong { border-color: var(--danger); background: #fff0f0; }

.btn-submit {
  padding: 8px 22px; border-radius: 20px;
  background: var(--text); border: none;
  font-size: .85rem; font-weight: 600; font-family: inherit; color: #fff;
  cursor: pointer; transition: opacity .12s;
}
.btn-submit:hover { opacity: .85; }
.btn-retry {
  padding: 8px 22px; border-radius: 20px;
  background: var(--bg); border: 1.5px solid var(--border);
  font-size: .85rem; font-weight: 600; font-family: inherit; color: var(--text2);
  cursor: pointer; transition: all .12s;
}
.btn-retry:hover { background: var(--border); color: var(--text); }

.result-score-card {
  text-align: center; padding: 28px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: var(--radius); color: #fff; margin-bottom: 20px;
}
.result-score-big { font-size: 3.2rem; font-weight: 800; line-height: 1; }
.result-score-label { font-size: .85rem; opacity: .8; margin-top: 4px; }
.result-percentage { font-size: 1.1rem; font-weight: 700; margin-top: 6px; }
.result-item {
  padding: 11px 13px; border-radius: var(--radius-sm);
  margin-bottom: 8px; border: 1.5px solid var(--border);
}
.result-item.correct-item { border-color: var(--success); background: #f0faf5; }
.result-item.wrong-item { border-color: var(--danger); background: #fff0f0; }
.result-item-header { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.result-badge { padding: 2px 7px; border-radius: 20px; font-size: .72rem; font-weight: 700; }
.correct-item .result-badge { background: var(--success); color: #fff; }
.wrong-item .result-badge { background: var(--danger); color: #fff; }
.result-q { font-weight: 500; font-size: .85rem; }
.result-answers { font-size: .78rem; color: var(--text2); margin-top: 3px; }
.result-explanation { font-size: .78rem; color: var(--text2); margin-top: 4px; padding-top: 4px; border-top: 1px dashed var(--border); }

/* ── 마인드맵 에디터 ── */
.mm-fullscreen-body {
  padding: 0;
  overflow: hidden;
  max-width: 100%;
}
.mm-canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #f8f8f7;
  cursor: default;
}
.mm-svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1;
}
/* 마인드맵 노드 */
.mm-node {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: .85rem;
  font-family: 'Noto Sans KR', sans-serif;
  line-height: 1.4;
  text-align: center;
  cursor: grab;
  user-select: none;
  max-width: 160px;
  word-break: keep-all;
  transition: box-shadow .15s;
  white-space: pre-wrap;
}
.mm-node:active { cursor: grabbing; }
.mm-node.mm-center {
  background: var(--text);
  color: #fff;
  font-weight: 700;
  font-size: .95rem;
  padding: 14px 24px;
  border-radius: 24px;
  max-width: 200px;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
}
.mm-node.mm-regular {
  background: #fff;
  color: var(--text);
  font-weight: 500;
  border: 2px solid var(--primary);
  box-shadow: 0 2px 8px rgba(91,91,214,.12);
}
.mm-node.mm-regular:hover, .mm-node.mm-center:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
}
.mm-node.mm-selected {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
/* 간선 */
.mm-edge {
  stroke: #c8c8e8;
  stroke-width: 2;
  stroke-linecap: round;
  fill: none;
}
/* 헤더 버튼 */
.mm-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 7px 14px; border-radius: 20px;
  background: var(--bg); border: 1.5px solid var(--border);
  font-size: .82rem; font-family: inherit; color: var(--text2);
  cursor: pointer; transition: all .12s;
}
.mm-btn svg { width: 13px; height: 13px; }
.mm-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.mm-btn-save {
  background: var(--text); border-color: var(--text); color: #fff;
}
.mm-btn-save:hover { opacity: .8; background: var(--text); color: #fff; border-color: var(--text); }
.mm-btn-connect.active {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
/* 연결 모드일 때 캔버스 커서 */
.mm-canvas-wrap.connect-mode { cursor: crosshair; }
.mm-canvas-wrap.connect-mode .mm-node { cursor: pointer; }
/* 연결 대기 중인 노드 강조 */
.mm-node.mm-connect-source {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
  animation: mmPulse .8s ease-in-out infinite alternate;
}
@keyframes mmPulse {
  from { box-shadow: 0 0 0 0 rgba(91,91,214,.4); }
  to   { box-shadow: 0 0 0 8px rgba(91,91,214,0); }
}
/* 연결 가능한 노드 호버 */
.mm-canvas-wrap.connect-mode .mm-node:not(.mm-connect-source):hover {
  outline: 2px dashed var(--primary);
  outline-offset: 3px;
}
/* 노드 편집 팝업 */
.mm-node-editor {
  position: absolute;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 100;
  min-width: 220px;
}
.mm-node-input {
  width: 100%; padding: 8px 12px;
  border: 1.5px solid var(--border); border-radius: 20px;
  font-size: .88rem; font-family: inherit; outline: none;
  margin-bottom: 8px;
}
.mm-node-input:focus { border-color: var(--primary); }
.mm-node-editor-btns { display: flex; gap: 6px; }
.mm-editor-btn {
  flex: 1; padding: 6px 0; border-radius: 20px;
  font-size: .8rem; font-family: inherit; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--bg); color: var(--text2);
  transition: all .12s;
}
.mm-editor-ok { background: var(--text); border-color: var(--text); color: #fff; }
.mm-editor-ok:hover { opacity: .8; }
.mm-editor-del { border-color: var(--danger); color: var(--danger); }
.mm-editor-del:hover { background: #fff0f0; }
.mm-editor-cancel:hover { background: var(--border); }
/* 힌트 */
.mm-hint {
  position: absolute;
  bottom: 14px; left: 50%; transform: translateX(-50%);
  font-size: .75rem; color: var(--text3);
  background: rgba(255,255,255,.85);
  padding: 5px 14px; border-radius: 20px;
  pointer-events: none;
  white-space: nowrap;
}

/* ── 생성 중 카드 글로우 애니메이션 ── */
@keyframes generatingGlow {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.generating-studio-card {
  background: linear-gradient(
    135deg,
    #fff 0%, #f0f0ff 20%, #fff3ee 40%,
    #f0fff4 60%, #fff0f8 80%, #fff 100%
  ) !important;
  background-size: 300% 300% !important;
  animation: generatingGlow 3s ease-in-out infinite;
  border-color: transparent !important;
  box-shadow: 0 0 0 1.5px rgba(91,91,214,.25),
              0 2px 12px rgba(91,91,214,.1) !important;
  cursor: default !important;
}
.generating-studio-card:hover {
  box-shadow: 0 0 0 1.5px rgba(91,91,214,.4),
              0 4px 16px rgba(91,91,214,.15) !important;
}
.generating-label {
  color: var(--text3) !important;
  font-style: italic;
}
/* 채팅 메시지 안 생성 중 카드 */
.generating-card {
  background: linear-gradient(
    135deg,
    #fff 0%, #f0f0ff 25%, #fff3ee 50%,
    #f0fff4 75%, #fff 100%
  ) !important;
  background-size: 300% 300% !important;
  animation: generatingGlow 3s ease-in-out infinite;
  border-color: transparent !important;
  box-shadow: 0 0 0 1.5px rgba(91,91,214,.2),
              0 2px 10px rgba(91,91,214,.08) !important;
  cursor: default !important;
}

/* ── PPT 뷰어 ── */
.ppt-viewer-body {
  flex: 1; display: flex; overflow: hidden;
}
.ppt-sidebar {
  width: 160px; flex-shrink: 0;
  background: #f0f0ef;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 10px 8px;
  display: flex; flex-direction: column; gap: 8px;
}
.ppt-thumb {
  width: 100%; aspect-ratio: 16/9;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
  transition: all .15s;
  flex-shrink: 0;
  position: relative;
}
.ppt-thumb:hover { border-color: var(--primary); }
.ppt-thumb.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.ppt-thumb-num {
  position: absolute; bottom: 3px; right: 5px;
  font-size: .6rem; color: var(--text3);
}
.ppt-main {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: #404040; overflow: hidden; padding: 12px;
}
.ppt-slide-wrap {
  width: 100%; max-width: 100%;
  aspect-ratio: 16/9;
  background: #f8f9fa;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
  overflow: hidden;
  position: relative;
}
/* 슬라이드 내부 공통 */
.ppt-slide {
  width: 100%; height: 100%;
  position: relative;
  font-family: 'Noto Sans KR', sans-serif;
  overflow: hidden;
}
/* 커버 슬라이드 */
.ppt-cover {
  display: flex;
}
.ppt-cover-left {
  width: 39%; height: 100%;
  position: relative; flex-shrink: 0;
  overflow: hidden;
}
.ppt-cover-deco1 {
  position: absolute; width: 70%; aspect-ratio: 1;
  border-radius: 50%;
  top: -15%; left: -20%;
  opacity: .6;
}
.ppt-cover-deco2 {
  position: absolute; width: 55%; aspect-ratio: 1;
  border-radius: 50%;
  bottom: -10%; right: -10%;
  opacity: .7;
}
.ppt-cover-right {
  flex: 1; display: flex; flex-direction: column;
  justify-content: center; padding: 6% 5%;
}
.ppt-cover-title {
  font-size: clamp(1.4rem, 3.5vw, 2.8rem);
  font-weight: 800; line-height: 1.2;
  margin-bottom: 4%;
}
.ppt-cover-line {
  height: 3px; width: 40%; border-radius: 2px; margin-bottom: 3%;
}
.ppt-cover-subtitle {
  font-size: clamp(.75rem, 1.5vw, 1.1rem);
  line-height: 1.5;
}
/* 일반 슬라이드 헤더 */
.ppt-header {
  position: absolute; top: 0; left: 0; right: 0;
  height: 14%; background: #fff;
  display: flex; align-items: center;
  padding: 0 2%;
  border-bottom: 2px solid transparent;
}
.ppt-header-bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: .5%;
}
.ppt-header-title {
  font-size: clamp(.8rem, 1.8vw, 1.3rem);
  font-weight: 700; margin-left: 2%;
  flex: 1;
}
.ppt-header-badge {
  width: 4%; aspect-ratio: 1;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(.5rem, 1vw, .75rem);
  font-weight: 700; color: #fff;
  flex-shrink: 0;
}
/* 슬라이드 본문 */
.ppt-body {
  position: absolute; top: 14%; left: 0; right: 0; bottom: 0;
  padding: 2.5% 3%;
  display: flex; gap: 2%;
}
.ppt-bullets-col, .ppt-right-col {
  flex: 1; display: flex; flex-direction: column; gap: 4%;
  overflow: hidden;
}
.ppt-bullet-item {
  display: flex; align-items: flex-start; gap: 6%;
  font-size: clamp(.6rem, 1.3vw, .95rem);
  line-height: 1.5;
}
.ppt-bullet-badge {
  width: clamp(16px, 2.5%, 22px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(.45rem, .9vw, .65rem);
  font-weight: 700; color: #fff;
  flex-shrink: 0; margin-top: .1em;
}
/* 표 */
.ppt-table {
  width: 100%; border-collapse: collapse;
  font-size: clamp(.5rem, 1.1vw, .8rem);
}
.ppt-table th {
  padding: 3% 4%; text-align: center;
  font-weight: 700; color: #fff;
}
.ppt-table td {
  padding: 2.5% 4%; text-align: center;
  border-bottom: 1px solid #eee;
}
.ppt-table tr:last-child td { border-bottom: none; }
/* 차트 컨테이너 */
.ppt-chart-wrap {
  flex: 1; position: relative; min-height: 0;
}
.ppt-chart-wrap canvas { width: 100% !important; height: 100% !important; }
/* 엔딩 슬라이드 */
.ppt-ending {
  display: flex;
}
.ppt-ending-msg {
  font-size: clamp(1.2rem, 3vw, 2.4rem);
  font-weight: 800;
}
.ppt-ending-line {
  height: 3px; width: 35%; border-radius: 2px; margin-top: 3%;
}
/* 슬라이드 카운터 */
.ppt-slide-counter {
  font-size: .82rem; color: var(--text3);
  padding: 0 4px;
}

/* ── 영상 뷰어 ── */
.video-viewer-body {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: #1a1a1a; overflow: hidden; padding: 20px;
}
.video-player {
  width: 100%; max-width: 1280px;
  max-height: calc(100vh - 80px);
  border-radius: 6px;
  box-shadow: 0 4px 32px rgba(0,0,0,.6);
  background: #000;
  outline: none;
}
/* 영상 카드 */
.video-card:hover {
  border-color: #ddd6fe;
  box-shadow: 0 2px 8px rgba(124,58,237,.1);
}

/* ── 타이머 위젯 ── */
.timer-widget {
  position: absolute; top: 12px; right: 12px; z-index: 20;
  background: rgba(30,30,30,.92); backdrop-filter: blur(10px);
  border-radius: 10px; padding: 8px 14px;
  display: none; flex-direction: column; align-items: center; gap: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.4); min-width: 110px;
  color: #fff; font-size: .82rem; user-select: none;
}
.timer-widget.show { display: flex; }
.timer-display {
  font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums;
  letter-spacing: .04em; color: #e0e0e0;
}
.timer-display.running { color: #4ade80; }
.timer-display.paused { color: #facc15; }
.timer-label { font-size: .72rem; color: rgba(255,255,255,.5); }
.timer-btns { display: flex; gap: 4px; }
.timer-btn {
  width: 28px; height: 28px; border-radius: 6px; border: none;
  background: rgba(255,255,255,.12); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s; font-size: .72rem;
}
.timer-btn:hover { background: rgba(255,255,255,.22); }
.timer-btn.active { background: var(--primary); }


/* ── 펜 모드 ── */
.pdf-controls-left { display: flex; align-items: center; gap: 4px; }
.pen-btn {
  width: 32px; height: 32px; border-radius: 16px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.pen-btn:hover { background: rgba(255,255,255,.22); }
.pen-btn.active {
  background: var(--primary); border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(91,91,214,.35);
}
.pen-btn svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2; }

/* ── 드로잉 툴바 ── */
.draw-toolbar {
  position: absolute; bottom: 56px; left: 50%;
  transform: translateX(-50%);
  background: rgba(30,30,30,.94); backdrop-filter: blur(10px);
  border-radius: 12px; padding: 8px 14px;
  display: none; align-items: center; gap: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.5); z-index: 25;
}
.draw-toolbar.show { display: flex; }
.draw-tool-group { display: flex; gap: 4px; }
.draw-tool {
  width: 30px; height: 30px; border-radius: 8px; border: 2px solid transparent;
  background: rgba(255,255,255,.1); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .12s; color: #fff; font-size: .7rem;
}
.draw-tool:hover { background: rgba(255,255,255,.2); }
.draw-tool.active { border-color: var(--primary); background: rgba(91,91,214,.25); }
.draw-tool svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.draw-sep { width: 1px; height: 24px; background: rgba(255,255,255,.15); }
.draw-colors { display: flex; gap: 4px; align-items: center; }
.draw-color {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; transition: all .12s;
}
.draw-color:hover { transform: scale(1.15); }
.draw-color.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.3); }
.draw-size { display: flex; align-items: center; gap: 4px; }
.draw-size input[type="range"] {
  width: 60px; accent-color: var(--primary); height: 4px;
}
.draw-size-label { font-size: .68rem; color: rgba(255,255,255,.5); min-width: 18px; text-align: center; }

/* ── 드로잉 오버레이 ── */
.drawing-overlay {
  position: absolute; inset: 0; z-index: 15;
  pointer-events: none; touch-action: none;
}
.drawing-overlay.canvas-active { pointer-events: auto; cursor: crosshair; }
.drawing-overlay.eraser-cursor { cursor: cell; }

/* ── 메모리 토스트 ── */
.memory-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px);
  background: var(--text); color: var(--surface); padding: 10px 20px;
  border-radius: 20px; font-size: .82rem; font-weight: 500;
  box-shadow: var(--shadow-lg); z-index: 9999;
  opacity: 0; transition: all .35s ease; pointer-events: none;
}
.memory-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── 온보딩 페이지 ── */
.onb-page-body { min-height: 100vh; display: flex; flex-direction: column; }
.onb-page {
  max-width: 680px; width: 100%; margin: 0 auto;
  padding: 0 24px 24px;
  display: flex; flex-direction: column;
  min-height: 100vh;
}
.onb-page-messages {
  flex: 1; overflow-y: auto; padding: 24px 0;
  display: flex; flex-direction: column; gap: 14px;
}
.onb-page-input-row {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 16px 0 24px;
  background: var(--bg);
}
.onb-page-input-wrap {
  flex: 1; background: var(--bg);
  border-radius: 24px; overflow: hidden;
  border: 1px solid var(--border);
  transition: border-color .15s;
}
.onb-page-input-wrap:focus-within { border-color: var(--primary); }
.onb-page-input {
  width: 100%; padding: 11px 18px; border: none; background: none;
  font-size: .88rem; font-family: inherit; color: var(--text);
  outline: none; line-height: 1.4;
}
.onb-page-input::placeholder { color: var(--text3); }
.onb-page-send {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: var(--text); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--surface); transition: opacity .15s, transform .1s;
}
.onb-page-send:hover { opacity: .8; }
.onb-page-send:active { transform: scale(.95); }
.onb-page-send:disabled { opacity: .35; cursor: default; }
.onb-page-send svg { width: 20px; height: 20px; }

/* 온보딩 사용자 말풍선 */
.onb-bubble {
  max-width: 85%; padding: 10px 16px; border-radius: 18px;
  font-size: .85rem; line-height: 1.55; word-break: break-word;
}
.onb-bubble-user {
  align-self: flex-end;
  background: var(--text); color: #fff;
  border-bottom-right-radius: 6px;
}

/* 온보딩 AI 일반 텍스트 */
.onb-ai-text {
  font-size: .87rem; line-height: 1.65; color: var(--text);
  word-break: break-word;
}
.onb-ai-text .md-h1, .onb-ai-text .md-h2, .onb-ai-text .md-h3,
.onb-ai-text .md-h4, .onb-ai-text .md-h5, .onb-ai-text .md-h6 {
  font-weight: 600; margin: 8px 0 4px; color: var(--text);
}
.onb-ai-text .md-h1 { font-size: 1.2rem; }
.onb-ai-text .md-h2 { font-size: 1.08rem; }
.onb-ai-text .md-h3 { font-size: .98rem; }
.onb-ai-text .md-p { margin: 3px 0; line-height: 1.65; }
.onb-ai-text .md-gap { height: 6px; }
.onb-ai-text .md-ul, .onb-ai-text .md-ol { margin: 4px 0; padding-left: 18px; }
.onb-ai-text .md-li { margin: 2px 0; line-height: 1.5; }
.onb-ai-text .md-bq {
  border-left: 3px solid var(--callout-bar);
  padding: 4px 12px; margin: 6px 0; color: var(--text2);
  background: rgba(0,0,0,.02); border-radius: 0 6px 6px 0;
}
.onb-ai-text .md-hr { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.onb-ai-text .md-pre {
  background: rgba(0,0,0,.04); padding: 10px 14px; border-radius: 8px;
  overflow-x: auto; margin: 6px 0; font-size: .8rem;
}
.onb-ai-text .md-inline-code {
  background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 3px;
  font-size: .82rem; font-family: monospace;
}
.onb-ai-text strong { font-weight: 600; }
.onb-ai-text em { font-style: italic; }
.onb-ai-text del { text-decoration: line-through; opacity: .6; }
.onb-ai-text .md-link { color: var(--primary); text-decoration: underline; }

/* 온보딩 타이핑 인디케이터 */
.onb-typing {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 8px;
}
.onb-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text3); animation: onbDot 1.3s infinite ease-in-out;
}
.onb-typing span:nth-child(2) { animation-delay: .15s; }
.onb-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes onbDot {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-8px); opacity: 1; }
}

@media (max-width: 768px) {
  .home-container { padding: 40px 20px 80px; }
  .viewer-layout { flex-direction: column; }
  .chat-panel { width: 100%; max-width: 100%; border-left: none; border-top: 1px solid var(--border); height: 45vh; }
  .pdf-panel { height: 55vh; }
  .panel-divider { display: none; }
}
