/* Open Notebook — Cloudflare 포팅. 외부 CDN 의존 없음(엄격 CSP). */
/* 다크(기본) 토큰 */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1014; --surface: #171a21; --surface-2: #1d212a; --surface-3: #232834;
  --border: #282d38; --border-2: #333a48;
  --text: #e8ebf1; --muted: #98a1b2; --faint: #6b7383;
  --accent: #7c9bff; --accent-2: #5570f2; --accent-soft: rgba(108,140,255,.14);
  --ok: #46c08a; --warn: #e0a64a; --danger: #e8606a; --chip: #232834;
  --radius-sm: 8px; --radius: 11px; --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.2);
  --shadow: 0 8px 30px rgba(0,0,0,.4);
  --ring: 0 0 0 3px var(--accent-soft);
  --sp1: 4px; --sp2: 8px; --sp3: 12px; --sp4: 16px; --sp5: 24px;
}
/* 라이트 토큰 — 명시적 선택 시 */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f9; --surface: #ffffff; --surface-2: #f3f5f9; --surface-3: #eaeef4;
  --border: #e3e7ee; --border-2: #d4dae4;
  --text: #161b25; --muted: #5b6472; --faint: #8b94a4;
  --accent: #3a5bd9; --accent-2: #3050d4; --accent-soft: rgba(58,91,217,.10);
  --ok: #2e9c6e; --warn: #c98a2e; --danger: #d6505a;
  --chip: #eef1f6; --shadow-sm: 0 1px 2px rgba(20,30,60,.06); --shadow: 0 10px 34px rgba(20,30,60,.12);
}
/* 시스템 설정 따름(테마 미지정) + OS 라이트 */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #f5f6f9; --surface: #ffffff; --surface-2: #f3f5f9; --surface-3: #eaeef4;
    --border: #e3e7ee; --border-2: #d4dae4;
    --text: #161b25; --muted: #5b6472; --faint: #8b94a4;
    --accent: #3a5bd9; --accent-2: #3050d4; --accent-soft: rgba(58,91,217,.10);
    --ok: #2e9c6e; --warn: #c98a2e; --danger: #d6505a;
    --chip: #eef1f6; --shadow-sm: 0 1px 2px rgba(20,30,60,.06); --shadow: 0 10px 34px rgba(20,30,60,.12);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Malgun Gothic", "맑은 고딕", sans-serif;
  font-size: 14px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

/* 스크롤바 */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ── 헤더 ─────────────────────────────────────────────── */
header.topbar {
  display: flex; align-items: center; gap: var(--sp3);
  padding: 10px 20px; min-height: 56px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: var(--sp2); font-weight: 700; font-size: 15.5px; cursor: pointer; letter-spacing: -.01em; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #fff; font-size: 16px;
  box-shadow: 0 2px 8px var(--accent-soft);
}
.brand small { color: var(--faint); font-weight: 500; font-size: 11px; }
.topbar .spacer { flex: 1; }
.badge { font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 10px; background: var(--chip); border-radius: 999px; }

/* ── 버튼 ─────────────────────────────────────────────── */
.btn {
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text);
  padding: 8px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .14s, border-color .14s, transform .08s, box-shadow .14s;
  white-space: nowrap; line-height: 1.2;
}
.btn:hover { border-color: var(--accent); background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--border-2); }
.btn.danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn.danger:hover { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 7px; }
.btn.lg { padding: 12px 22px; font-size: 15px; border-radius: var(--radius); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ── 레이아웃 ─────────────────────────────────────────── */
main { padding: 24px; max-width: 1600px; margin: 0 auto; }
.row { display: flex; align-items: center; gap: 10px; }
.muted { color: var(--muted); }
.section-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }

/* ── 노트북 그리드 ─────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: var(--sp3); margin-bottom: var(--sp5); flex-wrap: wrap; }
.toolbar h1 { font-size: 24px; margin: 0; letter-spacing: -.02em; }
.search { flex: 1; min-width: 180px; max-width: 360px; }
input.search, input.text, textarea, select {
  width: 100%; background: var(--surface); border: 1px solid var(--border-2); color: var(--text);
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13.5px; font-family: inherit;
  transition: border-color .14s, box-shadow .14s;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
::placeholder { color: var(--faint); }
label { font-size: 13px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(264px, 1fr)); gap: var(--sp4); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 18px 16px; cursor: pointer; position: relative;
  transition: border-color .14s, transform .12s, box-shadow .14s;
}
.card::before { content: "📓"; position: absolute; top: 16px; right: 16px; font-size: 16px; opacity: .35; }
.card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: var(--shadow); }
.card h3 { margin: 0 0 6px; font-size: 16px; letter-spacing: -.01em; padding-right: 24px; }
.card p { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.5; min-height: 39px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { display: flex; gap: 12px; font-size: 12px; color: var(--faint); padding-top: 12px; border-top: 1px solid var(--border); }
.card .meta b { color: var(--text); }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* ── 환영(첫 화면) ─────────────────────────────────────── */
.welcome { max-width: 620px; margin: 40px auto; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 40px 32px; box-shadow: var(--shadow); }
.welcome-logo { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 16px; font-size: 34px;
  display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.welcome h2 { margin: 0 0 8px; font-size: 22px; }
.welcome > p { margin: 0 auto 24px; max-width: 460px; }
.steps { display: grid; gap: 12px; text-align: left; margin: 0 auto 26px; max-width: 430px; }
.step { display: flex; gap: 12px; align-items: flex-start; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.step-n { flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%; color: #fff; font-weight: 700;
  display: grid; place-items: center; background: var(--accent-2); font-size: 13px; }
.step b { font-size: 14px; } .step .muted { font-size: 12.5px; }
.btn.lg { padding: 12px 22px; font-size: 15px; }

/* ── 노트북 상세: 3패널 ───────────────────────────────── */
.detail-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.detail-head h1 { margin: 0; font-size: 20px; }
.detail-head .desc { color: var(--muted); font-size: 13px; margin-top: 3px; }
.panels { display: grid; grid-template-columns: 300px 1fr 380px; gap: var(--sp4); align-items: start; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  display: flex; flex-direction: column; max-height: calc(100vh - 110px); overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.panel > .phead { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); min-height: 50px; }
.panel > .phead .spacer { flex: 1; }
.panel > .pbody { padding: 12px; overflow-y: auto; flex: 1; }

/* 리스트 아이템 */
.list-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 12px; margin-bottom: 8px;
  background: var(--surface-2); cursor: pointer; transition: border-color .12s, background .12s, transform .08s;
}
.list-item:hover { border-color: var(--accent); background: var(--surface-3); }
.list-item:active { transform: translateY(1px); }
.list-item .li-title { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 7px; }
.list-item .li-sub { color: var(--faint); font-size: 11.5px; margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tag { font-size: 11px; line-height: 1; padding: 3px 6px; border-radius: 6px; background: var(--chip); color: var(--muted); }
.tag.ai { color: var(--accent); }
.tag.url { color: var(--ok); } .tag.file { color: var(--warn); } .tag.text { color: var(--muted); }
.li-check { accent-color: var(--accent); width: 15px; height: 15px; flex: 0 0 auto; }

/* ── 챗 ──────────────────────────────────────────────── */
.chat-panel { min-height: 520px; }
.messages { display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 86%; padding: 12px 15px; border-radius: 16px; font-size: 14px; line-height: 1.62; white-space: pre-wrap; word-break: break-word; box-shadow: var(--shadow-sm); }
.msg.user { align-self: flex-end; background: var(--accent-2); color: #fff; border-bottom-right-radius: 5px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg .cites { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 6px; }
.msg.user .cites { border-top-color: rgba(255,255,255,.25); }
.cite-chip { font-size: 11px; padding: 3px 9px; background: var(--chip); border-radius: 999px; color: var(--accent); cursor: help; }
.typing { color: var(--muted); font-size: 13px; font-style: italic; }

/* ── 모달 ─────────────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(8,10,15,.6); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 50; padding: 18px; animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; animation: pop .16s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } }
.modal .mhead { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal .mhead h2 { margin: 0; font-size: 17px; flex: 1; letter-spacing: -.01em; }
.modal .mbody { padding: 22px; }
.modal .mfoot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: 0; background: var(--surface); }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs .tab { padding: 7px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; font-weight: 600; }
.tabs .tab.active { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }

/* 마크다운-라이트 렌더 */
.md h1,.md h2,.md h3 { margin: .6em 0 .3em; line-height: 1.3; }
.md p { margin: .4em 0; } .md ul,.md ol { margin: .4em 0; padding-left: 1.3em; }
.md code { background: var(--chip); padding: 1px 5px; border-radius: 4px; font-size: .92em; }
.md strong { font-weight: 700; }

/* 토스트 */
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--surface-2); border: 1px solid var(--border); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; animation: slideup .2s; }
.toast.ok { border-color: var(--ok); } .toast.err { border-color: var(--danger); }
@keyframes slideup { from { opacity: 0; transform: translateY(8px); } }

.spin { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* 팟캐스트 대본 / 오디오 */
.seg { margin-bottom: 10px; } .seg .spk { font-weight: 700; color: var(--accent); font-size: 12px; }
.seg .txt { font-size: 13px; }
.audio-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
audio { margin-top: 4px; }

/* 노트북 가이드 카드 */
.guide-card { background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 11px 13px; margin-bottom: 12px; }
.guide-h { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.guide-sum { font-size: 13px; line-height: 1.55; margin-bottom: 8px; }

/* 칩(주제/추천질문) */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { font-size: 12.5px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text); line-height: 1.3; }
.chip.topic { color: var(--muted); cursor: default; background: var(--surface-2); }
.chip.q { cursor: pointer; transition: border-color .12s, color .12s, background .12s; text-align: left; }
.chip.q:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* 메시지 액션(노트로 저장) */
.msg-actions { margin-top: 8px; display: flex; gap: 6px; }
.msg.assistant .msg-actions .btn { font-size: 11px; padding: 3px 8px; }

/* 스튜디오 바(리포트 버튼) */
.studio-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.studio-bar .btn { font-size: 12px; }

/* ── NotebookLM 레이아웃 ─────────────────────────────────── */
.top-title { font-weight: 700; font-size: 15px; min-width: 0; }
.nb-title { outline: none; padding: 3px 6px; border-radius: 6px; }
.nb-title[contenteditable="true"]:hover, .nb-title[contenteditable="true"]:focus { background: var(--surface-2); }
main { max-width: 1600px; }
.panels { grid-template-columns: 300px 1fr 380px; }
.panel-tools { padding: 12px 12px 4px; }
.btn.block { width: 100%; justify-content: center; }

/* 빈 상태 일러스트 */
.empty-illus { text-align: center; padding: 40px 18px; color: var(--muted); }
.empty-illus .ei-icon { width: 52px; height: 52px; margin: 0 auto; border-radius: 14px; display: grid; place-items: center;
  font-size: 26px; background: var(--surface-2); border: 1px solid var(--border); }
.empty-illus .ei-title { font-weight: 600; color: var(--text); margin: 14px 0 6px; font-size: 14px; }
.empty-illus .ei-sub { font-size: 12.5px; line-height: 1.65; max-width: 280px; margin: 0 auto; }

/* 출처 목록 */
.src-allrow { display: flex; align-items: center; gap: 8px; padding: 6px 4px 10px; font-size: 12px; color: var(--muted); cursor: pointer; border-bottom: 1px solid var(--border); margin-bottom: 8px; }

/* 채팅 히어로(빈 상태) */
.chat-hero { text-align: center; padding: 36px 12px; }
.chat-hero .hero-icon { width: 60px; height: 60px; margin: 0 auto 12px; border-radius: 16px; font-size: 30px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); }
.chat-hero .hero-title { font-size: 20px; font-weight: 700; }
.chat-hero .hero-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* 채팅 입력바 */
.chat-input { padding: 12px; border-top: 1px solid var(--border); }
.chat-input-inner { border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); padding: 8px 10px; }
.chat-input-inner textarea { border: none; background: transparent; padding: 4px 2px; min-height: 24px; max-height: 140px; }
.chat-input-inner textarea:focus { outline: none; }
.chat-input-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.chat-input-foot .src-count { flex: 1; font-size: 12px; color: var(--muted); }
.send-btn { width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--accent-2); color: #fff; font-size: 14px; display: grid; place-items: center; }
.send-btn:hover { background: var(--accent); }

/* 스튜디오 타일 그리드 */
.studio-grid-wrap { padding: 12px; border-bottom: 1px solid var(--border); }
.studio-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.studio-tile { display: flex; align-items: center; gap: 10px; text-align: left; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text);
  transition: border-color .14s, transform .1s, box-shadow .14s; }
.studio-tile:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.studio-tile:active { transform: translateY(0); }
.studio-tile .st-icon { width: 30px; height: 30px; flex: 0 0 auto; border-radius: 9px; display: grid; place-items: center;
  font-size: 15px; background: var(--accent-soft); }
.studio-tile .st-label { flex: 1; font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.studio-tile .st-arrow { color: var(--faint); font-size: 16px; }
.studio-tile.soon { opacity: .5; }
.studio-tile.soon:hover { transform: none; border-color: var(--border); box-shadow: none; }
.studio-tile .st-soon { font-size: 9.5px; font-weight: 600; color: var(--warn); border: 1px solid var(--border-2); border-radius: 999px; padding: 1px 6px; }
.studio-foot { padding: 12px; border-top: 1px solid var(--border); }

/* 스튜디오 뷰어 */
.studio-view { max-height: 64vh; overflow: auto; }
.mindmap, .mindmap ul { list-style: none; margin: 0; padding-left: 18px; }
.mindmap > li { padding-left: 0; }
.mindmap li { position: relative; margin: 4px 0; }
.mindmap .mm-node { display: inline-block; padding: 5px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: 13px; margin: 2px 0; }
.mindmap > li > .mm-node { background: var(--accent-2); color: #fff; border-color: var(--accent-2); font-weight: 700; }
.mindmap ul { border-left: 1px dashed var(--border); margin-left: 8px; }

.quiz-q { margin-bottom: 18px; }
.quiz-qt { font-weight: 600; margin-bottom: 8px; }
.quiz-opts { display: grid; gap: 6px; }
.quiz-opt { text-align: left; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); color: var(--text); }
.quiz-opt:hover:not(:disabled) { border-color: var(--accent); }
.quiz-opt.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 18%, transparent); }
.quiz-opt.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 18%, transparent); }
.quiz-exp { margin-top: 8px; font-size: 13px; color: var(--muted); background: var(--surface-2); padding: 8px 10px; border-radius: 8px; }

.fc-wrap { text-align: center; }
.flashcard { min-height: 180px; display: grid; place-items: center; padding: 24px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface-2); font-size: 17px; line-height: 1.5; cursor: pointer; transition: .15s; }
.flashcard.flipped { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }
.fc-nav { display: flex; justify-content: center; gap: 10px; margin-top: 12px; }

.dtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.dtable th, .dtable td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.dtable th { background: var(--surface-2); font-weight: 700; }

.slides { display: grid; gap: 12px; }
.slide { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--surface-2); }
.slide .slide-n { font-size: 11px; color: var(--muted); }
.slide h3 { margin: 4px 0 8px; }
.slide ul { margin: 0; padding-left: 1.2em; } .slide li { margin: 3px 0; font-size: 13px; }

.report-menu { display: grid; gap: 8px; }

/* 모바일 패널 탭 */
.ptabs { display: none; }
@media (max-width: 1080px) {
  main { padding: 14px; }
  .ptabs { display: flex; gap: 6px; margin-bottom: 12px; position: sticky; top: 56px; z-index: 10; }
  .ptab { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; font-size: 13px; }
  .ptab.active { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }
  .panels { grid-template-columns: 1fr; }
  .panels > .panel { display: none; max-height: none; }
  .panels[data-show="sources"] > [data-panel="sources"],
  .panels[data-show="chat"] > [data-panel="chat"],
  .panels[data-show="studio"] > [data-panel="studio"] { display: flex; }
  .panels:not([data-show]) > [data-panel="sources"] { display: flex; }
  .panel { max-height: calc(100vh - 170px); }
  .studio-grid { grid-template-columns: 1fr 1fr; }
  .topbar { flex-wrap: wrap; }
  .top-title { order: 3; width: 100%; }
}
@media (max-width: 460px) { .studio-grid { grid-template-columns: 1fr; } }

/* ── 드래그앤드롭 ─────────────────────────────────────────── */
.panel { position: relative; }
.dropzone { border: 2px dashed var(--border-2); border-radius: var(--radius-lg); padding: 30px 18px;
  text-align: center; cursor: pointer; transition: border-color .14s, background .14s; }
.dropzone:hover { border-color: var(--accent); background: var(--surface-2); }
.dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { font-size: 26px; }
.dz-title { font-weight: 600; margin: 8px 0 4px; }
.dz-sub { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.dz-list { margin-top: 12px; display: grid; gap: 6px; }
.dz-file { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2); font-size: 12.5px; }
.dz-file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dz-file-size { color: var(--faint); font-size: 11px; }

/* 패널 드롭 오버레이 */
.drop-overlay { position: absolute; inset: 6px; display: none; place-items: center; z-index: 6; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 2px dashed var(--accent); border-radius: var(--radius); }
.panel.dragover .drop-overlay { display: grid; }
.drop-msg { text-align: center; color: var(--accent); font-weight: 600; font-size: 14px; padding: 0 16px; }
.drop-msg .dz-icon { font-size: 30px; margin-bottom: 8px; }

.theme-btn { font-size: 14px; line-height: 1; padding: 6px 9px; }

/* ════════ 디자인 고도화 v2 ════════ */

/* 상단바: 반투명 + 블러 */
header.topbar {
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
}

/* 기본 버튼 그라데이션 */
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent;
  box-shadow: 0 2px 10px var(--accent-soft); }
.btn.primary:hover { background: linear-gradient(135deg, var(--accent), var(--accent-2)); filter: brightness(1.08); border-color: transparent; }
.send-btn { background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 2px 10px var(--accent-soft); }
.send-btn:hover { filter: brightness(1.1); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

/* 스튜디오 타일: 유형별 컬러 아이콘 */
.studio-tile .st-icon { background: var(--tc-soft, var(--accent-soft)); }
.studio-tile.st-audio       { --tc-soft: rgba(167,139,250,.16); }
.studio-tile.st-report      { --tc-soft: rgba(96,165,250,.16); }
.studio-tile.st-mindmap     { --tc-soft: rgba(52,211,153,.16); }
.studio-tile.st-quiz        { --tc-soft: rgba(251,191,36,.18); }
.studio-tile.st-flashcards  { --tc-soft: rgba(244,114,182,.16); }
.studio-tile.st-datatable   { --tc-soft: rgba(45,212,191,.16); }
.studio-tile.st-slides      { --tc-soft: rgba(251,146,60,.16); }
.studio-tile.st-video       { --tc-soft: rgba(248,113,113,.14); }
.studio-tile.st-infographic { --tc-soft: rgba(34,211,238,.14); }

/* 리스트 아이템 좌측 액센트 바 */
.list-item { position: relative; overflow: hidden; }
.list-item::before { content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 3px 3px 0; background: transparent; transition: background .14s; }
.list-item:hover::before { background: var(--accent); }

/* 마이크로 인터랙션: 등장 애니메이션 */
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg { animation: fadeUp .24s ease both; }
.studio-grid .studio-tile { animation: fadeUp .26s ease both; }
.studio-grid .studio-tile:nth-child(2) { animation-delay: .02s; }
.studio-grid .studio-tile:nth-child(3) { animation-delay: .04s; }
.studio-grid .studio-tile:nth-child(4) { animation-delay: .06s; }
.studio-grid .studio-tile:nth-child(5) { animation-delay: .08s; }
.studio-grid .studio-tile:nth-child(6) { animation-delay: .10s; }
.card { animation: fadeUp .26s ease both; }

/* 가이드 카드: 은은한 액센트 배경 */
.guide-card { background: linear-gradient(180deg, var(--accent-soft), transparent), var(--surface-2); }

/* 코드/표 가독성 미세조정 */
.md code { border: 1px solid var(--border); }
.dtable tbody tr:hover { background: var(--surface-2); }

/* 모션 최소화 선호 존중 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0 !important; transition-duration: .001ms !important; }
}
