:root { color-scheme: light; --bg:#f7f2e9; --card:#fffdf8; --text:#29251f; --muted:#655e55; --line:#d5ccc0; --accent:#695a3d; --font-size:18px; }
:root[data-theme="sepia"] { --bg:#eee1cb; --card:#f8edda; --text:#35291c; --muted:#685742; --line:#cdbca1; --accent:#6d5030; }
:root[data-theme="dark"] { color-scheme:dark; --bg:#24221f; --card:#302d29; --text:#ede8de; --muted:#c0b5a5; --line:#5a5147; --accent:#dbc18c; }
* { box-sizing:border-box; }
html { scroll-behavior:auto; }
body { margin:0; background:var(--bg); color:var(--text); font:16px/1.5 system-ui,sans-serif; }
button,input { font:inherit; }
button { cursor:pointer; }
button:focus-visible,input:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.topbar { position:sticky; top:0; z-index:2; display:flex; justify-content:space-between; gap:12px; padding:12px max(18px,calc((100% - 680px)/2)); background:var(--card); border-bottom:1px solid var(--line); }
.topbar strong { font-size:19px; }
.topbar span,.muted,.hint { color:var(--muted); }
main { width:min(100%,680px); margin:auto; padding:24px 18px 94px; }
.view[hidden],.notice[hidden] { display:none; }
h1 { margin:8px 0 16px; font:normal 32px/1.2 Georgia,serif; }
.eyebrow { margin:0; color:var(--accent); font-size:12px; font-weight:700; letter-spacing:.12em; text-transform:uppercase; }
.hint { font-size:13px; }
.book-list { display:grid; gap:14px; margin:24px 0; }
.book-card { display:flex; align-items:center; gap:20px; width:100%; margin:24px 0; padding:14px; text-align:left; color:var(--text); background:var(--card); border:1px solid var(--line); border-radius:12px; }
.book-list .book-card { margin:0; }
.book-card img { width:100px; height:138px; object-fit:cover; border-radius:4px; }
.book-card span { display:grid; gap:8px; }
.book-card strong { font:normal 23px/1.2 Georgia,serif; }
.book-card small { color:var(--muted); }
.book-card em { color:var(--accent); font-style:normal; font-weight:600; }
.detail-cover { width:158px; max-width:45%; height:auto; margin:20px 0; border-radius:5px; }
.primary { padding:11px 18px; color:var(--card); background:var(--accent); border:1px solid var(--accent); border-radius:7px; }
:root[data-theme="dark"] .primary { color:#24221f; }
.detail-actions,.auth-actions { display:flex; flex-wrap:wrap; gap:10px; margin:18px 0 10px; }
.detail-actions button,.auth-actions button,#logout-account { padding:11px 18px; color:var(--text); background:var(--card); border:1px solid var(--line); border-radius:7px; }
.detail-actions .primary,.auth-actions .primary { color:var(--card); background:var(--accent); border-color:var(--accent); }
:root[data-theme="dark"] .detail-actions .primary,:root[data-theme="dark"] .auth-actions .primary { color:#24221f; }
.pwa-card { display:flex; align-items:center; justify-content:space-between; gap:20px; margin:28px 0 18px; padding:18px; background:var(--card); border:1px solid var(--line); border-radius:12px; }
.pwa-card h2 { margin:5px 0; font:normal 24px/1.2 Georgia,serif; }
.pwa-card p { margin:5px 0; }
.pwa-actions { display:grid; gap:8px; min-width:190px; }
.pwa-actions button { padding:10px 12px; border:1px solid var(--line); border-radius:7px; }
.pwa-actions button:not(.primary) { color:var(--text); background:var(--bg); }
button:disabled { cursor:default; opacity:.62; }
.text-button { padding:0; color:var(--accent); background:none; border:0; }
.bottom-nav { position:fixed; bottom:0; left:0; right:0; z-index:3; display:flex; justify-content:center; background:var(--card); border-top:1px solid var(--line); }
.bottom-nav button { flex:1; max-width:136px; min-height:58px; padding:8px 2px; color:var(--muted); background:none; border:0; font-size:12px; }
.bottom-nav button[aria-current="page"] { color:var(--accent); font-weight:700; border-top:3px solid var(--accent); }
.reader-tools { position:sticky; top:52px; z-index:2; display:flex; gap:6px; margin:-12px 0 12px; padding:6px 0; background:var(--bg); }
.reader-tools button,.chapter-controls button,.dialog-head button,.bookmark-row button { padding:7px 9px; color:var(--text); background:var(--card); border:1px solid var(--line); border-radius:6px; }
.reader-tools button:last-child { margin-left:auto; }
.reader-book-title { margin:4px 0 0; color:var(--accent); font:normal 18px/1.3 Georgia,serif; }
#reading-progress { font-size:12px; }
.book-text { font:var(--font-size)/1.65 Georgia,serif; overflow-wrap:break-word; -webkit-user-select:none; user-select:none; }
.book-text h1,.book-text h2 { line-height:1.23; font-weight:normal; }
.book-text h1 { font-size:1.6em; }
.book-text h2 { margin-top:1.7em; font-size:1.3em; }
.book-text p { margin:0 0 .9em; }
.book-text [id] { scroll-margin-top:110px; }
.book-text figure { margin:1.5em 0; text-align:center; }
.book-text img { max-width:100%; height:auto; cursor:zoom-in; }
.chapter-controls { display:flex; justify-content:space-between; gap:12px; margin-top:34px; }
.chapter-controls button:disabled { opacity:.4; cursor:default; }
#font-size { display:block; width:100%; margin:16px 0 28px; }
form { display:grid; gap:14px; max-width:520px; }
form label:not(.check-row) { display:grid; gap:6px; color:var(--muted); font-size:14px; }
form input[type="email"],form input[type="tel"],form input[type="password"] { width:100%; padding:11px; color:var(--text); background:var(--card); border:1px solid var(--line); border-radius:7px; }
.check-row { display:flex; align-items:flex-start; gap:8px; font-size:14px; }
.account-data { display:grid; gap:0; margin:20px 0; background:var(--card); border:1px solid var(--line); border-radius:10px; }
.account-data div { display:grid; grid-template-columns:110px 1fr; gap:12px; padding:11px 14px; border-bottom:1px solid var(--line); }
.account-data div:last-child { border-bottom:0; }
.account-data dt { color:var(--muted); }
.account-data dd { margin:0; overflow-wrap:anywhere; }
fieldset { display:grid; gap:12px; padding:16px; margin-bottom:24px; border:1px solid var(--line); border-radius:8px; }
legend { padding:0 5px; }
.bookmark-row { display:flex; gap:8px; align-items:center; margin:12px 0; padding:10px; background:var(--card); border:1px solid var(--line); border-radius:7px; }
.bookmark-row button:first-child { flex:1; text-align:left; }
dialog { width:min(100% - 24px,600px); max-height:85dvh; padding:18px; color:var(--text); background:var(--card); border:1px solid var(--line); border-radius:10px; }
dialog::backdrop { background:#0009; }
.image-viewer { width:100vw; max-width:none; height:100dvh; max-height:none; margin:0; padding:18px; background:#111; border:0; border-radius:0; overflow:hidden; }
.image-viewer[open] { display:flex; align-items:center; justify-content:center; }
.image-viewer::backdrop { background:#111; }
.image-viewer img { display:block; max-width:100%; max-height:100%; width:auto; height:auto; object-fit:contain; }
.image-viewer button { position:fixed; top:max(14px,env(safe-area-inset-top)); right:max(14px,env(safe-area-inset-right)); z-index:1; width:44px; height:44px; padding:0; color:#fff; background:#000b; border:1px solid #fff8; border-radius:50%; font-size:22px; }
body.image-viewer-open { overflow:hidden; }
.dialog-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
#toc-search { width:100%; padding:8px; margin-bottom:12px; color:var(--text); background:var(--bg); border:1px solid var(--line); border-radius:6px; }
#toc-list { max-height:60dvh; overflow:auto; }
#toc-list button { display:block; width:100%; padding:8px; text-align:left; color:var(--text); background:none; border:0; border-bottom:1px solid var(--line); }
#toc-list button.subhead { padding-left:22px; color:var(--muted); font-size:14px; }
.notice { position:fixed; left:16px; right:16px; bottom:72px; z-index:5; width:fit-content; margin:auto; padding:9px 14px; color:var(--card); background:var(--accent); border-radius:6px; }
@media(min-width:620px) { .book-list { grid-template-columns:1fr 1fr; } }
@media(max-width:520px) { .pwa-card { align-items:stretch; flex-direction:column; } .pwa-actions { min-width:0; } }
@media(max-width:390px) { .reader-tools { flex-wrap:wrap; } .reader-tools button { font-size:13px; } h1 { font-size:28px; } .book-card { gap:12px; } .book-card img { width:82px; height:116px; } .book-card strong { font-size:19px; } .bottom-nav button { font-size:10px; } }
@media print { body { display:none !important; } }
