:root {
  --bg: #faf7f2; --surface: #ffffff; --surface-2: #f3eee6; --text: #2b2622; --muted: #7a6f65;
  --line: #e4dcd0; --accent: #b4532a; --accent-text: #ffffff; --danger: #b3261e;
  --shadow: 0 1px 2px rgba(60, 40, 20, .08), 0 6px 18px rgba(60, 40, 20, .06);
  --sans: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --serif: "Noto Serif KR", "Nanum Myeongjo", "Batang", Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1815; --surface: #25211d; --surface-2: #2e2924; --text: #ece5db; --muted: #a09588;
    --line: #3a342d; --accent: #e07b4c; --accent-text: #1b1815; --danger: #f2877f;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--sans); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* top bar */
.bar { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line); }
.bar .wrap { display: flex; align-items: center; justify-content: space-between; height: 54px; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font: 700 18px var(--serif); color: var(--text); }
.ico { flex: none; }
.brand:hover { text-decoration: none; }
.bar-right { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
main.wrap { padding-top: 24px; padding-bottom: 80px; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
textarea { resize: vertical; line-height: 1.7; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small-text { font-size: 13px; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin: 6px 0; }

/* auth */
.auth { max-width: 380px; margin: 8vh auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.auth h1 { display: flex; align-items: center; justify-content: center; gap: 10px; font: 700 24px var(--serif); margin-bottom: 4px; }
.auth .sub { text-align: center; color: var(--muted); margin-bottom: 20px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; margin-bottom: 18px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 7px; cursor: pointer; color: var(--muted); }
.tabs button[aria-selected=true] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

/* shelf */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font: 700 26px var(--serif); }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 18px; }
.book { cursor: pointer; display: flex; flex-direction: column; gap: 8px; }
.book.dragging { opacity: .4; }
.cover { aspect-ratio: 3 / 4; border-radius: 4px 10px 10px 4px; padding: 16px 14px 14px 22px; display: flex; flex-direction: column;
  justify-content: space-between; color: #fff; position: relative; box-shadow: var(--shadow), inset 6px 0 0 rgba(0,0,0,.18); overflow: hidden;
  transition: transform .15s; }
.book:hover .cover { transform: translateY(-4px); }
.cover .t { margin-top: 14px; font: 700 17px/1.35 var(--serif); word-break: keep-all; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.cover .g { font-size: 12px; opacity: .85; }
.cover .badge { position: absolute; top: 8px; right: 8px; font-size: 11px; background: rgba(0,0,0,.35); padding: 1px 7px; border-radius: 10px; }
.book .meta { font-size: 13px; color: var(--muted); padding: 0 2px; }
.book.new .cover { background: transparent; border: 2px dashed var(--line); color: var(--muted); align-items: center; justify-content: center; box-shadow: none; font-size: 15px; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* book page */
.book-head { display: flex; gap: 22px; align-items: flex-start; margin-bottom: 22px; flex-wrap: wrap; }
.book-head .cover { width: 130px; flex: none; }
.book-head .info { flex: 1; min-width: 220px; }
.book-head h1 { font: 700 26px var(--serif); margin-bottom: 4px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 18px; }
.eps { list-style: none; margin: 0; padding: 0; }
.ep { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.ep:hover { background: var(--surface-2); }
.ep.dragging { opacity: .4; }
.ep .no { font: 700 15px var(--serif); width: 44px; color: var(--accent); }
.ep .tt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.pill.final { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.handle { display: inline-flex; color: var(--muted); cursor: grab; user-select: none; }
details.card > summary { cursor: pointer; font-weight: 600; }
details.card[open] > summary { margin-bottom: 14px; }

/* editor */
.ed-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.ed-top .title-in { flex: 1; min-width: 200px; font: 700 18px var(--serif); }
.save-state { font-size: 13px; color: var(--muted); min-width: 70px; text-align: right; }
.ed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 800px) { .ed-grid { grid-template-columns: 1fr; } }
.pane { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; }
.pane-head b { font-size: 14px; }
.pane textarea { min-height: 52vh; }
.pane textarea.body { font-family: var(--serif); font-size: 16px; line-height: 1.9; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 0; }
.toolbar select { width: auto; }
.ai-panel { margin-top: 14px; border: 1px solid var(--accent); border-radius: 12px; background: var(--surface); }
.ai-panel .head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ai-out { padding: 14px 16px; white-space: pre-wrap; font: 16px/1.9 var(--serif); max-height: 55vh; overflow: auto; }
.spin { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: sp .8s linear infinite; display: inline-block; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } .cover { transition: none; } }

/* dialog */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { font: 700 20px var(--serif); margin-bottom: 14px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.ver { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }

/* reader */
.reader { min-height: 100vh; background: var(--r-bg); color: var(--r-text); transition: background .2s; }
.reader[data-rtheme="light"] { --r-bg: #ffffff; --r-text: #222; --r-line: #e5e5e5; --r-muted: #888; }
.reader[data-rtheme="sepia"] { --r-bg: #f4ecd8; --r-text: #4a3b2a; --r-line: #dccfb0; --r-muted: #8a7a62; }
.reader[data-rtheme="dark"] { --r-bg: #14120f; --r-text: #d8d2c8; --r-line: #2d2923; --r-muted: #8a8378; }
.reader .rbar { position: sticky; top: 0; background: var(--r-bg); border-bottom: 1px solid var(--r-line); }
.reader .rbar .wrap { display: flex; gap: 8px; align-items: center; height: 52px; }
.reader .rbar .btn { background: transparent; border-color: var(--r-line); color: var(--r-text); }
.reader .rbar a { color: var(--r-text); }
.reader article { max-width: 680px; margin: 0 auto; padding: 36px 20px 40px; font-family: var(--serif); }
.reader h1 { font-size: 1.15em; margin: 0 0 4px; }
.reader .sub { color: var(--r-muted); font-size: 14px; margin-bottom: 30px; }
.reader article p { margin: 0 0 1.5em; white-space: pre-line; word-break: keep-all; }
.reader .nav { display: flex; gap: 10px; justify-content: space-between; max-width: 680px; margin: 0 auto; padding: 0 20px 60px; }
.reader .nav .btn { flex: 1; background: transparent; border-color: var(--r-line); color: var(--r-text); }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #2b2622; color: #fff; padding: 10px 16px;
  border-radius: 10px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 100; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* footer, notices, consent, cards */
.foot { display: flex; gap: 16px; justify-content: center; padding-top: 8px; padding-bottom: 36px; font-size: 13px; }
.foot a { color: var(--muted); }
.notice { background: color-mix(in srgb, var(--accent) 12%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }
.consents { display: grid; gap: 8px; margin: 4px 0 12px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--text); margin: 0; line-height: 1.5; }
.check input { margin-top: 3px; flex: none; }
.card-title { font: 700 17px var(--serif); margin-bottom: 12px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }

/* admin */
.admin-tabs { max-width: 560px; margin-bottom: 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat .num { font: 700 28px var(--serif); line-height: 1.2; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 2px; }
.bar-fill { width: 100%; max-width: 44px; background: var(--accent); border-radius: 4px 4px 0 0; }
.bar-n { font-size: 12px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; min-width: 640px; font-size: 14px; }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.tbl tr:last-child td { border-bottom: 0; }
dialog.wide { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto; }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv > span:last-child { text-align: right; word-break: break-all; }
.evlist { max-height: 180px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 13px; }
.ev { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.radio-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; color: var(--text); margin: 0; cursor: pointer; }
.radio-card input { margin-top: 4px; }
code { font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

/* legal pages */
.legal { max-width: 760px; margin: 0 auto; padding: 32px 16px 80px; }
.legal h1 { font: 700 26px var(--serif); margin-bottom: 6px; }
.legal h2 { font: 700 18px var(--serif); margin: 30px 0 10px; }
.legal p, .legal li { line-height: 1.8; }
.legal table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 10px 0; }
.legal th, .legal td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.legal th { background: var(--surface-2); }
.legal .draft { background: color-mix(in srgb, var(--accent) 12%, transparent); border: 1px solid var(--accent); border-radius: 8px; padding: 10px 14px; font-size: 14px; }

/* lore */
.lore-list { display: grid; gap: 8px; margin-bottom: 12px; }
.lore-item { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.lore-main { min-width: 0; flex: 1; }
.lore-text { white-space: pre-wrap; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* =====================================================================
   모바일 / 터치 대응 (파일 맨 아래: 위의 기본 규칙을 덮어씀)
   ===================================================================== */
html { -webkit-tap-highlight-color: transparent; }
body { overflow-wrap: anywhere; }                       /* 공백 없는 긴 글자가 화면 밖으로 밀리지 않게 */
button, a, input, select, summary, [role=tab], [role=button] { touch-action: manipulation; }
input, select, textarea { font-size: 16px; }            /* 16px 미만이면 iOS 가 입력창을 확대함 */
.wrap { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
main.wrap { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
#toast { bottom: calc(24px + env(safe-area-inset-bottom)); }

/* 상단 바: 로고는 한 줄 유지, 긴 필명은 말줄임 */
.bar .wrap { height: auto; min-height: 54px; flex-wrap: nowrap; }
.brand { white-space: nowrap; flex: none; }
.bar-right { min-width: 0; flex: 1 1 auto; justify-content: flex-end; flex-wrap: nowrap; }
.bar-right > * { flex: none; }
.bar-right > .user-link { flex: 0 1 auto; min-width: 0; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 순서 변경 버튼: 터치 기기에서만 보이고, 끌어서 옮기기 안내는 마우스 기기에서만 보임 */
.reorder, .only-coarse { display: none; }
.book .reorder { justify-content: center; gap: 8px; }
@media (hover: none), (pointer: coarse), (max-width: 640px) {
  .reorder { display: flex; align-items: center; gap: 4px; flex: none; }
  .only-coarse { display: inline; }
  .only-fine, .handle { display: none; }
}

/* 책 목록·회차 목록 */
.ep { flex-wrap: wrap; row-gap: 6px; }
.ep .tt { flex: 1 1 120px; }

/* 집필 화면 상단 */
.ed-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 0 0 12px; }
.ed-back { flex: 1 1 200px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-sib { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.ed-top .title-in { flex: 1 1 240px; min-width: 0; }
.ed-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.ed-meta select { width: auto; max-width: 150px; }

/* 읽기 모드 상단 */
.reader .rbar .wrap { height: auto; flex-wrap: wrap; justify-content: space-between; padding-top: 8px; padding-bottom: 8px; gap: 6px 12px; }
.rctl { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

/* 대화상자: 화면보다 커지지 않고, 길면 안에서 스크롤 */
dialog { width: min(480px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; padding: 20px; }
dialog.wide { width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
dialog .actions { flex-wrap: wrap; }

/* 관리자 검색줄 */
.admin-search input[name=q] { flex: 1 1 260px; min-width: 0; }
.admin-tabs button { padding: 8px 2px; font-size: 14px; }

/* 터치 대상 크기: 손가락으로 누르기 편하게 최소 44px (보조 버튼 40px) */
@media (hover: none), (pointer: coarse), (max-width: 640px) {
  .btn { min-height: 44px; }
  .btn.small { min-height: 40px; padding: 0 12px; }
  .tabs button { min-height: 44px; }
  input[type=text], input[type=email], input[type=password], select { min-height: 44px; }
  input[type=color] { height: 44px; width: 72px; padding: 4px; }
  input[type=range] { min-height: 36px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  details.card > summary { line-height: 44px; }
  details.card[open] > summary { margin-bottom: 6px; }
  .check { padding: 4px 0; }
  .foot a { padding: 10px 4px; }
}

@media (max-width: 640px) {
  main.wrap { padding-top: 16px; }
  .page-head h1, .book-head h1 { font-size: 22px; }
  .shelf { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 18px 14px; }
  .book-head { gap: 14px; }
  .book-head .cover { width: 104px; }
  .book-head .info { flex: 1 1 200px; min-width: 0; }
  .auth { margin-top: 3vh; padding: 22px 18px; }
  .ed-top .title-in { flex-basis: 100%; }
  .pane textarea { min-height: 46vh; }
  .toolbar .btn.primary { flex: 1 1 auto; }
  .ep .no { width: auto; }
  .ep .chars { display: none; }
  dialog { padding: 18px; }
  dialog .actions .btn { flex: 1 1 auto; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat { padding: 12px; }
  .stat .num { font-size: 24px; }
  .admin-search input[name=q] { flex-basis: 100%; }
  .admin-search select { flex: 1; width: auto; }
  .reader article { padding: 24px 18px 28px; }
  .reader .nav { padding: 0 18px 48px; }

  /* 표 → 카드: 가로로 밀리지 않고 칸마다 제목이 붙어서 보임 */
  .table-wrap { border: 0; background: transparent; overflow: visible; }
  .tbl { min-width: 0; display: block; }
  .tbl thead { display: none; }
  .tbl tbody { display: grid; gap: 10px; }
  .tbl tr { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; }
  .tbl td { display: flex; justify-content: space-between; align-items: center; gap: 12px; white-space: normal; border: 0; padding: 7px 0; text-align: right; overflow-wrap: anywhere; }
  .tbl td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: none; }
  .tbl td[colspan]::before, .tbl td:not([data-label])::before { display: none; }
  .tbl td:last-child:not([data-label]) { justify-content: flex-end; }

  /* 약관/처리방침의 표도 카드로 */
  .legal { padding: 20px max(16px, env(safe-area-inset-left)) 60px; }
  .legal table, .legal tbody { display: block; border: 0; }
  .legal tr { display: block; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 4px 12px; }
  .legal tr:has(th) { display: none; }
  .legal td { display: block; border: 0; padding: 6px 0; }
  .legal td::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); }
}

/* 표지·배지 다듬기 */
.pill { white-space: nowrap; flex: none; }
.cover .g { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-head .cover { padding: 12px 10px 10px 16px; }
.book-head .cover .t { margin-top: 6px; font-size: 14px; -webkit-line-clamp: 3; }
.book-head .cover .g { font-size: 11px; }

@media (max-width: 640px) {
  .ep { column-gap: 8px; padding: 6px 10px; }
  .ep .tt { flex: 1 1 70px; }
  .ep .btn.small { padding: 0 8px; min-width: 40px; }
}

/* 이야기 나누기 */
.nowrap { white-space: nowrap; }
.parts { display: grid; gap: 10px; max-height: 50vh; overflow: auto; padding-right: 2px; }
.part { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); }
.part .row { flex-wrap: nowrap; }
.part .row input { flex: 1; min-width: 0; }
.part-no { font: 700 15px var(--serif); color: var(--accent); flex: none; min-width: 34px; }
.part-text { margin-top: 6px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.batch { display: grid; gap: 8px; }
.batch-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.batch-row .tt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-row.ok { border-color: var(--accent); }
.batch-row.fail { border-color: var(--danger); }
.batch-row.fail .muted { color: var(--danger); white-space: normal; }
@media (max-width: 640px) { .part .row { flex-wrap: wrap; } .part .row input { flex-basis: 100%; order: 3; } }

/* 한도 안내, 요구사항 메모, 목차 */
dialog.limit h2 { color: var(--danger); }
.limit-time { font-size: 17px; background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }
.stat.warn { border-color: var(--danger); }
.notes-list { display: grid; gap: 6px; margin-bottom: 10px; }
.note { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.note.off { opacity: .55; }
.note .check { padding: 2px 0; }
.nav-top { padding: 14px 20px 0; align-items: center; }
.nav-top .btn { flex: 0 1 auto; min-width: 96px; }
.nav-pos { color: var(--r-muted); white-space: nowrap; }
.toc { display: grid; gap: 4px; max-height: 60vh; overflow: auto; }
.toc-item { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; color: var(--text); text-decoration: none; min-height: 44px; }
.toc-item:hover { background: var(--surface-2); text-decoration: none; }
.toc-item b { font: 700 15px var(--serif); color: var(--accent); flex: none; min-width: 40px; }
.toc-item .tt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-item.now { background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* 격자 안의 긴 글자가 칸을 밀어내지 않게 (min-width: auto 방지) */
.toc, .parts, .batch, .notes-list, .lore-list, .consents { grid-template-columns: minmax(0, 1fr); }
.toc-item, .part, .batch-row, .note, .lore-item { min-width: 0; }

/* 회차 상태 표시 */
.pill.raw { background: transparent; border: 1px dashed var(--accent); color: var(--accent); }
.pill.empty { background: transparent; border: 1px dashed var(--line); }

/* 회차 행: 버튼들을 한 묶음으로. 좁은 화면에서는 제목 줄 아래 오른쪽에 정렬 */
.ep-actions { display: flex; align-items: center; gap: 6px; flex: none; }
@media (max-width: 640px) {
  .ep-actions { flex-basis: 100%; justify-content: flex-end; margin-top: -2px; }
  .ep .tt { flex: 1 1 60px; }
}

/* 만드는 중 표시 */
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain:disabled { opacity: .6; }
.progress { display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.progress .spin { flex: none; }
.btn .spin { margin-right: 2px; }
.btn.primary .spin { border-color: color-mix(in srgb, var(--accent-text) 35%, transparent); border-top-color: var(--accent-text); }

/* 대화상자가 길어도 아래 버튼(취소/확인)은 항상 보이게 고정 */
dialog .actions { position: sticky; bottom: 0; z-index: 1; background: var(--surface); margin-top: 14px; padding: 12px 0 2px; box-shadow: 0 -10px 10px -10px rgba(0,0,0,.12); }

/* 진행 표시: 화면 맨 위 막대, 불러오는 중, 처리 중인 버튼 */
#topbar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 300; pointer-events: none; opacity: 0; transition: opacity .15s;
  background: linear-gradient(90deg, transparent 0, var(--accent) 50%, transparent 100%); background-size: 40% 100%; background-repeat: no-repeat; animation: topbar 1.1s ease-in-out infinite; }
#topbar.on { opacity: 1; }
@keyframes topbar { 0% { background-position: -40% 0; } 100% { background-position: 140% 0; } }
.empty.loading { display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn[aria-busy="true"] { cursor: progress; }
input:disabled + .spin { vertical-align: middle; }
@media (prefers-reduced-motion: reduce) { #topbar { animation: none; background: var(--accent); } }

/* 관리자 작품 열람 */
dialog.viewer { width: min(760px, calc(100vw - 24px)); }
.viewer-note { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.viewer-timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 4px 0 12px; font-size: 14px; }
.linklike { background: none; border: 0; padding: 4px 0; color: var(--accent); cursor: pointer; text-decoration: underline; font: inherit; min-height: 32px; }
.vsec { margin-bottom: 18px; } .vsec h3 { font: 700 15px var(--serif); margin: 0 0 8px; }
.vtext { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; line-height: 1.8; max-height: 50vh; overflow: auto; font-family: var(--serif); }
.vlist { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.vitem { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); min-width: 0; }
.vitem.col { flex-direction: column; align-items: stretch; margin-bottom: 8px; }
.vmain { min-width: 0; flex: 1; }

/* 읽기: 장면 구분선 */
.reader hr.scene { border: 0; text-align: center; margin: 2.2em 0; height: 1em; }
.reader hr.scene::before { content: '· · ·'; color: var(--r-muted); letter-spacing: .6em; }
