:root{
    --wine:#7b2d35; --wine-dark:#5e2129; --paper:#fdfbf6; --ink:#2b2723;
    --box-blue:#eef4fb; --box-blue-line:#3b6ea5;
    --box-green:#eff7ee; --box-green-line:#4a7d4e;
    --hl:#fff3a0; --cut-note:#fff8e1; --cut-note-line:#d4a017;
    --rail-w:280px;
  }
  *{box-sizing:border-box; margin:0; padding:0;}
  html{scroll-behavior:smooth;}
  body{
    font-family:"Malgun Gothic","맑은 고딕",Pretendard,sans-serif;
    background:#efece5; color:var(--ink); line-height:1.75; font-size:16.5px;
  }
  #layout{position:relative; max-width:900px; margin:0 auto; padding:0 16px 80px;}

  /* ── 상단 고정 모드 바 ── */
  .modebar{
    position:sticky; top:0; z-index:50; background:var(--wine); color:#fff;
    margin:0 -16px; padding:10px 16px 8px; box-shadow:0 2px 8px rgba(0,0,0,.25);
  }
  .modebar .title{font-size:14px; opacity:.85; letter-spacing:.06em;}
  .modebar h1{font-size:20px; margin:2px 0 8px; font-weight:800;}
  .btns{display:flex; flex-wrap:wrap; gap:6px;}
  .btns button{
    font:inherit; font-size:14.5px; font-weight:700; cursor:pointer;
    border:1.5px solid rgba(255,255,255,.55); background:transparent; color:#fff;
    border-radius:20px; padding:6px 14px;
  }
  .btns button.on{background:#fff; color:var(--wine-dark); border-color:#fff;}
  .btns button.util{border-style:dashed; opacity:.92;}
  .modehint{font-size:13px; margin-top:6px; opacity:.9;}

  .howto{background:#fff; border:1px solid #ddd5c8; border-radius:10px; padding:14px 18px; margin:18px 0; font-size:14.5px;}
  .howto b{color:var(--wine);}
  .toolrow{margin:10px 0 0; display:flex; gap:8px; flex-wrap:wrap;}
  .toolrow button{font:inherit; font-size:13.5px; cursor:pointer; border:1px solid #bbb; background:#fff; border-radius:8px; padding:5px 12px;}

  /* ── 개요 카드 ── */
  .overview{background:#fff; border-radius:12px; padding:20px 24px; margin:14px 0 26px; border-top:5px solid var(--wine);}
  .overview h2{font-size:18px; color:var(--wine); margin-bottom:10px;}
  .overview table{width:100%; border-collapse:collapse; font-size:15px;}
  .overview td{padding:5px 8px; vertical-align:top; border-bottom:1px dashed #e5decf;}
  .overview td:first-child{width:110px; font-weight:800; color:var(--wine-dark); white-space:nowrap;}

  /* ── 본문 블록 ── */
  section.block{background:#fff; border-radius:12px; padding:22px 26px; margin:22px 0; box-shadow:0 1px 3px rgba(0,0,0,.06);}
  .badge{display:inline-block; font-size:13px; font-weight:800; color:#fff; background:var(--wine); border-radius:6px; padding:2px 10px; margin-bottom:8px;}
  .badge .t50{opacity:.85; font-weight:600;}
  section.block h2{font-size:20px; color:var(--wine-dark); margin-bottom:4px;}
  .goal{font-size:14px; color:#7a6f5f; margin-bottom:12px;}

  /* ★ v2 — 소단원 카드로 시각 구분 */
  .sub{
    border:1.5px solid #e7dfd0; border-radius:12px; background:#fcfaf4;
    padding:0 16px 12px; margin:18px 0; overflow:hidden;
  }
  .sub > h3{
    font-size:16.5px; color:#fff; background:linear-gradient(90deg,var(--wine),#9a4a52);
    margin:0 -16px 12px; padding:7px 16px; font-weight:800;
  }
  .sublabel{
    display:inline-block; font-size:12.5px; font-weight:800; color:#8a7350;
    letter-spacing:.08em; margin:8px 0 2px;
  }
  .flow{margin:2px 0 8px; background:#fff; border:1px dashed #ddd2bd; border-radius:8px; padding:8px 10px;}
  .flow li{margin:5px 0 5px 24px;}

  .say{
    background:#fdf6ec; border:1.5px solid #e8cfa3; border-radius:10px;
    padding:10px 14px; margin:10px 0; font-size:15.5px; position:relative;
  }
  .say::before{content:"💬 멘트 예시"; display:block; font-weight:800; color:#b07d2a; font-size:12.5px; margin-bottom:2px;}
  .act{color:#3b6ea5; font-weight:700;}
  .ans{background:#fdf3d7; border-radius:8px; padding:8px 14px; margin:8px 0; font-size:14.5px;}
  .ans::before{content:"🗣 예상 답변 · "; font-weight:800; color:#a07d1c;}

  /* ★ v2 — 샘플 대본 아코디언 */
  details.fulltext{margin:10px 0 4px; border:1.5px solid #cbbfa4; border-radius:10px; background:#fffdf5; overflow:hidden;}
  details.fulltext > summary{
    cursor:pointer; list-style:none; padding:9px 14px; font-weight:800; font-size:14.5px;
    color:#6d5a33; background:#f6efdd; user-select:none;
  }
  details.fulltext > summary::before{content:"📜 "; }
  details.fulltext > summary::after{content:" ▾"; float:right; color:#a08c5f;}
  details.fulltext[open] > summary::after{content:" ▴";}
  .ft{
    padding:14px 18px; font-family:"Batang","바탕","Malgun Gothic",serif;
    font-size:16px; line-height:2.0; background:
      repeating-linear-gradient(transparent, transparent 31px, #efe6d2 32px);
  }
  .ft p{margin:0 0 12px;}
  .ft .act{font-family:"Malgun Gothic","맑은 고딕",sans-serif; font-size:14px;}

  .kbox{background:var(--box-blue); border-left:5px solid var(--box-blue-line); border-radius:0 10px 10px 0; padding:12px 16px; margin:14px 0; font-size:15px;}
  .kbox .kt{font-weight:800; color:var(--box-blue-line); display:block; margin-bottom:4px;}
  .kbox li{margin:4px 0 4px 20px;}
  .faq{background:var(--box-green); border-left:5px solid var(--box-green-line); border-radius:0 10px 10px 0; padding:12px 16px; margin:14px 0; font-size:15px;}
  .faq .kt{font-weight:800; color:var(--box-green-line); display:block; margin-bottom:4px;}
  .faq p{margin:6px 0;}
  .faq b{color:var(--box-green-line);}

  /* ── 컷(50분판 제외분) ── */
  .cut-note{display:none;}
  body[data-mode="m50"] .cut{display:none;}
  body[data-mode="cmp"] .cut{background:var(--hl); border-radius:4px;}
  body[data-mode="cmp"] span.cut{box-shadow:0 0 0 3px var(--hl);}
  body[data-mode="cmp"] div.cut, body[data-mode="cmp"] li.cut{padding:8px 12px; border-radius:8px;}
  body[data-mode="cmp"] .cut-note{
    display:block; background:var(--cut-note); border:1.5px dashed var(--cut-note-line);
    border-radius:8px; padding:8px 14px; margin:6px 0 14px; font-size:14px; color:#6b5510;
  }
  .cut-note::before{content:"✂ 50분판에서 뺀 부분 — "; font-weight:800;}

  /* ── 퀴즈 ── */
  #quiz{display:none;}
  body[data-mode="quiz"] #script-root{display:none;}
  body[data-mode="quiz"] #quiz{display:block;}
  .qlevel{margin:26px 0 10px; font-size:18px; color:var(--wine-dark); font-weight:800; border-bottom:3px solid var(--wine); padding-bottom:4px;}
  .q{background:#fff; border-radius:10px; padding:14px 18px; margin:10px 0; box-shadow:0 1px 3px rgba(0,0,0,.06); position:relative; border-left:5px solid transparent;}
  .q .qh{font-weight:700; padding-right:120px;}
  .q .qno{color:var(--wine); font-weight:800; margin-right:6px;}
  .tag{display:inline-block; font-size:12px; font-weight:700; border-radius:4px; padding:1px 7px; margin-left:6px; vertical-align:2px;}
  .tag.t1{background:#e8f1e4; color:#4a7d4e;} .tag.t2{background:#e8eef7; color:#3b6ea5;}
  .tag.t3{background:#f7f0e0; color:#a07d1c;} .tag.t4{background:#f7e8e4; color:#b0543f;}
  .tag.t5{background:#efe4f7; color:#7d3fb0;}
  .q details{margin-top:8px; font-size:15px;}
  .q summary{cursor:pointer; font-weight:700; color:#3b6ea5;}
  .q .a{background:#f4f8f4; border-radius:8px; padding:8px 12px; margin-top:6px;}
  .q .a b{color:#2c6e31;}
  .q .a .wrong{color:#8a6d3b; font-size:14px; display:block; margin-top:4px;}
  .choices li{list-style:none; margin:3px 0 3px 8px;}

  /* ★ v2 — 문제 표시(빼기/더) */
  .qtools{position:absolute; top:10px; right:12px; display:flex; gap:5px;}
  .qtools button{
    font:inherit; font-size:12px; font-weight:700; cursor:pointer;
    border:1px solid #ccc; background:#fafafa; color:#777; border-radius:14px; padding:2px 9px;
  }
  .q.skip{border-left-color:#c0392b; opacity:.55;}
  .q.skip .qh{text-decoration:line-through; text-decoration-color:#c0392b66;}
  .q.skip .qtools .b-skip{background:#c0392b; color:#fff; border-color:#c0392b; }
  .q.more{border-left-color:#2c6e31;}
  .q.more .qtools .b-more{background:#2c6e31; color:#fff; border-color:#2c6e31;}
  .q.reserve{display:none;}
  .q.reserve.revealed{display:block; border-left-color:#7d3fb0; background:#fdfbff;}
  .rtag{display:inline-block; font-size:12px; font-weight:800; background:#7d3fb0; color:#fff; border-radius:4px; padding:1px 7px; margin-right:6px; vertical-align:2px;}
  #qsummary{position:sticky; top:118px; z-index:10; background:#fffdf2; border:1.5px solid #d4a017;
    border-radius:10px; padding:8px 14px; margin:12px 0; font-size:14px; display:flex; align-items:center; gap:10px; flex-wrap:wrap;}
  #qsummary b.sk{color:#c0392b;} #qsummary b.mo{color:#2c6e31;}

  /* ── ★ v3 — 어절 캡슐 하이라이트 (논문분쇄기 이식) ── */
  .w{border-radius:6px; cursor:pointer;}
  .w:hover{background:rgba(130,120,100,.13);}
  .w.sel{background:#ffe9a8; box-shadow:0 0 0 1.5px #d4a017;}
  .seg{border-top:1.6px solid; border-bottom:1.6px solid; padding-top:1px; padding-bottom:2px;
    -webkit-box-decoration-break:slice; box-decoration-break:slice; cursor:pointer;
    -webkit-print-color-adjust:exact; print-color-adjust:exact;}
  .seg:not(.jl){border-left:1.6px solid; border-top-left-radius:11px; border-bottom-left-radius:11px; margin-left:1.5px; padding-left:3px;}
  .seg:not(.jr){border-right:1.6px solid; border-top-right-radius:11px; border-bottom-right-radius:11px; margin-right:1.5px; padding-right:3px;}
  .w.active-cap{box-shadow:inset 0 0 0 1.5px #e67e22;}
  #links{position:absolute; top:0; left:0; pointer-events:none; z-index:5; overflow:visible;}
  #floatbar{
    position:absolute; z-index:200; display:none; background:#333; border-radius:10px;
    padding:5px 7px; box-shadow:0 4px 14px rgba(0,0,0,.35); gap:4px; white-space:nowrap;
  }
  #floatbar button{font-size:14px; border:none; cursor:pointer; border-radius:6px; padding:3px 8px; font-weight:700;}
  #fb-h{background:#ffe9a8;} #fb-m{background:#fff;} #fb-x{background:#e8e8e8;}
  #floatbar .kbd{color:#bbb; font-size:11px; margin-left:2px;}

  #pop{
    position:absolute; z-index:210; display:none; width:270px; background:#fff;
    border:1.5px solid #d4a017; border-radius:10px; box-shadow:0 6px 18px rgba(0,0,0,.25); padding:10px;
  }
  #pop textarea{width:100%; min-height:64px; font:inherit; font-size:14px; border:1px solid #ddd; border-radius:6px; padding:6px; resize:vertical;}
  #pop .row{display:flex; gap:6px; margin-top:6px; align-items:center;}
  #pop .dot{width:18px; height:18px; border-radius:50%; border:1.5px solid #0002; cursor:pointer;}
  #pop .dots{display:flex; gap:4px; flex-wrap:wrap; align-items:center;}
  #pop .sp{flex:1;}
  #pop button{font:inherit; font-size:13px; cursor:pointer; border:1px solid #ccc; background:#f7f7f7; border-radius:6px; padding:3px 10px;}
  #pop .del{color:#c0392b; border-color:#c0392b55;}

  /* 여백 메모 레일 (구글독스식) */
  #rail{position:absolute; top:0; left:100%; width:var(--rail-w); pointer-events:none;}
  .mcard{
    position:absolute; left:14px; width:calc(var(--rail-w) - 20px); pointer-events:auto;
    background:#fffef7; border:1.5px solid #e3d089; border-left:5px solid #e6b93d;
    border-radius:8px; padding:8px 10px; font-size:13px; line-height:1.55;
    box-shadow:0 2px 6px rgba(0,0,0,.12); cursor:pointer; transition:top .2s;
  }
  .mcard .mq{color:#9a8a60; font-size:12px; display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
  .mcard .mt{display:block; margin-top:3px; white-space:pre-wrap;}
  .mcard.active{border-color:#e67e22; box-shadow:0 3px 10px rgba(230,126,34,.35);}
  @media (max-width:1470px){ #rail{display:none;} }

  /* 모달 */
  .modal-bg{position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:300; display:none; align-items:flex-start; justify-content:center; padding:40px 16px;}
  .modal-bg.on{display:flex;}
  .modal{background:#fff; border-radius:14px; max-width:680px; width:100%; max-height:82vh; overflow:auto; padding:22px 26px;}
  .modal h2{color:var(--wine-dark); font-size:19px; margin-bottom:10px;}
  .modal h3{font-size:16px; color:var(--wine); margin:16px 0 6px;}
  .modal .close{float:right; font:inherit; font-size:14px; cursor:pointer; border:1px solid #ccc; background:#f7f7f7; border-radius:6px; padding:2px 10px;}
  .modal ul{margin:6px 0 6px 22px;}
  .modal li{margin:5px 0;}
  .modal .item{background:#faf8f0; border-radius:8px; padding:7px 10px; margin:6px 0; font-size:14px;}
  .modal .item .mq{color:#9a8a60; font-size:12.5px;}
  kbd{background:#eee; border:1px solid #ccc; border-radius:4px; padding:0 5px; font-size:12px; font-family:inherit;}

  #toast{position:fixed; bottom:26px; left:50%; transform:translateX(-50%); z-index:400;
    background:#333; color:#fff; border-radius:20px; padding:7px 18px; font-size:14px; display:none;}

  .foot{margin-top:40px; font-size:13px; color:#8a8172; text-align:center;}

  @media print{
    body{background:#fff; font-size:13.5px;}
    .modebar{position:static; box-shadow:none;}
    .btns,.modehint,.howto,.toolrow,.qtools,#qsummary,#rail,#floatbar,#pop{display:none !important;}
    section.block,.q{box-shadow:none; border:1px solid #ddd; page-break-inside:avoid;}
    .q .qh{padding-right:0;}
    .q details,.q details>*{display:block;}
  }