/* Layout: AI-chat shell. Sidebar = nav + library and chapters as plain chat-history rows. Header picker = chapter switcher (books are picked in the sidebar). Centered 48rem thread, composer pinned at the bottom. UI in Korean or English. */
:root{
  --bg:#ffffff; --side:#f9f9f9; --fg:#0d0d0d; --muted:#5d5d5d; --faint:#8f8f8f;
  --bubble:#f3f3f3; --line:#e6e6e6; --hover:#ececec; --chip:#f1f1f1;
  --ink:#0d0d0d; --on-ink:#ffffff; --mark:#ffe58a; --mark-fg:#0d0d0d; --shade:rgba(0,0,0,.42);
  --pop:#ffffff; --pop-shadow:0 10px 30px rgba(0,0,0,.14),0 0 0 1px rgba(0,0,0,.06); --bad:#c63b3b;
  --sans:ui-sans-serif,-apple-system,"Segoe UI","Apple SD Gothic Neo","Malgun Gothic","Noto Sans KR",system-ui,sans-serif;
  --serif:"EB Garamond","Iowan Old Style",Georgia,"Times New Roman",serif;
  --mincho:"Hiragino Mincho ProN","Yu Mincho","YuMincho","MS PMincho","Noto Serif JP","Noto Serif CJK JP",serif; /* Japanese originals (人間失格) */
  --side-w:300px; --accent:#3d6ae0; --avatar:#bf463c;
}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){
  --bg:#212121; --side:#171717; --fg:#ececec; --muted:#b4b4b4; --faint:#8a8a8a;
  --bubble:#303030; --line:#363636; --hover:#2a2a2a; --chip:#2c2c2c;
  --ink:#ececec; --on-ink:#171717; --mark:#6b5410; --mark-fg:#fff6d6; --shade:rgba(0,0,0,.6);
  --pop:#2a2a2a; --pop-shadow:0 10px 30px rgba(0,0,0,.5),0 0 0 1px rgba(255,255,255,.08); --bad:#ff7b7b;
  color-scheme:dark}}
:root[data-theme="dark"]{
  --bg:#212121; --side:#171717; --fg:#ececec; --muted:#b4b4b4; --faint:#8a8a8a;
  --bubble:#303030; --line:#363636; --hover:#2a2a2a; --chip:#2c2c2c;
  --ink:#ececec; --on-ink:#171717; --mark:#6b5410; --mark-fg:#fff6d6; --shade:rgba(0,0,0,.6);
  --pop:#2a2a2a; --pop-shadow:0 10px 30px rgba(0,0,0,.5),0 0 0 1px rgba(255,255,255,.08); --bad:#ff7b7b;
  color-scheme:dark}

[hidden]{display:none!important}
/* own reset, so the page looks the same wherever it is served */
*,*::before,*::after{box-sizing:border-box}
body,h1,h2,h3,p,figure,blockquote,ul,ol{margin:0}
input,textarea,select{font:inherit;color:inherit;max-width:100%}
html,body{height:100%}
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
body{background:var(--bg);color:var(--fg);font:15px/1.6 var(--sans);overflow:hidden;-webkit-font-smoothing:antialiased}
button{font:inherit;color:inherit;background:none;border:0;cursor:pointer;padding:0}
button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline:2px solid var(--ink);outline-offset:2px;border-radius:8px}
svg{display:block;flex:none}
.app{display:flex;height:100%;height:100dvh;overflow:hidden}

/* ---------- sidebar ---------- */
.side{width:var(--side-w);flex:none;background:var(--side);border-right:1px solid var(--line);display:flex;flex-direction:column;height:100%;
  padding:8px 8px 10px max(8px,env(safe-area-inset-left,0px));overflow:hidden}
.side-top{display:flex;align-items:center;justify-content:space-between;height:44px;padding:0 4px}
.logo{width:32px;height:32px;border-radius:8px;display:grid;place-items:center}
.icon-btn{width:36px;height:36px;border-radius:8px;display:grid;place-items:center;color:var(--muted);flex:none}
.icon-btn:hover{background:var(--hover);color:var(--fg)}
.side-close{display:none}
.nav{display:flex;flex-direction:column;gap:1px;margin-top:4px}
.nav-item{display:flex;align-items:center;gap:10px;height:36px;padding:0 10px;border-radius:8px;text-align:left;width:100%;font-size:14px}
.nav-item:hover{background:var(--hover)}
.nav.nav-more{margin:0 0 10px}
/* a hairline under the fixed "새 채팅" row, only while the list below is scrolled (#side.scrolled, set on scroll) */
.nav{position:relative}
.nav:not(.nav-more)::after{content:"";position:absolute;left:-8px;right:-8px;bottom:-1px;height:1px;background:var(--line);opacity:0;transition:opacity .15s;pointer-events:none}
.side.scrolled .nav:not(.nav-more)::after{opacity:1}
.side-folded .nav::after{display:none}
/* the scroll box reaches the sidebar's right edge (the sidebar pads 8px there), so its scrollbar sits against the border line; the rows keep their width */
.side-scroll{flex:1;overflow-y:auto;margin:1px -8px 0 0;padding-right:8px;min-height:0;scrollbar-width:thin;position:relative;overscroll-behavior:contain}
.side-h{font-size:12px;color:var(--faint);padding:14px 10px 6px;letter-spacing:.02em}
.row{display:flex;align-items:center;gap:10px;height:36px;padding:0 8px;border-radius:8px;width:100%;text-align:left;font-size:14px;min-width:0}
.row:hover{background:var(--hover)}
.row > span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
.row small{color:var(--faint);font-size:12px;margin-left:auto;white-space:nowrap;flex:none;max-width:50%;overflow:hidden;text-overflow:ellipsis}
.row .face{width:24px;height:24px;border-radius:50%;flex:none}
.chat-row{display:block;width:100%;text-align:left;padding:7px 10px;border-radius:8px;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-row:hover,.chat-row.on{background:var(--hover)}
.chat-row.off{color:var(--faint);cursor:default}
.chat-row.off:hover{background:none}
.me-row{display:flex;align-items:center;gap:10px;padding:8px;border-radius:10px;margin-top:6px;width:100%;text-align:left}
.me-row:hover{background:var(--hover)}
.me-dot{width:28px;height:28px;border-radius:50%;background:var(--ink);color:var(--on-ink);display:grid;place-items:center;font-size:12px;font-weight:600;flex:none}
.me-row div{font-size:14px;line-height:1.25}
.me-row small{display:block;color:var(--faint);font-size:12px}
.ini{display:grid;place-items:center;border-radius:50%;color:#fff;font-weight:650;font-size:14px}
/* phone-only pieces of the sidebar (big title, round search, new-chat pill, "see all") stay hidden on wide screens */
.side-title,.side-find,.new-pill,.side-more,.chat-row .row-ic{display:none}
.side-foot{position:relative}
/* wide screens: the sidebar folds into a thin rail of icons, like ChatGPT's "Close sidebar" (setFold below; this browser remembers it) */
.side-fold{display:none}
@media (min-width:821px){
  .side-fold{display:grid}
  .side-anim .side{transition:width .2s cubic-bezier(.2,.8,.2,1)}
  .nav-item{white-space:nowrap}
  .side-folded .side{width:52px}
  .side-folded .side-top{justify-content:center;padding:0}
  .side-folded .logo,.side-folded .nav-item span,.side-folded .me-row div{display:none}
  .side-folded .nav-item{justify-content:center;padding:0}
  /* folded rail: of the scrolling part only the menu icons stay */
  .side-folded .side-scroll{overflow:hidden}
  .side-folded .side-scroll > :not(.nav-more){display:none!important}
  .side-folded .side-foot{margin-top:auto}
  .side-folded .me-row{justify-content:center;padding:4px}
}

/* ---------- main ---------- */
.main{flex:1;min-width:0;display:flex;flex-direction:column;height:100%;position:relative}
.top{height:calc(52px + env(safe-area-inset-top,0px));padding-top:env(safe-area-inset-top,0px);flex:none;display:flex;align-items:center;gap:4px;
  padding-left:max(8px,env(safe-area-inset-left,0px));padding-right:max(8px,env(safe-area-inset-right,0px))}
.menu-btn{display:none}
.model{display:flex;align-items:center;gap:6px;height:36px;padding:0 10px;border-radius:8px;font-size:17px;font-weight:600;white-space:nowrap;min-width:0;overflow:hidden}
.model:hover{background:var(--hover)}
.model .sub{color:var(--faint);font-weight:500}
.top-sp{flex:1}
.pill{display:flex;align-items:center;gap:6px;height:34px;padding:0 12px;border-radius:999px;font-size:13px;border:1px solid var(--line);white-space:nowrap}
.pill:hover{background:var(--hover)}
.pill[aria-pressed="true"]{background:var(--ink);color:var(--on-ink);border-color:var(--ink)}
.pill img,.pill .ini{width:20px;height:20px;border-radius:50%;margin-left:-6px;font-size:10px}

/* the text runs on under the search box and fades out beside and below it; --comp-h is the box's height, set from script */
.scroll{flex:1;overflow-y:auto;min-height:0;padding-bottom:var(--comp-h,110px);scroll-padding-bottom:var(--comp-h,110px)}
.thread{max-width:48rem;margin:0 auto;padding-block:16px 28px;
  padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px));
  display:flex;flex-direction:column;gap:20px}

/* home: new-chat style greeting + resume card + shelf */
.home-wrap{max-width:52rem;margin:0 auto;padding-block:8vh 32px;
  padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px))}
.greet{font-size:28px;font-weight:600;text-align:center;margin:0 0 24px;text-wrap:balance;letter-spacing:-.01em}
.resume{display:flex;flex-direction:column;align-items:flex-start;gap:2px;width:100%;text-align:left;border:1px solid var(--line);border-radius:16px;padding:12px 16px;margin-bottom:14px;min-width:0}
.resume:hover{background:var(--hover)}
.resume-k{font-size:12px;color:var(--faint)}
.resume-t{font-size:15px;font-weight:650}
.resume-q{font-size:14px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}
.shelf{display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:12px}
.book-card{display:flex;flex-direction:column;text-align:left;border:1px solid var(--line);border-radius:16px;overflow:hidden;background:var(--bg)}
.book-card:hover{background:var(--hover)}
.book-card[aria-disabled="true"]{cursor:default}
.book-card[aria-disabled="true"]:hover{background:var(--bg)}
.cv{display:block;aspect-ratio:16/10;max-width:100%;position:relative;overflow:hidden;container-type:inline-size}
.cv img{width:100%;height:100%;object-fit:cover;display:block}
.cv-t{position:absolute;inset:0;display:flex;flex-direction:column;justify-content:flex-end;padding:12px 14px;color:#fff;font-size:19px;font-weight:650;line-height:1.25}
.cv-t small{font-family:var(--serif);font-style:italic;font-weight:400;font-size:14px;opacity:.8;margin-top:2px}
.book-card[aria-disabled="true"] .cv{opacity:.72}
/* who loved or adapted the book (window.FAME in library.js), as a small tag on the cover.
   the tag text shrinks with the card (11.5px at 172px wide and up, down to 9px) so long tags are not cut on narrow phones */
.cv .fame{position:absolute;left:8px;top:8px;max-width:calc(100% - 16px);padding:2px .78em;border-radius:999px;background:rgba(15,15,15,.72);color:#fff;font-size:11.5px;font-size:clamp(9px,calc(11.5px - (172px - 100cqi)*.075),11.5px);font-weight:600;line-height:1.55;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px)}
.meta{display:flex;flex-direction:column;gap:1px;padding:10px 12px 12px}
.meta b{font-size:15px;font-weight:650}
.meta small{color:var(--faint);font-size:12.5px}
.st{font-size:12.5px;color:var(--faint);margin-top:6px}
.st.on{color:var(--fg)}
.st.has-now{display:flex;align-items:center;justify-content:space-between;gap:6px}
.st-t{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.now{display:inline-flex;align-items:center;gap:4px;flex:none;font-weight:600;color:var(--muted)}
.now svg{color:var(--faint);opacity:.8}
.book-card .meta{flex:1}
.book-card .st{margin-top:auto;padding-top:6px}
.empty{color:var(--muted);text-align:center;grid-column:1/-1}
.more{text-align:center;color:var(--muted);font-size:14px;margin-top:22px}
.link{color:var(--fg);text-decoration:underline;text-underline-offset:3px;font-size:inherit}

/* user-style bubble (right) */
.u{display:flex;flex-direction:column;align-items:flex-end;gap:8px}
.u .bub{background:var(--bubble);border-radius:20px;padding:10px 18px;max-width:min(75%,34rem);font-size:16px;line-height:1.5;overflow-wrap:anywhere}
.u .bub p{margin:0}
.u .bub p+p{margin-top:.5em}
.cover{display:block;border-radius:16px;overflow:hidden;max-width:min(320px,80%);line-height:0}
.cover img{width:100%;height:auto}

/* assistant-style plain text */
.a{font-size:16px;line-height:1.75;overflow-wrap:anywhere}
.a h2{font-size:17px;font-weight:650;margin-bottom:4px;text-wrap:balance}
.a p{margin:0}
.a p+p{margin-top:.6em}
.a .hint{color:var(--muted);font-size:14px}
.next{display:inline-flex;align-items:center;gap:6px;margin-top:10px;min-height:36px;padding:5px 14px;border-radius:18px;border:1px solid var(--line);font-size:14px;line-height:1.5;text-align:left}
.next:hover{background:var(--hover)}

/* speeches */
.say{display:grid;grid-template-columns:36px minmax(0,1fr);column-gap:12px;position:relative}
.say .av{width:36px;height:36px;position:relative}
.say .av img,.say .av .ini{width:36px;height:36px;border-radius:50%;display:grid}
.say .av > :nth-child(2){position:absolute;left:14px;top:14px;width:26px;height:26px;box-shadow:0 0 0 2px var(--bg);font-size:11px}
.say .who{font-size:14px;font-weight:650;line-height:20px;display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.say .who small{font-weight:400;color:var(--faint);font-size:12.5px}
.who-n{font-weight:inherit;text-align:left;line-height:inherit}
.who-n:hover{text-decoration:underline;text-underline-offset:3px}
/* faces off (profile menu, for reading somewhere discreet): lines read as plain text; the name still opens the character card */
.no-face .say{grid-template-columns:minmax(0,1fr)}
.no-face .say .av,.no-face #castList .face,.no-face .pill img,.no-face .pill .ini,.no-face .card > img,.no-face .card > .ini{display:none}
.no-face .pill{padding:0 12px}
/* a short note above the first face of a chapter, the first two chapters a reader sees faces in: they can be turned off right here.
   Readers did not find the switch in the settings (4% opened them); the same switch is also in the character card */
.tip{align-self:flex-start;max-width:100%;display:flex;align-items:center;gap:6px;color:var(--muted);font-size:13.5px;line-height:1.4;border:1px solid var(--line);border-radius:12px;padding:5px 5px 5px 14px}
.tip span{flex:1;min-width:0;margin-right:4px}
.tip-b{flex:none;height:34px;padding:0 14px;border-radius:999px;border:1px solid var(--line);font-size:13px;color:var(--fg)}
.tip-x{flex:none;width:34px;height:34px;border-radius:8px;display:grid;place-items:center;color:var(--faint)}
.tip-b:hover,.tip-x:hover{background:var(--hover)}
.mk{display:none;color:var(--fg)}
.marked .mk{display:inline-grid}
.txt{font-size:16px;line-height:1.75;margin-top:2px;overflow-wrap:anywhere}
.txt p{margin:0}
.txt p+p{margin-top:.55em}
.txt[lang="en"]{line-height:1.65}
.dir{display:inline-block;font-size:12.5px;line-height:1.5;color:var(--muted);background:var(--chip);border-radius:6px;padding:0 6px;margin-right:4px;vertical-align:1px;font-family:var(--sans);font-style:normal}
.alt{display:none;margin-top:8px;padding:8px 0 2px 12px;border-left:2px solid var(--line);font-size:15px;line-height:1.7;color:var(--muted)}
.alt[lang="en"],.alt[lang="de"],.alt[lang="fr"]{font-family:var(--serif);font-size:16.5px;line-height:1.55}
.alt[lang="ja"]{font-family:var(--mincho);font-size:15.5px;line-height:1.85}
.alt p+p{margin-top:.5em}
.show-alt .alt,.all-alt .alt{display:block}
.acts{display:flex;gap:2px;margin-top:4px;margin-left:-6px;opacity:0;pointer-events:none;transition:opacity .12s}
/* a line's buttons stay out of sight and float in at its top right when the line is clicked or tapped (.acts-on), or reached by keyboard */
.say:not(.me):not(.tail) .acts,.nar:not(.tail) .acts{position:absolute;right:0;top:auto;bottom:calc(100% - 2px);margin:0;z-index:2;background:var(--pop);border-radius:12px;box-shadow:var(--pop-shadow);padding:5px 6px;gap:2px}
/* the floating box says what each button does in words; the always-visible row (and the point-of-view bubble's) keeps the small icons */
.act .lb,.act .lb-on{display:none}
.say:not(.me):not(.tail) .act,.nar:not(.tail) .act{height:32px;padding:0 12px;border-radius:8px;font-size:13.5px;font-weight:500;letter-spacing:0;color:var(--fg);white-space:nowrap}
.say:not(.me):not(.tail) .act .lb,.nar:not(.tail) .act .lb{display:inline}
.say:not(.me):not(.tail) .act svg,.say:not(.me):not(.tail) .act .ic,.nar:not(.tail) .act svg,.nar:not(.tail) .act .ic,
.say:not(.me):not(.tail) .act .lb-on,.nar:not(.tail) .act .lb-on{display:none}
.say.marked:not(.me):not(.tail) .act .lb-on,.nar.marked:not(.tail) .act .lb-on{display:inline}
.say.marked:not(.me):not(.tail) .act .lb-off,.nar.marked:not(.tail) .act .lb-off{display:none}
.say:focus-within .acts,.nar:focus-within .acts,.acts-on .acts,.tail .acts{opacity:1;pointer-events:auto}
/* .tail: the line that closes a reply, right before my bubble, keeps its row in view like the end of a chat answer */
.act{height:28px;min-width:28px;border-radius:6px;display:grid;place-items:center;color:var(--faint);font-size:11.5px;font-weight:600;letter-spacing:.04em;padding:0 5px}
.act:hover{background:var(--hover);color:var(--fg)}
.show-alt .act-alt,.marked .act-mark{color:var(--fg)}
.act-mark .on,.marked .act-mark .off{display:none}
.marked .act-mark .on{display:block}

/* point-of-view: chosen character's lines become the right-hand bubble */
.say.me{display:flex;flex-direction:column;align-items:flex-end}
.say.me .av,.say.me .who{display:none}
.say.me .body{max-width:min(75%,34rem);display:flex;flex-direction:column;align-items:flex-end}
.say.me .txt{background:var(--bubble);border-radius:20px;padding:10px 16px;margin-top:0}
.say.me .alt{border-left:0;border-right:2px solid var(--line);padding:8px 12px 2px 0;text-align:right}
.say.me .acts{margin-left:0;margin-right:-6px}

/* prose: narration paragraphs read like the assistant's answer */
.nar{position:relative}
.nar .txt{margin-top:0}
.nar + .nar{margin-top:-8px}
.nar.marked::before{content:"";position:absolute;left:-12px;top:5px;bottom:5px;width:2px;border-radius:2px;background:var(--fg)}
.noted .act-note{color:var(--fg)}

/* 좋아요 goes on one sentence (.s) of a line, never the whole line. Choosing a sentence tints it (.on) and the line's box of
   buttons gains "좋아요"; a liked sentence (.lk) keeps a small thumb after its last word (.nb holds the two on one line).
   Nothing else shows while reading: no counts, and no thumb in the row of small icons. */
.s.on{background:rgba(127,127,127,.2);background:color-mix(in srgb,var(--fg) 11%,transparent);border-radius:4px;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding:3px 0}
.nb{white-space:nowrap}
/* the thumb sits close to its own full stop and well clear of the next sentence, so it reads as the mark of the sentence before it;
   nothing follows the last sentence of a paragraph, so no gap there (a speech bubble stays even) */
.lkm{display:inline-block;vertical-align:-1px;margin:0 5px 0 1px;color:var(--fg)}
.s:last-child>.nb>.lkm{margin-right:0}
.act-like{display:none}
.say:not(.me):not(.tail).s-on .act-like,.nar:not(.tail).s-on .act-like{display:grid}
/* a line whose buttons are the always-there row of icons (.tail) or sit under my own bubble gets "좋아요" alone, in a box over the sentence */
.lkpop{position:absolute;z-index:3;background:var(--pop);border-radius:12px;box-shadow:var(--pop-shadow);padding:5px 6px}
.lkpop .act{display:grid;height:32px;padding:0 12px;border-radius:8px;font-size:13.5px;font-weight:500;letter-spacing:0;color:var(--fg);white-space:nowrap}
.lkpop .act .lb{display:inline}
/* the end of a chapter: a few sentences to choose one favourite from; after choosing, my bubble and what the others chose */
.end{display:contents}
.pq{display:flex;flex-direction:column;gap:8px;margin-top:12px}
.pq-b{display:block;width:100%;text-align:left;border:1px solid var(--line);border-radius:16px;padding:10px 14px;font-size:15px;line-height:1.6}
.pq-b:hover{background:var(--hover)}
.pq-b small,.po small{display:block;color:var(--muted);font-size:12.5px;line-height:1.5}
.po{margin-top:14px;display:flex;flex-direction:column;gap:10px;font-size:15px;line-height:1.6}
.po-h{color:var(--muted);font-size:13px}
.po-r{display:flex;gap:14px;align-items:flex-end;align-items:last baseline}
.po-r span{flex:1;min-width:0}
.po-r b{flex:none;font-weight:600;font-size:13.5px;color:var(--muted)}
.pq + p,.po + p{margin-top:12px}

/* my side of the chat: a follow-up prompt every screen or so, and the reader's own notes as messages they sent */
.u.turn{margin-block:6px 0}
.memo .bub{white-space:pre-wrap}
.memo-f{display:flex;gap:2px;justify-content:flex-end;margin:-6px -6px -10px 0;opacity:0;transition:opacity .12s}
.memo:hover .memo-f,.memo:focus-within .memo-f{opacity:1}
@media (hover:none){.memo-f{opacity:.75}}
.act.sure{color:var(--bad);font-size:12.5px;letter-spacing:0;padding:0 8px}
.memo-ed{width:min(100%,36rem);background:var(--bubble);border-radius:20px;padding:12px 14px 10px}
.memo-ed:focus-within{box-shadow:0 0 0 2px var(--line)}
.memo-ed textarea{display:block;width:100%;font:inherit;font-size:16px;line-height:1.65;color:var(--fg);background:none;border:0;resize:none;outline:none;min-height:3.3em;max-height:40vh}
.memo-ed textarea:focus-visible{outline:none}
.memo-ed-f{display:flex;align-items:center;justify-content:flex-end;gap:8px;margin-top:8px}
.memo-ed-f small{flex:1;min-width:0;color:var(--faint);font-size:12px}
@media (hover:none){.memo-ed-f small{visibility:hidden}}
.ghost{height:36px;padding:0 16px;border-radius:999px;background:var(--bg);border:1px solid var(--line);font-size:14px}
.ghost:hover{background:var(--hover)}
.toast{position:fixed;left:50%;bottom:calc(100px + env(safe-area-inset-bottom,0px));transform:translateX(-50%);z-index:60;background:var(--ink);color:var(--on-ink);border-radius:12px;padding:9px 14px;font-size:13.5px;line-height:1.5;width:max-content;max-width:min(92vw,420px);box-shadow:var(--pop-shadow)}
.toast-b{margin-left:12px;font-weight:650;text-decoration:underline;text-underline-offset:3px}
.boss .toast{display:none}

/* stage directions styled like a tool-status line */
.stage{display:flex;align-items:center;gap:8px;color:var(--muted);font-size:14px;line-height:1.5}
.stage svg{color:var(--faint)}
.stage .alt-s{display:none;color:var(--faint);font-size:14px}
.stage .alt-s[lang="en"],.stage .alt-s[lang="de"],.stage .alt-s[lang="fr"]{font-family:var(--serif);font-style:italic;font-size:15px}
.stage .alt-s[lang="ja"]{font-family:var(--mincho);font-size:14.5px}
.all-alt .stage .alt-s{display:inline}

mark{background:var(--mark);color:var(--mark-fg);border-radius:3px;padding:0 1px}
.hit-now{outline:2px solid var(--ink);outline-offset:6px;border-radius:12px}

/* ---------- composer ---------- */
.composer{position:absolute;left:0;right:0;bottom:0;z-index:5;pointer-events:none;padding-top:30px;
  background:linear-gradient(to bottom,rgba(0,0,0,0),var(--bg) 72%);
  padding-bottom:max(10px,env(safe-area-inset-bottom,0px));
  padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px))}
.box{max-width:48rem;margin:0 auto;display:flex;align-items:center;gap:8px;background:var(--bg);
  border:1px solid var(--line);border-radius:28px;padding:8px 8px 8px 18px;box-shadow:0 2px 12px rgba(0,0,0,.05)}
.box input{flex:1;min-width:0;border:0;background:none;color:var(--fg);font:inherit;font-size:16px;height:36px;outline:none}
.box input::placeholder{color:var(--faint)}
.count{font-size:13px;color:var(--faint);font-variant-numeric:tabular-nums;white-space:nowrap}
.send{width:36px;height:36px;border-radius:50%;background:var(--ink);color:var(--on-ink);display:grid;place-items:center}
.send:disabled{opacity:.25;cursor:default}
.composer .box,.composer .foot{pointer-events:auto}
.foot{max-width:48rem;margin:8px auto 0;text-align:center;font-size:12px;color:var(--faint);line-height:1.5}
/* reading screens keep only a little air under the search box; the bar already sits above the phone's home indicator */
.foot-gap{height:max(4px,calc(18px - env(safe-area-inset-bottom,0px)))}

/* ---------- popovers ---------- */
.menu{position:absolute;z-index:30;background:var(--pop);border-radius:16px;box-shadow:var(--pop-shadow);padding:6px;width:290px;max-height:70vh;overflow-y:auto}
.menu.fixed{position:fixed;z-index:46;width:220px}
.menu h3{font-size:12px;font-weight:500;color:var(--faint);padding:8px 10px 6px}
.opt{display:flex;align-items:center;gap:10px;width:100%;text-align:left;padding:7px 10px;border-radius:10px;font-size:14px}
.opt:hover{background:var(--hover)}
.opt.off{color:var(--faint);cursor:default}
.opt.off:hover{background:none}
.opt small{display:block;color:var(--faint);font-size:12px;line-height:1.3}
.opt .chk{margin-left:auto;opacity:0}
.opt[aria-checked="true"] .chk{opacity:1}
.sep{height:1px;background:var(--line);margin:6px 4px}
.card{position:fixed;z-index:40;width:250px;background:var(--pop);border-radius:18px;box-shadow:var(--pop-shadow);padding:16px;text-align:center}
.card img,.card .ini{width:132px;height:132px;border-radius:50%;margin:0 auto 10px;font-size:44px}
.card b{display:block;font-size:17px}
.card small{display:block;color:var(--faint);font-size:12.5px;margin-top:1px}
.card p{font-size:14px;line-height:1.6;color:var(--muted);margin-top:8px;text-align:left}
.card-btn{margin-top:12px;width:100%;height:36px;border-radius:999px;border:1px solid var(--line);font-size:13.5px}
.card-btn:hover{background:var(--hover)}
.card-face{display:block;margin:10px auto 0;padding:4px 8px;font-size:12.5px;color:var(--faint);text-decoration:underline;text-underline-offset:3px}
.card-face:hover{color:var(--muted)}
.shade{position:fixed;inset:0;background:var(--shade);z-index:35}
.lightbox{position:fixed;inset:0;z-index:50;display:grid;place-items:center;padding:24px;background:var(--shade)}
.lightbox figure{margin:0;max-width:min(960px,100%)}
.lightbox img{width:100%;height:auto;border-radius:10px}
.lightbox figcaption{color:#f2f2f2;font-size:13px;margin-top:10px;text-align:center;line-height:1.5}

/* ---------- dialogs (map, bookmarks, requests) ---------- */
.modal{position:fixed;inset:0;z-index:38;display:grid;place-items:center;background:var(--shade);
  padding:calc(12px + env(safe-area-inset-top,0px)) max(12px,env(safe-area-inset-right,0px)) calc(12px + env(safe-area-inset-bottom,0px)) max(12px,env(safe-area-inset-left,0px))}
.sheet{background:var(--bg);border-radius:20px;box-shadow:var(--pop-shadow);width:min(940px,100%);max-height:100%;display:flex;flex-direction:column;overflow:hidden}
.sheet.narrow{width:min(560px,100%)}
.sheet-h{display:flex;align-items:center;gap:10px;padding:14px 12px 6px 20px}
.sheet-h h2{font-size:17px;font-weight:650;line-height:1.3}
.sheet-h small{display:block;color:var(--faint);font-size:12.5px}
.sheet-b{overflow-y:auto;min-height:0;padding:6px 20px 20px;display:flex;flex-direction:column;gap:20px}
.note{color:var(--muted);font-size:14px;line-height:1.6}
.map-wrap{flex:1;min-height:0;overflow:auto;padding:0 12px 6px}
.map{display:block;width:100%;min-width:680px;height:auto}
.map .edge{stroke:var(--faint);stroke-width:1.6;fill:none}
.map .edge.dash{stroke-dasharray:5 5}
.map .edge.bad{stroke:var(--bad);stroke-width:2;stroke-dasharray:6 5}
.map .edge.good{stroke:var(--fg);stroke-width:2.2}
.map .edge.fade{opacity:.3}
.map .chip rect{fill:var(--bg);stroke:var(--line)}
.map .chip text{fill:var(--muted);font-size:12px}
.map .chip.bad rect{stroke:var(--bad)}
.map .chip.bad text{fill:var(--bad);font-weight:650}
.map .chip.good rect{stroke:var(--fg)}
.map .chip.good text{fill:var(--fg);font-weight:650}
.map .chip.fade{opacity:.5}
.map .node{cursor:pointer;outline:none}
.map .ring{fill:none;stroke:var(--line);stroke-width:2}
.map .node:hover .ring,.map .node:focus-visible .ring{stroke:var(--fg);stroke-width:2.5}
.map .nm{fill:var(--fg);font-size:14px;font-weight:650;text-anchor:middle}
.map .rl{fill:var(--faint);font-size:11.5px;text-anchor:middle}
.sheet-f{display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px;padding:10px 20px 14px;color:var(--muted);font-size:12.5px;border-top:1px solid var(--line)}
.lg{display:flex;align-items:center;gap:6px}
.lg line{stroke:var(--faint);stroke-width:2}
.lg.b line{stroke:var(--bad)}
.sheet-f .sp{flex:1}

.mk-item{display:flex;align-items:flex-start;gap:4px;border-top:1px solid var(--line);padding:4px 0}
.mk-item:first-child{border-top:0}
.mk-go{flex:1;min-width:0;text-align:left;padding:8px 8px;border-radius:10px;display:flex;flex-direction:column;gap:2px}
.mk-go:hover{background:var(--hover)}
.mk-go b{font-size:13.5px}
.mk-go span{font-size:15px;line-height:1.6;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.mk-go small{color:var(--faint);font-size:12.5px}
.mk-go b{display:flex;align-items:center;gap:6px}
.mk-go b svg{color:var(--faint);flex:none}
.mk-note{display:-webkit-box;-webkit-line-clamp:4;-webkit-box-orient:vertical;overflow:hidden;font-style:normal;margin:4px 0 2px;padding:6px 12px;background:var(--bubble);border-radius:14px;font-size:14px;line-height:1.55;white-space:pre-wrap;align-self:flex-end;max-width:90%}
.icon-btn.sure{width:auto;padding:0 10px;color:var(--bad);font-size:13px;font-weight:600}
.tabs{display:flex;gap:6px;margin-bottom:-10px}
.tab{height:32px;padding:0 13px;border-radius:999px;font-size:13.5px;color:var(--muted);border:1px solid var(--line)}
.tab:hover{background:var(--hover)}
.tab.on{background:var(--ink);color:var(--on-ink);border-color:var(--ink)}
.tab span{font-variant-numeric:tabular-nums;opacity:.7;margin-left:2px}

form.req{display:flex;flex-direction:column;gap:12px}
/* feedback form: a hidden trap field for bots, and the owner's list */
.hp{position:absolute;left:-9999px;width:1px;height:1px;opacity:0;pointer-events:none}
.fb-mail{font-size:12.5px;color:var(--faint)}
.fb-mail a{color:var(--muted);text-decoration:underline;text-underline-offset:2px}
.rq-b p.fb-text{color:var(--fg);font-size:14px;white-space:pre-wrap;margin:0 0 2px}
.fld{display:flex;flex-direction:column;gap:6px}
.fld label{font-size:13px;color:var(--muted)}
.fld input,.fld textarea{font:inherit;font-size:15px;color:var(--fg);background:var(--bg);border:1px solid var(--line);border-radius:12px;padding:9px 12px;width:100%;resize:vertical}
.fld input:disabled,.fld textarea:disabled{background:var(--side);color:var(--faint)}
.form-foot{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.form-foot span{flex:1;min-width:0;font-size:13px;color:var(--muted)}
.primary{height:38px;padding:0 18px;border-radius:999px;background:var(--ink);color:var(--on-ink);font-size:14px;font-weight:600}
.primary:disabled{opacity:.35;cursor:default}
.why{background:var(--side);border:1px solid var(--line);border-radius:12px;padding:10px 12px;font-size:13.5px;color:var(--muted)}
/* settings dialog: grouped rows with a segmented choice or a switch on the right */
.set-g{display:flex;flex-direction:column}
.set-g h3{font-size:12.5px;font-weight:600;color:var(--faint);margin:0 0 2px}
.set-row{display:flex;align-items:center;gap:12px 16px;padding:12px 0;border-bottom:1px solid var(--line);flex-wrap:wrap}
.set-row:last-child{border-bottom:0}
.set-row .lbl{flex:1;min-width:150px;font-size:14.5px}
.set-row .lbl small{display:block;color:var(--faint);font-size:12.5px;line-height:1.4;margin-top:2px}
.seg{display:flex;gap:2px;padding:3px;border-radius:10px;background:var(--chip)}
.seg button{height:30px;padding:0 12px;border-radius:8px;font-size:13.5px;color:var(--muted);white-space:nowrap}
.seg button[aria-checked="true"]{background:var(--bg);color:var(--fg);box-shadow:0 1px 2px rgba(0,0,0,.14)}
.sw{position:relative;flex:none;width:44px;height:26px;border-radius:13px;background:var(--line);transition:background .15s}
.sw::after{content:"";position:absolute;top:3px;left:3px;width:20px;height:20px;border-radius:50%;background:#fff;box-shadow:0 1px 2px rgba(0,0,0,.25);transition:transform .15s}
.sw[aria-checked="true"]{background:var(--ink)}
.sw[aria-checked="true"]::after{transform:translateX(18px);background:var(--on-ink)}
.set-more{color:var(--faint);font-size:12.5px;line-height:1.5}
.set-more a{color:var(--muted);text-decoration:underline;text-underline-offset:2px}
.set-more a:hover{color:var(--fg)}
/* search pages (/book/<id>/ and /book/<id>/<ch>/ on the site build): the build puts a plain article (#seoPage) in the page
   for search engines and AI crawlers. A chapter article is replaced by the chat thread; a book article is shown as the book's intro. */
a.book-card,a.chat-row{color:inherit;text-decoration:none}
.seo-page{display:none}
.app.bookpage .seo-page{display:block;max-width:48rem;margin:0 auto;padding:18px 20px 56px;font-size:15.5px;line-height:1.75}
.app.bookpage #home,.app.bookpage #thread{display:none!important}
.seo-page a{color:inherit;text-underline-offset:3px}
.seo-crumb{font-size:13px;color:var(--faint);margin-bottom:14px}
.seo-crumb a{text-decoration:none}
.seo-cover{display:block;width:100%;height:auto;border-radius:16px;margin:0 0 18px}
.seo-page h1{font-size:26px;font-weight:700;line-height:1.3;margin:0 0 10px}
.seo-page h2{font-size:18px;font-weight:650;margin:30px 0 10px}
.seo-page h3{font-size:15px;font-weight:650;margin:14px 0 2px}
.seo-page p{margin:0 0 .6em}
.seo-lead{color:var(--muted)}
.seo-start{display:inline-flex;align-items:center;height:40px;padding:0 18px;border-radius:999px;background:var(--ink);color:var(--on-ink)!important;text-decoration:none;font-weight:600;font-size:14.5px;margin:6px 0 4px}
.seo-page table{width:100%;border-collapse:collapse;font-size:14px;line-height:1.55}
.seo-page caption{text-align:left;color:var(--faint);font-size:12.5px;padding-bottom:6px}
.seo-page th,.seo-page td{text-align:left;vertical-align:top;padding:8px 10px 8px 0;border-bottom:1px solid var(--line)}
.seo-page th[scope="row"]{white-space:nowrap;font-weight:600}
.seo-page td:last-child{color:var(--muted)}
.seo-toc{padding-left:1.3em}
.seo-toc li{margin:4px 0}
.seo-toc small{display:block;color:var(--faint);font-size:13px;line-height:1.5}
.seo-src{font-size:12.5px;color:var(--faint)}
.sec-h{font-size:13.5px;font-weight:650;margin-bottom:6px;display:flex;gap:8px;align-items:baseline;flex-wrap:wrap}
.sec-h small{font-weight:400;color:var(--faint);font-size:12.5px}
.rq{display:flex;gap:8px;align-items:flex-start;padding:12px 0;border-top:1px solid var(--line)}
.rq > .badge,.rq > select{margin-top:1px}
.rq > .icon-btn{width:30px;height:30px;margin:-3px -6px 0 0}
.rq-b{flex:1;min-width:0;overflow-wrap:anywhere}
.rq-b b{font-size:14.5px}
.rq-b small{display:block;color:var(--faint);font-size:12.5px;margin-top:1px}
.rq-b p{font-size:13.5px;color:var(--muted);margin-top:2px;overflow-wrap:anywhere}
.badge{font-size:12px;border-radius:999px;padding:1px 9px;background:var(--chip);color:var(--muted);white-space:nowrap}
.badge.done{background:var(--ink);color:var(--on-ink)}
.rq select{font:inherit;font-size:12.5px;color:var(--fg);background:var(--bg);border:1px solid var(--line);border-radius:8px;padding:3px 6px}
.tally{display:flex;flex-wrap:wrap;gap:6px;margin:4px 0 8px}
.tally span{font-size:12.5px;border:1px solid var(--line);border-radius:999px;padding:2px 10px;font-variant-numeric:tabular-nums}

/* fake work chat */
.code{background:var(--side);border:1px solid var(--line);border-radius:12px;padding:12px 14px;font:13.5px/1.6 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;overflow-x:auto;margin-top:.6em}
.a ol{padding-left:1.3em;margin-top:.5em}
.a li+li{margin-top:.35em}

/* view switches: home vs reading, the boss screen over both, and the boss screen's language */
.home .read-only{display:none!important}
.home-only{display:none!important}
.home .home-only{display:block!important}
.boss-only{display:none!important}
.boss .boss-only{display:block!important}
.boss .thread.boss-only{display:flex!important}
.boss .norm-only{display:none!important}
.boss.lang-en .boss-only.ko-only,.boss:not(.lang-en) .boss-only.en-only{display:none!important}

/* ---------- narrow screens ---------- */
/* the sidebar stays put under the chat; opening it slides the chat aside as a rounded card, like a phone chat app.
   A sideways swipe drags the chat with the finger (nav-drag); the chat is never washed or blurred. */
@media (max-width:820px){
  :root{--dw:min(calc(100vw - 72px),360px);--ease:cubic-bezier(.2,.8,.2,1)}
  html,body{overscroll-behavior:none}
  /* phones: the input bar sits right above the screen edge (or the home indicator), like the ChatGPT app; no extra air */
  .composer{padding-bottom:max(8px,env(safe-area-inset-bottom,0px))}
  .foot-gap{height:0}
  .app{background:var(--side)}
  .side{position:fixed;left:0;top:0;bottom:0;z-index:0;width:var(--dw);border-right:0;visibility:hidden;transition:visibility 0s .32s;
    padding:calc(10px + env(safe-area-inset-top,0px)) 10px 0 max(10px,env(safe-area-inset-left,0px))}
  .nav-open .side,.nav-drag .side{visibility:visible;transition:none}
  .main{z-index:1;background:var(--bg);touch-action:pan-y pinch-zoom;transition:transform .32s var(--ease),border-radius .32s,box-shadow .32s}
  .side{touch-action:pan-y pinch-zoom}
  .nav-open .main,.nav-drag .main{border-radius:28px;overflow:hidden;box-shadow:0 0 0 1px var(--line),-10px 0 40px rgba(0,0,0,.12)}
  .nav-open .main{transform:translateX(var(--dw))}
  .nav-drag .main{transition:border-radius .2s,box-shadow .2s}
  /* a clear layer over the pushed-aside chat: one tap brings it back, and nothing under it reacts */
  .nav-shade{position:absolute;inset:0;z-index:70;width:100%;cursor:default;background:none;-webkit-tap-highlight-color:transparent}
  .menu-btn{display:grid}
  .side-close,.logo,#findBtn{display:none}

  /* phone sidebar: a touch bigger than the desktop one (14px), not a jump */
  .side-top{height:52px;padding:0 2px 0 12px;gap:10px}
  .side-title{display:block;font-size:20px;font-weight:700;letter-spacing:-.01em;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
  .side-find{display:grid;place-items:center;width:40px;height:40px;border-radius:50%;background:var(--bg);color:var(--fg);flex:none;
    box-shadow:0 2px 10px rgba(0,0,0,.06),0 0 0 1px var(--line)}
  .side-find svg{width:19px;height:19px}
  .nav{margin-top:8px;gap:1px}
  .nav-item{height:44px;gap:12px;padding:0 12px;font-size:15px;border-radius:10px}
  .nav-item svg{width:20px;height:20px}
  .side-scroll{margin-top:1px;padding-bottom:16px}
  .nav.nav-more{margin:0 0 2px}
  .side-h{font-size:13px;font-weight:600;color:var(--faint);letter-spacing:0;padding:18px 12px 4px}
  .chat-row{font-size:15px;padding:10px 12px;border-radius:10px}
  .chat-row.bk,.side-more{display:flex;align-items:center;gap:12px}
  .chat-row .row-ic{display:block;width:20px;height:20px}
  .chat-row.bk > span{overflow:hidden;text-overflow:ellipsis;min-width:0}
  .side-more{color:var(--faint);width:100%}
  .row{height:44px;gap:12px;padding:0 12px;font-size:15px;border-radius:10px}
  .row .face{width:26px;height:26px}
  .row small{font-size:12px}
  #side:not(.all-books) #bookList .xtra,#side:not(.all-cast) #castList .xtra{display:none}

  .side-foot{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 4px calc(12px + env(safe-area-inset-bottom,0px))}
  .side-foot::before{content:"";position:absolute;left:0;right:0;top:-24px;height:24px;background:linear-gradient(rgba(0,0,0,0),var(--side));pointer-events:none}
  /* "새 채팅" is a plain row at the top of the menu, like the other items (2026-12-02); the floating pill stays hidden */
  .new-pill{display:none;align-items:center;gap:8px;height:46px;padding:0 20px 0 16px;border-radius:999px;background:var(--accent);color:#fff;font-size:15px;font-weight:600;
    box-shadow:0 4px 14px rgba(61,106,224,.28);white-space:nowrap}
  .new-pill svg{width:19px;height:19px}
  .side-foot .me-row{width:46px;height:46px;padding:0;margin:0;border-radius:50%;display:grid;place-items:center;background:var(--bg);flex:none;
    box-shadow:0 2px 10px rgba(0,0,0,.06),0 0 0 1px var(--line)}
  .side-foot .me-dot{width:36px;height:36px;font-size:13.5px;background:var(--avatar);color:#fff}
  .side-foot .me-row div{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}

  .model{font-size:16px}
  .model .sub{display:none}
  .pill .lbl{display:none}
  .pill{padding:0 10px}
  .greet{font-size:23px}
}
/* touch screens: bigger line buttons, 16px form text so iOS doesn't zoom in */
/* tablets held upright (700-820px wide) get the phone layout, where the text would run the full width (~70 Hangul a line):
   keep the reading column, its input bar and the footnote to 42.5rem, centered. The home shelf keeps its full width. */
@media (min-width:700px) and (max-width:820px){
  .app:not(.home) .thread,.app:not(.home) .box,.app:not(.home) .foot{max-width:42.5rem}
}
@media (hover:none){
  .act{height:32px;min-width:34px}
  .fld input,.fld textarea,.rq select{font-size:16px}
}
/* phones: two books per row, dialogs rise from the bottom, the character card docks at the bottom */
@media (max-width:560px){
  .home-wrap{padding-block:5vh 24px}
  .greet{font-size:22px;margin-bottom:18px}
  .shelf{grid-template-columns:1fr 1fr;gap:10px}
  .book-card{border-radius:14px}
  .meta{padding:8px 10px 10px}
  .meta b{font-size:14.5px;line-height:1.35}
  .meta small,.st{font-size:12px}
  .cv-t{font-size:15px;padding:10px}
  .modal{place-items:end stretch;padding:calc(16px + env(safe-area-inset-top,0px)) 0 0}
  .sheet,.sheet.narrow{width:100%;border-radius:22px 22px 0 0;animation:rise .26s var(--ease)}
  .sheet-h{padding:16px 10px 6px 20px}
  .sheet-b{padding-bottom:calc(20px + env(safe-area-inset-bottom,0px))}
  .sheet-f{padding-bottom:calc(14px + env(safe-area-inset-bottom,0px))}
  .card{left:12px!important;right:12px;top:auto!important;bottom:calc(12px + env(safe-area-inset-bottom,0px));width:auto;animation:rise .22s var(--ease)}
  .card img,.card .ini{width:108px;height:108px}
  .menu:not(.fixed){width:min(290px,calc(100vw - 16px))}
}
@keyframes rise{from{transform:translateY(28px);opacity:.4}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
