/* EPUB Viewer */
.ev-msg { font-size: 0.82rem; min-height: 1.3em; margin-top: 12px; color: var(--text-secondary); }
.ev-msg.is-error { color: #ef6b6b; }

.ev-shell {
    position: relative;
    display: flex;
    flex-direction: column;
    height: min(80vh, 920px);
    min-height: 480px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.ev-shell:fullscreen { height: 100%; border: 0; border-radius: 0; background: var(--bg); }
.ev-shell[hidden] { display: none; }

/* top bar */
.ev-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-sidebar);
}
.ev-title {
    flex: 1;
    min-width: 0;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.25;
    overflow: hidden;
}
.ev-title span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-title small { display: block; font-weight: 500; font-size: 0.72rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-bar .btn { white-space: nowrap; }
.ev-bar .btn.is-active { border-color: var(--accent); color: var(--accent); }

/* body: side panel + stage */
.ev-body { flex: 1; display: flex; min-height: 0; position: relative; }

.ev-side {
    width: 310px;
    flex: none;
    display: none;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--border);
    background: var(--bg-card);
}
.ev-shell.side-open .ev-side { display: flex; }

.ev-tabs { display: flex; border-bottom: 1px solid var(--border); }
.ev-tab {
    flex: 1;
    padding: 10px 6px;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}
.ev-tab:hover { color: var(--text-primary); }
.ev-tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.ev-pane { display: none; flex: 1; min-height: 0; overflow-y: auto; padding: 10px; }
.ev-pane.is-active { display: block; }

/* contents */
.ev-toc { list-style: none; margin: 0; padding: 0; }
.ev-toc button {
    display: block;
    width: 100%;
    text-align: left;
    font: inherit;
    font-size: 0.82rem;
    line-height: 1.35;
    color: var(--text-secondary);
    background: transparent;
    border: 0;
    border-radius: 6px;
    padding: 7px 8px;
    cursor: pointer;
}
.ev-toc button:hover { background: var(--bg-input); color: var(--text-primary); }
.ev-toc button.is-current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* search */
.ev-search-row { display: flex; gap: 6px; margin-bottom: 8px; }
.ev-search-row .text-input { flex: 1; min-width: 0; }
.ev-search-status { font-size: 0.76rem; color: var(--text-muted); margin: 0 0 8px; min-height: 1.2em; }
.ev-hits { list-style: none; margin: 0; padding: 0; }
.ev-hit {
    display: block;
    width: 100%;
    text-align: left;
    font: inherit;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text-secondary);
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--border);
    padding: 8px 4px;
    cursor: pointer;
}
.ev-hit:hover { background: var(--bg-input); }
.ev-hit b { display: block; font-size: 0.7rem; font-weight: 600; color: var(--text-muted); margin-bottom: 2px; }
.ev-hit mark { background: rgba(255, 196, 0, 0.35); color: var(--text-primary); border-radius: 2px; padding: 0 1px; }

/* info */
.ev-info-cover { display: block; max-width: 150px; max-height: 220px; margin: 4px auto 14px; border-radius: 6px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.ev-info dl { margin: 0; font-size: 0.8rem; }
.ev-info dt { color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 10px; }
.ev-info dd { margin: 2px 0 0; color: var(--text-primary); word-break: break-word; line-height: 1.45; }
.ev-info .ev-desc { color: var(--text-secondary); max-height: 14em; overflow-y: auto; }

/* stage */
.ev-stage { flex: 1; min-width: 0; position: relative; background: #fbfbfa; }
.ev-frame { display: block; width: 100%; height: 100%; border: 0; background: transparent; }
.ev-loading {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.18);
    pointer-events: none;
}
.ev-loading.is-on { display: flex; }

/* display popover */
.ev-pop {
    position: absolute;
    top: 52px;
    right: 10px;
    z-index: 6;
    width: 290px;
    max-width: calc(100% - 20px);
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.ev-pop[hidden] { display: none; }
.ev-pop .row { margin-bottom: 12px; }
.ev-pop .row:last-child { margin-bottom: 0; }
.ev-pop .field-label { margin-bottom: 6px; }
.ev-seg { display: flex; gap: 6px; flex-wrap: wrap; }
.ev-seg .btn { flex: 1; justify-content: center; min-width: 54px; }
.ev-size-row { display: flex; align-items: center; gap: 8px; }
.ev-size-row .ev-size-val { flex: 1; text-align: center; font-family: 'JetBrains Mono', monospace; font-size: 0.82rem; color: var(--accent); }
.ev-pop select { width: 100%; }

/* footer */
.ev-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-top: 1px solid var(--border);
    background: var(--bg-sidebar);
}
.ev-seek { flex: 1; min-width: 0; accent-color: var(--accent); }
.ev-pos { min-width: 112px; text-align: right; font-size: 0.74rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; white-space: nowrap; }
.ev-foot .btn:disabled { opacity: 0.4; cursor: default; }
.ev-foot .btn:disabled:hover { border-color: var(--border); color: inherit; }

.ev-keys { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.9; }
.ev-keys kbd {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    padding: 1px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-input);
}

@media (max-width: 780px) {
    .ev-shell { height: 78vh; min-height: 420px; }
    .ev-side {
        position: absolute;
        z-index: 5;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(88%, 350px);
        box-shadow: var(--shadow);
    }
    .ev-bar .btn .lbl { display: none; }
    .ev-pos { min-width: 0; }
    #evPosLabel .long { display: none; }
}
