:root { color-scheme: dark; --bg:#07070a; --panel:#121116; --border:rgba(255,255,255,.13); --gold:#f0d78c; --red:#a20d17; --muted:rgba(255,255,255,.66); }
* { box-sizing:border-box; }
html, body { margin:0; min-height:100%; background:radial-gradient(circle at 15% 0,rgba(139,0,0,.25),transparent 34%),var(--bg); color:#f7f1df; font-family:Inter,Segoe UI,Arial,sans-serif; }
button, a { font:inherit; }
.offline-header { position:sticky; top:0; z-index:10; display:flex; align-items:center; justify-content:space-between; gap:16px; min-height:68px; padding:12px clamp(16px,4vw,48px); background:rgba(7,7,10,.94); border-bottom:1px solid var(--border); backdrop-filter:blur(16px); }
.offline-brand { display:flex; align-items:center; gap:11px; color:#fff; text-decoration:none; font-weight:800; letter-spacing:.04em; }
.offline-brand img { width:40px; height:40px; }
.offline-actions { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.offline-button { display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:42px; padding:10px 16px; color:#fff; background:rgba(255,255,255,.07); border:1px solid var(--border); border-radius:11px; text-decoration:none; cursor:pointer; }
.offline-button.primary { color:#120b02; background:var(--gold); border-color:var(--gold); font-weight:800; }
.offline-button.danger { color:#ffd7d7; border-color:rgba(255,70,70,.45); }
.offline-button:disabled { opacity:.55; cursor:wait; }
.offline-status { display:inline-flex; align-items:center; gap:7px; color:var(--muted); font-size:.88rem; }
.offline-status::before { content:""; width:8px; height:8px; border-radius:50%; background:#41d681; box-shadow:0 0 12px #41d681; }
.offline-status.is-offline::before { background:#ffb547; box-shadow:0 0 12px #ffb547; }
.offline-main { width:min(1160px,calc(100% - 32px)); margin:0 auto; padding:54px 0 80px; }
.offline-hero { padding:clamp(24px,5vw,48px); background:linear-gradient(135deg,rgba(139,0,0,.65),rgba(35,25,13,.75)); border:1px solid rgba(240,215,140,.25); border-radius:24px; }
.offline-hero h1 { margin:8px 0 12px; font-size:clamp(2rem,6vw,4rem); line-height:1; }
.offline-hero p { max-width:760px; color:rgba(255,255,255,.76); line-height:1.65; }
.offline-kicker { color:var(--gold); font-weight:800; letter-spacing:.12em; text-transform:uppercase; font-size:.78rem; }
.offline-library-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:20px; margin-top:30px; }
.offline-card { overflow:hidden; background:rgba(18,17,22,.94); border:1px solid var(--border); border-radius:18px; }
.offline-cover { aspect-ratio:3/4; display:grid; place-items:center; background:linear-gradient(145deg,#25100e,#17141e); overflow:hidden; }
.offline-cover img { width:100%; height:100%; object-fit:cover; }
.offline-cover span { font-size:4rem; color:var(--gold); }
.offline-card-body { padding:18px; }
.offline-card h2 { margin:0 0 6px; font-size:1.15rem; }
.offline-card p { margin:0 0 14px; color:var(--muted); }
.offline-progress { height:7px; overflow:hidden; background:rgba(255,255,255,.09); border-radius:99px; margin-bottom:8px; }
.offline-progress span { display:block; height:100%; background:linear-gradient(90deg,var(--red),var(--gold)); }
.offline-card-meta { display:flex; justify-content:space-between; color:var(--muted); font-size:.78rem; margin-bottom:15px; }
.offline-card-actions { display:flex; gap:8px; }
.offline-card-actions .offline-button { flex:1; padding-inline:10px; }
.offline-empty { margin-top:30px; padding:48px 22px; text-align:center; background:var(--panel); border:1px dashed rgba(240,215,140,.35); border-radius:18px; color:var(--muted); }
.offline-note { margin-top:30px; padding:16px 18px; color:var(--muted); background:rgba(255,181,71,.07); border:1px solid rgba(255,181,71,.2); border-radius:13px; font-size:.9rem; }
.offline-reader-page { height:100vh; overflow:hidden; }
.offline-reader { height:calc(100vh - 68px); display:grid; grid-template-rows:auto 1fr; }
.offline-reader-toolbar { display:flex; align-items:center; justify-content:center; gap:10px; padding:10px; background:var(--panel); border-bottom:1px solid var(--border); }
.offline-reader-stage { min-height:0; overflow:auto; display:grid; place-items:start center; padding:22px; }
.offline-reader-stage canvas { max-width:100%; height:auto; background:#fff; box-shadow:0 18px 50px rgba(0,0,0,.5); }
.offline-reader-message { margin:auto; max-width:620px; padding:30px; text-align:center; color:var(--muted); }
.offline-page-count { min-width:110px; text-align:center; color:var(--muted); }
@media (max-width:640px) { .offline-header { align-items:flex-start; } .offline-brand span { display:none; } .offline-main { width:min(100% - 20px,1160px); padding-top:24px; } .offline-reader-toolbar { flex-wrap:wrap; } }

.offline-page-jump { display:flex; align-items:center; gap:7px; color:var(--muted); }
.offline-page-jump input { width:72px; min-height:42px; padding:8px; color:#fff; background:rgba(255,255,255,.07); border:1px solid var(--border); border-radius:9px; text-align:center; }
.offline-reader-workspace { position:relative; min-height:0; overflow:hidden; }
.offline-reader-workspace .offline-reader-stage { box-sizing:border-box; height:100%; }
.offline-page-surface { position:relative; flex:none; background:#fff; box-shadow:0 18px 50px rgba(0,0,0,.5); touch-action:none; }
.offline-page-surface canvas { display:block; box-shadow:none; }
.offline-highlight-layer { position:absolute; inset:0; pointer-events:none; overflow:hidden; }
.offline-page-surface.is-highlighting { cursor:crosshair; }
.offline-page-surface.is-highlighting .offline-highlight-layer { pointer-events:auto; }
.offline-highlight { position:absolute; z-index:2; background:rgba(255,224,72,.42); border:1px solid rgba(235,174,0,.48); mix-blend-mode:multiply; }
.offline-highlight.is-preview { background:rgba(255,224,72,.25); border-style:dashed; }
.offline-annotations { position:absolute; z-index:8; top:0; right:0; width:min(390px,100%); height:100%; box-sizing:border-box; padding:22px; overflow:auto; color:#fff; background:rgba(14,13,18,.98); border-left:1px solid var(--border); box-shadow:-18px 0 50px rgba(0,0,0,.38); transform:translateX(105%); transition:transform .2s ease; }
.offline-annotations.is-open { transform:translateX(0); }
.offline-annotations-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:18px; }
.offline-annotations h2 { margin:5px 0 0; font-size:1.35rem; }
.offline-annotations h3 { margin:26px 0 10px; font-size:1rem; }
.offline-annotations label { display:block; margin-bottom:7px; color:var(--muted); font-size:.9rem; }
.offline-annotations textarea { box-sizing:border-box; width:100%; margin-bottom:9px; padding:12px; resize:vertical; color:#fff; background:rgba(255,255,255,.07); border:1px solid var(--border); border-radius:10px; font:inherit; }
.offline-annotation-list { display:grid; gap:10px; }
.offline-annotation-item { padding:12px; background:rgba(255,255,255,.05); border:1px solid var(--border); border-radius:11px; }
.offline-annotation-item p { margin:5px 0; color:rgba(255,255,255,.82); white-space:pre-wrap; overflow-wrap:anywhere; }
.offline-annotation-item small,.offline-annotation-empty { color:var(--muted); }
.offline-annotation-actions { display:flex; gap:7px; margin-top:9px; }
.offline-annotation-actions .offline-button { min-height:34px; padding:6px 10px; }
@media (max-width:760px) { .offline-reader-toolbar { justify-content:flex-start; overflow-x:auto; flex-wrap:nowrap; } .offline-reader-toolbar > * { flex:none; } .offline-reader-stage { padding:12px; } }
@media print { body { display:none !important; } }

/* Immersive reader studio */
.offline-reader-page {
    --bg:#17191d;
    --panel:rgba(29,31,36,.9);
    --border:rgba(255,255,255,.09);
    --gold:#e9c46a;
    --red:#a9242f;
    --muted:#aaa8a2;
    background:
        radial-gradient(circle at 8% 12%,rgba(169,36,47,.13),transparent 28rem),
        radial-gradient(circle at 92% 10%,rgba(233,196,106,.07),transparent 24rem),
        var(--bg);
    color:#f8f5ee;
}
.offline-reader-page .offline-header {
    min-height:76px;
    padding:10px clamp(14px,2.5vw,34px);
    background:rgba(20,21,25,.88);
    border-bottom-color:var(--border);
    box-shadow:0 12px 35px rgba(0,0,0,.16);
    backdrop-filter:blur(20px) saturate(140%);
}
.offline-reader-page .offline-brand { min-width:0; gap:13px; letter-spacing:0; }
.offline-reader-page .offline-brand img {
    width:40px;
    height:50px;
    padding:5px;
    background:linear-gradient(145deg,#641820,#282128);
    border:1px solid rgba(255,255,255,.12);
    border-radius:7px;
    box-shadow:0 7px 18px rgba(0,0,0,.35);
}
.offline-brand-copy { min-width:0; display:grid; gap:2px; }
.offline-brand-copy small { color:var(--gold); font-size:.65rem; font-weight:800; letter-spacing:.15em; text-transform:uppercase; }
.offline-brand-copy strong {
    max-width:min(52vw,650px);
    overflow:hidden;
    color:#f8f5ee;
    font-family:Georgia,"Times New Roman",serif;
    font-size:clamp(.98rem,2.2vw,1.18rem);
    font-weight:600;
    white-space:nowrap;
    text-overflow:ellipsis;
}
.offline-reader-page .offline-button {
    min-height:38px;
    padding:8px 12px;
    color:#f8f5ee;
    background:transparent;
    border-color:transparent;
    border-radius:9px;
    transition:background 160ms ease,border-color 160ms ease,color 160ms ease,transform 160ms ease;
}
.offline-reader-page .offline-button:hover { background:rgba(255,255,255,.09); transform:translateY(-1px); }
.offline-reader-page .offline-button.primary { color:#21180a; background:linear-gradient(135deg,#f4dda1,#dcb657); border-color:var(--gold); }
.offline-reader-page .offline-button.danger { color:#ffc8ca; border-color:rgba(255,90,98,.3); }
.offline-reader-page .offline-button:disabled { opacity:.36; cursor:not-allowed; transform:none; }
.offline-button.compact { border:1px solid var(--border); background:rgba(255,255,255,.045); }
.offline-button.icon-button { width:38px; min-width:38px; padding:0; font-size:1.45rem; line-height:1; }
.offline-reader-page .offline-status { font-size:.75rem; }
.offline-reader-page .offline-status::before { background:#e9c46a; box-shadow:0 0 11px rgba(233,196,106,.7); }
.offline-reader-page .offline-status.is-offline::before { background:#55d68a; box-shadow:0 0 11px rgba(85,214,138,.7); }
.offline-reader { height:calc(100vh - 76px); grid-template-rows:auto 1fr; }
.offline-reader-toolbar {
    min-height:58px;
    gap:10px;
    padding:9px clamp(12px,2vw,28px);
    background:rgba(29,31,36,.87);
    border-bottom-color:var(--border);
    box-shadow:0 10px 30px rgba(0,0,0,.12);
    backdrop-filter:blur(18px);
}
.offline-tool-group {
    display:flex;
    align-items:center;
    gap:5px;
    padding:4px;
    background:rgba(0,0,0,.12);
    border:1px solid rgba(255,255,255,.075);
    border-radius:13px;
}
.offline-toolbar-divider { width:1px; height:25px; background:var(--border); }
.offline-page-jump { min-height:36px; gap:6px; padding:0 7px; font-size:.78rem; }
.offline-page-jump label { color:#d4d0c7; }
.offline-page-jump input {
    width:54px;
    min-height:30px;
    padding:4px 5px;
    background:rgba(255,255,255,.055);
    border-color:var(--border);
    border-radius:7px;
}
.visually-hidden {
    position:absolute!important;
    width:1px!important;
    height:1px!important;
    padding:0!important;
    margin:-1px!important;
    overflow:hidden!important;
    clip:rect(0,0,0,0)!important;
    white-space:nowrap!important;
    border:0!important;
}
.offline-reader-workspace {
    background:
        linear-gradient(90deg,rgba(255,255,255,.018) 1px,transparent 1px),
        linear-gradient(rgba(255,255,255,.018) 1px,transparent 1px);
    background-size:32px 32px;
}
.offline-reader-stage { padding:34px 20px 112px; }
.offline-page-surface {
    border:1px solid rgba(255,255,255,.18);
    border-radius:4px;
    box-shadow:0 22px 58px rgba(0,0,0,.48),0 2px 7px rgba(0,0,0,.3);
    overflow:hidden;
}
.offline-reader-message {
    display:grid;
    justify-items:center;
    gap:14px;
    margin:15vh auto 0;
    color:var(--muted);
    font-weight:700;
}
.offline-loader { width:34px; height:34px; border:2px solid rgba(255,255,255,.1); border-top-color:var(--gold); border-radius:50%; animation:offline-spin .8s linear infinite; }
@keyframes offline-spin { to { transform:rotate(360deg); } }
.offline-annotations {
    top:14px;
    right:14px;
    bottom:74px;
    width:min(390px,calc(100% - 28px));
    height:auto;
    padding:20px;
    background:rgba(25,26,31,.97);
    border:1px solid var(--border);
    border-radius:18px;
    box-shadow:0 24px 70px rgba(0,0,0,.55);
}
.offline-annotations h2 { font-family:Georgia,"Times New Roman",serif; font-weight:600; }
.offline-annotations h3 { color:var(--gold); font-size:.72rem; letter-spacing:.13em; text-transform:uppercase; }
.offline-annotations textarea,.offline-annotation-item { background:rgba(255,255,255,.045); border-radius:12px; }
.offline-reader-progress {
    position:absolute;
    z-index:6;
    left:50%;
    bottom:16px;
    width:min(600px,calc(100% - 28px));
    min-height:50px;
    display:grid;
    grid-template-columns:auto minmax(100px,1fr) 42px;
    align-items:center;
    gap:12px;
    padding:8px 12px;
    color:var(--muted);
    background:rgba(25,26,31,.88);
    border:1px solid var(--border);
    border-radius:16px;
    box-shadow:0 18px 55px rgba(0,0,0,.4);
    backdrop-filter:blur(22px) saturate(145%);
    transform:translateX(-50%);
    font-size:.75rem;
}
.offline-progress-label { color:#f8f5ee; font-weight:700; }
.offline-progress-track { height:5px; overflow:hidden; background:rgba(255,255,255,.1); border-radius:99px; }
.offline-progress-track span { display:block; width:0; height:100%; background:linear-gradient(90deg,var(--red),var(--gold)); transition:width .22s ease; }
.offline-progress-percent { text-align:right; }
@media (max-width:640px) {
    .offline-reader-page .offline-header { min-height:62px; padding:7px 9px; align-items:center; }
    .offline-reader-page .offline-brand img { width:32px; height:42px; }
    .offline-brand-copy small,.offline-reader-page .offline-status { display:none; }
    .offline-reader-page .offline-brand .offline-brand-copy { display:grid; }
    .offline-brand-copy strong { max-width:46vw; font-size:.92rem; }
    .offline-reader { height:calc(100vh - 62px); }
    .offline-reader-toolbar { min-height:52px; justify-content:flex-start; gap:7px; padding:6px 8px; }
    .offline-tool-group { padding:3px; }
    .offline-toolbar-divider { display:none; }
    .offline-reader-stage { padding:14px 7px 94px; }
    .offline-reader-progress { bottom:7px; width:calc(100% - 14px); min-height:46px; padding:6px 10px; border-radius:13px; }
    .offline-annotations { top:auto; right:0; bottom:0; width:100%; height:min(78vh,640px); border-radius:18px 18px 0 0; transform:translateY(105%); }
    .offline-annotations.is-open { transform:translateY(0); }
}
@media (prefers-reduced-motion:reduce) {
    .offline-reader-page .offline-button,.offline-annotations,.offline-progress-track span { transition:none; }
    .offline-loader { animation:none; }
}
