/* ── Book reader ── */
#readerSection { display: none; max-width: 1280px; margin: 0 auto; font-family: var(--font); }
#readerSection.active { display: block; }
.rd-upload-btn { display: inline-flex; align-items: center; padding: 8px 16px; border-radius: 10px; background: var(--primary); color: #fff; font-weight: 600; cursor: pointer; }
.rd-books { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.rd-book { position: relative; display: flex; flex-direction: column; gap: 8px; text-align: left; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); font-weight: 400; }
.rd-book:hover:not(:disabled) { border-color: var(--primary); }
.rd-book b { color: var(--text); padding-right: 28px; }
.rd-book .muted { font-size: .84em; }
.rd-book .cv-del { position: absolute; top: 10px; right: 10px; padding: 2px 8px; font-size: .8em; }
.rd-book-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.rd-book-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
                font-size: .86em; color: var(--text-2); }
.rd-tag { padding: 1px 8px; border-radius: 999px; font-size: .75em; font-weight: 600; background: var(--surface-3); color: var(--text-2); }
.rd-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.rd-filters[hidden] { display: none; }
.rd-filters input { flex: 1 1 220px; }
.rd-download { padding: 6px 12px; border: 1px solid var(--border-strong); border-radius: 999px; color: var(--primary);
               font-weight: 600; font-size: .88em; text-decoration: none; white-space: nowrap; }
.rd-download:hover { border-color: var(--primary); background: var(--primary-soft); }
.rd-download[hidden] { display: none; }
.rd-figure { margin: 0; display: grid; place-items: center; min-height: 100%; }
.rd-figure img { max-width: 100%; height: auto; border-radius: var(--radius); background: var(--surface); }
.rd-media { display: grid; place-items: center; gap: 12px; padding: 24px; }
.rd-media video { width: 100%; max-height: 70vh; border-radius: var(--radius); background: #000; }
.rd-media audio { width: min(560px, 100%); }
.rd-desc { max-width: 720px; margin: 0 auto 12px; color: var(--text-2); white-space: pre-wrap; }
.rd-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.rd-head b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 16px; align-items: start; }
.rd-content { position: relative; height: calc(100vh - 150px); overflow-y: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.rd-page { position: relative; margin: 0 auto 12px; background: var(--surface); box-shadow: var(--shadow-sm); }
.rd-page canvas { display: block; }
.rd-page-num { position: absolute; bottom: 4px; right: 8px; font-size: .75em; color: var(--muted); }
.rd-text { max-width: 720px; margin: 0 auto; background: var(--surface); padding: 28px 36px; border-radius: var(--radius); font-family: Georgia, 'Times New Roman', serif; font-size: 1.12em; line-height: 1.75; color: var(--text); }
.rd-text h2 { font-family: var(--font); margin: 28px 0 12px; }
.rd-text h3 { font-family: var(--font); font-size: 1.05em; margin: 20px 0 8px; }
.rd-text p { margin: 0 0 14px; }
.rd-text-figure { margin: 18px 0; text-align: center; }
.rd-text-figure img { max-width: 100%; height: auto; border-radius: 6px; background: #fff; }   /* transparent diagrams stay readable in the dark theme */
.rd-panel { position: sticky; top: 12px; max-height: calc(100vh - 150px); overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.rd-fab {
  position: fixed; z-index: 50; display: none; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--primary); background: var(--primary); color: #fff; font-weight: 700; font-size: .88em;
  box-shadow: var(--shadow-sm); cursor: pointer;
}
.rd-fab.saved { background: var(--success-soft); color: var(--text); border-color: var(--border); cursor: default; }
.rd-panel-empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.rd-word { display: flex; align-items: center; gap: 8px; font-size: 1.3em; }
.rd-ipa { font-family: monospace; color: var(--success-text); margin: 4px 0 10px; }
.rd-pos { font-family: var(--font); font-size: .8em; color: var(--muted); font-style: italic; }
.rd-meaning { font-size: 1.1em; font-weight: 700; color: var(--primary); }
.rd-explain, .rd-example, .rd-context { margin-top: 8px; font-size: .92em; color: var(--text-2); }
.rd-context { border-left: 3px solid var(--border-strong); padding-left: 10px; color: var(--muted); }
.rd-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0 4px; }
.rd-yg { overflow: hidden; border-radius: var(--radius); }
@media (max-width: 900px) {
  .rd-layout { grid-template-columns: 1fr; }
  .rd-content { height: 60vh; }
  .rd-panel { position: static; max-height: none; }
  .rd-text { padding: 18px; }
}

/* what selecting a word does (books.js: modes) */
.rd-modes { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: .9em; }
.rd-modes legend { padding: 0 4px; color: var(--muted); font-size: .85em; font-weight: 600; }
.rd-modes label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.rd-vi { font-size: 1.05em; font-weight: 600; margin-bottom: 10px; }
.rd-no-mode { margin: 8px 0; }
#rdPanelBody [hidden] { display: none !important; }
