:root{
  --bg:#f7f5f0; --card:#fff; --ink:#2c2a26; --muted:#8a857c;
  --accent:#c4654a; --accent2:#e8d9c5; --line:#e3ddd2; --ok:#5a8f6b;
  --sidebar:220px; --topbar-h:56px;
}
*{box-sizing:border-box}
body{margin:0;font-family:'Pretendard',-apple-system,'Malgun Gothic',sans-serif;
  background:var(--bg);color:var(--ink);line-height:1.6}
a{color:var(--accent)}

/* 상단바 */
.topbar{display:flex;flex-wrap:nowrap;align-items:center;gap:10px;
  padding:10px 16px;background:var(--card);border-bottom:1px solid var(--line);
  position:sticky;top:0;z-index:10;overflow-x:auto}
.topbar h1{font-size:18px;margin:0;white-space:nowrap;flex-shrink:0}
.topbar h1 .icon{width:17px;height:17px;vertical-align:-3px;margin-right:1px}
.proj-controls{display:flex;align-items:center;gap:6px;flex-wrap:nowrap;flex-shrink:0}
.proj-controls select{padding:6px 8px;border:1px solid var(--line);border-radius:6px;max-width:150px}
.proj-controls button{padding:6px 10px;border:1px solid var(--line);background:#fff;
  border-radius:6px;cursor:pointer;font-size:13px;white-space:nowrap;flex-shrink:0}
.proj-controls button:hover{background:var(--accent2)}
.save-status{font-size:12px;color:var(--ok);min-width:48px;white-space:nowrap;flex-shrink:0}
.save-status .icon{width:12px;height:12px;vertical-align:-2px;margin-right:1px}

/* 화면 상단 가운데에 뜨는 저장 상태 배너 — "저장 중…" / "저장됨" / "저장 실패" */
.save-toast{position:fixed;top:10px;left:50%;transform:translateX(-50%);z-index:2000;
  padding:6px 16px;border-radius:20px;font-size:12px;font-weight:700;color:#fff;
  box-shadow:0 4px 14px rgba(0,0,0,.18);pointer-events:none;
  opacity:0;transition:opacity .2s}
.save-toast:not([hidden]){opacity:1}
.save-toast.saving{background:#d9a441}
.save-toast.saved{background:var(--ok)}
.save-toast.error{background:#e05050}
.user-auth{display:flex;align-items:center;gap:8px;margin-left:8px;flex-shrink:0}
.prof-bar-wrap{display:flex;align-items:center;gap:5px;font-size:12px;color:var(--muted);
  white-space:nowrap;flex-shrink:0}
.prof-bar-wrap .icon{width:13px;height:13px;vertical-align:-2px;flex-shrink:0}
.prof-bar-wrap select{padding:3px 6px;border:1px solid var(--line);border-radius:6px;
  font-size:12px;max-width:170px}
.user-menu-wrap{position:relative;flex-shrink:0}
#userMenuBtn.avatar-btn{padding:0;border:none;background:transparent;border-radius:50%;
  width:32px;height:32px;overflow:hidden;display:flex;align-items:center;justify-content:center}
#userMenuBtn.avatar-btn:hover{filter:brightness(.92)}
#userMenuBtn.avatar-btn .avatar-fallback{width:32px;height:32px;border-radius:50%;
  background:var(--accent);color:#fff;display:flex;align-items:center;justify-content:center;
  font-size:14px;font-weight:700;text-transform:uppercase}
.user-menu{position:fixed;background:#fff;
  border:1px solid var(--line);border-radius:10px;box-shadow:0 6px 20px rgba(0,0,0,.14);
  min-width:170px;z-index:1000;overflow:hidden;padding:4px 0}
.user-menu-email{padding:8px 14px;font-size:12px;color:var(--muted);
  border-bottom:1px solid var(--line);margin-bottom:4px;word-break:break-all}
.user-menu button{display:block;width:100%;text-align:left;padding:9px 14px;
  border:none;background:transparent;cursor:pointer;font-size:13px;color:var(--ink)}
.user-menu button:hover{background:var(--bg)}

/* 레이아웃 */
.layout{display:flex;min-height:calc(100vh - var(--topbar-h))}

/* 왼쪽 메뉴·플롯 목록·미리보기 접기/펼치기 — 접히기 전엔 각 화면 상단, 접히면 그 접힌 자리에
   아이콘이 남는다 (곰국을끼리오너라 프로젝트 참고) */
body.sb-collapsed .sidebar{display:none}
body.sb-collapsed main{padding-left:44px}
body.toc-collapsed .write-plotlist{display:none}
body.preview-collapsed .write-preview{display:none}
/* 미리보기를 접으면 경계 드래그 핸들도 같이 숨기고, 본문이 비게 된 폭을 채우도록 확장한다 */
body.preview-collapsed .write-resizer{display:none}
body.preview-collapsed .write-main{flex:1 1 auto!important}
.sb-toggle{position:fixed;left:0;top:var(--topbar-h);z-index:6;width:32px;height:32px;
  display:flex;align-items:center;justify-content:center;background:var(--card);
  border:1px solid var(--line);border-left:none;border-radius:0 0 8px 0;cursor:pointer;color:var(--muted)}
.sb-toggle:hover{color:var(--ink);background:var(--accent2)}
.sb-toggle svg{width:17px;height:17px;transition:transform .15s}
body.sb-collapsed .sb-toggle svg{transform:rotate(180deg)}
.panel-toggle{position:fixed;top:var(--topbar-h);z-index:6;width:32px;height:32px;
  display:flex;align-items:center;justify-content:center;background:var(--card);
  border:1px solid var(--line);border-radius:8px;cursor:pointer;color:var(--muted)}
.panel-toggle:hover{color:var(--ink);background:var(--accent2)}
.panel-toggle svg{width:17px;height:17px;transition:transform .15s}
.toc-toggle{left:var(--sidebar);border-left:none;border-radius:0 0 8px 0}
body.sb-collapsed .toc-toggle{left:36px}
.preview-toggle{right:0;border-right:none;border-radius:0 0 0 8px}
body.toc-collapsed .toc-toggle svg{transform:rotate(180deg)}
body.preview-collapsed .preview-toggle svg{transform:rotate(180deg)}

/* 사이드바 */
.sidebar{width:var(--sidebar);flex-shrink:0;background:var(--card);
  border-right:1px solid var(--line);padding:16px 0;position:sticky;
  top:var(--topbar-h);height:calc(100vh - var(--topbar-h));overflow-y:auto}
.nav-group{margin-bottom:6px}
.nav-label{font-size:11px;font-weight:700;color:var(--muted);padding:8px 16px 4px;
  text-transform:uppercase;letter-spacing:.06em}
.nav-label .icon{width:12px;height:12px;vertical-align:-2px;margin-right:1px}
.tab{display:block;width:100%;text-align:left;padding:8px 16px 8px 20px;
  border:none;background:transparent;cursor:pointer;font-size:14px;
  color:var(--ink);border-left:3px solid transparent}
.tab:hover{background:var(--bg)}
.tab.active{background:var(--accent2);color:var(--accent);
  border-left-color:var(--accent);font-weight:600}

/* 메인 콘텐츠 */
main{flex:1;padding:24px 28px 60px;max-width:860px}

.card{background:var(--card);border:1px solid var(--line);border-radius:12px;
  padding:20px 22px;margin-bottom:18px}
.card h2{margin:0 0 4px;font-size:18px}
.card .hint{color:var(--muted);font-size:13px;margin:0 0 16px}
.section-title{font-size:15px;font-weight:700;margin:18px 0 8px;color:var(--accent)}

label{display:block;font-size:13px;font-weight:600;margin:12px 0 4px}
input[type=text],textarea,select{width:100%;padding:9px 11px;border:1px solid var(--line);
  border-radius:8px;font:inherit;background:#fff;color:var(--ink)}
textarea{resize:vertical;min-height:70px}
.row{display:flex;gap:12px;flex-wrap:wrap}
.row>div{flex:1;min-width:160px}

/* 기획서 작성 — 항목별 블럭 + 8pt 작성 가이드 */
.plan-row{display:flex;gap:12px;flex-wrap:wrap}
.plan-row>.plan-block{flex:1;min-width:160px}
.plan-block{border:1px solid var(--line);border-radius:10px;background:#fbfaf7;
  padding:12px 14px;margin-bottom:12px}
.plan-block label{margin:0 0 2px;color:var(--accent)}
.plan-guide{font-size:8pt;color:var(--muted);margin:0 0 8px;line-height:1.4}
.plan-block textarea{min-height:64px}
.plan-block textarea.plan-ta-lg{min-height:110px}
.plan-block textarea.plan-ta-xl{min-height:220px}

/* 세계관 설정 — 용어사전(설정 관리) 카드 리스트 */
.wv-glossary-list{display:flex;flex-direction:column;gap:12px;margin-bottom:10px}
.wv-term-head{display:flex;align-items:center;gap:8px}
.wv-term-head .wv-term-name{flex:1;font-weight:700}
.wv-term textarea{min-height:56px}

/* 캐릭터 */
.charlist .char-item{border:1px solid var(--line);border-radius:10px;padding:14px;margin-bottom:14px;background:#fcfbf9}
.char-item .char-head{display:flex;justify-content:space-between;align-items:center}
.char-item h3{margin:0;font-size:15px}

/* 버튼 */
.btn{padding:9px 16px;border:none;border-radius:8px;background:var(--accent);color:#fff;
  cursor:pointer;font-size:14px;font-weight:600;display:inline-flex;align-items:center;
  justify-content:center;line-height:1.2;vertical-align:middle}
.btn:hover{filter:brightness(1.07)}
.btn.ghost{background:#fff;color:var(--accent);border:1px solid var(--accent)}
.btn.sm{padding:5px 10px;font-size:12px}
.btn.danger{background:#fff;color:#b3503a;border:1px solid #e3c3ba}

/* 플롯 단계 */
.stage{border:1px solid var(--line);border-radius:10px;margin-bottom:12px;overflow:hidden}
.stage-head{display:flex;align-items:center;gap:10px;padding:12px 14px;background:#fbf8f3;cursor:pointer}
.stage-num{background:var(--accent);color:#fff;width:26px;height:26px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:700;flex-shrink:0}
.stage-head .st-name{font-weight:700;font-size:14px}
.stage-head .st-desc{color:var(--muted);font-size:12px}
.stage-body{padding:0 14px 14px;display:none}
.stage.open .stage-body{display:block}
.stage .filled-dot{margin-left:auto;color:var(--ok);font-size:12px}

/* 아이디어 모음 */
.idea-compose-row{margin-top:10px}
.idea-compose-row input{font-size:13px;padding:7px 10px}
.idea-tag-row{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
.idea-filter-card{padding:12px 22px;margin-bottom:14px}
.idea-filter-bar{display:flex;flex-wrap:wrap;gap:6px}
.idea-block-list{display:flex;flex-direction:column;gap:8px}
.idea-block{position:relative;background:var(--card);border:1px solid var(--line);
  border-left:7px solid var(--ok);border-radius:8px;padding:9px 30px 8px 30px;transition:opacity .15s,background .4s}
.idea-block.dragging{opacity:.4}
/* 플롯 생성에서 "아이디어 수집으로 보내기"로 넘어왔을 때 잠깐 강조 */
.idea-block.idea-flash{background:var(--accent2)}
.idea-handle{position:absolute;left:7px;top:50%;transform:translateY(-50%);
  cursor:grab;color:var(--muted);font-size:12px;line-height:1;user-select:none;padding:5px 3px;border-radius:4px}
.idea-handle:hover{color:var(--ink);background:var(--bg)}
.idea-handle:active{cursor:grabbing}
.idea-handle .icon{width:11px;height:11px;vertical-align:middle}
.idea-block-text{font-size:13px;font-weight:600;white-space:pre-wrap;outline:none;min-height:18px}
.idea-block-text:focus{background:var(--bg);border-radius:6px}
.idea-block-tags{display:flex;flex-wrap:wrap;gap:5px;margin-top:7px}
.idea-tag{display:inline-flex;align-items:center;gap:4px;background:var(--accent2);color:var(--accent);
  border:1px solid transparent;border-radius:999px;padding:2px 8px;font-size:11px;font-weight:600}
.tag-color-dot{width:9px;height:9px;border-radius:50%;flex-shrink:0;cursor:pointer;
  border:1px solid rgba(0,0,0,.15)}
.tag-color-dot:hover{transform:scale(1.15)}
.idea-tag-x{cursor:pointer;opacity:.6}
.idea-tag-x:hover{opacity:1}
.idea-tag-x .icon{width:9px;height:9px;vertical-align:-1px}
.idea-tag.add{background:transparent;border:1px dashed var(--line);color:var(--muted);cursor:pointer}
.idea-tag.add:hover{color:var(--accent);border-color:var(--accent)}
.idea-tag.filter,.idea-tag.pick{cursor:pointer}
.idea-tag-picker{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-top:8px;
  padding-top:8px;border-top:1px dashed var(--line)}
.idea-tag-picker input{width:auto;flex:1;min-width:140px;font-size:11px;padding:4px 7px}
.idea-del{position:absolute;top:6px;right:8px;background:transparent;border:none;
  color:var(--muted);font-size:12px;cursor:pointer;line-height:1;padding:2px}
.idea-del:hover{color:#b3503a}
.idea-del .icon{width:11px;height:11px;vertical-align:middle}

/* 플롯 생성 */
.plot-structure-choices{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:12px}
.plot-struct-btn{text-align:left;border:1px solid var(--line);background:#fcfbf9;border-radius:10px;
  padding:16px;cursor:pointer;transition:border-color .12s,background .12s}
.plot-struct-btn:hover{border-color:var(--accent);background:var(--accent2)}
.plot-struct-btn .ps-title{font-weight:700;font-size:15px;color:var(--ink);margin-bottom:4px}
.plot-struct-btn .ps-sub{font-size:12px;color:var(--muted);line-height:1.5}
.plot-struct-btn .ps-guide{font-size:11.5px;color:var(--muted);line-height:1.5;margin-top:8px;
  padding-top:8px;border-top:1px dashed var(--line)}
.plot-toolbar{display:flex;gap:8px;flex-wrap:wrap}
.plot-empty{margin:0;padding:6px 4px;font-size:12px;text-align:center;color:var(--muted)}
.plot-sections{display:flex;flex-direction:column;gap:14px}
.plot-section{padding:14px 16px}
.plot-section.sec-dragging{opacity:.4}
.plot-section-head{display:flex;align-items:center;gap:6px}
.plot-sec-num{background:var(--accent);color:#fff;width:24px;height:24px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;flex-shrink:0}
.plot-sec-name{font-weight:700;font-size:15px;color:var(--ink)}
.plot-sec-spacer{flex:1}
.plot-sec-count{font-size:12px;color:var(--muted);white-space:nowrap;flex-shrink:0;margin-right:2px}
.plot-icon-btn{background:transparent;border:none;cursor:pointer;color:var(--muted);
  font-size:15px;line-height:1;padding:5px 6px;border-radius:6px;flex-shrink:0}
.plot-icon-btn:hover{background:var(--bg);color:var(--ink)}
.plot-icon-btn .icon{vertical-align:middle}
.plot-sec-move{cursor:grab}
.plot-sec-move:active{cursor:grabbing}
.plot-sec-del:hover{color:#b3503a;background:#f7e9e5}
.plot-sec-desc{color:var(--muted);font-size:12px;margin:2px 0 12px;line-height:1.5;white-space:pre-wrap}
.plot-section-body{display:flex;flex-direction:column;gap:8px}
.plot-section-body:not(:empty){margin-bottom:8px}
.plot-idea{display:flex;align-items:flex-start;gap:8px;background:#fff;border:1px solid var(--line);
  border-left:5px solid var(--line);border-radius:8px;padding:9px 11px;transition:opacity .15s}
.plot-idea.dragging{opacity:.4}
.plot-idea-handle{cursor:grab;color:var(--muted);font-size:14px;line-height:1.4;user-select:none;flex-shrink:0}
.plot-idea-handle:active{cursor:grabbing}
.plot-idea-handle .icon{width:13px;height:13px;vertical-align:middle}
.plot-idea-content{flex:1;display:flex;flex-direction:column;gap:5px;min-width:0}
.plot-idea-text{font-size:13px;font-weight:600;white-space:pre-wrap;word-break:break-word;outline:none;
  border-radius:5px;cursor:text;padding:3px 6px;border:1px dashed transparent;transition:background .1s,border-color .1s}
.plot-idea-text:hover{background:#faf8f4;border-color:var(--line)}
.plot-idea-text:focus{background:#fff;border:1px solid var(--accent);box-shadow:0 0 0 2px var(--accent2)}
.plot-idea-text:empty:before{content:attr(data-ph);color:var(--muted);font-weight:400}
.plot-idea-edit{background:transparent;border:none;color:var(--muted);cursor:pointer;
  font-size:13px;line-height:1;padding:2px 5px;flex-shrink:0;border-radius:4px}
.plot-idea-edit:hover{color:var(--accent);background:var(--accent2)}
.plot-idea-edit .icon{width:12px;height:12px;vertical-align:middle}
.plot-idea-tags{display:flex;flex-wrap:wrap;gap:4px}
.plot-idea-tag{font-size:11px;font-weight:600;border:1px solid transparent;border-radius:999px;padding:1px 7px}
.plot-idea-rm{background:transparent;border:none;cursor:pointer;color:var(--muted);
  font-size:12px;line-height:1;padding:2px 4px;flex-shrink:0}
.plot-idea-rm:hover{color:#b3503a}
.plot-idea-rm .icon{width:11px;height:11px;vertical-align:middle}
/* ＋ 아이디어 가져오기 / ＋ 아이디어 생성 박스 */
.plot-add-row{display:flex;gap:8px}
.plot-add-box{flex:1;display:flex;align-items:center;justify-content:center;gap:6px;
  border:1px dashed var(--line);border-radius:8px;padding:11px;cursor:pointer;
  background:#faf8f4;color:var(--muted);font-size:13px;font-weight:600;transition:border-color .12s,color .12s}
.plot-add-box:hover,.plot-add-box.drop-hover{border-color:var(--accent);color:var(--accent);background:var(--accent2)}
.plot-add-plus{font-size:16px;line-height:1}
.plot-add-plus .icon{width:14px;height:14px;vertical-align:middle}
/* 아이디어 선택 팝업 */
.plot-modal-overlay{position:fixed;inset:0;z-index:2000;background:rgba(0,0,0,.4);
  display:flex;align-items:center;justify-content:center;padding:20px}
/* 브라우저 창 전체가 아니라 왼쪽 사이드바를 뺀 "작업 영역" 가운데에 뜨도록 함(플롯 생성의 아이디어 피커 등) */
.plot-modal-overlay.center-content{left:var(--sidebar)}
body.sb-collapsed .plot-modal-overlay.center-content{left:44px}
.plot-modal{background:var(--card);border-radius:14px;box-shadow:0 12px 40px rgba(0,0,0,.25);
  width:520px;max-width:100%;max-height:85vh;display:flex;flex-direction:column;padding:16px 18px}
.plot-picker-top{display:flex;align-items:center;margin-bottom:12px}
.plot-picker-title{flex:1;font-size:15px;font-weight:700;color:var(--accent)}
.plot-picker-filter{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:12px;
  padding-bottom:12px;border-bottom:1px dashed var(--line)}
.plot-picker-list{display:flex;flex-direction:column;gap:6px;overflow-y:auto;flex:1}
.plot-pick-item{display:flex;align-items:center;flex-wrap:wrap;gap:6px;background:#fff;
  border:1px solid var(--line);border-left:4px solid var(--line);border-radius:7px;
  padding:7px 10px;cursor:pointer;transition:background .1s,border-color .1s}
.plot-pick-item:hover{background:var(--accent2);border-color:var(--accent)}
.plot-pick-text{flex:1;font-size:13px;font-weight:600;min-width:0;word-break:break-word}

/* ===== ✍️ 글쓰기 ===== */
#app.wide{max-width:none}
.write-layout{display:flex;gap:14px;align-items:flex-start}
.write-plotlist{flex:0 0 200px;min-width:160px;position:sticky;top:70px;
  background:var(--card);border:1px solid var(--line);border-radius:12px;padding:12px;
  max-height:calc(100vh - 90px);overflow-y:auto}
.wpl-head{display:flex;justify-content:space-between;align-items:baseline;
  font-size:12px;font-weight:700;color:var(--muted);padding-bottom:8px;margin-bottom:8px;border-bottom:1px solid var(--line)}
.wpl-total{color:var(--accent)}
.wpl-item{padding:8px 8px;border-radius:8px;cursor:pointer;margin-bottom:2px}
.wpl-item:hover{background:var(--bg)}
.wpl-name{font-size:13px;font-weight:600;line-height:1.4}
.wpl-meta{display:flex;justify-content:space-between;font-size:11px;color:var(--muted);margin-top:2px}
.wpl-pct{font-weight:700;color:var(--accent)}
.wpl-bar{height:4px;background:var(--line);border-radius:999px;margin-top:5px;overflow:hidden}
.wpl-bar-fill{height:100%;background:var(--accent);border-radius:999px;transition:width .2s}
.wpl-blocks{margin:6px 0 2px;padding-left:6px;border-left:2px solid var(--accent2);display:flex;flex-direction:column;gap:2px}
.wpl-block{font-size:11px;color:var(--muted);line-height:1.5;cursor:pointer;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding:1px 4px;border-radius:4px}
.wpl-block:hover{background:var(--bg);color:var(--ink)}
.wpl-btnrow{display:flex;gap:4px;margin-top:5px}
.wpl-add{flex:1;background:transparent;border:1px dashed var(--line);
  border-radius:6px;color:var(--muted);font-size:11px;font-weight:600;cursor:pointer;padding:4px 2px}
.wpl-add:hover{border-color:var(--accent);color:var(--accent)}
.wpl-load:hover{border-color:var(--ok);color:var(--ok)}
.wpl-add-section{margin-top:12px;width:100%;background:var(--accent2);border:none;
  border-radius:8px;color:var(--accent);font-size:12px;font-weight:700;cursor:pointer;padding:8px}
.wpl-add-section:hover{filter:brightness(.97)}

.write-main{flex:0 1 800px;min-width:0}
/* 본문·미리보기 경계 드래그로 폭 조절 (곰국을끼리오너라 프로젝트 참고) */
.write-resizer{flex:0 0 8px;align-self:stretch;cursor:col-resize;position:relative;background:transparent}
.write-resizer::after{content:"";position:absolute;left:3px;top:0;bottom:0;width:2px;
  background:var(--line);border-radius:2px;transition:background .1s}
.write-resizer:hover::after,.write-resizer.dragging::after{background:var(--accent)}
.write-toolbar{display:flex;justify-content:space-between;gap:8px;margin-bottom:10px}
.write-group{margin-bottom:18px}
.write-divider{display:flex;align-items:center;gap:8px;margin:6px 0 10px;
  padding-bottom:6px;border-bottom:2px solid var(--accent2)}
.write-divider .wd-num{background:var(--accent);color:#fff;width:22px;height:22px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;flex-shrink:0}
.write-divider .wd-name{font-weight:700;font-size:14px;color:var(--accent)}
.write-divider .wd-spacer{flex:1}
.wd-icon{background:transparent;border:1px solid var(--line);border-radius:6px;cursor:pointer;
  font-size:13px;line-height:1;padding:3px 8px;color:var(--muted);flex-shrink:0}
.wd-icon:hover{border-color:var(--accent);color:var(--accent);background:var(--accent2)}
.write-blocklist{display:flex;flex-direction:column;gap:10px;min-height:20px}
.scene-block{background:var(--card);border:1px solid var(--line);border-left:6px solid var(--accent2);
  border-radius:10px;padding:10px 12px;transition:opacity .15s}
.scene-block.dragging{opacity:.4}
.scene-head{display:flex;align-items:flex-start;gap:5px;margin-bottom:8px;flex-wrap:nowrap}
.scene-hicon{flex-shrink:0;padding:4px 7px;font-size:13px;line-height:1;min-width:28px;text-align:center}
.scene-handle,.scene-num,.scene-hicon,.scene-del-btn{margin-top:2px}
.scene-handle{cursor:grab;color:var(--muted);font-size:14px;user-select:none}
.scene-handle:active{cursor:grabbing}
.scene-handle .icon{width:13px;height:13px;vertical-align:middle}
.scene-num{background:var(--ok);color:#fff;min-width:22px;height:20px;border-radius:5px;
  display:inline-flex;align-items:center;justify-content:center;font-size:11px;font-weight:700;padding:0 6px;flex-shrink:0}
.scene-spacer{flex:1}
.scene-add-btn{background:#eef1ec;color:var(--ok);border:none;border-radius:6px;
  cursor:pointer;font-size:12px;font-weight:600;padding:4px 9px}
.scene-add-btn:hover{filter:brightness(.96)}
.scene-dlg-btn{background:var(--accent2);color:var(--accent);border:none;border-radius:6px;
  cursor:pointer;font-size:12px;font-weight:600;padding:4px 9px}
.scene-dlg-btn:hover{filter:brightness(.96)}
.scene-del-btn{background:transparent;border:none;color:var(--muted);cursor:pointer;font-size:12px;padding:2px 5px}
.scene-del-btn:hover{color:#b3503a}
.scene-title{flex:1 1 auto;min-width:0;font-size:11px;font-weight:800;color:var(--ink);
  border:1px solid var(--line);border-radius:6px;line-height:1.5;
  padding:6px 10px;margin:0;background:#e2dbca;font-family:inherit;cursor:default;
  white-space:pre-wrap;word-break:break-word;outline:none}
.scene-title:empty:before{content:attr(data-ph);color:var(--muted);font-weight:600}
.scene-title[contenteditable="true"]{border-color:var(--accent);background:#fff;cursor:text;box-shadow:0 0 0 2px var(--accent2)}
.scene-edit-btn{background:transparent;border:1px solid var(--line);color:var(--muted);
  border-radius:6px;cursor:pointer;font-size:12px;font-weight:600;padding:4px 9px}
.scene-edit-btn:hover{border-color:var(--accent);color:var(--accent)}
/* 하위 블록(본문/대사) */
.scene-items{display:flex;flex-direction:column;gap:6px}
.scene-items:empty{display:none}
.sub-empty{margin:0;padding:8px;font-size:12px;color:var(--muted);text-align:center;
  border:1px dashed var(--line);border-radius:7px}
.sub-block{display:flex;align-items:flex-start;gap:8px;border:1px solid var(--line);
  border-radius:7px;padding:7px 9px;transition:opacity .15s;background:#fff}
.sub-block.dragging{opacity:.4}
.sub-block.sub-line{background:#fbf8f3}
.sub-block.sub-text{flex-direction:column;align-items:stretch}
.sub-main-row{display:flex;align-items:flex-start;gap:8px}
.sub-handle{cursor:grab;color:var(--muted);font-size:13px;user-select:none;flex-shrink:0;padding-top:2px}
.sub-handle:active{cursor:grabbing}
.sub-handle .icon{width:12px;height:12px;vertical-align:middle}
.sub-textarea{flex:1;min-width:0;height:auto;min-height:0;border:none;background:transparent;
  font-family:inherit;font-size:11px;line-height:1.5;resize:none;overflow:hidden;color:var(--ink);padding:2px 0}
.sub-textarea:focus{outline:none}
/* 분기 본문 블록 — 절반 크기로 2열 배치, 폰트 1pt 작게, 두 열 사이에 세로 구분선 */
.sub-branches{display:grid;grid-template-columns:1fr 1fr;column-gap:10px;row-gap:6px;margin-top:6px;
  padding-top:6px;border-top:1px dashed var(--line);position:relative}
.sub-branches::before{content:"";position:absolute;top:6px;bottom:0;left:50%;width:1px;
  background:var(--line);transform:translateX(-.5px)}
.sub-branch{display:flex;align-items:flex-start;gap:4px;border:1px solid var(--line);
  border-radius:6px;padding:5px 7px;background:#fbfbf9;transition:opacity .15s}
.sub-branch.dragging{opacity:.4}
.sub-branch .branch-textarea{font-size:calc(11px - 1pt)}
.branch-del{padding:1px 3px}
.branch-handle{padding-top:1px}
.branch-handle .icon{width:10px;height:10px}
.sub-line .dlg-who{font-size:11px;font-weight:700;color:var(--accent);flex-shrink:0;white-space:nowrap;padding-top:1px}
.sub-line .dlg-text{flex:1;font-size:11px;min-width:0;word-break:break-word;padding-top:1px;cursor:text;border-radius:3px}
.sub-line .dlg-text[contenteditable="true"]{outline:1px solid var(--accent);background:#fff;box-shadow:0 0 0 2px var(--accent2)}
.sub-del{background:transparent;border:none;color:var(--muted);cursor:pointer;font-size:11px;padding:2px 4px;flex-shrink:0}
.sub-del .icon{width:10px;height:10px;vertical-align:middle}
.sub-del:hover{color:#b3503a}
.write-add-block{width:100%;margin-top:10px;background:transparent;border:1px dashed var(--line);
  border-radius:8px;padding:9px;cursor:pointer;color:var(--muted);font-size:13px;font-weight:600}
.write-add-block:hover{border-color:var(--accent);color:var(--accent)}
/* 대사 추가 팝업 */
.dlg-modal label{margin-top:6px}
.dlg-modal .dlg-input-text{width:100%;min-height:80px;resize:vertical}
.dlg-modal-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:14px}
/* 미리보기 */
.write-preview{flex:1 1 0;min-width:300px;position:sticky;top:70px;max-height:calc(100vh - 90px);overflow-y:auto}
.wp-page{background:#e9e6df;padding:14px;border-radius:10px}
.wp-inner{position:relative;background:#fff;box-shadow:0 1px 4px rgba(0,0,0,.1);
  padding:40px 48px;font-size:13px;line-height:1.9;color:#222}
.wp-block{margin-bottom:2px}
.wp-text{margin:0 0 8px;white-space:pre-wrap}
.wp-line{margin:0 0 4px}
.wp-pagebreak{position:absolute;left:0;right:0;border-top:1px dashed #c0392b;pointer-events:none}
/* 화면이 좁으면 미리보기 숨김 (중앙 본문이 남은 폭 사용) */
@media(max-width:1023px){
  .write-preview{display:none}
  .write-main{flex:1 1 auto}
  .write-resizer{display:none}
}
/* 더 좁으면 좌측 플롯 목록을 위로 */
@media(max-width:820px){
  .write-layout{flex-direction:column}
  .write-plotlist{position:static;flex-basis:auto;width:100%;max-height:none}
}

/* ===== 배경 설정 · 사건 설정 — 오른쪽에 기획서 미리보기(읽기 전용) 분할 화면 ===== */
.setting-split{display:flex;gap:14px;align-items:flex-start}
.setting-main{flex:0 1 60%;min-width:0}
.setting-planview{flex:0 1 40%;min-width:260px;position:sticky;top:70px;
  max-height:calc(100vh - 90px);overflow-y:auto}
.plan-viewer-card h3{margin:0 0 4px;font-size:15px}
.plan-view-block{background:#fbfaf7}
.plan-view-block label{color:var(--accent);margin-top:12px}
.plan-view-text{font-size:13px;line-height:1.7;color:var(--ink)}
.plan-view-text.empty{color:var(--muted);font-style:italic}
@media(max-width:1023px){
  .setting-planview{display:none}
  .setting-main{flex:1 1 auto}
}

/* 아이디어 탐색 */
.explore-dbstatus{background:#fbf8f3;border:1px solid var(--line);border-radius:8px;
  padding:10px 12px;font-size:13px;color:var(--ink)}
.explore-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:12px}
.explore-slot label{margin:0 0 4px}
.match-card{border:1px solid var(--line);border-radius:10px;padding:12px 14px;margin-bottom:10px;background:#fcfbf9}
.match-head{display:flex;justify-content:space-between;align-items:center;font-size:14px}
.match-score{font-size:12px;color:var(--accent);font-weight:700}
.match-tags{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
.explore-results{margin-top:14px}
#adminNavGroup .nav-label{color:var(--accent)}

/* AI 박스 */
.ai-box{background:#fbf8f3;border:1px dashed var(--accent2);border-radius:10px;
  padding:14px;margin-top:10px;white-space:pre-wrap;font-size:14px}
.ai-box.empty{color:var(--muted);font-style:italic}
.spinner{display:inline-block;width:14px;height:14px;border:2px solid var(--accent2);
  border-top-color:var(--accent);border-radius:50%;animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* ===== 전체화면 로그인 오버레이 ===== */
.login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: #f7f8fa;
}
.login-box {
  text-align: center; padding: 48px 40px;
  background: #fff; border-radius: 18px;
  box-shadow: 0 10px 40px rgba(0,0,0,.08);
  width: 380px; max-width: 90vw;
  max-height: 90vh; overflow-y: auto;
}
.login-box .login-sub {
  font-size: .85em; color: #9aa0a6; margin: 0 0 4px; letter-spacing: .02em;
}
.login-box h1 { margin: 0 0 24px; font-size: 1.7em; font-weight: 700; color: #202124; }
.login-box h1 .icon{width:22px;height:22px;vertical-align:-4px;margin-right:2px}
.login-box .login-desc { margin: 0 0 20px; font-size: .88em; line-height: 1.7; color: #80868b; }
body.logged-in .login-overlay { display: none; }

/* 로그인/회원가입 탭 */
.auth-tabs { display: flex; gap: 4px; background: #f1f2f4; border-radius: 10px; padding: 4px; margin-bottom: 22px; }
.auth-tab { flex: 1; padding: 9px 0; border: none; background: transparent; border-radius: 8px;
  font-size: .9em; font-weight: 600; color: #80868b; cursor: pointer; }
.auth-tab.active { background: #fff; color: #2b3a67; box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* 로그인/회원가입 폼 */
.auth-panel { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.auth-panel[hidden] { display: none; }
.auth-panel input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 8px;
  font-size: .92em; background: #fbfbfa;
}
.auth-panel input:focus { outline: none; border-color: #2b3a67; background: #fff; }
.auth-submit {
  width: 100%; padding: 13px 0; font-size: 1.0em; font-weight: 600; cursor: pointer;
  background: #2b3a67; color: #fff; border: none; border-radius: 10px;
  margin-top: 4px; transition: background .15s;
}
.auth-submit:hover { background: #1f2c52; }
.auth-error { min-height: 18px; font-size: .82em; color: #c4654a; margin: 0; text-align: center; }
.auth-link { display: block; text-align: center; font-size: .82em; color: #80868b; margin-top: 2px; }
.auth-link:hover { color: #2b3a67; }


/* 관리자 — 회원 관리 · 학생 관리 표 / 서버 초기화 (2026-08-20: 행 높이를 촘촘하게 축소) */
.admin-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 4px; }
.admin-table th, .admin-table td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; line-height: 1.3; }
.admin-table th { background: var(--accent2); color: var(--accent); font-weight: 700; }
.admin-table tbody tr:nth-child(even) { background: #fbfaf7; }
.settings-prof-list { margin: 4px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.settings-prof-list li { margin: 2px 0; }
.admin-reset-row { display: flex; gap: 14px; flex-wrap: wrap; }
.admin-reset-box { flex: 1; min-width: 220px; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.admin-reset-box .plan-guide { margin: 4px 0 10px; }

.muted { color: var(--muted); }

/* 카드 제목 줄에 버튼(제출 등)을 오른쪽에 나란히 배치 */
.card-h2-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.card-h2-row h2 { margin: 0; }

/* 넓은 모달(과제 제출함/첨삭 화면 등) */
.plot-modal.wide { width: 760px; }

/* 교수 코드 입력/표시 (설정) */
.prof-code-display { font-size: 28px; font-weight: 700; letter-spacing: .12em; color: var(--accent);
  text-align: center; background: var(--accent2); border-radius: 10px; padding: 14px; margin-top: 6px; }

/* 제출 대상 과제 선택 목록 (학생) / 제출함 목록 (교수) — 공용 */
.submit-assign-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.submit-assign-item { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left;
  width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; cursor: pointer; }
.submit-assign-item:hover { border-color: var(--accent); background: var(--accent2); }
/* 교수 — 과제 폴더 제출함: 한 줄(가로)로 압축 표시 (좁으면 가로 스크롤) */
.submit-assign-list--compact .submit-assign-item { flex-direction: row; flex-wrap: nowrap; align-items: center;
  gap: 8px; padding: 8px 12px; overflow-x: auto; white-space: nowrap; }
.submit-assign-list--compact .submit-assign-item > * { white-space: nowrap; flex-shrink: 0; }
.submit-assign-list--compact .submit-assign-item > .hint:last-child { margin-left: auto; }
.submit-already { font-size: 12px; color: var(--accent); font-weight: 600; }
.assign-type-badge { display: inline-block; font-size: 11px; font-weight: 700; color: var(--accent);
  background: var(--accent2); border-radius: 999px; padding: 2px 9px; }

/* 교수 — 과제 폴더 제출함 목록의 각 줄: 제출물 버튼 + (버전이 2개 이상이면) 작은 버전 드롭다운 */
.submit-assign-row { display: flex; align-items: center; gap: 6px; }
.submit-assign-row .submit-assign-item { flex: 1; min-width: 0; }
.submit-version-select { flex-shrink: 0; font-size: 11px; padding: 3px 4px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; color: var(--ink); cursor: pointer; }

/* 교수 — 과제 폴더 그리드 */
.prof-assign-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-top: 10px; }
.assign-folder { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer; background: #fff; }
.assign-folder:hover { border-color: var(--accent); background: var(--accent2); }
.assign-folder-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.assign-folder-title { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 5px; }
.assign-folder-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.assign-folder-del { background: transparent; border: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; }
.assign-folder-del:hover { color: #b3503a; background: var(--accent2); }
.assign-folder-del .icon { width: 14px; height: 14px; vertical-align: middle; }
.assign-folder-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

/* 제출 마감 스위치 */
.assign-switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.assign-switch input { opacity: 0; width: 0; height: 0; }
.assign-switch-slider { position: absolute; inset: 0; background: var(--line); border-radius: 999px; cursor: pointer; transition: background .15s; }
.assign-switch-slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: transform .15s; }
.assign-switch input:checked + .assign-switch-slider { background: var(--ok); }
.assign-switch input:checked + .assign-switch-slider::before { transform: translateX(16px); }

/* 첨삭 화면 — 기본은 원본 블록 한 줄, 우클릭해서 [첨삭]을 누른 블록만 이전 버전(위)/첨삭(아래)으로 분리 */
.review-pair { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.review-pair.split { gap: 0; }
.review-before-text { white-space: pre-wrap; font-size: 13px; line-height: 1.6; color: var(--ink); }
.review-before { background: #fbfaf7; }
.review-after textarea { min-height: 90px; }

/* 이전 버전(위)과 첨삭/첨삭 결과(아래)를 여백 없이 붙여서, 맞닿는 모서리만 직각으로 만든다 */
.ta-wrap{border:1px solid var(--line);border-radius:10px;background:#fbfaf7;padding:12px 14px;margin-bottom:12px}
.ta-wrap label{margin:0 0 2px;color:var(--accent);display:block}
.ta-wrap textarea{min-height:90px}
.version-prev{border:1px solid var(--line);border-bottom:none;border-radius:6px 6px 0 0;
  background:#f6f2e9;padding:0}
.version-prev-toggle{display:flex;align-items:center;gap:4px;font-size:10px;color:var(--muted);
  cursor:pointer;user-select:none;padding:4px 8px}
.version-prev-toggle:hover{color:var(--accent)}
.version-prev-text{white-space:pre-wrap;word-break:break-word;font-size:14px;line-height:1.5;
  color:var(--muted);padding:0 8px 6px}
.version-prev.collapsed .version-prev-text{display:none}
/* 이전 버전 안에서, 지금 입력 중인 첨삭 내용과 비교했을 때 실제로 달라진 부분만 옅은 붉은 배경으로 표시 */
.version-prev-text .diff-bg{background:#f6d3cc;border-radius:2px}
.ta-wrap.version-current{border-radius:0 0 6px 6px;border-color:var(--line);background:#fff}

/* ===== 첨삭 화면 — 메모(첨삭과 별도로 학생 원본 텍스트에 다는 메모) =====
   드래그로 선택해서 단 메모: 선택 범위 배경을 노랗게(mark.memo-hl) + 끝에 작은 각주번호(sup.memo-fn-num).
   선택 없이 블록을 그냥 우클릭해서 단 메모: 각주번호 없이 블록 끝에 *(sup.memo-star)만 표시.
   메모 카드(.memo-block)는 그 블록 텍스트 바로 아래에 여백 없이(margin-top:0) 붙고, 옅은 노란색 배경 +
   돋움체를 쓴다. */
mark.memo-hl{background:#ffe066;border-radius:2px;padding:0 1px;font:inherit;color:inherit}
sup.memo-fn-num{font-size:10px;font-weight:700;color:var(--accent);margin:0 1px}
sup.memo-star{font-size:12px;font-weight:700;color:var(--accent);margin:0 1px}
.memo-block-list{margin-top:0;display:flex;flex-direction:column;gap:2px}
/* 이전 버전(prev) 패널은 자체 padding이 0이고 안쪽 version-prev-text가 하단 padding을 갖고 있어서,
   메모 카드 목록을 그 바로 밑에 진짜 "여백 없이" 붙이려면 그 하단 padding만큼 끌어올려야 한다 */
.version-prev > .memo-block-list{margin-top:-6px}
.memo-block{background:#fdf6d3;padding:5px 8px;display:flex;align-items:flex-start;gap:6px}
.memo-block-marker{flex-shrink:0;font-size:11px;font-weight:700;color:var(--accent);line-height:1.6}
.memo-block-text{flex:1;min-width:0;font-family:Dotum,"돋움",sans-serif;font-size:12px;line-height:1.6;
  color:var(--ink);white-space:pre-wrap;word-break:break-word}
.memo-block-del{flex-shrink:0;background:transparent;border:none;color:var(--muted);cursor:pointer;
  font-size:11px;padding:2px 4px}
.memo-block-del:hover{color:#b3503a}

/* ===== 심플라인 아이콘 / 아이콘 버튼 ===== */
.icon{width:15px;height:15px;vertical-align:-3px;flex-shrink:0}
.icon-btn{display:inline-flex;align-items:center;gap:5px}
.icon-btn .icon{vertical-align:-2px}
/* 탭 헤더의 [제출]/[첨삭 보기] 버튼을 한 덩어리로 묶어서, card-h2-row(space-between)에서
   h2와 떨어진 오른쪽 끝에 나란히 붙어있게 함 */
.submit-btn-group{display:flex;gap:6px;flex-shrink:0}

/* ===== 상단 툴바 왼쪽 아이콘 그룹 (새로 만들기/저장/불러오기/내보내기) ===== */
.mb-left{display:flex;align-items:center;gap:2px;flex-shrink:0}
.mb-icon{width:34px;height:34px;display:inline-flex;align-items:center;justify-content:center;
  border:1px solid transparent;background:transparent;border-radius:8px;cursor:pointer;
  flex-shrink:0;color:var(--muted)}
.mb-icon .icon{width:18px;height:18px;vertical-align:middle}
.mb-icon:hover{background:var(--accent2);border-color:var(--line);color:var(--ink)}
.mb-icon:disabled{opacity:.35;cursor:default}
.mb-icon:disabled:hover{background:transparent;border-color:transparent}
.mb-sep{width:1px;height:22px;background:var(--line);margin:0 6px;flex-shrink:0}
.mb-export{position:relative}
.mb-export-menu{position:fixed;background:var(--card);border:1px solid var(--line);
  border-radius:8px;box-shadow:0 6px 20px rgba(0,0,0,.14);padding:4px;z-index:1000;min-width:170px}
.mb-export-menu[hidden]{display:none}
.mb-export-menu button{display:block;width:100%;text-align:left;padding:8px 12px;border:none;
  background:transparent;border-radius:6px;cursor:pointer;font-size:13px;color:var(--ink);white-space:nowrap}
.mb-export-menu button:hover{background:var(--accent2)}

/* ===== 상단바 작품 탭 (곰국을끼리오너라 프로젝트의 file-tab 참고 — 실제 파일탭처럼
   위쪽만 둥글고 아래쪽은 열려서 본문 영역에 붙어 보이도록) ===== */
.ptabs{flex:1 1 auto;min-width:40px;align-self:stretch;display:flex;align-items:flex-end;
  gap:2px;overflow-x:auto;overflow-y:hidden;scrollbar-width:thin}
.ptab{display:flex;align-items:center;gap:6px;max-width:180px;padding:7px 10px;
  border:1px solid var(--line);border-bottom:none;border-radius:8px 8px 0 0;background:var(--bg);
  color:var(--muted);font-size:13px;cursor:pointer;white-space:nowrap;flex-shrink:0}
.ptab:hover{background:var(--accent2);color:var(--ink)}
.ptab.active{background:var(--card);color:var(--ink);font-weight:600}
.ptab-dot{width:7px;height:7px;border-radius:50%;background:var(--ok);flex-shrink:0;transition:background .2s}
.ptab-label{overflow:hidden;text-overflow:ellipsis;min-width:0;max-width:120px}
.ptab-close{width:16px;height:16px;flex-shrink:0;border:none;border-radius:4px;background:transparent;
  color:inherit;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;
  opacity:.5;padding:0}
.ptab-close .icon{width:10px;height:10px;vertical-align:middle}
.ptab-close:hover{background:var(--line);opacity:1}

/* ===== 캐릭터 설정: 갤러리/관계도 ===== */
.char-toolbar{display:flex;align-items:center;gap:10px;margin-bottom:14px;flex-wrap:wrap}
.char-view-toggle{display:flex;border:1px solid var(--line);border-radius:8px;overflow:hidden}
.char-view-btn{display:flex;align-items:center;gap:5px;padding:7px 12px;border:none;background:#fff;
  color:var(--muted);font-size:12px;font-weight:600;cursor:pointer}
.char-view-btn+.char-view-btn{border-left:1px solid var(--line)}
.char-view-btn.active{background:var(--accent2);color:var(--accent)}
.char-toolbar .btn{margin-left:auto}
.char-gallery{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:14px}
.char-card-mini{position:relative;border:1px solid var(--line);border-radius:12px;padding:16px 12px;
  background:#fcfbf9;cursor:pointer;text-align:center;transition:box-shadow .15s,border-color .15s}
.char-card-mini:hover{border-color:var(--accent);box-shadow:0 4px 14px rgba(0,0,0,.08)}
.char-avatar{width:52px;height:52px;border-radius:50%;margin:0 auto 8px;display:flex;align-items:center;
  justify-content:center;color:#fff;font-size:20px;font-weight:800;overflow:hidden;flex-shrink:0}
.char-avatar img{width:100%;height:100%;object-fit:cover}
.char-img-row{display:flex;gap:14px;align-items:center;margin-bottom:6px}
.char-avatar-lg{width:76px;height:76px;font-size:28px;margin:0}
.char-img-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
.char-img-actions .hint{flex-basis:100%;color:var(--muted);font-size:11px}
.char-card-name{font-size:14px;font-weight:800;color:var(--ink)}
.char-card-role{font-size:11px;color:var(--muted);margin-top:2px}
.char-card-badges{display:flex;flex-wrap:wrap;justify-content:center;gap:4px;margin-top:8px}
.char-badge{background:var(--accent2);color:var(--accent);font-size:10px;font-weight:700;
  border-radius:8px;padding:2px 7px}
.char-badge.arc-badge{background:#e7f0e9;color:var(--ok)}
.char-card-rel{margin-top:6px;font-size:10px;color:var(--muted)}
.char-card-del{position:absolute;top:6px;right:6px;background:transparent;border:none;
  color:var(--muted);cursor:pointer;padding:3px;border-radius:6px;opacity:0}
.char-card-mini:hover .char-card-del{opacity:1}
.char-card-del:hover{color:#b3503a;background:var(--accent2)}
.char-card-del .icon{width:13px;height:13px}
.char-modal-body{overflow-y:auto;flex:1}
.char-detail-top{display:flex;align-items:center;gap:14px;margin-bottom:14px}
.char-detail-top h2{margin:0}
.char-detail-sub{margin:18px 0 4px;font-size:14px;border-top:1px dashed var(--line);padding-top:14px}
.char-arc-preview{display:flex;align-items:stretch;gap:8px;margin:8px 0 4px}
.arc-box{flex:1;min-width:0;background:#fbf8f3;border:1px solid var(--line);border-radius:8px;
  padding:8px 10px;font-size:12px;color:var(--ink);white-space:pre-wrap;word-break:break-word}
.arc-box.arc-before{border-left:4px solid var(--muted)}
.arc-box.arc-after{border-left:4px solid var(--ok)}
.arc-box-label{font-size:10px;font-weight:800;color:var(--muted);margin-bottom:4px}
.arc-empty{color:var(--muted);font-style:italic}
.type-desc-box{margin-top:6px;padding:8px 10px;background:#fbf8f3;border:1px solid var(--line);
  border-radius:8px;font-size:11px;line-height:1.5;color:var(--muted)}
.type-desc-box:empty{display:none}
.arc-arrow{display:flex;align-items:center;justify-content:center;color:var(--accent);
  font-size:16px;font-weight:700;flex-shrink:0}
.char-rel-list{display:flex;flex-direction:column;gap:6px;margin-bottom:10px}
.char-rel-item{display:flex;align-items:center;gap:8px;background:var(--accent2);border-radius:8px;
  padding:6px 10px;font-size:12px}
.char-rel-target{font-weight:800;color:var(--accent);flex-shrink:0}
.char-rel-label{flex:1;color:var(--ink)}
.char-rel-add{display:flex;gap:6px;flex-wrap:wrap;align-items:center}
.char-rel-add select{flex:1;min-width:120px}
.char-rel-add input{flex:1;min-width:140px}
.char-rel-mutual{display:flex;align-items:center;gap:5px;font-size:12px;color:var(--muted);cursor:pointer;white-space:nowrap}
.char-graph-wrap{overflow:auto;border:1px solid var(--line);border-radius:10px;background:#fcfbf9}
.char-graph-svg{display:block;margin:0 auto}
.char-graph-edge{stroke:var(--accent);stroke-width:1.5;opacity:.75}
.char-graph-arrowhead{fill:var(--accent);opacity:.9}
.char-graph-edge-label-bg{fill:var(--card);stroke:var(--line);stroke-width:1}
.char-graph-edge-label{font-size:10px;font-weight:600;fill:var(--ink);text-anchor:middle}
.char-graph-node{cursor:pointer}
.char-graph-node text{font-size:11px;font-weight:800;fill:#fff;text-anchor:middle}

/* ===== PDF 인쇄용 미리보기(평소엔 숨김, 인쇄 시에만 표시) ===== */
.print-preview{display:none}
@media print{
  body>*:not(#preview){display:none!important}
  #preview{display:block!important;position:static}
}

/* ===== 글쓰기 툴바 ===== */
.write-toolbar{align-items:center}
.write-toolbar-right{display:flex;gap:6px;margin-left:auto;flex-wrap:wrap}
.wt-selecting{background:var(--accent2)!important;border-color:var(--accent)!important;color:var(--accent)!important}

/* ===== 본문 블록 선택 · 그룹화 ===== */
.scene-select-chk{flex-shrink:0;margin-top:6px;width:15px;height:15px;cursor:pointer}
.scene-block.selected{outline:2px solid var(--accent);outline-offset:1px}
.write-blockgroup{border:1px dashed var(--line);border-radius:10px;padding:10px;margin-bottom:10px;
  background:#faf8f3}
.wg-head{display:flex;align-items:center;gap:8px;margin-bottom:8px}
.wg-title{font-size:12px;font-weight:800;color:var(--accent);flex:1;min-width:0;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.wg-actions{display:flex;gap:4px}
.wg-actions button{background:transparent;border:1px solid var(--line);border-radius:6px;
  cursor:pointer;font-size:11px;padding:3px 7px;color:var(--muted)}
.wg-actions button:hover{border-color:var(--accent);color:var(--accent)}
.write-blockgroup .wg-body{display:flex;flex-direction:column;gap:8px}

/* ===== 우클릭 컨텍스트 메뉴 ===== */
.ctx-menu{position:fixed;z-index:200;background:#fff;border:1px solid var(--line);
  border-radius:8px;box-shadow:0 6px 20px rgba(0,0,0,.16);padding:4px;min-width:170px;font-size:13px}
.ctx-menu[hidden]{display:none}
.ctx-menu button{display:flex;align-items:center;gap:8px;width:100%;text-align:left;
  padding:8px 10px;border:none;background:transparent;border-radius:6px;cursor:pointer;
  font-size:13px;color:var(--ink)}
.ctx-menu button:hover{background:var(--accent2)}
.ctx-menu button.danger{color:#b3503a}
.ctx-menu hr{border:none;border-top:1px solid var(--line);margin:4px 2px}

/* ===== 내보내기 탭 ===== */
.export-btnrow{display:flex;gap:8px;flex-wrap:wrap;margin:10px 0}

/* ===== 본문 블록: 배경/캐릭터 태그 · 점선 추가버튼 ===== */
.scene-tagbtn{flex-shrink:0;display:inline-flex;align-items:center;gap:3px;margin-top:2px;
  background:transparent;border:1px solid var(--line);color:var(--muted);border-radius:6px;
  cursor:pointer;font-size:11px;font-weight:600;padding:4px 8px}
.scene-tagbtn:hover{border-color:var(--accent);color:var(--accent);background:var(--accent2)}
.scene-meta-row{display:grid;grid-template-columns:1fr 1fr;gap:4px 10px;margin:0 0 8px}
.scene-meta-col{display:flex;flex-wrap:wrap;align-items:center;gap:0;font-size:11px;
  background:var(--accent2);border-radius:8px;padding:5px 9px}
.scene-meta-label{font-weight:800;color:var(--accent);flex-shrink:0;white-space:nowrap}
.scene-meta-comma{color:var(--muted)}
.scene-meta-item{display:inline-flex;align-items:center;gap:2px;color:var(--ink);font-weight:600}
.chip-x{display:inline-flex;align-items:center;justify-content:center;background:transparent;
  border:none;cursor:pointer;color:var(--muted);padding:2px;border-radius:50%}
.chip-x .icon{width:10px;height:10px}
.chip-x:hover{color:#b3503a;background:#fff}
.scene-dashed-row{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:8px}
.scene-dashed-add{display:flex;align-items:center;justify-content:center;gap:5px;width:100%;
  padding:8px;border:1.5px dashed var(--line);border-radius:8px;background:transparent;
  color:var(--muted);font-size:12px;font-weight:600;cursor:pointer}
.scene-dashed-add:hover{border-color:var(--accent);color:var(--accent);background:var(--accent2)}

/* ===== 콘티제작 (storyboard) ===== */
.storyboard-layout{display:flex;flex-direction:column;gap:0;max-width:1100px}
.sb-section{margin-bottom:18px}
.sb-divider{display:flex;align-items:center;gap:8px;margin:6px 0 10px}
.sb-divider .wd-name{font-weight:700;font-size:14px;color:var(--accent)}
.sb-rowlist{display:flex;flex-direction:column;gap:10px}
.sb-row{display:flex;align-items:stretch;gap:10px;background:var(--card);
  border:1px solid var(--line);border-radius:10px;padding:10px}
.sb-row.dragging{opacity:.4}
.sb-row-handle{cursor:grab;color:var(--muted);display:flex;align-items:center;flex-shrink:0}
.sb-row-handle:hover{color:var(--accent)}
.sb-row-num{flex-shrink:0;width:22px;height:22px;border-radius:50%;background:var(--accent2);
  color:var(--accent);font-size:11px;font-weight:800;display:flex;align-items:center;justify-content:center;margin-top:1px}
.sb-text-cell{flex:1 1 50%;min-width:0;padding:2px 6px}
.sb-text-title{font-weight:700;font-size:13px;color:var(--ink);margin-bottom:4px}
.sb-text-body{font-size:12.5px;color:var(--muted);line-height:1.5;white-space:pre-wrap;word-break:break-word}
.sb-storyboard-cell{flex:1 1 50%;min-width:0;display:flex;align-items:center;justify-content:center;padding:2px 6px}
.sb-slot{display:flex;align-items:center;justify-content:center;width:100%}
.sb-placeholder{border:2px dashed var(--line);border-radius:10px;display:flex;flex-direction:column;
  gap:10px;align-items:center;justify-content:center;padding:20px;width:100%;min-height:140px}
.sb-placeholder-actions{display:flex;flex-wrap:wrap;gap:8px;justify-content:center}
.sb-thumb-wrap{position:relative;display:inline-block;line-height:0}
.sb-thumb-wrap img{display:block;object-fit:contain;background:#fff;border:1px solid var(--line);
  border-radius:8px;max-width:100%}
.sb-thumb-actions{position:absolute;top:6px;right:6px;display:flex;gap:4px;opacity:0;transition:opacity .15s}
.sb-thumb-wrap:hover .sb-thumb-actions{opacity:1}
.sb-thumb-actions .plot-icon-btn{background:rgba(255,255,255,.92);border:1px solid var(--line)}
.sb-size-list{display:flex;flex-direction:column;gap:8px;margin-top:10px;min-width:240px}
.sb-size-btn{display:flex;flex-direction:column;align-items:flex-start;gap:2px;text-align:left;padding:10px 12px}
.sb-size-btn .hint{margin:0}

/* 그리기 툴 팝업 — 바깥을 눌러도 닫히지 않으며 "저장 후 종료"로만 닫힌다 */
.draw-modal-overlay{position:fixed;inset:0;z-index:2100;background:rgba(0,0,0,.5);
  display:flex;align-items:center;justify-content:center;padding:20px}
.draw-modal{background:var(--card);border-radius:14px;box-shadow:0 12px 40px rgba(0,0,0,.3);
  padding:16px;display:flex;flex-direction:column;gap:12px;max-height:94vh;overflow:auto}
.draw-toolbar{display:flex;align-items:center;gap:14px;flex-wrap:wrap}
.draw-swatches{display:flex;align-items:center;gap:6px}
.draw-color-swatch{width:22px;height:22px;border-radius:50%;border:2px solid var(--line);cursor:pointer;padding:0}
.draw-color-swatch.active{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent2)}
.draw-color-custom{width:26px;height:26px;border:1px solid var(--line);border-radius:6px;cursor:pointer;padding:0}
.draw-width-wrap{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--muted)}
.draw-toolbar .icon-btn.on{background:var(--accent2);border-color:var(--accent);color:var(--accent)}
.draw-canvas-wrap{border:1px solid var(--line);background:#fff;align-self:center;border-radius:4px;overflow:hidden}
canvas.draw-canvas{display:block;touch-action:none;cursor:crosshair}

/* ===== 📚 학습 메뉴 (스토리텔링 구성요소 & 로그라인 카드) ===== */
.learn-section{margin-top:22px}
.learn-section:first-child{margin-top:4px}
.learn-section-title{font-size:16px;font-weight:800;color:var(--ink);margin:0 0 2px}
.learn-formula{margin:8px 0 14px;padding:10px 14px;background:#fbf8f3;border:1px dashed var(--line);
  border-radius:8px;font-size:12px;color:var(--accent);font-weight:700;letter-spacing:.2px}
.learn-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:12px}
.learn-card-mini{border:1px solid var(--line);border-radius:12px;padding:14px 14px 12px;
  background:#fcfbf9;cursor:pointer;transition:box-shadow .15s,border-color .15s}
.learn-card-mini:hover{border-color:var(--accent);box-shadow:0 4px 14px rgba(0,0,0,.08)}
.learn-card-num{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;
  border-radius:50%;background:var(--accent2);color:var(--accent);font-size:11px;font-weight:800;margin-bottom:8px}
.learn-card-title{font-size:14px;font-weight:800;color:var(--ink);margin-bottom:6px}
.learn-card-summary{font-size:12px;color:var(--muted);line-height:1.5}
.learn-card-count{margin-top:8px;font-size:10px;color:var(--accent);font-weight:700}
.learn-detail-body{overflow-y:auto}
.learn-table{width:100%;border-collapse:collapse;margin-bottom:14px}
.learn-table th,.learn-table td{border:1px solid var(--line);padding:9px 12px;font-size:13px;text-align:left;vertical-align:top}
.learn-table th{width:34%;background:#fbf8f3;color:var(--ink);font-weight:700;white-space:nowrap}
.learn-table td{color:var(--muted)}
.learn-bullets{display:flex;flex-wrap:wrap;gap:8px;list-style:none;padding:0;margin:0 0 14px}
.learn-bullets li{background:var(--accent2);color:var(--accent);font-size:12px;font-weight:700;
  border-radius:8px;padding:6px 12px}
.learn-notes{display:flex;flex-direction:column;gap:6px}
.learn-note{font-size:12px;color:var(--ok);background:#e7f0e9;border-radius:8px;padding:8px 12px;font-weight:600}
