@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700;900&family=ZCOOL+XiaoWei&display=swap');

:root {
    --ink: #07090a;
    --panel: rgba(12, 16, 16, 0.9);
    --line: rgba(230, 190, 100, 0.24);
    --gold: #d6b35a;
    --gold-soft: #f0d990;
    --jade: #5fb8a8;
    --text: #f4efe3;
    --muted: #bcb2a2;
    --paper: #f7f2e8;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: 'Noto Serif SC', 'Songti SC', serif;
    color: var(--text);
    background:
        linear-gradient(180deg, rgba(7, 9, 10, 0.94), rgba(10, 14, 14, 0.98)),
        var(--ink);
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    opacity: 0.34;
    background-image:
        linear-gradient(rgba(214, 179, 90, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(214, 179, 90, 0.035) 1px, transparent 1px);
    background-size: 72px 72px;
}

a {
    color: inherit;
}

button,
input {
    font: inherit;
}

.reader-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto minmax(150px, 1fr);
    align-items: center;
    gap: 14px;
    min-height: 72px;
    padding: 12px clamp(14px, 3vw, 34px);
    border-bottom: 1px solid var(--line);
    background: rgba(7, 9, 10, 0.9);
    backdrop-filter: blur(18px);
}

.reader-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
    color: var(--gold-soft);
    text-decoration: none;
}

.reader-brand span {
    display: grid;
    place-items: center;
    width: 38px;
    aspect-ratio: 1;
    border: 1px solid var(--gold);
    border-radius: 50%;
    font-family: 'ZCOOL XiaoWei', serif;
    flex: 0 0 auto;
}

.reader-brand strong {
    min-width: 0;
    overflow: hidden;
    font-size: 1.06rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reader-tools,
.reader-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
}

.reader-actions {
    justify-content: flex-end;
    justify-self: end;
}

.icon-button,
.fit-button,
.download-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    border: 1px solid rgba(214, 179, 90, 0.34);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--gold-soft);
    text-decoration: none;
    cursor: pointer;
}

.icon-button {
    width: 42px;
    padding: 0;
}

.fit-button {
    padding: 0 12px;
}

.download-button {
    padding: 0 14px;
    background: linear-gradient(135deg, var(--gold), var(--jade));
    color: #07100f;
    font-weight: 700;
}

.icon-button:hover,
.fit-button:hover {
    border-color: rgba(240, 217, 144, 0.7);
    background: rgba(214, 179, 90, 0.1);
}

.icon-button:disabled,
.fit-button:disabled {
    cursor: not-allowed;
    opacity: 0.42;
}

.icon-button svg,
.download-button svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.page-control {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 42px;
    padding: 0 10px;
    border: 1px solid rgba(214, 179, 90, 0.26);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.035);
    color: var(--muted);
}

.page-control input {
    width: 64px;
    height: 30px;
    border: 1px solid rgba(214, 179, 90, 0.22);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.22);
    color: var(--text);
    text-align: center;
}

.tool-divider {
    width: 1px;
    height: 28px;
    background: rgba(214, 179, 90, 0.2);
}

.reader-shell {
    width: min(1180px, calc(100% - 28px));
    margin: 0 auto;
    padding: 18px 0 38px;
}

.reader-status {
    min-height: 28px;
    margin-bottom: 12px;
    color: var(--muted);
    text-align: center;
}

.reader-status.is-error {
    color: #ffb4a8;
}

.reader-stage {
    display: grid;
    place-items: start center;
    min-height: calc(100vh - 150px);
    padding: clamp(10px, 2vw, 22px);
    border: 1px solid rgba(214, 179, 90, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.045);
    overflow: auto;
}

.reader-stage canvas {
    display: block;
    max-width: 100%;
    height: auto;
    background: var(--paper);
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
}

.reader-fallback {
    margin: 18px auto 0;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    text-align: center;
}

.reader-fallback div {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

@media (max-width: 860px) {
    .reader-bar {
        grid-template-columns: minmax(0, 1fr) max-content;
        overflow: hidden;
    }

    .reader-tools {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: flex-start;
        max-width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .reader-actions {
        grid-column: 2;
        grid-row: 1;
        justify-content: flex-end;
    }
}

@media (max-width: 520px) {
    .reader-bar {
        min-height: 64px;
        gap: 10px;
    }

    .reader-brand strong {
        font-size: 0.96rem;
    }

    .reader-brand span,
    .icon-button {
        width: 38px;
    }

    .icon-button,
    .fit-button,
    .download-button,
    .page-control {
        min-height: 38px;
    }

    .reader-actions {
        display: none;
    }

    .page-control input {
        width: 54px;
    }

    .tool-divider {
        display: none;
    }

    .reader-shell {
        width: min(100% - 16px, 1180px);
        padding-top: 10px;
    }
}
