/* Ranobe Atelier: a private writer's desk for clean LitRPG.
   White paper, ink, deep ink blue. Cinzel for names and titles, EB Garamond for reading,
   Figtree for the working UI, IBM Plex Mono for System boxes and the notebook counter. */
:root {
  --bg: #ffffff; --panel: #f4f4f6; --ink: #15161a; --soft: #5d5f68; --line: #dcdde2;
  --blue: #1f3a8a; --blue2: #dfe6fb; --on-blue: #ffffff; --seal: #b9bcc6; --fade: #eef0f4;
  --red: #b42318; --red2: #fbe9e7; --ok: #18794e; --ok2: #e3f3ea; --amber: #8a4a10; --amber2: #fbefe0;
  --violet: #45339a; --violet2: #ece8fb; --shadow: 0 14px 34px rgba(20,22,30,.14);
  --ui: Figtree, system-ui, sans-serif; --head: Cinzel, 'Times New Roman', serif; --read: 'EB Garamond', Georgia, serif; --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121317; --panel: #1b1d23; --ink: #ecebe8; --soft: #a3a3a8; --line: #2c2f37;
    --blue: #8aa6ff; --blue2: #1f2a4d; --on-blue: #0d1430; --seal: #4a4e59; --fade: #23262d;
    --red: #ff8a80; --red2: #3a1f1f; --ok: #5fd49b; --ok2: #16301f; --amber: #ffcf99; --amber2: #3a2a17;
    --violet: #c9bcff; --violet2: #2a2445; --shadow: 0 14px 34px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121317; --panel: #1b1d23; --ink: #ecebe8; --soft: #a3a3a8; --line: #2c2f37;
  --blue: #8aa6ff; --blue2: #1f2a4d; --on-blue: #0d1430; --seal: #4a4e59; --fade: #23262d;
  --red: #ff8a80; --red2: #3a1f1f; --ok: #5fd49b; --ok2: #16301f; --amber: #ffcf99; --amber2: #3a2a17;
  --violet: #c9bcff; --violet2: #2a2445; --shadow: 0 14px 34px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.55 var(--ui); overflow-x: clip; min-height: 100vh; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.loading { padding: 48px; color: var(--soft); }

/* top bar */
.top { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); }
.topin { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 10px max(4vw, 16px); }
.brand { font: 800 17px var(--head); letter-spacing: 2px; text-decoration: none; display: flex; align-items: center; gap: 8px; white-space: nowrap; color: var(--ink); }
.brand svg { width: 22px; height: 22px; flex: none; color: var(--blue); }
.crumbs { display: flex; gap: 4px 6px; flex-wrap: wrap; align-items: center; font-size: 14px; color: var(--soft); flex: 1 1 260px; }
.crumbs a { text-decoration: none; color: var(--blue); }
.crumbs a:hover { text-decoration: underline; }
.crumbs .sep { color: var(--seal); }
.crumbs b { color: var(--ink); font-weight: 700; }
.tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.search { display: flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); color: var(--soft); width: 220px; }
.search svg { flex: none; }
.search input { flex: 1; border: 0; background: transparent; outline: none; font-size: 14px; color: var(--ink); width: 100%; }
.search input::placeholder { color: var(--soft); }
.lnk { border: 0; background: none; color: var(--soft); font: 600 13px var(--ui); padding: 6px 8px; border-radius: 8px; min-height: 36px; text-decoration: none; display: inline-flex; align-items: center; white-space: nowrap; }
.lnk:hover { color: var(--ink); background: var(--panel); }

main.wrap { max-width: 1240px; margin: 0 auto; padding: 22px max(4vw, 16px) 64px; display: flex; flex-direction: column; gap: 22px; }

h1 { font: 700 clamp(28px, 4.6vw, 46px)/1.08 var(--head); letter-spacing: .5px; margin: 0; overflow-wrap: anywhere; }
h2 { font: 700 20px/1.2 var(--head); margin: 0; letter-spacing: .3px; }
h2 a { text-decoration: none; }
h2 a:hover { color: var(--blue); }
.sub { color: var(--soft); margin: 0; }
.eyebrow { font: 600 12px var(--head); letter-spacing: 3px; text-transform: uppercase; color: var(--soft); }
.muted { color: var(--soft); }
.small { font-size: 13px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.between { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1 1 0; }

/* buttons */
.btn { font: 700 15px var(--ui); min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: var(--blue); }
.btn.pri { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.btn.small { font-size: 13px; min-height: 36px; padding: 0 12px; border-radius: 8px; }
.btn.on { border-color: var(--blue); color: var(--blue); background: var(--blue2); }
.btn[disabled] { opacity: .5; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; padding: 2px; background: var(--panel); }
.seg button { border: 0; background: transparent; color: var(--soft); font: 700 13px var(--ui); padding: 0 12px; min-height: 32px; border-radius: 99px; }
.seg button.on { background: var(--ink); color: var(--bg); }

/* pills and banners */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap; background: var(--panel); color: var(--soft); width: max-content; }
.pill.running, .pill.run { background: var(--blue2); color: var(--blue); }
.pill.needs_input, .pill.ask { background: var(--red2); color: var(--red); }
.pill.done { background: var(--ok2); color: var(--ok); }
.pill.paused { background: var(--amber2); color: var(--amber); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.6s infinite; flex: none; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }
.banner { display: flex; gap: 10px 12px; align-items: center; flex-wrap: wrap; border: 1px solid var(--blue); background: var(--blue2); border-radius: 10px; padding: 12px 16px; text-decoration: none; color: var(--ink); }
.banner b { font-weight: 700; }
.banner.ask { border-color: var(--red); background: var(--red2); }
.banner .q { flex: 1 1 320px; line-height: 1.55; }
.dots { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12px; font-weight: 700; color: var(--soft); }
.dots .ok { color: var(--ok); }
.dots .new { color: var(--amber); }

/* cards */
.card { border: 1px solid var(--line); border-radius: 12px; padding: 18px; background: var(--bg); }
.card.flat { background: var(--panel); border-color: transparent; }

/* library: pen and series rows */
.pen-head { display: flex; flex-direction: column; gap: 6px; }
.series-box { display: flex; flex-direction: column; gap: 14px; }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.vol { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--bg); display: flex; flex-direction: column; gap: 8px; position: relative; }
.vol:hover { border-color: var(--blue); }
.vol .t { font-weight: 700; font-size: 15px; line-height: 1.25; text-decoration: none; overflow-wrap: anywhere; }
.vol .t:hover { color: var(--blue); }
.vol .n { font-size: 12px; color: var(--soft); }
.vol.plan { border-style: dashed; background: transparent; }
.vol .pinmark { position: absolute; top: 18px; right: 18px; color: #ffd166; text-shadow: 0 1px 2px rgba(0,0,0,.6); font-size: 16px; }
.cover { position: relative; display: block; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden; text-decoration: none; background: var(--panel); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .gen { position: absolute; inset: 0; background: linear-gradient(160deg, #1c2a5c, #0c0f1d); color: #f4f1ea; display: flex; flex-direction: column; justify-content: space-between; padding: 10% 8%; text-align: center; }
.cover .gen .l { font: 500 8px/1.4 var(--head); letter-spacing: .8px; opacity: .85; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.cover .gen .b { font: 800 17px/1.05 var(--head); letter-spacing: 1px; text-transform: uppercase; overflow-wrap: anywhere; }
.cover .gen .a { font: 700 8px var(--head); letter-spacing: 2px; text-transform: uppercase; }
.cover.big .gen .l { font-size: 10px; } .cover.big .gen .b { font-size: 24px; } .cover.big .gen .a { font-size: 10px; }
.vol.plan .cover { background: var(--panel); border: 1px dashed var(--line); }
.vol.plan .cover .gen { background: none; color: var(--soft); }
.dl { display: flex; gap: 4px; flex-wrap: wrap; }
.dl button { flex: 1 1 auto; min-height: 30px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: 700 12px var(--ui); }
.dl button:hover { border-color: var(--blue); color: var(--blue); }

/* notebook grid */
.nb { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; }
.nb i { display: block; aspect-ratio: 3 / 4; border-radius: 2px; background: var(--seal); }
.nb i.r { background: var(--blue); }
.nb i.f { background: var(--fade); outline: 1px dashed var(--seal); outline-offset: -1px; }
.nb i.t { background: transparent; outline: 1px dashed var(--red); outline-offset: -1px; }
.legend { display: flex; gap: 8px 14px; flex-wrap: wrap; font-size: 14px; margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend b { width: 12px; height: 16px; border-radius: 2px; display: inline-block; }
.counter { font: 700 26px/1 var(--head); display: flex; gap: 18px; flex-wrap: wrap; margin: 12px 0 14px; }
.counter small { display: block; font: 500 12px var(--ui); color: var(--soft); margin-top: 4px; letter-spacing: 0; }

/* book page */
.bk { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 24px 28px; align-items: start; }
.bk > div { display: flex; flex-direction: column; gap: 18px; }
.covercard { display: flex; gap: 16px; align-items: flex-start; }
.covercard .cover { width: 150px; flex: none; box-shadow: var(--shadow); }
.covercard .col { flex: 1 1 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stats div { background: var(--panel); border-radius: 10px; padding: 10px 12px; }
.stats b { display: block; font: 800 22px var(--ui); overflow-wrap: anywhere; }
.stats span { font-size: 13px; color: var(--soft); }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.vers { display: grid; gap: 4px; font-size: 13px; color: var(--soft); }
.ver { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.ver b { color: var(--ink); min-width: 84px; font-weight: 700; }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--panel); border: 1px solid transparent; font-size: 14px; font-weight: 600; text-align: left; color: var(--ink); min-height: 52px; }
button.check:hover { border-color: var(--blue); }
.check .box { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--seal); flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; }
.check.yes .box { background: var(--ok); border-color: var(--ok); color: var(--bg); }
.check small { display: block; font-weight: 400; color: var(--soft); font-size: 12px; }
.check .warn { display: block; margin-top: 4px; color: var(--amber); font-weight: 700; }

.chs { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.chs > li { border-bottom: 1px solid var(--line); }
.chs .ch { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 4px; }
.chs .ch:hover { background: var(--panel); }
.chs .n { font: 700 18px var(--head); color: var(--soft); text-align: right; line-height: 1.4; }
.chs .n.on { color: var(--blue); }
.chs .tt { font-weight: 700; text-decoration: none; }
.chs a.tt:hover, .chs a.sm:hover { color: var(--blue); }
.chs .sm { font-size: 14px; color: var(--soft); display: block; margin-top: 2px; text-decoration: none; line-height: 1.5; }
.chs .sm.en { font-style: italic; }
.chs .cnt { font: 500 12px var(--mono); color: var(--soft); display: block; margin-top: 4px; }
.chs .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--soft); margin-top: 6px; }
.chs .meta button { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 99px; font: 700 12px var(--ui); min-height: 28px; padding: 0 10px; }
.notes { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; margin: 0 4px 12px 60px; border-radius: 10px; background: var(--panel); }
.note { display: flex; gap: 12px; font-size: 14px; line-height: 1.55; }
.tag { flex: none; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 6px; height: fit-content; white-space: nowrap; background: var(--panel); }
.tag.Fixed { background: var(--ok2); color: var(--ok); }
.tag.Decided { background: var(--violet2); color: var(--violet); }
.tag.Review { background: var(--amber2); color: var(--amber); }
.setting { line-height: 1.65; margin: 0; }

/* chapter reader */
.rd { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 32px; align-items: start; }
.side { position: sticky; top: 74px; font-size: 14px; max-height: calc(100svh - 96px); overflow: auto; display: flex; flex-direction: column; gap: 1px; }
.side a { display: block; padding: 6px 8px; border-radius: 6px; text-decoration: none; color: var(--soft); }
.side a:hover { color: var(--ink); background: var(--panel); }
.side a.on { background: var(--blue2); color: var(--blue); font-weight: 700; }
.side a.wait { opacity: .55; }
.page { max-width: 700px; width: 100%; display: flex; flex-direction: column; gap: 14px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { font: 700 14px var(--ui); min-height: 40px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; }
.tab[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.okline { font: 700 13px var(--ui); color: var(--ok); }
.chead { text-align: center; margin: 14px 0 22px; }
.chead .lab { font: 600 12px var(--head); letter-spacing: 4px; color: var(--soft); }
.chead .num { font: 800 34px/1.15 var(--head); }
.chead .ttl { font: italic 400 24px/1.3 var(--read); margin-top: 4px; }
.chead .cn, .prose .cn { font: 500 12px var(--mono); letter-spacing: 1px; color: var(--soft); margin-top: 12px; text-align: center; }
.prose { font: 20px/1.7 var(--read); overflow-wrap: break-word; }
.prose p { margin: 0 0 .25em; text-indent: 1.4em; }
.prose p.first, .prose .brk + p, .prose .sys + p, .prose .cn + p, .prose h3 + p { text-indent: 0; }
.prose p.written { text-indent: 0; text-align: center; font-style: italic; margin: .6em 0; }
.prose .brk { text-align: center; color: var(--soft); margin: 1em 0; font-size: 14px; }
.prose p.first::first-letter { font: 800 3.2em/0.8 var(--head); float: left; margin: .08em .1em 0 0; color: var(--ink); }
.prose h3 { font: 700 17px var(--head); text-align: center; margin: 1.2em 0 .6em; }
.prose.raw { color: var(--soft); }
.sys { margin: 16px 0; padding: 10px 14px; background: var(--panel); border: 1px solid var(--ink); border-radius: 6px; box-shadow: 3px 3px 0 var(--ink); font: 500 15px/1.6 var(--mono); overflow-wrap: anywhere; }
.sys .sl { font-size: 11px; letter-spacing: 3px; border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 6px; color: var(--soft); }
.pn { display: flex; justify-content: space-between; gap: 10px; margin-top: 26px; flex-wrap: wrap; }
.mono { background: var(--panel); border-radius: 10px; padding: 16px 18px; font: 500 13px/1.6 var(--mono); white-space: pre-wrap; overflow-x: auto; overflow-wrap: anywhere; }
.sumtxt { font: 19px/1.65 var(--read); margin: 0; }

/* lists, forms, dialogs */
.file-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 12px 4px; border-top: 1px solid var(--line); }
.file-row .fname { flex: 1 1 240px; font-weight: 700; word-break: break-all; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--panel); white-space: nowrap; }
.badge.done { background: var(--ok2); color: var(--ok); }
.badge.needs_input { background: var(--red2); color: var(--red); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; }
input.inp, select.inp, textarea.inp { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-weight: 400; font-size: 15px; width: 100%; }
textarea.inp { min-height: 110px; resize: vertical; line-height: 1.55; }
.kdp { display: flex; flex-direction: column; gap: 6px; }
.kdp .line { display: flex; gap: 8px; align-items: flex-start; }
.kdp .line > :first-child { flex: 1; }
.kdp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 180px; padding: 18px; border-radius: 12px; border: 2px dashed var(--line); background: var(--panel); text-align: center; font-size: 14px; color: var(--soft); cursor: pointer; }
.drop.over { border-color: var(--blue); color: var(--ink); }
.drop b { color: var(--ink); }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 18px; }
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--ink); padding: 22px; width: min(500px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10,12,20,.45); }
dialog form { display: flex; flex-direction: column; gap: 14px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 700; z-index: 60; max-width: calc(100vw - 32px); box-shadow: var(--shadow); }
details.card > summary { cursor: pointer; font: 700 17px var(--head); }
details.card[open] > summary { margin-bottom: 12px; }
.err { color: var(--red); font-size: 14px; }
.empty { padding: 40px 0; text-align: center; }
.empty h1 { margin-bottom: 8px; }

/* sign-in */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; }
.login .mark { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.login .mark svg { width: 44px; height: 44px; color: var(--blue); }
.login .mark .nm { font: 800 30px/1.1 var(--head); letter-spacing: 3px; }
.login .nbline { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; width: 100%; }
.login .nbline i { display: block; height: 10px; border-radius: 1px; background: var(--seal); }
.login .nbline i.r { background: var(--blue); }

@media (max-width: 900px) {
  .bk, .rd { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: none; flex-direction: row; gap: 4px; overflow-x: auto; padding-bottom: 4px; }
  .side a { white-space: nowrap; flex: none; }
}
@media (max-width: 600px) {
  .top { position: static; }
  .topin { padding: 8px 16px; gap: 6px 8px; }
  .brand { order: 1; margin-right: auto; }
  .tools { display: contents; }
  .lnk { order: 2; }
  .search { order: 4; width: 100%; height: 36px; }
  .crumbs { order: 3; flex-basis: 100%; font-size: 13px; }
  .cover.big .gen .b { font-size: 15px; }
  .cover.big .gen .l, .cover.big .gen .a { font-size: 8px; }
  .lnk { padding: 6px; }
  .brand span { font-size: 15px; }
  .prose { font-size: 18px; }
  .stats b { font-size: 19px; }
  .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .covercard .cover { width: 110px; }
  .notes { margin-left: 4px; }
  .chs .ch { grid-template-columns: 34px minmax(0, 1fr); }
  .chs .ch > .pill { grid-column: 2; }
  .card { padding: 16px; }
}
