.books-panel {
  --book-bg:#121812;
  --book-panel:#1b241a;
  --book-input:#252f22;
  --book-ink:#edf3e7;
  --book-muted:#b2c0a8;
  --book-line:#3c4936;
  --book-accent:#d4f88a;
  box-sizing:border-box;
  width:min(1020px,calc(100% - 24px));
  max-height:92dvh;
  overflow:auto;
  padding:clamp(10px,2vw,22px);
  border:1px solid var(--book-line);
  border-radius:18px;
  background:var(--book-bg);
  color:var(--book-ink);
  color-scheme:dark;
}

.books-panel::backdrop { background:#000b; }
.books-panel [hidden] { display:none !important; }
.books-panel * { box-sizing:border-box; }
.books-panel .book-header {
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  margin-bottom:12px;
}
.books-panel h2,.books-panel h3,.book-player p,.book-reader p { margin:0; }
.books-panel .book-header h2 { font-size:clamp(21px,3vw,28px); }
.books-panel button,.books-panel select,.books-panel input:not([type=range],[type=checkbox]) {
  max-width:100%;
  min-height:42px;
  padding:7px 10px;
  border:1px solid var(--book-line);
  border-radius:9px;
  background:var(--book-input);
  color:var(--book-ink);
  font:inherit;
}
.books-panel button { cursor:pointer; }
.books-panel button:hover:not(:disabled) { border-color:var(--book-accent); }
.books-panel button:disabled { opacity:.45;cursor:default; }
.books-panel :is(button,a,input,select,summary):focus-visible {
  outline:2px solid var(--book-accent);
  outline-offset:3px;
}
.books-panel a,.books-panel #book-add { color:var(--book-accent); }
.books-panel .book-toolbar {
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:8px;
}
.books-panel .book-toolbar>label,.books-panel .book-toolbar>input { min-width:0; }
.books-panel .book-toolbar>label input[type=file] { display:block;width:100%; }
.books-panel .book-toolbar input[type=url] { flex:1 1 155px;width:100%;min-width:0; }
.book-import-tools,.book-player,.book-navigation,.book-reader,.book-admin {
  min-width:0;
  padding:clamp(10px,2.5vw,18px);
  border:1px solid var(--book-line);
  border-radius:13px;
  background:var(--book-panel);
}
.book-import-tools { margin-bottom:12px; }
.book-import-tools form { margin-top:8px; }
.books-panel .book-small { color:var(--book-muted);font-size:.875em; }
.books-panel .book-status { color:var(--book-accent);margin:0 0 10px;overflow-wrap:anywhere; }
.books-panel .book-status:empty { display:none; }
.books-panel .book-status.error { color:#ffb5ae; }
.book-layout {
  display:grid;
  align-items:start;
  grid-template-columns:minmax(0,1fr);
  grid-template-areas:"player" "nav";
  gap:12px;
  max-width:620px;
  margin-inline:auto;
}
.book-player { grid-area:player; }
.book-navigation { grid-area:nav; }
.book-reader { grid-area:reader; }

.book-player-heading {
  display:grid;
  grid-template-columns:auto minmax(0,1fr) auto;
  align-items:center;
  text-align:center;
  gap:6px;
  margin-bottom:12px;
}
.books-panel #book-title {
  color:var(--book-accent);
  font-size:clamp(24px,4vw,36px);
  line-height:1.1;
  overflow-wrap:anywhere;
  margin:4px 0;
}
.book-player-heading p { overflow-wrap:anywhere; }
.book-player #book-audio-unit { margin-bottom:3px;overflow-wrap:anywhere; }
.books-panel .book-icon {
  padding:4px;
  min-width:40px;
  white-space:nowrap;
  font-size:.875em;
}
.book-player-heading .book-icon { font-size:1.5em; }
.book-progress-row {
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:center;
  gap:8px;
  margin-bottom:7px;
}
.books-panel #book-seek { width:100%;margin:0;accent-color:var(--book-accent); }
.books-panel #book-seek:disabled { opacity:.45; }
.books-panel #book-progress { font-size:.875em;font-variant-numeric:tabular-nums;white-space:nowrap; }
.book-deck,.book-transport { display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:6px; }
.book-deck { justify-content:space-between; }
.books-panel .book-play {
  box-sizing:border-box;
  width:56px;
  min-height:56px;
  border-radius:50%;
  border:3px solid #526934;
  background:var(--book-accent);
  color:#192410;
  font-size:1.15em;
}
.book-options { margin-top:8px; }
.book-options[open] .book-toolbar { margin-top:8px; }
.book-options label { display:grid;gap:3px; }
.book-options [data-book-label=offlineHint] { margin-top:6px; }
.books-panel summary { cursor:pointer;min-height:35px;padding:5px 0; }

.book-tabs,.book-reader-toolbar,.book-reader-actions { display:flex;flex-wrap:wrap;align-items:center;gap:6px; }
.book-tabs { margin-bottom:6px; }
.books-panel .book-tabs [aria-pressed=true] {
  border-color:var(--book-accent);
  color:var(--book-accent);
}
.book-chapters,.book-reader { overflow:auto;max-height:52dvh;overscroll-behavior:contain; }
.book-chapters { display:grid;gap:5px; }
.books-panel .book-chapter-row {
  width:100%;
  border-color:transparent;
  background:transparent;
  text-align:start;
  overflow-wrap:anywhere;
}
.books-panel .book-chapter-row[aria-current=true] {
  background:var(--book-input);
  color:var(--book-accent);
  border-color:var(--book-line);
}
.book-row {
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:6px;
  padding:8px 0;
  border-bottom:1px solid var(--book-line);
}
.book-row>span { flex:1 1 155px;overflow-wrap:anywhere; }
.book-row button[aria-current=true] { color:var(--book-accent); }
.book-offline-link { display:inline-block;margin:5px 0 0; }
.books-panel #book-quota { margin:12px 0 0; }
.books-panel #book-quota:empty { display:none; }
.book-admin { margin-top:10px; }
.book-admin label { display:block;margin:0 0 6px; }

.books-panel[data-book-reading=true] .book-layout { grid-template-areas:"nav" "player" "reader";max-width:none; }
.books-panel[data-book-reading=true] .book-player-heading { display:none; }
.books-panel[data-book-reading=true] .book-player { position:sticky;top:0;z-index:1; }
.books-panel[data-book-reading=true] .book-tabs { margin-bottom:0; }
.book-reader-toolbar { justify-content:space-between; }
.book-reader-toolbar>p { min-width:0;overflow-wrap:anywhere; }
.book-reader-actions { margin-top:12px; }
.books-panel #book-reader-title {
  font:600 clamp(23px,3.5vw,32px)/1.17 Georgia,serif;
  margin:7px 0 12px;
  overflow-wrap:anywhere;
}
.book-reader-text {
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  font:1.15rem/1.65 Georgia,serif;
  max-width:68ch;
}
.book-reader[data-size="1"] .book-reader-text { font-size:1.32rem; }
.book-reader[data-size="2"] .book-reader-text { font-size:1.5rem; }

@media(max-width:739px) {
  .books-panel[data-book-reading=true][data-book-index=false] :is(#book-chapters,#book-library) { display:none; }
  .books-panel[data-book-reading=true][data-book-index=true] .book-tabs { margin-bottom:6px; }
}
@media(min-width:740px) {
  .books-panel[data-book-reading=true] .book-layout {
    grid-template-columns:minmax(200px,.6fr) minmax(0,1.4fr);
    grid-template-areas:"nav reader" "player player";
  }
  .books-panel[data-book-reading=true] .book-player { top:auto;bottom:0; }
  .books-panel[data-book-reading=true] .book-tabs { margin-bottom:6px; }
  .books-panel[data-book-reading=true] #book-library { max-height:44dvh;overflow:auto; }
}
@media(max-width:420px) {
  .header-actions { flex-wrap:wrap; }
  .book-deck { display:grid;grid-template-columns:minmax(0,1fr) auto;justify-items:start; }
  .book-deck>.book-transport { grid-column:1 / -1;grid-row:1;justify-self:center; }
}

.books-embedded { position:static;width:100%;max-width:none;max-height:none;margin:20px 0 0;overflow:visible; }
.books-embedded #books-close { display:none; }
.book-workspace { scroll-margin-top:24px; }
.book-workspace>button,.book-workspace #book-model {
  font:inherit;padding:10px 16px;border:1px solid var(--line);border-radius:12px;
  background:var(--panel);color:var(--ink);margin:6px 6px 6px 0;max-width:100%;
}
.book-workspace #book-login-code { font-size:30px;letter-spacing:.15em; }
#books-open { white-space:nowrap; }

.books-offline { font:16px/1.5 system-ui,sans-serif;background:#121725;color:#edf0f7;margin:0; }
.books-offline main { max-width:720px;margin:auto;padding:24px; }
.books-offline a { color:#a7c9ff; }
.books-offline article { padding:12px 0;display:flex;gap:12px;flex-wrap:wrap;border-bottom:1px solid #39425a; }
.books-offline audio { display:block;width:100%;margin:18px 0; }
.books-offline button,.books-offline select {
  font:inherit;min-height:42px;border-radius:9px;padding:8px 12px;border:1px solid #596583;background:#202b41;color:inherit;
}
