@charset "UTF-8";

:root {
  color-scheme: dark;
  --bg: #000;
  --panel: #101010;
  --raised: #181818;
  --hover: #202020;
  --ink: #f5f5f5;
  --sub: #b3b3b3;
  --muted: #979797;
  --line: #303030;
  --edge: #494949;
  --serif: "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", Georgia, serif;
  --sans: Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --rail: 212px;
  --gutter: clamp(24px, 4.4vw, 72px);
  font-synthesis: weight style;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { font: 14px/1.6 var(--sans); }
[hidden] { display: none !important; }
a, button { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { color: inherit; font: inherit; }
button { border: 0; background: transparent; cursor: pointer; }
button:disabled { opacity: .35; cursor: default; }
:focus-visible { outline: 2px solid #eee; outline-offset: 4px; }
input, select, textarea {
  background: #0b0b0b; color: var(--ink); border: 1px solid var(--edge); border-radius: 5px;
  width: 100%; min-width: 0; padding: 11px 13px;
}
input::placeholder, textarea::placeholder { color: #949494; }
input:focus, textarea:focus, select:focus { border-color: #bcbcbc; }
textarea { resize: vertical; }
input[type="checkbox"], input[type="range"] { accent-color: #dcdcdc; }
label { display: block; margin: 16px 0 7px; color: #ddd; font-size: 13px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 600; line-height: 1.45; }
h1, h2 { font-family: var(--serif); }
svg.icon {
  width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.55;
  stroke-linecap: round; stroke-linejoin: round; fill: none; flex: none; vertical-align: middle;
}
[data-icon] { display: inline-flex; align-items: center; justify-content: center; }
button .icon { pointer-events: none; }
::selection { color: #0a0a0a; background: #dedede; }
.muted { color: var(--sub); }
.button, .icon-button, .text-button, .screen-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; }
.button {
  min-height: 42px; padding: 9px 17px; border: 1px solid var(--edge); border-radius: 5px;
  background: #141414; color: #f5f5f5; font-weight: 500; line-height: 1.5;
}
.button:hover, .icon-button:hover, .screen-button:hover { background: var(--hover); }
.button:disabled:hover { background: #141414; }
.button.primary { border-color: #adadad; background: #252525; color: white; }
.button.primary:hover { border-color: #fff; background: #333; }
.button.small { min-height: 36px; padding: 7px 12px; font-size: 12px; }
.button.small .icon { width: 16px; height: 16px; }
.button.full { width: 100%; }
.icon-button { border-radius: 5px; width: 42px; height: 42px; flex: none; color: #dedede; }
.text-button { color: var(--sub); padding: 9px 0; }
.text-button:hover { color: #fff; text-decoration: underline; }
.danger { border-style: dashed; }
.boot { min-height: 100svh; display: flex; align-items: center; justify-content: center; gap: 14px; color: var(--sub); }

/* The sign-in spread echoes a clothbound book and its facing title page. */
.login { min-height: 100svh; display: grid; place-items: center; background: #080808; padding: 44px; }
.login-spread { display: grid; grid-template-columns: 1.06fr 1fr; width: min(1080px, 100%); min-height: min(650px, 78svh); }
.jacket-scene {
  display: grid; place-items: center; position: relative; isolation: isolate; overflow: hidden;
  background: radial-gradient(ellipse at 41% 38%,#212121 0%,#111 40%,#0a0a0a 73%);
  border: 1px solid #2c2c2c; border-radius: 8px 0 0 8px;
}
.jacket-shadow {
  position: absolute; width: 53%; height: 62%; background: #000; border-radius: 5px;
  filter: blur(18px); transform: translate(24px,29px) rotate(-9deg);
}
.jacket {
  width: clamp(160px, 19vw, 263px); aspect-ratio: 0.69; position: relative; border-radius: 4px 6px 5px 3px;
  transform: perspective(1000px) rotateY(-10deg) rotateZ(-9deg);
  background: linear-gradient(90deg,#080808 0%,#292929 4%,#151515 7%,#1e1e1e 9%,transparent 10%),
    repeating-linear-gradient(95deg,#ffffff03 0 1px,#00000003 1px 3px), linear-gradient(130deg,#242424,#121212 80%);
  border: 1px solid #424242;
  box-shadow: 1px 1px #757575, 2px 2px #272727, 3px 3px #797979, 4px 4px #454545, 5px 5px #717171,
    6px 6px #272727, 7px 7px #525252, 8px 8px #101010, 9px 9px #4c4c4c, 17px 21px 35px #000a;
}
.jacket-frame { position: absolute; inset: 6% 7% 6% 13%; border: 1px solid #6a6a6a; display: grid; place-items: center; }
.jacket-frame::before, .jacket-frame::after { content: ""; position: absolute; left: 12%; right: 12%; border-top: 1px solid #494949; }
.jacket-frame::before { top: 11%; } .jacket-frame::after { bottom: 11%; }
.jacket-title { writing-mode: vertical-rl; font: 500 clamp(34px,4vw,55px)/1.35 var(--serif); letter-spacing: .2em; color: #e4e4e4; }
.ribbon { position: absolute; top: -1px; right: 13%; width: 12px; height: 33px; background: #aaa; clip-path: polygon(0 0,100% 0,100% 100%,50% 81%,0 100%); }
.login-panel { display: grid; place-items: center; padding: clamp(28px,5vw,70px); background: #0c0c0c; border: 1px solid #303030; border-left: 0; border-radius: 0 8px 8px 0; }
.login-form { width: 100%; max-width: 330px; }
.login-symbol { color: #c4c4c4; margin-bottom: 20px; }
.login-symbol svg.icon { width: 34px; height: 34px; stroke-width: 1.1; }
.login-form h1 { font-size: clamp(28px,3vw,40px); letter-spacing: .085em; }
.login-form label { margin-top: 39px; }
.password-wrap { position: relative; }
.password-wrap input { height: 49px; padding-right: 49px; }
.password-wrap button { position: absolute; right: 3px; top: 4px; color: var(--sub); }
.login-form .button { justify-content: space-between; min-height: 47px; }
.form-error { font-size: 12px; color: #fff; margin: 9px 0; }
.form-error:not(:empty) { border-left: 2px solid #bbb; padding-left: 9px; }
.login-form .form-error { min-height: 11px; }
.app-download { display: inline-block; margin-top: 16px; padding-block: 4px; color: var(--sub); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }

/* Library shell */
.app { min-height: 100svh; }
.sidebar {
  display: flex; flex-direction: column; width: var(--rail); position: fixed; inset: 0 auto 0 0;
  background: #0e0e0e; border-right: 1px solid var(--line); padding: 32px 15px 23px; z-index: 20;
}
.brand, .mobile-brand { display: inline-flex; align-items: center; gap: 12px; font: 600 27px/1.3 var(--serif); letter-spacing: .08em; }
.brand { margin: 3px 16px 48px; }
.brand .icon { width: 30px; height: 30px; stroke-width: 1.35; }
.nav-item {
  display: flex; align-items: center; gap: 13px; width: 100%; min-height: 45px; margin: 3px 0;
  padding: 10px 15px; border-radius: 4px; color: var(--sub); text-align: left; font-size: 13px;
}
.nav-item.active { color: white; background: #212121; box-shadow: inset 2px 0 #d5d5d5; }
.nav-item:hover, .mobile-nav button:hover { color: white; background: #1c1c1c; }
.nav-item .icon { width: 18px; height: 18px; }
.nav-count { margin-left: auto; font: 11px var(--mono); color: var(--sub); }
.sidebar-bottom { margin-top: auto; border-top: 1px solid var(--line); padding-top: 13px; }
.workspace { margin-left: var(--rail); min-height: 100svh; }
.topbar { height: 70px; border-bottom: 1px solid #282828; display: none; justify-content: space-between; align-items: center; gap: 14px; padding: 0 var(--gutter); }
.detail-back:hover { color: white; }
.shelf-import { margin-left: auto; align-self: center; }
.topbar-right { display: flex; gap: 9px; flex: none; align-items: center; }
.mobile-brand, .mobile-lock, .mobile-nav { display: none; }
#main { padding: clamp(32px,4vw,62px) var(--gutter) 65px; max-width: 1450px; margin: 0 auto; }
.shelf-heading { display: flex; align-items: baseline; gap: 19px; flex-wrap: wrap; margin-bottom: 29px; }
.shelf-heading h1, .detail-copy h1 { font: 600 clamp(30px,3vw,44px)/1.35 var(--serif); letter-spacing: .045em; }
.shelf-heading p, .book-facts { font-size: 12px; color: var(--muted); }
.shelf-heading p span, .book-facts span { margin: 0 8px; }
.resume { display: flex; align-items: center; gap: 24px; padding: 22px 26px; margin: 8px 0 26px; background: #141414; border: 1px solid #353535; border-radius: 6px; }
.resume-spine { width: 41px; height: 59px; border-radius: 2px 4px 4px 2px; border: 1px solid #666; box-shadow: inset 4px 0 #242424,inset 5px 0 #555,2px 1px #555; display: grid; place-items: center; background: #202020; flex: none; }
.resume-spine .icon { height: 17px; }
.resume-copy { min-width: 0; flex: 1; }
.resume-copy > span { font-size: 11px; color: var(--muted); }
.resume-copy h2 { margin: 3px 0; font-size: clamp(20px,2vw,26px); overflow-wrap: anywhere; }
.resume-copy p { color: var(--sub); font-size: 13px; overflow-wrap: anywhere; }
.resume .button { flex: none; font-size: 12px; }
.shelf-tools { display: flex; justify-content: space-between; align-items: center; gap: 15px; border-top: 1px solid var(--line); padding: 18px 0 25px; }
.search-field { display: flex; align-items: center; gap: 8px; min-width: 0; background: #0f0f0f; border: 1px solid var(--line); border-radius: 5px; padding: 0 12px; }
.search-field .icon { width: 16px; height: 16px; color: var(--muted); }
.search-field input { background: transparent; border: 0; padding: 8px 0; font-size: 13px; }
.search-field:focus-within { border-color: #999; }
.search-field input:focus-visible { outline-offset: 1px; }
.shelf-tools .search-field { width: min(310px,65%); }
.sort-select { width: auto; min-width: 100px; font-size: 12px; padding: 8px 10px; border-color: var(--line); }
.books-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(150px,1fr)); gap: 30px 25px; align-items: start; }
.book-card { position: relative; min-width: 0; }
.book-open { display: block; width: 100%; padding: 0; text-align: left; border-radius: 4px; }
.book-cover {
  --jacket: #202020;
  position: relative; display: flex; padding: 12% 9% 12% 14%; width: 100%; aspect-ratio: 0.71; overflow: hidden;
  background: linear-gradient(90deg,#0007,transparent 5%,#0006 6%,#fff1 7%,transparent 9%),var(--jacket);
  border: 1px solid #464646; border-right: 3px double #686868; border-radius: 2px 5px 5px 2px;
  box-shadow: 2px 3px #111, 3px 4px #343434; transition: transform .18s ease, border-color .18s;
}
.cover-1 { --jacket: #292929; }
.cover-2 { --jacket: #171717; }
.cover-3 { --jacket: #242424; }
.cover-frame { position: relative; width: 100%; border: 1px solid #646464; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: 17px 12px; gap: 13px; }
.cover-1 .cover-frame { border-width: 2px 0 1px; border-style: double; }
.cover-2 .cover-frame { border: 0; border-left: 1px solid #777; }
.cover-3 .cover-frame { outline: 1px solid #494949; outline-offset: 3px; }
.cover-title { font: 500 clamp(18px,1.55vw,26px)/1.55 var(--serif); color: #fafafa; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; overflow-wrap: anywhere; }
.cover-author { font-size: 10px; color: #bababa; overflow-wrap: anywhere; }
.book-open:hover .book-cover { transform: translateY(-3px); border-color: #888; }
.book-card-info { padding-top: 14px; }
.book-card-info h2 { font: 550 15px/1.5 var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-meta { font-size: 11px; margin-top: 4px; color: var(--muted); }
.card-favorite { position: absolute; right: 5px; top: 5px; width: 34px; height: 34px; background: #151515; border: 1px solid #4c4c4c; }
.card-favorite .icon { width: 15px; height: 15px; }
.card-favorite.selected .icon { fill: currentColor; }
.empty-state { display: grid; justify-items: center; align-content: center; text-align: center; border: 1px solid var(--line); border-radius: 6px; min-height: min(47vh,390px); padding: 40px 20px; background: #0c0c0c; }
.empty-state h2 { font-size: 24px; margin-bottom: 7px; }
.empty-state p { font-size: 13px; color: var(--sub); }
.empty-state .button { margin-top: 22px; }
.empty-shelf { display: flex; align-items: flex-end; gap: 4px; width: 90px; height: 55px; padding: 0 8px 2px; border-bottom: 2px solid #888; margin: 0 0 24px; }
.empty-shelf i { height: 39px; width: 12px; border: 1px solid #aaa; border-radius: 2px; background: linear-gradient(0deg,transparent 12%,#777 13% 16%,transparent 17% 78%,#888 79% 81%,transparent 82%); }
.empty-shelf i:nth-child(2) { height: 49px; width: 15px; } .empty-shelf i:nth-child(3) { height: 32px; }
.empty-shelf i:last-child { transform: rotate(-16deg); transform-origin: bottom left; margin-left: 9px; height: 40px; }

/* Book detail and table of contents */
.detail-back { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 24px; font-size: 12px; color: var(--sub); }
.detail-back .icon { width: 16px; height: 16px; }
.detail-header { display: grid; grid-template-columns: clamp(115px,14vw,178px) minmax(0,1fr); gap: clamp(21px,4vw,48px); align-items: center; margin: 0 0 38px; }
.detail-header .book-cover { padding: 12% 9% 12% 14%; }
.detail-copy h1 { overflow-wrap: anywhere; margin-bottom: 10px; }
.detail-copy .author { font-size: 14px; color: #d3d3d3; margin: 0 0 7px; }
.detail-description { white-space: pre-wrap; max-width: 64ch; max-height: 10em; overflow: auto; margin: 13px 0; color: var(--sub); }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
.detail-actions .icon { width: 16px; height: 16px; }
.detail-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 13px; }
.detail-toolbar h2 { font-size: 25px; }
.detail-toolbar > div { display: flex; gap: 8px; }
.volume, .toc-list details { border-top: 1px solid var(--line); }
.volume:last-child { border-bottom: 1px solid var(--line); }
.volume summary, .toc-list summary { cursor: pointer; padding: 17px 3px; color: #e5e5e5; font-weight: 550; overflow-wrap: anywhere; }
.volume summary small { font: 11px var(--sans); color: var(--muted); margin-left: 12px; }
.chapter-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 24px; padding-bottom: 12px; }
.chapter-row, .bookmark-item { display: flex; align-items: center; min-width: 0; border-top: 1px solid #252525; }
.chapter-row > button:first-child, .toc-chapter { flex: 1; min-width: 0; text-align: left; padding: 12px 9px; font-size: 13px; overflow-wrap: anywhere; }
.chapter-row > button:first-child:hover, .toc-chapter:hover, .bookmark-item > button:hover { background: #1c1c1c; }
.chapter-row .icon-button { width: 36px; height: 39px; color: #a8a8a8; }
.chapter-row .icon { width: 14px; height: 14px; }

/* Dialogs and controls */
.modal {
  color-scheme: dark; background: #121212; color: var(--ink); border: 1px solid #555; border-radius: 9px;
  padding: 0; width: min(570px,calc(100% - 36px)); max-width: none; max-height: 89svh; overflow: auto;
  box-shadow: 0 24px 90px #000b; overscroll-behavior: contain;
}
.modal.compact { max-width: 420px; } .modal.wide { max-width: 800px; width: calc(100% - 36px); }
.modal::backdrop { background: #000b; }
.modal-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 19px 25px 12px; }
.modal-head h2 { font-size: 23px; }
.modal-body { padding: 0 25px 25px; }
.modal-body > p { color: var(--sub); }
.modal-footer, .editor-footer { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 19px; }
.editor-footer { justify-content: space-between; }
.dropzone { border: 1px dashed #555; border-radius: 6px; padding: 28px 14px; text-align: center; background: #0b0b0b; }
.dropzone.dragging { border-color: #fff; background: #242424; }
.dropzone > .icon { width: 28px; height: 28px; margin-bottom: 10px; }
.dropzone h3 { font-size: 15px; margin: 0 0 5px; }
.dropzone p, .upload-limits { font-size: 12px; color: var(--muted); }
.upload-buttons { display: flex; justify-content: center; margin-top: 18px; flex-wrap: wrap; gap: 8px; }
.upload-buttons .button { min-height: 36px; padding: 7px 12px; font-size: 12px; }
.upload-buttons .icon { width: 16px; height: 16px; }
.upload-limits { margin-top: 13px; }
.progress-track { height: 3px; background: #323232; margin: 17px 0 8px; }
.progress-track span { display: block; background: #e0e0e0; height: 100%; }
#upload-status, .inline-note { font-size: 12px; color: var(--sub); }
.inline-note { padding: 11px 0 0; }
.import-preview { max-height: 225px; overflow: auto; border: 1px solid var(--line); border-radius: 5px; padding: 0 13px; margin-top: 17px; }
.import-preview details { border-bottom: 1px solid var(--line); padding: 10px 0; font-size: 13px; }
.import-preview details:last-child { border: 0; }
.import-preview summary { cursor: pointer; }
.import-preview p { color: var(--sub); font-size: 12px; margin: 6px 0 0 16px; }
.import-preview small { margin-left: 6px; font: 10px var(--mono); color: var(--muted); }
.two-columns, .chapter-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.chapter-fields { grid-template-columns: 1fr 112px; }
.checkbox-label { display: flex; align-items: center; gap: 9px; color: var(--sub); font-size: 12px; }
.checkbox-label input { width: 16px; height: 16px; margin: 0; }
.danger-zone { display: flex; justify-content: space-between; gap: 14px; align-items: center; border-top: 1px solid var(--line); margin-top: 20px; padding-top: 16px; font-size: 12px; color: var(--sub); }
.text-editor { font: 14px/1.8 var(--mono),var(--sans); min-height: 250px; tab-size: 4; }
.help-list { margin: 0; }
.help-list dt { margin: 15px 0 4px; font-weight: 550; }
.help-list dd { margin: 0; font-size: 13px; color: var(--sub); line-height: 1.9; }
.toc-tools { margin-bottom: 12px; }
.toc-list { max-height: 58svh; overflow: auto; }
.toc-list summary { padding: 12px 4px; }
.toc-chapter { display: block; width: 100%; }
.toc-chapter.active { background: #252525; box-shadow: inset 2px 0 #ddd; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 60px; border-top: 1px solid var(--line); }
.settings-row label { margin: 0; }
.settings-row select { width: 120px; padding: 7px 10px; }
.stepper { display: flex; align-items: center; gap: 9px; }
.stepper .icon-button { width: 36px; height: 36px; border: 1px solid var(--edge); }
.stepper .icon { width: 15px; height: 15px; }
.stepper output { min-width: 30px; text-align: center; font: 13px var(--mono); }
.bookmark-item { gap: 6px; }
.bookmark-item > button:first-child { flex: 1; min-width: 0; padding: 12px 6px; text-align: left; }
.bookmark-item strong { display: block; font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.bookmark-item small { color: var(--muted); font-size: 11px; }
.bookmark-item .icon { width: 16px; height: 16px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%,7px); background: #272727; color: white; border: 1px solid #555; border-radius: 5px; padding: 9px 15px; z-index: 100; max-width: 90vw; text-align: center; opacity: 0; pointer-events: none; transition: opacity .14s,transform .14s; font-size: 12px; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.loading-state, .error-state { text-align: center; color: var(--sub); padding: 66px 10px; }
.error-state p { margin: 12px 0 20px; }

/* Chapter page */
.reader {
  --font-size: 20px; --line-height: 1.9; --read-width: 720px; --read-font: var(--serif);
  position: fixed; inset: 0; z-index: 30; display: grid;
  grid-template-rows: auto minmax(0,1fr) auto; background: #000; color: #f5f5f5;
}
.reader-top, .reader-bottom { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #080808; }
.reader-top { min-height: 62px; border-bottom: 1px solid #282828; padding: 7px clamp(14px,3.5vw,52px); }
.reader-top-left, .reader-top-actions { display: flex; align-items: center; gap: 7px; min-width: 0; }
.reader-top-actions { flex: none; }
.reader-book-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 15px var(--serif); letter-spacing: .045em; }
.type-button { font: 18px Georgia,var(--serif); }
.reader-scroll { min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-color: #444 #090909; }
.reader-scroll:focus-visible { outline-offset: -2px; }
.android-reader .reader-scroll { grid-row: 1 / -1; padding-top: 62px; padding-bottom: 54px; }
.android-reader .reader-top, .android-reader .reader-bottom { position: absolute; z-index: 1; left: 0; right: 0; }
.android-reader .reader-top { top: 0; }
.android-reader .reader-bottom { bottom: 0; }
.android-reader.bars-hidden .reader-top, .android-reader.bars-hidden .reader-bottom { visibility: hidden; pointer-events: none; }
@media (max-width: 680px) {
  .android-reader .reader-scroll { padding-top: 51px; padding-bottom: 48px; }
}
.reader-article { width: min(var(--read-width),calc(100% - 72px)); margin: auto; padding: clamp(40px,7vh,78px) 0 48px; font: var(--font-size)/var(--line-height) var(--read-font); overflow-wrap: anywhere; }
.chapter-heading { text-align: center; padding-bottom: clamp(24px,4vh,43px); margin-bottom: clamp(24px,4vh,42px); border-bottom: 1px solid #393939; }
.chapter-heading p { color: var(--sub); font: 12px/1.7 var(--sans); letter-spacing: .12em; }
.reader-title { font: 600 1.63em/1.55 var(--read-font); margin-top: 12px; letter-spacing: .035em; color: #fff; }
.chapter-body { color: #fff; }
.chapter-body:not(.markdown) p { margin: 0 0 .9em; text-indent: 2em; white-space: pre-wrap; }
.chapter-body.markdown > :first-child { margin-top: 0; }
.markdown p { margin: .9em 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6 { font-family: var(--read-font); color: white; line-height: 1.55; margin: 1.8em 0 .6em; }
.markdown h1 { font-size: 1.52em; } .markdown h2 { font-size: 1.32em; }
.markdown h3 { font-size: 1.15em; } .markdown :is(h4,h5,h6) { font-size: 1em; }
.markdown strong { color: white; font-weight: 700; }
.markdown em { font-style: italic; } .markdown s { color: #b9b9b9; }
.markdown a { text-decoration: underline; text-decoration-color: #999; text-underline-offset: .16em; }
.markdown a:hover { text-decoration-color: white; }
.markdown blockquote { border-left: 2px solid #929292; margin: 1.3em 0; padding: .12em 0 .12em 1.15em; color: #d1d1d1; }
.markdown blockquote > :first-child, .markdown li > :first-child { margin-top: 0; }
.markdown blockquote > :last-child, .markdown li > :last-child { margin-bottom: 0; }
.markdown ul, .markdown ol { margin: .8em 0; padding-inline-start: 1.8em; }
.markdown li { padding-inline-start: .14em; margin: .23em 0; }
.markdown li > :is(ul,ol) { margin: .18em 0; }
.markdown hr { border: 0; border-top: 1px solid #555; width: 40%; margin: 2em auto; }
.markdown :not(pre)>code { font: .84em var(--mono); background: #202020; border: 1px solid #3b3b3b; border-radius: 3px; padding: .08em .3em; overflow-wrap: anywhere; }
.markdown pre, .table-scroll { width: 100%; overflow: auto; overscroll-behavior-x: contain; scrollbar-color: #555 #151515; }
.markdown pre { background: #141414; border: 1px solid #3d3d3d; border-radius: 5px; padding: 15px 18px; margin: 1.2em 0; }
.markdown pre code { font: .82em/1.65 var(--mono); white-space: pre; overflow-wrap: normal; tab-size: 4; }
.table-scroll { margin: 1.2em 0; }
.markdown table { border-collapse: collapse; min-width: min(100%,20em); font-size: .9em; }
.markdown th, .markdown td { padding: .45em .7em; border: 1px solid #444; text-align: start; }
.markdown th { background: #191919; font-weight: 600; }
.markdown img { display: block; max-width: 100%; max-height: 65vh; object-fit: contain; margin: .8em auto; }
.external-image, .image-fallback { font: 12px/1.65 var(--sans); color: #c4c4c4; }
.external-image { border: 1px solid var(--edge); padding: 7px 12px; border-radius: 4px; }
.chapter-body mark.search-hit { background: #eee; color: #101010; border-radius: 2px; }
.reader-pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; font: 12px var(--sans); border-top: 1px solid #363636; margin-top: 2.8em; padding-top: 22px; }
.reader-pagination button, .screen-button { display: inline-flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: 4px; font-size: 12px; }
.reader-pagination button:hover { background: #1e1e1e; }
.reader-pagination .icon, .screen-button .icon { width: 15px; height: 15px; }
.reader-pagination > span, #sync-status { color: var(--muted); font-size: 11px; }
.reader-bottom { border-top: 1px solid #282828; padding: 5px clamp(13px,3.5vw,52px) max(5px,env(safe-area-inset-bottom)); min-height: 48px; }
.progress-controls { display: flex; align-items: center; justify-content: center; gap: 13px; width: min(450px,66%); min-width: 0; }
.progress-controls label { margin: 0; font-size: 11px; white-space: nowrap; color: #c9c9c9; font-variant-numeric: tabular-nums; }
#read-progress { border: 0; padding: 0; flex: 1; min-width: 38px; height: 16px; accent-color: #ddd; }
#sync-status { white-space: nowrap; }

@media (min-width: 1500px) { .books-grid { grid-template-columns: repeat(auto-fill,minmax(175px,1fr)); } }
@media (max-width: 1050px) {
  :root { --rail: 166px; --gutter: 27px; }
  .sidebar { padding: 26px 10px 16px; }
  .brand { margin: 2px 11px 34px; }
  .nav-item { padding: 11px; gap: 9px; }
  .books-grid { grid-template-columns: repeat(auto-fill,minmax(140px,1fr)); gap: 24px 18px; }
}
@media (max-width: 700px) {
  :root { --gutter: 20px; }
  .login { padding: 18px; }
  .login-spread { display: flex; flex-direction: column; max-width: 480px; min-height: 0; }
  .jacket-scene { height: clamp(108px,25svh,198px); border-radius: 7px 7px 0 0; border-bottom: 0; }
  .jacket { width: auto; height: 78%; }
  .jacket-title { font-size: clamp(18px,3.2vh,27px); }
  .ribbon { width: 6px; height: 17px; }
  .jacket-shadow { height: 66%; width: 90px; }
  .login-panel { border: 1px solid var(--line); border-radius: 0 0 7px 7px; padding: 25px clamp(20px,7vw,38px) 33px; }
  .login-symbol { display: none; }
  .login-form h1 { font-size: 29px; }
  .login-form label { margin-top: 24px; }
  .sidebar { display: none; }
  .workspace { margin: 0; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .topbar { height: 59px; display: flex; }
  .shelf-import { display: none; }
  .mobile-brand, .mobile-lock { display: inline-flex; }
  .mobile-brand { font-size: 22px; gap: 9px; }
  .mobile-brand .icon { width: 24px; height: 24px; }
  .mobile-lock { width: 35px; }
  #main { padding-top: 28px; padding-bottom: 25px; }
  .mobile-nav { position: fixed; z-index: 20; inset: auto 0 0; display: flex; justify-content: space-around; background: #0f0f0f; border-top: 1px solid var(--line); padding: 5px 8px max(5px,env(safe-area-inset-bottom)); }
  .mobile-nav button { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 10px; min-width: 58px; min-height: 44px; justify-content: center; border-radius: 4px; }
  .mobile-nav .icon { width: 19px; height: 19px; } .mobile-nav .active { color: white; }
  .shelf-heading { margin-bottom: 23px; gap: 13px; }
  .shelf-heading h1 { font-size: 31px; }
  .shelf-heading p { font-size: 11px; }
  .shelf-tools { padding: 14px 0 19px; }
  .books-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 23px 17px; }
  .cover-title { font-size: clamp(17px,5vw,23px); }
  .resume { gap: 13px; padding: 16px; margin: 0 0 19px; }
  .resume-spine { width: 29px; height: 44px; }
  .resume .button { font-size: 11px; padding: 7px 10px; min-height: 35px; }
  .resume .button .icon { display: none; }
  .empty-state { min-height: 300px; }
  .detail-header { grid-template-columns: clamp(90px,29vw,145px) minmax(0,1fr); gap: 18px; margin-bottom: 26px; }
  .detail-copy h1 { font-size: 24px; }
  .detail-back { margin-bottom: 16px; }
  .detail-header .cover-frame { padding: 7px; gap: 5px; }
  .detail-header .cover-title { font-size: 17px; }
  .detail-copy .author,.detail-description { font-size: 12px; }
  .detail-actions { gap: 5px; margin-top: 13px; }
  .detail-actions .button { font-size: 12px; padding: 7px 9px; min-height: 35px; }
  .detail-actions .icon { display: none; }
  .detail-toolbar h2 { font-size: 21px; }
  .chapter-grid { grid-template-columns: 1fr; }
  .modal { width: calc(100% - 22px); max-height: 90svh; }
  .modal.wide { width: calc(100% - 22px); }
  .modal-head { padding: 13px 17px 8px; }
  .modal-head h2 { font-size: 21px; }
  .modal-body { padding: 0 17px 20px; }
  .width-setting { display: none; }
  .toast { bottom: calc(69px + env(safe-area-inset-bottom)); width: max-content; }
  .reader-top { min-height: 51px; padding: 4px 8px; gap: 4px; }
  .reader-top-left, .reader-top-actions { gap: 0; }
  .reader-top .icon-button { width: 36px; height: 40px; }
  .reader-book-title { font-size: 13px; }
  .reader-article { width: calc(100% - 42px); padding: 35px 0 30px; }
  .reader-title { font-size: 1.36em; }
  .chapter-heading { padding-bottom: 23px; margin-bottom: 26px; }
  .reader-bottom { min-height: 44px; padding-left: 5px; padding-right: 5px; gap: 5px; }
  .screen-button { width: 38px; min-height: 33px; padding: 6px; }
  .screen-button span, #sync-status { display: none; }
  .progress-controls { flex: 1; gap: 9px; }
  .reader-pagination { padding-top: 14px; }
}
@media (max-width: 365px) {
  :root { --gutter: 14px; }
  .book-facts span { margin: 0 4px; }
  .chapter-fields { grid-template-columns: minmax(0,1fr) 98px; }
  .upload-buttons { gap: 5px; }
  .upload-buttons .button { padding: 6px 9px; }
  .two-columns { grid-template-columns: 1fr; gap: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
