@font-face { font-family: "Inter Books"; src: url("../fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-display: block; }

/* ---------- tokens ---------- */
:root {
  --bg: #ffffff;
  --bg-2: #f5f5f7;
  --surface: #ffffff;
  --glass: rgba(250, 250, 252, .78);
  --fg: #1d1d1f;
  --fg-2: #6e6e73;
  --fg-3: #a1a1a6;
  --line: rgba(0, 0, 0, .08);
  --line-2: rgba(0, 0, 0, .14);
  --hover: rgba(0, 0, 0, .045);
  --press: rgba(0, 0, 0, .08);
  --accent: #0a72ff;
  --accent-2: #0060df;
  --accent-soft: rgba(10, 114, 255, .11);
  --on-accent: #ffffff;
  --danger: #e5352b;
  --warn: #b25000;
  --scrim: rgba(18, 20, 28, .26);
  --shadow-pop: 0 0 0 .5px rgba(0, 0, 0, .12), 0 10px 30px rgba(0, 0, 0, .14), 0 2px 6px rgba(0, 0, 0, .06);
  --shadow-panel: 0 0 0 .5px rgba(0, 0, 0, .1), 0 40px 100px -20px rgba(0, 20, 60, .35), 0 10px 30px rgba(0, 0, 0, .08);
  --cover-shadow: 0 1px 1.5px rgba(0, 0, 0, .1), 0 10px 24px -8px rgba(0, 0, 0, .28);
  --cover-shadow-hover: 0 2px 3px rgba(0, 0, 0, .1), 0 22px 40px -12px rgba(0, 0, 0, .34);
  --cover-empty: linear-gradient(160deg, #e9edf5, #d7dce6);
  --font: "Inter Books", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --r-s: 6px; --r-m: 10px; --r-l: 14px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161617; --bg-2: #1e1e20; --surface: #232325; --glass: rgba(40, 40, 43, .78);
    --fg: #f5f5f7; --fg-2: #a1a1a6; --fg-3: #6e6e73;
    --line: rgba(255, 255, 255, .08); --line-2: rgba(255, 255, 255, .15);
    --hover: rgba(255, 255, 255, .06); --press: rgba(255, 255, 255, .1);
    --accent: #2f8bff; --accent-2: #4b9bff; --accent-soft: rgba(47, 139, 255, .18);
    --danger: #ff5147; --warn: #ffb340; --scrim: rgba(0, 0, 0, .5);
    --shadow-pop: 0 0 0 .5px rgba(255, 255, 255, .12), 0 12px 34px rgba(0, 0, 0, .5);
    --shadow-panel: 0 0 0 .5px rgba(255, 255, 255, .1), 0 40px 100px -20px rgba(0, 0, 0, .7);
    --cover-shadow: 0 1px 1.5px rgba(0, 0, 0, .4), 0 10px 24px -8px rgba(0, 0, 0, .7);
    --cover-shadow-hover: 0 2px 3px rgba(0, 0, 0, .4), 0 22px 40px -12px rgba(0, 0, 0, .8);
    --cover-empty: linear-gradient(160deg, #2c2f36, #202227);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161617; --bg-2: #1e1e20; --surface: #232325; --glass: rgba(40, 40, 43, .78);
  --fg: #f5f5f7; --fg-2: #a1a1a6; --fg-3: #6e6e73;
  --line: rgba(255, 255, 255, .08); --line-2: rgba(255, 255, 255, .15);
  --hover: rgba(255, 255, 255, .06); --press: rgba(255, 255, 255, .1);
  --accent: #2f8bff; --accent-2: #4b9bff; --accent-soft: rgba(47, 139, 255, .18);
  --danger: #ff5147; --warn: #ffb340; --scrim: rgba(0, 0, 0, .5);
  --shadow-pop: 0 0 0 .5px rgba(255, 255, 255, .12), 0 12px 34px rgba(0, 0, 0, .5);
  --shadow-panel: 0 0 0 .5px rgba(255, 255, 255, .1), 0 40px 100px -20px rgba(0, 0, 0, .7);
  --cover-shadow: 0 1px 1.5px rgba(0, 0, 0, .4), 0 10px 24px -8px rgba(0, 0, 0, .7);
  --cover-shadow-hover: 0 2px 3px rgba(0, 0, 0, .4), 0 22px 40px -12px rgba(0, 0, 0, .8);
  --cover-empty: linear-gradient(160deg, #2c2f36, #202227);
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: var(--bg); color: var(--fg); font: 13.5px/1.4 var(--font); -webkit-font-smoothing: antialiased; user-select: none; cursor: default; transition: background-color .3s; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: default; }
input { font: inherit; color: inherit; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.i { width: 18px; height: 18px; flex: none; }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; border: 3.5px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--fg-3); }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }

.btn { height: 32px; padding: 0 14px; border-radius: 8px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: background .15s, opacity .15s, transform .1s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.primary:disabled { opacity: .4; transform: none; }
.btn.quiet { background: var(--hover); }
.btn.quiet:hover { background: var(--press); }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; display: inline-grid; place-items: center; color: var(--fg-2); transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--hover); color: var(--fg); }
.icon-btn.on { color: var(--accent); }
.icon-btn:disabled { opacity: .35; background: none; }

/* ---------- title bar with tabs (Windows 11 caption buttons) ---------- */
:root { --strip: #ececef; --tab-on: #ffffff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --strip: #0f0f10; --tab-on: #232325; } }
:root[data-theme="dark"] { --strip: #0f0f10; --tab-on: #232325; }
.titlebar { position: fixed; top: 0; left: 0; right: 0; height: 40px; display: flex; align-items: stretch; z-index: 50; background: var(--strip); transition: opacity .35s var(--ease), background-color .35s; }
.titlebar .drag { flex: 1; min-width: 40px; -webkit-app-region: drag; }
body.no-drag .titlebar .drag { -webkit-app-region: no-drag; }
.tabs { display: flex; align-items: flex-end; gap: 2px; padding: 0 0 0 8px; min-width: 0; flex: 0 1 auto; overflow: hidden; }
.tab { position: relative; height: 32px; flex: 0 1 220px; min-width: 64px; display: flex; align-items: center; gap: 8px; padding: 0 6px 0 11px; border-radius: 9px 9px 0 0; color: var(--fg-2); font-size: 12.5px; cursor: default; transition: background .15s, color .15s; }
.tab:hover { background: var(--hover); color: var(--fg); }
.tab.on { background: var(--tab-on); color: var(--fg); }
.tab.on::before, .tab.on::after { content: ""; position: absolute; bottom: 0; width: 10px; height: 10px; pointer-events: none; }
.tab.on::before { left: -10px; background: radial-gradient(circle at 0 0, transparent 9.5px, var(--tab-on) 10px); }
.tab.on::after { right: -10px; background: radial-gradient(circle at 100% 0, transparent 9.5px, var(--tab-on) 10px); }
.tab:not(.on):not(:hover) + .tab:not(.on):not(:hover)::before { content: ""; position: absolute; left: -1px; top: 9px; bottom: 9px; width: 1px; background: var(--line-2); }
.tab-ic { width: 14px; height: 18px; flex: none; border-radius: 2px; background: center / cover no-repeat; display: grid; place-items: center; }
.tab-ic.cover { box-shadow: 0 0 0 .5px rgba(0,0,0,.2); }
.tab-ic.logo svg { width: 18px; height: 18px; }
.tab-t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab-x { width: 22px; height: 22px; flex: none; border-radius: 6px; display: grid; place-items: center; opacity: 0; transition: opacity .12s, background .12s; }
.tab-x .i { width: 12px; height: 12px; }
.tab:hover .tab-x, .tab.on .tab-x { opacity: .7; }
.tab-x:hover { opacity: 1 !important; background: var(--press); }
.tab-new { width: 30px; height: 30px; margin: 0 0 1px 4px; align-self: center; flex: none; border-radius: 8px; display: grid; place-items: center; color: var(--fg-2); }
.tab-new .i { width: 16px; height: 16px; }
.tab-new:hover { background: var(--hover); color: var(--fg); }
.caption { display: flex; -webkit-app-region: no-drag; }
.caption button { width: 46px; height: 40px; display: grid; place-items: center; color: var(--fg); opacity: .8; transition: background .12s; }
.caption button:hover { background: var(--hover); opacity: 1; }
.caption button.close:hover { background: #c42b1c; color: #fff; }
.caption svg { width: 10px; height: 10px; }
body.reading .titlebar { background: color-mix(in srgb, var(--r-bg) 88%, var(--r-fg)); color: var(--r-fg); }
body.reading .tab { color: var(--r-fg2); }
body.reading .tab:hover { background: var(--r-hover); color: var(--r-fg); }
body.reading .tab.on { --tab-on: var(--r-bg); color: var(--r-fg); }
body.reading .tab-new, body.reading .caption button { color: var(--r-fg); }
body.reading.immersed .titlebar { opacity: 0; }
body.reading.immersed .titlebar:hover { opacity: 1; }
body.fullscreen .titlebar { display: none; }
body.fullscreen .library, body.fullscreen .reader { top: 0 !important; }

/* ---------- library ---------- */
.library { position: absolute; inset: var(--top) 0 0 0; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
.lib-head { position: sticky; top: 0; z-index: 5; display: flex; align-items: flex-end; gap: 16px; padding: 26px 48px 16px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(24px) saturate(1.8); transition: box-shadow .2s, background-color .3s; }
.lib-head.scrolled { box-shadow: 0 .5px 0 var(--line-2); }
.lib-head h1 { margin: 0; font-size: 30px; line-height: 1.1; font-weight: 700; letter-spacing: -.025em; font-variation-settings: "opsz" 32; }
.lib-head .count { margin: 3px 0 0; color: var(--fg-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.lib-head .grow { flex: 1; }
.lib-tools { display: flex; gap: 6px; align-items: center; }
.search { position: relative; display: flex; align-items: center; }
.search .i { position: absolute; left: 9px; width: 15px; height: 15px; color: var(--fg-3); pointer-events: none; }
.search input { width: 190px; height: 32px; border-radius: 8px; border: 0; background: var(--hover); padding: 0 10px 0 30px; transition: width .25s var(--ease), background .15s, box-shadow .15s; }
.search input::placeholder { color: var(--fg-3); }
.search input:focus { width: 240px; background: var(--surface); box-shadow: 0 0 0 1px var(--line-2), 0 0 0 4px var(--accent-soft); }
.pill-btn { height: 32px; padding: 0 10px 0 12px; border-radius: 8px; display: inline-flex; align-items: center; gap: 4px; color: var(--fg-2); font-weight: 500; }
.pill-btn .i { width: 14px; height: 14px; }
.pill-btn:hover { background: var(--hover); color: var(--fg); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card, 150px), 1fr)); gap: 40px 32px; padding: 20px 48px 120px; align-items: start; }
.book { display: flex; flex-direction: column; gap: 10px; min-width: 0; border-radius: 6px; outline-offset: 6px; }
.book .cover { position: relative; aspect-ratio: 10 / 16; border-radius: 4px; overflow: hidden; background: var(--cover-empty); box-shadow: var(--cover-shadow); transition: transform .35s var(--ease), box-shadow .35s var(--ease); transform-origin: 50% 100%; }
.book .cover img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .4s; }
.book .cover img.ok { opacity: 1; }
.book .cover::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,.16) 0, rgba(255,255,255,.18) 1.2%, rgba(0,0,0,.08) 2.6%, transparent 6%), linear-gradient(180deg, rgba(255,255,255,.06), transparent 30%);
  box-shadow: inset 0 0 0 .5px rgba(0,0,0,.12); }
.book:hover .cover { transform: translateY(-4px); box-shadow: var(--cover-shadow-hover); }
.book:active .cover { transform: translateY(-1px) scale(.99); }
.book.selected .cover { box-shadow: 0 0 0 2.5px var(--bg), 0 0 0 5px var(--accent), var(--cover-shadow); }
.book .meta { display: flex; flex-direction: column; gap: 3px; padding: 0 1px; }
.book .title { font-size: 13.5px; font-weight: 600; line-height: 1.3; letter-spacing: -.005em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.book .sub { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.book .sub .sp { flex: 1; }
.book .new { color: var(--accent); font-weight: 600; font-size: 10.5px; letter-spacing: .06em; }
.book .pct { color: var(--fg-3); }
.book .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(0,0,0,.25); }
.book .bar i { display: block; height: 100%; background: var(--accent); }
.book.missing .cover { filter: grayscale(1); opacity: .45; }
.book.missing .sub { color: var(--warn); }
.book .rename { font: inherit; font-size: 13.5px; font-weight: 600; width: 100%; border: 0; border-radius: 6px; padding: 3px 6px; margin: -3px -6px; background: var(--surface); box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-soft); user-select: text; }
.book.drop-in { animation: dropIn .6s var(--ease) both; }
@keyframes dropIn { from { opacity: 0; transform: translateY(12px) scale(.97); } }

.empty { position: absolute; inset: 110px 48px 80px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; }
.empty .logo { width: 104px; height: 104px; margin-bottom: 10px; }
.empty h2 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.015em; }
.empty p { margin: 0; color: var(--fg-2); font-size: 14px; }
.empty .btn { margin-top: 18px; }
.no-results { padding: 60px 48px; color: var(--fg-2); text-align: center; }

.fab { position: fixed; right: 32px; bottom: 30px; z-index: 6; height: 44px; padding: 0 20px 0 16px; border-radius: 22px; background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 14px; letter-spacing: -.005em; display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 8px 24px -6px color-mix(in srgb, var(--accent) 70%, transparent), 0 1px 2px rgba(0,0,0,.15); transition: transform .25s var(--ease), box-shadow .25s var(--ease), background .15s; }
.fab .i { width: 18px; height: 18px; stroke-width: 2; }
.fab:hover { background: var(--accent-2); transform: translateY(-2px); box-shadow: 0 14px 30px -8px color-mix(in srgb, var(--accent) 75%, transparent), 0 1px 2px rgba(0,0,0,.15); }
.fab:active { transform: translateY(0) scale(.97); }

.drop-zone { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(10px); pointer-events: none; opacity: 0; transition: opacity .2s; }
.drop-zone.on { opacity: 1; }
.drop-zone div { padding: 28px 40px; border-radius: 20px; border: 2px dashed var(--accent); color: var(--accent); font-size: 17px; font-weight: 600; background: var(--accent-soft); }

/* ---------- menu ---------- */
.menu-layer { position: fixed; inset: 0; z-index: 100; }
.menu { position: fixed; min-width: 232px; padding: 5px; border-radius: 10px; background: var(--glass); backdrop-filter: blur(30px) saturate(1.8); box-shadow: var(--shadow-pop); opacity: 0; transform: scale(.98); transform-origin: top left; transition: opacity .12s, transform .12s var(--ease); }
.menu.show { opacity: 1; transform: none; }
.menu-item { width: 100%; height: 30px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border-radius: 6px; text-align: left; font-size: 13px; }
.menu-item .i { width: 16px; height: 16px; color: var(--fg-2); }
.menu-item img.i { border-radius: 3px; }
.menu-item .ml { flex: 1; white-space: nowrap; }
.menu-item .mk { color: var(--fg-3); font-size: 12px; }
.menu-item .chev { width: 13px; height: 13px; margin-right: -3px; }
.menu-item:hover, .menu-item:focus-visible, .menu-item.open { background: var(--accent); color: var(--on-accent); outline: none; }
.menu-item:hover .i, .menu-item:focus-visible .i, .menu-item.open .i, .menu-item:hover .mk, .menu-item:focus-visible .mk, .menu-item.open .mk { color: inherit; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .i { color: var(--danger); }
.menu-item.danger:hover, .menu-item.danger:focus-visible { background: var(--danger); color: #fff; }
.menu-item.danger:hover .i, .menu-item.danger:focus-visible .i { color: #fff; }
.menu-item:disabled { opacity: .4; background: none !important; color: inherit !important; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 10px; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 34px; z-index: 120; display: flex; align-items: center; gap: 14px; max-width: min(560px, calc(100vw - 48px)); padding: 10px 12px 10px 18px; border-radius: 12px; background: rgba(30, 30, 32, .92); color: #f5f5f7; backdrop-filter: blur(20px); box-shadow: 0 12px 30px rgba(0,0,0,.25);
  font-size: 13px; transform: translate(-50%, 14px); opacity: 0; pointer-events: none; transition: opacity .25s, transform .3s var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-msg { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 4px 0; }
.toast-act { color: #6cb2ff; font-weight: 600; padding: 4px 8px; border-radius: 6px; }
.toast-act:hover { background: rgba(255,255,255,.1); }
.toast:not(:has(.toast-act)) { padding-right: 18px; }

/* ---------- modal (Add panel) ---------- */
.scrim { position: fixed; inset: 0; z-index: 60; background: var(--scrim); display: grid; place-items: center; opacity: 0; transition: opacity .22s; }
.scrim.show { opacity: 1; }
.panel { position: relative; display: grid; grid-template-columns: 2fr 1fr; background: var(--surface); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-panel); transform: translateY(10px) scale(.985); transition: transform .32s var(--ease); }
.scrim.show .panel { transform: none; }

.fb { display: grid; grid-template-columns: 172px 1fr; grid-template-rows: auto 1fr auto; min-width: 0; min-height: 0; background: var(--bg-2); border-right: 1px solid var(--line); }
.fb-bar { grid-column: 1 / -1; display: flex; align-items: center; gap: 4px; padding: 10px 10px; border-bottom: 1px solid var(--line); }
.fb-bar .icon-btn { width: 30px; height: 30px; }
.fb-bar .i { width: 16px; height: 16px; }
.crumbs { flex: 1; min-width: 0; height: 30px; display: flex; align-items: center; gap: 1px; padding: 0 4px; border-radius: 7px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; white-space: nowrap; }
.crumbs button { padding: 3px 6px; border-radius: 5px; font-size: 12.5px; color: var(--fg); flex: none; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.crumbs button:hover { background: var(--hover); }
.crumbs .gt { color: var(--fg-3); flex: none; }
.crumbs .gt .i { width: 12px; height: 12px; }
.crumbs .more { color: var(--fg-3); }
.fb-bar .search input { width: 150px; height: 30px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.fb-bar .search input:focus { width: 170px; }
.fb-side { overflow-y: auto; padding: 10px 8px; display: flex; flex-direction: column; gap: 1px; border-right: 1px solid var(--line); }
.fb-side .lbl { font-size: 11px; font-weight: 600; color: var(--fg-3); padding: 10px 10px 4px; letter-spacing: .02em; }
.fb-side .lbl:first-child { padding-top: 2px; }
.place { height: 30px; display: flex; align-items: center; gap: 9px; padding: 0 10px; border-radius: 7px; text-align: left; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.place .i { width: 16px; height: 16px; color: var(--accent); }
.place:hover { background: var(--hover); }
.place.on { background: var(--press); font-weight: 500; }
.fb-list { overflow-y: auto; min-width: 0; padding: 4px 8px 8px; position: relative; }
.fb-head, .fb-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px 74px; gap: 10px; align-items: center; padding: 0 10px; }
.fb-head { position: sticky; top: 0; z-index: 1; height: 30px; font-size: 11.5px; color: var(--fg-3); background: var(--bg-2); border-bottom: 1px solid var(--line); margin: 0 -8px 4px; padding: 0 18px; }
.fb-head button { text-align: left; color: inherit; display: inline-flex; align-items: center; gap: 2px; }
.fb-head button:hover { color: var(--fg); }
.fb-head button .i { width: 12px; height: 12px; }
.fb-row { height: 32px; border-radius: 7px; font-size: 13px; width: 100%; text-align: left; }
.fb-row:hover { background: var(--hover); }
.fb-row.sel { background: var(--accent); color: var(--on-accent); }
.fb-row.sel .d, .fb-row.sel .s, .fb-row.sel .i { color: inherit !important; }
.fb-row .n { display: flex; align-items: center; gap: 9px; min-width: 0; }
.fb-row .n span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-row .i { width: 17px; height: 17px; }
.fb-row .i.folder { color: #4a9eff; fill: color-mix(in srgb, #4a9eff 22%, transparent); }
.fb-row .i.pdf { color: #e5483d; }
.fb-row .d, .fb-row .s { color: var(--fg-2); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
.fb-row .s { text-align: right; }
.fb-row.added { opacity: .5; }
.fb-msg { padding: 40px 20px; text-align: center; color: var(--fg-2); }
.fb-foot { grid-column: 1 / -1; display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 8px 14px; border-top: 1px solid var(--line); color: var(--fg-3); font-size: 12px; }

.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 22px 22px 18px; gap: 16px; overflow-y: auto; }
.pane h3 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.cover-prev { align-self: center; position: relative; height: clamp(120px, 34%, 300px); aspect-ratio: 10 / 16; flex: none; border-radius: 4px; overflow: hidden; background: var(--cover-empty); box-shadow: var(--cover-shadow); display: grid; place-items: center; color: var(--fg-3); font-size: 12px; text-align: center; padding: 8px; }
.cover-prev canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.cover-prev::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.16) 0, rgba(255,255,255,.18) 1.2%, rgba(0,0,0,.08) 2.6%, transparent 6%); pointer-events: none; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.12); }
.cover-prev.busy canvas { opacity: .5; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; font-weight: 500; color: var(--fg-2); }
.input { height: 34px; width: 100%; border-radius: 8px; border: 0; padding: 0 11px; background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow .15s, background .15s; user-select: text; }
.input:focus { background: var(--surface); box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-soft); }
.input:disabled { opacity: .5; }
.row { display: flex; gap: 8px; align-items: center; }
.stepper { display: flex; align-items: center; height: 34px; border-radius: 8px; background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--line); flex: 1; min-width: 0; }
.stepper:focus-within { background: var(--surface); box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-soft); }
.stepper input { flex: 1; min-width: 0; border: 0; background: none; height: 100%; padding: 0 0 0 11px; font-variant-numeric: tabular-nums; user-select: text; }
.stepper .of { color: var(--fg-3); padding-right: 4px; white-space: nowrap; font-size: 12.5px; }
.stepper button { width: 28px; height: 100%; display: grid; place-items: center; color: var(--fg-2); }
.stepper button:hover { color: var(--fg); }
.stepper button .i { width: 14px; height: 14px; }
.stepper button:disabled { opacity: .3; }
.crop-btn { height: 34px; padding: 0 12px; border-radius: 8px; background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--line); display: inline-flex; align-items: center; gap: 6px; font-weight: 500; flex: none; }
.crop-btn .i { width: 16px; height: 16px; }
.crop-btn:hover { background: var(--hover); }
.crop-btn:disabled { opacity: .45; }
.crop-btn.set { color: var(--accent); }
.pane .grow { flex: 1; min-height: 8px; }
.picked { display: flex; gap: 11px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--line); min-width: 0; }
.picked .ic { width: 30px; height: 36px; flex: none; border-radius: 4px; background: #e5483d; color: #fff; font-size: 9px; font-weight: 700; letter-spacing: .04em; display: grid; place-items: end center; padding-bottom: 5px; position: relative; }
.picked .ic::before { content: ""; position: absolute; top: 0; right: 0; width: 9px; height: 9px; background: linear-gradient(225deg, var(--bg-2) 50%, rgba(0,0,0,.25) 50%); }
.picked .tx { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.picked .nm { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picked .mt { font-size: 12px; color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.picked.none { color: var(--fg-3); justify-content: center; min-height: 58px; font-size: 12.5px; }
.picked.warn { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 50%, transparent); }
.picked .mt.w { color: var(--warn); }
.actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- crop panel ---------- */
.crop-scrim { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: var(--scrim); opacity: 0; transition: opacity .2s; }
.crop-scrim.show { opacity: 1; }
.crop-card { display: flex; flex-direction: column; gap: 14px; padding: 18px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-panel); transform: scale(.97); transition: transform .3s var(--ease); max-width: 92vw; }
.crop-scrim.show .crop-card { transform: none; }
.crop-head { display: flex; align-items: center; gap: 10px; }
.crop-head h4 { margin: 0; font-size: 15px; font-weight: 650; flex: 1; }
.crop-head span { color: var(--fg-2); font-size: 12px; }
.crop-stage { position: relative; align-self: center; background: #fff; touch-action: none; }
.crop-stage canvas { display: block; }
.crop-box { position: absolute; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55); outline: 1.5px solid #fff; cursor: move; }
.crop-wrap { position: relative; overflow: hidden; border-radius: 3px; align-self: center; }
.crop-box .g { position: absolute; background: rgba(255,255,255,.35); pointer-events: none; }
.crop-box .g.v1 { left: 33.33%; top: 0; bottom: 0; width: 1px; } .crop-box .g.v2 { left: 66.66%; top: 0; bottom: 0; width: 1px; }
.crop-box .g.h1 { top: 33.33%; left: 0; right: 0; height: 1px; } .crop-box .g.h2 { top: 66.66%; left: 0; right: 0; height: 1px; }
.crop-box .hd { position: absolute; width: 18px; height: 18px; border: 3px solid #fff; }
.crop-box .hd.nw { left: -3px; top: -3px; border-right: 0; border-bottom: 0; cursor: nwse-resize; }
.crop-box .hd.ne { right: -3px; top: -3px; border-left: 0; border-bottom: 0; cursor: nesw-resize; }
.crop-box .hd.sw { left: -3px; bottom: -3px; border-right: 0; border-top: 0; cursor: nesw-resize; }
.crop-box .hd.se { right: -3px; bottom: -3px; border-left: 0; border-top: 0; cursor: nwse-resize; }
.crop-foot { display: flex; gap: 8px; align-items: center; }
.crop-foot .grow { flex: 1; }
.crop-foot .hint { color: var(--fg-3); font-size: 12px; }

/* ---------- reader (Apple Books style) ---------- */
body[data-rt="white"] { --r-bg: #ffffff; --r-paper: #ffffff; --r-fg: #1d1d1f; --r-fg2: rgba(29,29,31,.55); --r-line: rgba(0,0,0,.08); --r-hover: rgba(0,0,0,.05); --r-shadow: 0 0 0 .5px rgba(0,0,0,.07), 0 6px 24px rgba(0,0,0,.06); --r-panel: rgba(246,246,248,.78); --hl: rgba(255, 204, 0, .42); --hl-blend: multiply; }
body[data-rt="sepia"] { --r-bg: #f5ecdb; --r-paper: #f8f1e3; --r-fg: #4a3826; --r-fg2: rgba(74,56,38,.6); --r-line: rgba(74,56,38,.13); --r-hover: rgba(74,56,38,.07); --r-shadow: 0 0 0 .5px rgba(74,56,38,.1), 0 6px 24px rgba(74,56,38,.08); --r-panel: rgba(251,246,236,.8); --hl: rgba(255, 190, 0, .4); --hl-blend: multiply; }
body[data-rt="gray"] { --r-bg: #48484b; --r-paper: #505054; --r-fg: #ececee; --r-fg2: rgba(236,236,238,.55); --r-line: rgba(255,255,255,.1); --r-hover: rgba(255,255,255,.08); --r-shadow: 0 0 0 .5px rgba(255,255,255,.06), 0 6px 24px rgba(0,0,0,.25); --r-panel: rgba(66,66,70,.82); --hl: rgba(255, 214, 10, .32); --hl-blend: normal; }
body[data-rt="night"] { --r-bg: #0b0b0c; --r-paper: #111113; --r-fg: #d6d6d9; --r-fg2: rgba(214,214,217,.5); --r-line: rgba(255,255,255,.09); --r-hover: rgba(255,255,255,.07); --r-shadow: 0 0 0 .5px rgba(255,255,255,.07); --r-panel: rgba(28,28,30,.82); --hl: rgba(255, 214, 10, .28); --hl-blend: normal; }

.reader { position: absolute; inset: var(--top) 0 0 0; background: var(--r-bg); color: var(--r-fg); transition: background-color .4s; --r-chrome: color-mix(in srgb, var(--r-bg) 82%, transparent); }
.r-view { position: absolute; inset: 0; overflow: hidden; outline: none; }
.r-pages { height: 100%; display: flex; align-items: center; justify-content: center; gap: 30px; padding: 52px 40px 60px; }
.r-spread { display: flex; flex: none; }
.r-page { position: relative; flex: none; background: var(--r-paper); box-shadow: var(--r-shadow); transition: background-color .4s; }
.r-spread.two .r-page:first-child { box-shadow: var(--r-shadow), inset -26px 0 28px -26px rgba(0,0,0,.28); }
.r-spread.two .r-page:last-child:not(:first-child) { box-shadow: var(--r-shadow), inset 26px 0 28px -26px rgba(0,0,0,.28); }
.r-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
body[data-rt="sepia"] .r-page canvas { mix-blend-mode: multiply; }
body[data-rt="gray"] .r-page canvas { filter: invert(1) hue-rotate(180deg); mix-blend-mode: screen; }
body[data-rt="night"] .r-page canvas { filter: invert(1) hue-rotate(180deg) brightness(.85); mix-blend-mode: screen; }
.r-page .hl-layer { position: absolute; inset: 0; pointer-events: none; }
.reader:not(.notes-on) .hl-layer { display: none; }
.r-page .hl { position: absolute; background: var(--hl); mix-blend-mode: var(--hl-blend); border-radius: 2px; }
.r-page .ld { position: absolute; inset: 0; display: grid; place-items: center; color: var(--r-fg2); font-size: 12px; font-variant-numeric: tabular-nums; }
.r-page .ping { position: absolute; z-index: 4; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 75%, transparent) 0 28%, color-mix(in srgb, var(--accent) 30%, transparent) 30% 60%, transparent 62%);
  animation: ping 1.1s cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes ping { 0% { transform: scale(.4); opacity: 0; } 15% { opacity: 1; } 60% { transform: scale(1.5); opacity: .9; } 100% { transform: scale(2.2); opacity: 0; } }

.textLayer { position: absolute; text-align: initial; inset: 0; overflow: clip; opacity: 1; line-height: 1; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; caret-color: CanvasText; z-index: 0; user-select: text; }
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; }
.textLayer { --min-font-size: 1; --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size)); --min-font-size-inv: calc(1 / var(--min-font-size)); }
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) { z-index: 1; --font-height: 0; font-size: calc(var(--text-scale-factor) * var(--font-height)); --scale-x: 1; --rotate: 0deg; transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv)); }
.textLayer .markedContent { display: contents; }
.textLayer span[role="img"] { user-select: none; cursor: default; }
.textLayer ::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default; user-select: none; }
.textLayer.selecting .endOfContent { top: 0; }
.reader:not(.notes-on) .textLayer span { cursor: default; }

.r-top, .r-bot { position: absolute; left: 0; right: 0; z-index: 10; display: flex; align-items: center; transition: opacity .45s var(--ease), transform .45s var(--ease); }
.r-top { top: 0; height: 48px; padding: 0 12px; gap: 4px; background: linear-gradient(var(--r-chrome) 55%, transparent); }
.r-top .r-title { flex: 1; text-align: center; font-weight: 600; font-size: 13px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 12px; }
.r-bot { bottom: 0; height: 50px; justify-content: center; gap: 16px; background: linear-gradient(transparent, var(--r-chrome) 45%); font-size: 12px; font-variant-numeric: tabular-nums; }
.reader .icon-btn { color: var(--r-fg); opacity: .8; }
.reader .icon-btn:hover { background: var(--r-hover); opacity: 1; color: var(--r-fg); }
.reader .icon-btn.on { color: var(--accent); opacity: 1; }
.aa-btn { font: 600 15px/1 Georgia, "Times New Roman", serif; }
.r-back { height: 32px; padding: 0 10px 0 4px; border-radius: 8px; display: inline-flex; align-items: center; gap: 2px; font-weight: 500; opacity: .85; }
.r-back:hover { background: var(--r-hover); opacity: 1; }
.r-bot input[type=range] { -webkit-appearance: none; appearance: none; width: min(340px, 42%); height: 22px; background: transparent; margin: 0; }
.r-bot input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--r-fg) var(--p, 0%), var(--r-line) var(--p, 0%)); opacity: .6; }
.r-bot input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; margin-top: -5px; border-radius: 50%; background: var(--r-paper); box-shadow: 0 0 0 .5px rgba(0,0,0,.2), 0 1px 4px rgba(0,0,0,.3); transition: transform .15s; }
.r-bot input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.2); }
.r-pos { min-width: 96px; text-align: center; opacity: .6; border-radius: 6px; padding: 4px 6px; }
.r-pos:hover { background: var(--r-hover); opacity: 1; }
.r-pos-in { width: 96px; height: 26px; border-radius: 6px; border: 0; padding: 0 8px; text-align: center; background: var(--r-paper); color: var(--r-fg); box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-soft); font-variant-numeric: tabular-nums; user-select: text; }
.reader.immersed .r-top, .reader.immersed .r-bot { opacity: 0; pointer-events: none; }
.reader.immersed .r-top { transform: translateY(-6px); }
.reader.immersed .r-bot { transform: translateY(6px); }
.reader.immersed:not(.notes-on) .r-view { cursor: none; }

.pop { position: absolute; z-index: 20; border-radius: 14px; padding: 14px; background: color-mix(in srgb, var(--r-paper) 86%, transparent); color: var(--r-fg); backdrop-filter: blur(30px) saturate(1.6); box-shadow: 0 0 0 .5px var(--r-line), 0 18px 50px rgba(0,0,0,.22); opacity: 0; transform: translateY(-4px) scale(.985); transform-origin: top right; transition: opacity .16s, transform .2s var(--ease); }
.pop.show { opacity: 1; transform: none; }
.pop .lbl { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; opacity: .5; margin-bottom: 8px; }
.aa { top: 50px; right: 14px; width: 272px; display: flex; flex-direction: column; gap: 16px; }
.swatches { display: flex; gap: 12px; }
.swatch { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 15px; font-family: Georgia, serif; box-shadow: inset 0 0 0 1px rgba(128,128,128,.35); transition: box-shadow .15s, transform .15s; }
.swatch:hover { transform: scale(1.05); }
.swatch.on { box-shadow: inset 0 0 0 1px rgba(128,128,128,.35), 0 0 0 2px var(--r-paper), 0 0 0 4px var(--accent); }
.swatch.auto { background: linear-gradient(135deg, #fff 50%, #121213 50%); color: #888; }
.seg2 { display: flex; padding: 2px; border-radius: 9px; background: var(--r-hover); }
.seg2 button { flex: 1; height: 30px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; font-weight: 500; opacity: .75; }
.seg2 button .i { width: 15px; height: 15px; }
.seg2 button.on { background: var(--r-paper); opacity: 1; box-shadow: 0 0 0 .5px var(--r-line), 0 1px 3px rgba(0,0,0,.12); }

.r-loading { position: absolute; inset: 0; display: grid; place-items: center; z-index: 8; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--r-line, var(--line)); border-top-color: var(--r-fg, var(--fg)); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- notes panels ---------- */
.npanel { flex: none; display: flex; flex-direction: column; border-radius: 16px; background: var(--r-panel); backdrop-filter: blur(24px) saturate(1.5);
  box-shadow: 0 0 0 .5px var(--r-line), 0 14px 40px -12px rgba(0,0,0,.22); overflow: hidden; color: var(--r-fg); }
.np-head { height: 44px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 8px; border-bottom: .5px solid var(--r-line); }
.np-title { font-size: 10.5px; font-weight: 600; letter-spacing: .32em; padding-left: .32em; opacity: .55; user-select: none; }
.np-btn { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: var(--r-fg); opacity: .5; transition: opacity .15s, background .15s; }
.np-btn .i { width: 15px; height: 15px; }
.np-btn:hover { opacity: 1; background: var(--r-hover); }
.np-btn.has { opacity: .85; color: var(--accent); }
.np-btn.has .i circle { fill: color-mix(in srgb, var(--accent) 25%, transparent); }
.note-ed { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px 24px; font-size: 13.5px; line-height: 1.62; outline: none; user-select: text; cursor: text; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; caret-color: var(--accent); }
.note-ed:empty::before { content: attr(data-ph); opacity: .35; pointer-events: none; }
.note-ed ::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.note-ed a { color: var(--accent); text-decoration: none; border-bottom: 1.5px dotted color-mix(in srgb, var(--accent) 70%, transparent); cursor: pointer; }
.note-ed a:hover { border-bottom-style: solid; }
.note-ed span[style*="background"], .note-ed mark { color: inherit; border-radius: 2px; }
body[data-rt="gray"] .note-ed span[style*="background"], body[data-rt="night"] .note-ed span[style*="background"] { color: #1d1d1f; }
.note-ed::-webkit-scrollbar-thumb { background-color: var(--r-line); }

.reader.linking .r-view, .reader.linking .r-view * { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28'%3E%3Ccircle cx='14' cy='14' r='9' fill='%230a72ff' fill-opacity='.85' stroke='white' stroke-width='2.5'/%3E%3C/svg%3E") 14 14, crosshair !important; }
.reader.linking .npanel { opacity: .6; }

/* ---------- slate ---------- */
.slate-scrim { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: var(--scrim); opacity: 0; transition: opacity .22s; }
.slate-scrim.show { opacity: 1; }
.slate { width: 70vw; height: 70vh; min-width: 560px; min-height: 360px; display: flex; flex-direction: column; border-radius: 18px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow-panel); transform: scale(.97); transition: transform .3s var(--ease); color: var(--fg); }
.slate-scrim.show .slate { transform: none; }
.sl-bar { height: 52px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 10px 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.sl-title { display: flex; flex-direction: column; line-height: 1.15; margin-right: 10px; white-space: nowrap; }
.sl-title b { font-size: 13.5px; }
.sl-title span { font-size: 11.5px; color: var(--fg-2); }
.sl-group { display: flex; gap: 2px; align-items: center; }
.sl-div { width: 1px; height: 22px; background: var(--line); margin: 0 6px; flex: none; }
.sl-tool, .sl-size { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: var(--fg-2); flex: none; }
.sl-tool:hover, .sl-size:hover { background: var(--hover); color: var(--fg); }
.sl-tool.on, .sl-size.on { background: var(--accent-soft); color: var(--accent); }
.sl-size i { display: block; border-radius: 50%; background: var(--fg); }
.sl-color { width: 22px; height: 22px; border-radius: 50%; margin: 0 2px; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); transition: transform .12s; }
.sl-color:hover { transform: scale(1.12); }
.sl-color.on { box-shadow: inset 0 0 0 1px rgba(0,0,0,.18), 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.sl-custom { width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; overflow: hidden; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); margin-left: 4px; flex: none; cursor: pointer; }
.sl-custom::-webkit-color-swatch-wrapper { padding: 0; opacity: 0; }
.sl-custom.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.sl-stage { flex: 1; min-height: 0; display: grid; place-items: center; background: var(--bg-2); }
.sl-board { position: relative; background: #fdfdfb radial-gradient(circle, rgba(0,0,0,.09) 1px, transparent 1.4px) 0 0 / 26px 26px; border-radius: 6px; box-shadow: 0 0 0 .5px rgba(0,0,0,.12), 0 8px 26px -10px rgba(0,0,0,.25); overflow: hidden; touch-action: none; }
.sl-board canvas { position: absolute; inset: 0; }
.sl-board .sl-live { cursor: crosshair; }
.sl-board[data-tool="eraser"] .sl-live { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='12' cy='12' r='9' fill='white' fill-opacity='.6' stroke='%23555' stroke-width='1.5'/%3E%3C/svg%3E") 12 12, cell; }

/* ---------- confirm dialog ---------- */
.confirm-scrim { z-index: 110; }
.confirm { width: min(400px, calc(100vw - 48px)); padding: 22px 22px 18px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-panel); display: flex; flex-direction: column; gap: 8px; transform: scale(.97); transition: transform .25s var(--ease); }
.scrim.show .confirm { transform: none; }
.confirm h4 { margin: 0; font-size: 15.5px; font-weight: 650; letter-spacing: -.01em; }
.confirm p { margin: 0 0 10px; color: var(--fg-2); font-size: 13px; line-height: 1.5; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(1.08); }

/* ---------- view transitions ---------- */
.library, .reader { transition: opacity .28s var(--ease), transform .35s var(--ease); }
.library.away { opacity: 0; transform: scale(.985); pointer-events: none; }
.reader.enter { opacity: 0; transform: scale(1.01); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; } }


/* ---------- main frame (zoom scrolls inside it) ---------- */
.r-frame { flex: none; overflow: hidden; display: flex; justify-content: safe center; align-items: safe center; border-radius: 2px; }
.r-frame.zoomed { overflow: auto; }
.r-frame::-webkit-scrollbar-thumb, .sp-frame::-webkit-scrollbar-thumb { background-color: color-mix(in srgb, var(--r-fg) 25%, transparent); }
.zoom-badge { position: absolute; left: 50%; bottom: 64px; z-index: 12; transform: translate(-50%, 6px); padding: 5px 12px; border-radius: 10px; background: rgba(30,30,32,.88); color: #fff; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; opacity: 0; pointer-events: none; transition: opacity .2s, transform .25s var(--ease); }
.zoom-badge.show { opacity: 1; transform: translate(-50%, 0); }
.zoomrow { display: flex; align-items: center; gap: 4px; }
.zoomrow .z { flex: 1; text-align: center; font-variant-numeric: tabular-nums; font-size: 13px; opacity: .85; }
.fit-btn { height: 30px; padding: 0 12px; border-radius: 8px; font-size: 12px; font-weight: 600; background: var(--r-hover); color: var(--r-fg); }
.fit-btn:hover { background: color-mix(in srgb, var(--r-fg) 14%, transparent); }
.swatch span, .seg2 button span, .seg2 button svg, .icon-btn svg, .icon-btn span, .np-btn svg, .tab-new svg { pointer-events: none; }

/* ---------- second book (beside) ---------- */
.side-plus { position: absolute; left: 22px; top: 50%; z-index: 9; width: 44px; height: 44px; margin-top: -22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--r-panel); color: var(--r-fg); box-shadow: 0 0 0 .5px var(--r-line), 0 6px 18px -6px rgba(0,0,0,.3); backdrop-filter: blur(20px);
  opacity: .75; transition: opacity .2s, transform .25s var(--ease), box-shadow .2s; }
.side-plus .i { width: 18px; height: 18px; stroke-width: 1.8; }
.side-plus:hover { opacity: 1; transform: scale(1.08); box-shadow: 0 0 0 .5px var(--r-line), 0 10px 24px -8px rgba(0,0,0,.35); }
.reader.immersed .side-plus { opacity: 0; pointer-events: none; }
.sidep { flex: none; display: flex; flex-direction: column; border-radius: 16px; background: var(--r-panel); box-shadow: 0 0 0 .5px var(--r-line), 0 14px 40px -12px rgba(0,0,0,.22); overflow: hidden; color: var(--r-fg); }
.sp-head { height: 44px; flex: none; display: flex; align-items: center; gap: 2px; padding: 0 6px 0 14px; border-bottom: .5px solid var(--r-line); }
.sp-title { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 6px; }
.sp-pos { min-width: 64px; height: 26px; padding: 0 6px; border-radius: 6px; font-size: 12px; opacity: .65; font-variant-numeric: tabular-nums; }
.sp-pos:hover { background: var(--r-hover); opacity: 1; }
.sp-pos-in { width: 64px; height: 26px; border-radius: 6px; border: 0; text-align: center; background: var(--r-paper); color: var(--r-fg); box-shadow: 0 0 0 1px var(--accent); font-size: 12px; user-select: text; }
.sp-frame { flex: 1; min-height: 0; overflow: hidden; display: flex; justify-content: safe center; align-items: safe center; padding: 14px; }
.sp-frame.zoomed { overflow: auto; }
.reader:not(.notes-on) .sidep .textLayer span { cursor: text; }

.picker { width: 300px; max-height: min(460px, calc(100% - 120px)); display: flex; flex-direction: column; gap: 10px; transform-origin: left center; }
.picker input { height: 32px; border-radius: 8px; border: 0; padding: 0 10px; background: var(--r-hover); color: var(--r-fg); user-select: text; }
.picker input:focus { box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-soft); }
.pk-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -6px; min-height: 0; }
.pk-item { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 8px; text-align: left; font-size: 13px; color: var(--r-fg); }
.pk-item:hover { background: var(--r-hover); }
.pk-cover { width: 26px; height: 41px; flex: none; border-radius: 2px; background: var(--cover-empty) center / cover no-repeat; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.pk-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.pk-tag { font-size: 11px; opacity: .5; }
.pk-empty { padding: 16px; text-align: center; opacity: .55; font-size: 12.5px; }

/* ---------- iPhone / iPad ---------- */
:root { --top: 40px; --sb: 0px; }
html.web { --top: calc(40px + env(safe-area-inset-top, 0px)); --sb: env(safe-area-inset-bottom, 0px); }
html.phone { --top: env(safe-area-inset-top, 0px); }
* { -webkit-tap-highlight-color: transparent; }
body { -webkit-user-select: none; -webkit-touch-callout: none; }
.textLayer, .note-ed, input, .input, .rename { -webkit-user-select: text; }
.menu, .pop, .npanel, .toast, .lib-head, .sidep, .side-plus, .drop-zone { -webkit-backdrop-filter: blur(24px) saturate(1.6); }
html.web .titlebar { height: var(--top); padding-top: env(safe-area-inset-top, 0px); }
html.web .caption { display: none; }
html.web .tabs { padding-right: 8px; }
html.phone .titlebar { display: none; }
.touch-only { display: none !important; }
@media (pointer: coarse) { .touch-only { display: grid !important; } }
.reader:not(.notes-on) .notes-only { display: none !important; }
.r-view { touch-action: pan-x pan-y; }
.r-bot { padding-bottom: var(--sb); height: calc(50px + var(--sb)); }
.fab { bottom: calc(30px + var(--sb)); }
.toast { bottom: calc(34px + var(--sb)); }

.selpill { position: absolute; z-index: 25; display: flex; padding: 3px; border-radius: 12px; background: rgba(30,30,32,.94); color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.selpill button { height: 36px; padding: 0 12px; border-radius: 9px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
.selpill button:active { background: rgba(255,255,255,.16); }
.selpill .i { width: 16px; height: 16px; }

.panel.web .webpick { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 30px; text-align: center; background: var(--bg-2); border-right: 1px solid var(--line); min-width: 0; }
.webpick .wp-ic { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.webpick .wp-ic .i { width: 30px; height: 30px; }
.webpick .wp-t { font-size: 15px; font-weight: 600; }
.webpick .wp-btn { height: 40px; padding: 0 18px; font-size: 14px; }
.webpick .wp-btn .i { width: 16px; height: 16px; }
.webpick .wp-name { color: var(--fg-2); font-size: 12.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* iPhone */
html.phone .lib-head { padding: 14px 16px 12px; flex-wrap: wrap; gap: 10px; }
html.phone .lib-head h1 { font-size: 28px; }
html.phone .lib-head .grow { display: none; }
html.phone .lib-tools { width: 100%; }
html.phone .search { flex: 1; }
html.phone .search input, html.phone .search input:focus { width: 100%; }
html.phone .grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 26px 16px; padding: 12px 16px calc(110px + var(--sb)); }
html.phone .book .title { font-size: 12.5px; }
html.phone .empty { inset: 80px 24px 80px; }
html.phone .fab { right: 18px; }
html.phone .r-pages { padding: 52px 12px 60px; gap: 0; }
html.phone .r-top { padding: 0 6px; }
html.phone .r-back span { display: none; }
html.phone .npanel.phone { position: absolute; z-index: 11; right: 0; top: 52px; bottom: calc(54px + var(--sb)); width: min(86vw, 420px); border-radius: 18px 0 0 18px; box-shadow: 0 0 0 .5px var(--r-line), -20px 0 50px -20px rgba(0,0,0,.35); }
html.phone .aa { left: 12px; right: 12px; width: auto; }
html.phone .scrim { place-items: stretch; }
html.phone .panel { grid-template-columns: 1fr; grid-template-rows: auto 1fr; border-radius: 0; padding-top: env(safe-area-inset-top, 0px); padding-bottom: var(--sb); }
html.phone .panel.web .webpick { border-right: 0; border-bottom: 1px solid var(--line); padding: 18px; gap: 10px; }
html.phone .webpick .wp-ic { display: none; }
html.phone .pane { padding: 16px; }
html.phone .cover-prev { height: 190px; }
html.phone .slate { width: 100vw; height: 100dvh; min-width: 0; min-height: 0; border-radius: 0; padding-top: env(safe-area-inset-top, 0px); padding-bottom: var(--sb); }
html.phone .sl-title { display: none; }
html.phone .crop-card { max-width: 100vw; border-radius: 0; }
html.phone .confirm { margin: 0 16px; }
html.phone .sl-bar { flex-wrap: wrap; height: auto; padding: 8px 8px 6px; row-gap: 6px; overflow: visible; }
html.phone .sl-bar .sl-div { display: none; }
html.phone .cover-prev { height: 150px; }

/* ---------- sync ---------- */
#syncBtn.spin .i { animation: spin 1.1s linear infinite; color: var(--accent); }
#syncBtn.warn { color: var(--warn); }
#syncBtn.off { opacity: .55; }
.syncp { width: min(520px, calc(100vw - 32px)); max-height: min(80vh, 720px); display: flex; flex-direction: column; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-panel); overflow: hidden; transform: scale(.97); transition: transform .25s var(--ease); }
.scrim.show .syncp { transform: none; }
.syncp-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 14px 8px 22px; }
.syncp-head h3 { margin: 0; font-size: 17px; font-weight: 650; }
.sp-body { padding: 4px 22px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.sp-p { margin: 0; color: var(--fg-2); font-size: 13.5px; line-height: 1.5; }
.sp-err { margin: 0; color: var(--warn); font-size: 13px; }
.sp-acc { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 12px 14px; border-radius: 12px; background: var(--bg-2); }
.sp-acc div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sp-acc b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.sp-acc small, .sp-dn small { color: var(--fg-2); font-size: 12px; }
.sp-lbl { font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--fg-3); margin-top: 6px; }
.sp-devs { display: flex; flex-direction: column; gap: 2px; }
.sp-dev { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-radius: 10px; }
.sp-dev:hover { background: var(--hover); }
.sp-ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.sp-dn { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sp-dn b { font-size: 13.5px; font-weight: 600; }
.icon-btn.danger:hover { color: var(--danger); }
.sp-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.sp-path { flex: 1; min-width: 0; font-size: 12px; padding: 8px 10px; border-radius: 8px; background: var(--bg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: text; }
.sp-check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--fg-2); line-height: 1.45; }
.sp-check input { margin-top: 2px; accent-color: var(--accent); }
.sp-out { align-self: flex-start; margin-top: 6px; }
.spinner.sm { width: 14px; height: 14px; border-width: 2px; border-color: rgba(255,255,255,.4); border-top-color: #fff; }
.sync-screen { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: var(--bg); transition: opacity .3s; padding: 24px; text-align: center; }
.sync-screen.out { opacity: 0; pointer-events: none; }
.sync-screen .ss-t { color: var(--fg-2); font-size: 15px; max-width: 320px; line-height: 1.5; }
