/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  background-color: #f5f5f5;
  color: #333;
}

.flash-message {
  margin: 16px;
  padding: 16px;
  border-radius: 6px;
  border: 1px solid transparent;
}

.flash-message.-notice {
  background-color: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.flash-message.-alert {
  background-color: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

:root {
  --chat-bottom-offset: 0px;
  --chat-bottom-offset-negative: 0px;
  --chat-input-max-height: 80px;
}

.reader-shell {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.translation-modal__footer {
  padding-bottom: calc(16px + env(safe-area-inset-bottom) + var(--chat-bottom-offset, 0px));
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  z-index: 2;
}

.translation-page {
  background-color: #fff;
  padding: 0;
  margin: 0;
  display: flex;
  flex: 1;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.translation-page > #translation-modal {
  flex: 1;
  display: flex;
  min-height: 0;
}

body:has(.translation-page) {
  background-color: #fff;
  height: 100%;
}

#translation-modal.translation-modal {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

body.reader-mode .translation-page {
  height: 100%;
}

/* Utility */
.hidden { display: none !important; }

/* Header bar */
.header-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { font-weight: 600; font-size: 1.1rem; color: #1f2937; text-decoration: none; }
.brand:hover { text-decoration: underline; }

.nav { display: flex; align-items: center; gap: 16px; }
.nav-link { color: #4b5563; text-decoration: none; }
.nav-link:hover { color: #111827; text-decoration: underline; }

/* Desktop vs mobile visibility */
.nav-desktop { display: none; }
.nav-mobile { display: block; }
@media (min-width: 768px) {
  .nav-desktop { display: flex; }
  .nav-mobile { display: none; }
}

/* Account button & dropdown */
.account-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #d1d5db;
  padding: 4px 8px;
  border-radius: 20px;
  background: #fff;
  cursor: pointer;
}
.account-btn:hover { background: #f9fafb; }
.account-label { display: none; color: #111827; font-size: 0.9rem; }
@media (min-width: 1024px) { .account-label { display: inline; } }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: #667eea; color: #fff; font-weight: 600; font-size: 0.8rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.avatar-lg { width: 36px; height: 36px; font-size: 0.9rem; }
.caret { color: #6b7280; font-size: 0.8rem; }

.menu { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 200px; padding: 6px 0; background: #fff;
  border: 1px solid #e5e7eb; border-radius: 8px; box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}
.menu-item { display: block; padding: 8px 12px; color: #111827; text-decoration: none; font-size: 0.9rem; }
.menu-item:hover { background: #f9fafb; }
.menu-item.danger { color: #b91c1c; }
.menu-item.danger:hover { background: #fef2f2; }

/* Mobile menu */
.hamburger-btn {
  width: 40px; height: 40px; border: 1px solid #d1d5db; border-radius: 6px;
  background: #fff; cursor: pointer;
}
.hamburger-btn:hover { background: #f9fafb; }
.hamburger-icon { display: inline-block; width: 18px; height: 2px; background: #374151; position: relative; }
.hamburger-icon::before, .hamburger-icon::after { content: ""; position: absolute; left: 0; width: 18px; height: 2px; background: #374151; }
.hamburger-icon::before { top: -6px; }
.hamburger-icon::after { top: 6px; }

.mobile-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}
.mobile-panel-inner { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.mobile-account { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.mobile-account-label { font-size: 0.95rem; color: #111827; }
.mobile-link { display: block; padding: 8px 10px; border-radius: 6px; color: #111827; text-decoration: none; }
.mobile-link:hover { background: #f9fafb; }
.mobile-link.primary { background: #667eea; color: #fff; text-align: center; }
.mobile-link.primary:hover { background: #5a67d8; }
.mobile-link.danger { color: #b91c1c; }
.mobile-link.danger:hover { background: #fef2f2; }

/* Full-screen reader mode */
body.reader-mode {
  padding: 0;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
}

.bookshelf {
  max-width: 1200px;
  margin: 0 auto;
}

.bookshelf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid #ddd;
}

.bookshelf-header h1 {
  margin: 0;
  color: #2c3e50;
  font-size: 2rem;
}

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 180px));
  gap: 24px;
  margin-bottom: 30px;
}

@media (max-width: 500px) {
  .books-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 0 12px;
  }
}

.book-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: white;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.book-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}

.book-card:focus-visible {
  outline: 3px solid #667eea;
  outline-offset: 2px;
}

.book-cover {
  aspect-ratio: 2 / 3;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.book-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-placeholder {
  font-size: 3rem;
  color: white;
}

.book-placeholder--title {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.book-placeholder-title {
  display: block;
}

.book-title {
  margin: 0;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #2c3e50;
  line-height: 1.3;
}

.empty-bookshelf {
  text-align: center;
  padding: 60px 20px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.empty-bookshelf h2 {
  color: #666;
  margin-bottom: 10px;
}

.empty-bookshelf p {
  color: #999;
  margin-bottom: 30px;
}

.upload-book {
  max-width: 600px;
  margin: 0 auto;
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.upload-book h1 {
  margin-top: 0;
  color: #2c3e50;
  text-align: center;
  margin-bottom: 30px;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: #555;
}

.form-control {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  box-sizing: border-box;
}

.form-control:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.form-text {
  display: block;
  margin-top: 5px;
  font-size: 0.85rem;
  color: #666;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 30px;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s;
  display: inline-block;
  text-align: center;
}

.btn-primary {
  background-color: #667eea;
  color: white;
}

.btn-primary:hover {
  background-color: #5a67d8;
}

.btn-secondary {
  background-color: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background-color: #5a6268;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.875rem;
}

.error-messages {
  background-color: #f8d7da;
  color: #721c24;
  padding: 15px;
  border-radius: 4px;
  margin-bottom: 20px;
  border: 1px solid #f5c6cb;
}

.error-messages h4 {
  margin-top: 0;
  margin-bottom: 10px;
}

.error-messages ul {
  margin-bottom: 0;
  padding-left: 20px;
}

/* EPUB Reader Styles */
.reader-container {
  /*
    Uses height: 100% (not 100dvh) to fix PWA text bleed issue.

    HISTORY: The container was originally min-height: 100dvh but this caused text
    to bleed off the bottom of the screen in PWA mode. The 100dvh unit calculates
    the dynamic viewport height, which in PWA behaves differently than in regular
    browsers and resulted in the container being ~56px taller than intended. This
    cascaded to the EPUB viewer, causing it to measure its available space
    incorrectly.

    FIX: Changed to height: 100% which calculates relative to the parent layout
    height instead of the dynamic viewport unit. This ensures correct dimensions
    across all environments (PWA, mobile browser, desktop).

    For full investigation details, see:
    docs/plans/2026-02-08-fix-epub-text-bleed-investigation-plan.md

    See also: https://github.com/[repo]/pull/[PR] for commit history.
  */
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.reader-header {
  display: flex;
  flex-direction: column;
  padding: 10px 20px;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  flex-shrink: 0;
}

.reader-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.reader-nav .back-btn {
  color: #667eea;
  text-decoration: none;
  font-weight: 500;
  font-size: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background-color 0.2s;
}

.reader-nav .back-btn:hover {
  color: #5a67d8;
  background-color: rgba(102, 126, 234, 0.1);
}

.book-title {
  width: 100%;
}

.book-title h1 {
  margin: 0;
  font-size: 1.2rem;
  color: #2c3e50;
  text-align: center;
}

.reader-controls {
  display: flex;
  gap: 10px;
}

.bookmark-toggle {
  background: none;
  border: none;
  color: #5a67d8;
  display: inline-flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: opacity 0.2s;
  border-radius: 4px;
}

.bookmark-toggle:focus-visible {
  outline: 2px solid #5a67d8;
  outline-offset: 2px;
}

.bookmark-toggle:hover {
  opacity: 0.8;
}

.bookmark-toggle:active {
  opacity: 0.6;
}

.bookmark-ribbon {
  width: 22px;
  height: 36px;
  filter: drop-shadow(0 6px 12px rgba(15, 23, 42, 0.12));
}

.bookmark-ribbon-fill {
  fill: transparent;
}

.bookmark-ribbon-stroke {
  fill: none;
  stroke: #9ca3af;
  stroke-width: 2;
  stroke-linejoin: round;
}

.bookmark-toggle[data-bookmarked="true"] .bookmark-ribbon-fill {
  fill: #5a67d8;
}

.bookmark-toggle[data-bookmarked="true"] .bookmark-ribbon-stroke {
  stroke: #5a67d8;
}

.bookmark-corner {
  position: absolute;
  top: -4px;
  right: 18px;
  width: 24px;
  height: 44px;
  z-index: 9;
}

.reader-menu .menu-panel {
  right: 0;
  top: calc(100% + 6px);
}

.control-btn {
  background: #667eea;
  color: white;
  border: none;
  border-radius: 4px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.control-btn:hover {
  background: #5a67d8;
}

.search-btn {
  background: #667eea;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

.search-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.search-modal.hidden {
  display: none;
}

.search-modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: #333;
}

.search-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.search-panel-body {
  display: flex;
  flex-direction: column;
}

.search-panel-fixed {
  flex-shrink: 0;
}

.search-input-wrapper {
  margin-bottom: 1rem;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 2px solid #e5e7eb;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: #667eea;
}

.search-progress {
  text-align: center;
  padding: 1rem;
  color: #6b7280;
  font-size: 0.875rem;
}

.search-empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: #9ca3af;
}

.search-results-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.search-result-item {
  padding: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.search-result-item:hover {
  background: #f9fafb;
  border-color: #667eea;
}

.search-result-chapter {
  font-size: 0.875rem;
  font-weight: 600;
  color: #667eea;
  margin-bottom: 0.5rem;
}

.search-result-excerpt {
  font-size: 0.875rem;
  color: #374151;
  line-height: 1.5;
}

.search-result-excerpt strong {
  background: #fef3c7;
  color: #92400e;
  padding: 0.125rem 0.25rem;
  border-radius: 2px;
  font-weight: 600;
}

.search-error {
  text-align: center;
  padding: 2rem 1rem;
  color: #ef4444;
}

.reader-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.reader-sidebar {
  width: 300px;
  background: #f8f9fa;
  border-right: 1px solid #dee2e6;
  padding: 20px;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  position: absolute;
  height: calc(100vh - 120px);
  z-index: 10;
}

.reader-sidebar.visible {
  transform: translateX(0);
}

.reader-sidebar h3 {
  margin-top: 0;
  color: #2c3e50;
  font-size: 1.1rem;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-list li {
  margin-bottom: 8px;
}

.toc-list a {
  color: #667eea;
  text-decoration: none;
  display: block;
  padding: 8px 12px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.toc-list a:hover {
  background: #e9ecef;
  color: #5a67d8;
}

.reader-panel-overlay {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.reader-panel-overlay.search-modal-closing {
  opacity: 1;
}

.reader-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.reader-panel-header h2 {
  margin: 0;
  font-size: 1.4rem;
  color: #2c3e50;
}

.reader-panel-close {
  background: transparent;
  border: 1px solid #d1d5db;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  color: #374151;
  font-size: 1rem;
}

.reader-panel-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.reader-panel-section {
  flex: 1;
  min-height: 0;
}

.bookmark-list-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-bottom: 24px;
}

.reader-panel-section .toc-container {
  height: 100%;
  overflow-y: auto;
  padding-bottom: 24px;
}

.bookmark-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}

.bookmark-item:hover {
  border-color: #c7d2fe;
  background: #eef2ff;
}

.bookmark-item:focus-visible {
  outline: 2px solid #5a67d8;
  outline-offset: 0;
  border-color: #5a67d8;
}

.bookmark-item-title {
  font-weight: 600;
  color: #111827;
  margin-bottom: 6px;
}

.bookmark-item-snippet {
  color: #4b5563;
  font-size: 0.95rem;
}

.bookmark-item-meta {
  font-weight: 600;
  color: #5a67d8;
  white-space: nowrap;
}

.bookmark-empty-state {
  color: #6b7280;
  font-size: 1rem;
  text-align: center;
  padding: 40px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.reader-content {
  flex: 1;
  position: relative;
  overflow: hidden;
  padding-top: 44px; /* clear the bookmark ribbon which extends ~40px into content */
  padding-bottom: 10px;
  padding-left: 16px;
  padding-right: 20px; /* slightly larger than left to accommodate attachment margin icons */
  box-sizing: border-box;
}

#epub-viewer {
  width: 100%;
  height: 100%;
}

/* Short highlights often render as HTML overlays (.epubjs-hl). */
.epubjs-hl.bookr-highlight--translation::after,
.epubjs-hl.bookr-highlight--annotated::after,
.epubjs-hl.bookr-attachment::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-bottom: 2px dotted #7a7a7a;
  pointer-events: none;
}

/* Removed highlight with attachments (note/chat/translation) - underline only */
.epubjs-hl.bookr-attachment {
  background-color: transparent !important;
  pointer-events: none;
}

/* Temporary search result highlight - auto-fades after 3 seconds */
.epubjs-hl.search-highlight-temp {
  background-color: rgba(255, 235, 59, 0.4) !important;
  transition: background-color 0.5s ease-out;
  pointer-events: none;
}

/* Multi-line highlights can render as SVG <g> nodes; we inject <line> elements. */
.bookr-translation-underline,
.bookr-annotation-underline,
.bookr-attachment-underline {
  stroke: #7a7a7a;
  stroke-width: 2;
  stroke-dasharray: 4 2;
  pointer-events: none;
}

/* Attachment margin icons — positioned in .reader-content right margin */
.attachment-margin-icon {
  position: absolute;
  right: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: #7a7a7a;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  border-radius: 50%;
  z-index: 10;
  touch-action: manipulation;
  transform: translateY(-25%);
}

.attachment-margin-icon:hover {
  background: rgba(0, 0, 0, 0.06);
}

.attachment-icon-svg {
  width: 18px;
  height: 18px;
}

/* Reading mode variants */
.reading-mode-dark .attachment-margin-icon {
  color: #aaa;
}

.reading-mode-dark .attachment-margin-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}

.reading-mode-sepia .attachment-margin-icon {
  color: #8b7355;
}

/* Attachment icon picker — expands to the left of the count icon */
.attachment-icon-picker {
  position: absolute;
  right: 36px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  padding: 4px 0;
  z-index: 11;
  white-space: nowrap;
}

.attachment-icon-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 12px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  touch-action: manipulation;
  color: #3a3a3a;
  font-size: 13px;
}

.attachment-icon-picker-row:hover {
  background: rgba(0, 0, 0, 0.05);
}

.attachment-icon-picker-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-icon-picker-icon {
  flex-shrink: 0;
  color: #7a7a7a;
}

.reading-mode-dark .attachment-icon-picker {
  background: #2a2a2a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.reading-mode-dark .attachment-icon-picker-row {
  color: #ddd;
}
.reading-mode-dark .attachment-icon-picker-row:hover {
  background: rgba(255, 255, 255, 0.08);
}
.reading-mode-dark .attachment-icon-picker-icon {
  color: #aaa;
}

.reading-mode-sepia .attachment-icon-picker {
  background: #f5efe0;
}
.reading-mode-sepia .attachment-icon-picker-row {
  color: #4a3f2f;
}
.reading-mode-sepia .attachment-icon-picker-icon {
  color: #8b7355;
}

.loading-message, .error-message {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: #666;
}

.loading-message.is-hidden {
  display: none;
}

.error-message {
  color: #dc3545;
  flex-direction: column;
  padding: 20px;
}

.reader-footer {
  padding: 15px 20px 15px;
  background: #f8f9fa;
  border-top: 1px solid #dee2e6;
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 5;
}

.reading-progress {
  display: flex;
  align-items: center;
  gap: 15px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: #e9ecef;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.progress-bar::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  background: #667eea;
  border-radius: 50%;
  cursor: pointer;
}

.progress-bar::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #667eea;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.progress-text {
  font-size: 0.9rem;
  color: #666;
  min-width: 35px;
  text-align: right;
}

/* Action Menu Styles */
.action-menu-popup {
  position: fixed;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  padding: 8px;
  z-index: 1000;
  border: 1px solid #e9ecef;
  width: fit-content;
  max-width: calc(100vw - 12px);
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.1s ease, transform 0.1s ease;
  overflow: hidden;
}

.action-menu-body {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
}

.action-menu-popup.action-menu-popup-docked {
  width: fit-content;
}

.action-menu-popup.action-menu-popup--measure {
  visibility: hidden;
  display: block;
  position: absolute;
  top: -9999px;
  left: -9999px;
}

.action-menu-popup.visible {
  opacity: 1;
  transform: scale(1);
}

.action-menu-popup.hidden {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}

.action-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: transparent;
  pointer-events: auto;
  display: none;
}

.action-menu-backdrop.visible {
  display: block;
}

.action-menu-backdrop.hidden {
  display: none;
}

.offline-notice {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.pwa-install-banner.is-hidden {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

.swipe-debug-hud {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 99999;
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.25;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  border-radius: 8px;
  max-width: 92vw;
  pointer-events: none;
}

.offline-paint-watchdog-active {
  transform: translateZ(0);
}

.action-btn {
  background: transparent;
  color: #4b5563;
  border: 1.5px solid #d1d5db;
  border-radius: 4px;
  padding: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
  min-width: 44px;
  min-height: 44px;
}

.action-btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.action-btn-label {
  display: inline-block;
  max-width: 66px;
  line-height: 1.1;
}

.action-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.action-btn:active {
  background: #e5e7eb;
  border-color: #6b7280;
  transform: translateY(1px);
}

/* Button has existing content (note, translation, chat) */
.action-btn--has-content {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.action-btn--has-content:hover {
  background: #5a67d8;
  border-color: #5a67d8;
}

.action-btn--has-content:active {
  background: #4c51bf;
  border-color: #4c51bf;
}

.highlight-btn {
  background: #28a745;
  color: white;
  border-color: #28a745;
}

.highlight-btn:hover {
  background: #218838;
  border-color: #218838;
}

.highlight-btn:active {
  background: #1e7e34;
  border-color: #1e7e34;
}

.action-btn:disabled {
  background: transparent;
  color: #9ca3af;
  border-color: #e5e7eb;
  cursor: not-allowed;
  opacity: 0.6;
}

.remove-btn {
  background: #dc3545;
  color: white;
  border-color: #dc3545;
}

.remove-btn:hover {
  background: #c82333;
  border-color: #c82333;
}

.remove-btn:active {
  background: #bd2130;
  border-color: #bd2130;
}

/* Translation Modal Styles */
.translation-modal.fixed {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  transition: opacity 0.3s ease;
}

.translation-modal:not(.fixed) {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0;
  transition: opacity 0.3s ease;
}

.translation-modal.visible {
  opacity: 1;
  pointer-events: all;
}

.translation-modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.translation-modal.fixed .translation-modal-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
}

.translation-modal-content {
  background: #fff;
  border-radius: 0;
  box-shadow: none;
  width: 100%;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
}

.translation-modal__summary,
.translation-modal__conversation,
.translation-modal__footer {
  transition: opacity 0.2s ease;
}

.translation-modal__summary {
  flex: 0 0 auto;
  max-height: 40vh;
  overflow-y: auto;
}

.translation-modal__conversation {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.translation-chat {
  background-color: #f8fafc;
}

.translation-chat__header {
  flex: 0 0 auto;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 40vh;
  overflow-y: auto;
}

.translation-chat__closebar,
.modal-closebar {
  display: flex;
  justify-content: flex-end;
}

.translation-chat__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #64748b;
  font-weight: 600;
  margin: 0 0 4px 0;
}

.translation-chat__translated-text {
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.4;
  color: #111827;
  margin: 0;
}

.translation-chat__details {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f8fafc;
  padding: 8px 12px;
}

.translation-chat__details[open] {
  background: #fff;
}

.translation-chat__details-summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  list-style: none;
}

.translation-chat__details-summary::-webkit-details-marker {
  display: none;
}

.translation-chat__details-summary::marker {
  content: "";
}

.translation-chat__details-panel {
  margin-top: 12px;
}

.translation-chat__details-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.translation-chat__details-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #2563eb;
}

.translation-chat__details-text {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
  color: #111827;
  margin-top: 8px;
}

.translation-chat__details-actions {
  display: flex;
  justify-content: flex-end;
}

.translation-chat__messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 16px calc(12px + env(safe-area-inset-bottom) + var(--chat-input-height, 0px));
  background: #f8fafc;
}

.translation-chat__input {
  flex: 0 0 auto;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom) + var(--chat-bottom-offset, 0px));
  position: sticky;
  bottom: 0;
  z-index: 2;
}

@media (max-width: 768px) {
  #translation-modal .translation-modal__summary {
    max-height: 30vh;
    overflow-y: auto;
  }

  .keyboard-open #translation-modal .translation-modal__summary {
    max-height: 20vh;
  }

  .translation-chat__translated-text {
    font-size: 1.05rem;
  }
}

.keyboard-open .translation-chat__header {
  max-height: 25vh;
  padding-bottom: 8px;
}

.keyboard-open .translation-chat__translated-text {
  font-size: 1rem;
}

.keyboard-open .translation-chat__details {
  display: none;
}

.translation-modal-content--inline {
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
}

.translation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid #e2e8f0;
  background-color: #f8f9fa;
  flex-shrink: 0;
}

.translation-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1a202c;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #718096;
  text-decoration: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
}

.modal-close:hover {
  background-color: #f7fafc;
  color: #2d3748;
}

.translation-body {
  padding: 16px 20px 8px 20px;
  flex-shrink: 0;
  border-bottom: 1px solid #e2e8f0;
}

.original-section,
.translation-section {
  margin-bottom: 12px;
}

.translation-section:last-child {
  margin-bottom: 0;
}

.original-section label,
.translation-section label {
  display: block;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 4px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.original-text,
.translated-text {
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 8px 10px;
  margin: 0;
  line-height: 1.4;
  color: #374151;
  font-size: 0.875rem;
  min-height: 60px;
}

.language-selectors {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 0;
  padding: 8px;
  background-color: #f8f9fa;
  border-radius: 6px;
}

.language-select {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background-color: white;
  color: #374151;
  font-size: 0.875rem;
  min-width: 140px;
}

.language-select:focus {
  outline: none;
  border-color: #17a2b8;
  box-shadow: 0 0 0 2px rgba(23, 162, 184, 0.2);
}

.language-arrow {
  font-size: 1.2rem;
  color: #6b7280;
  font-weight: bold;
}

.loading-state {
  text-align: center;
  color: #6b7280;
  font-style: italic;
  padding: 20px;
}

.error-state {
  color: #dc2626;
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 12px;
  margin: 8px 0;
}

/* Conversation container fills remaining space under translation body */
.conversation-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* allow inner scroll area to size correctly */
  overflow: hidden;
}

.conversation-section {
  /* Section that contains the input form, pinned to bottom of modal */
  flex: 0 0 auto;
  display: block;
  padding: 0;
  position: sticky;
  bottom: 0;
  background-color: #f8f9fa;
  z-index: 5;
  padding-bottom: var(--chat-bottom-offset, 0px);
}

.message-input {
  width: 100%;
  min-height: 60px;
  max-height: 120px;
  padding: 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  resize: none;
  font-family: inherit;
  font-size: 0.875rem;
  overflow-wrap: break-word;
  box-sizing: border-box;
  line-height: 1.4;
}

.message-input:focus {
  outline: none;
  border-color: #17a2b8;
  box-shadow: 0 0 0 2px rgba(23, 162, 184, 0.2);
}

.message-input:disabled {
  background-color: #f9fafb;
  color: #9ca3af;
  cursor: not-allowed;
}

.send-btn {
  background-color: #3b82f6;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  font-size: 0.875rem;
  align-self: flex-end;
  min-width: 70px;
  height: 32px;
}

.send-btn:hover:not(:disabled) {
  background-color: #2563eb;
}

.send-btn:disabled {
  background-color: #9ca3af;
  cursor: not-allowed;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .reader-header {
    padding: 10px 15px;
  }

  .book-title h1 {
    font-size: 1rem;
  }

  .reader-sidebar {
    width: 280px;
  }

  .control-btn {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }

  .action-menu-popup {
    padding: 10px;
  }

  .action-btn {
    padding: 12px;
    font-size: 1rem;
  }
}

@media (max-width: 600px) {
  .translation-body {
    padding: 16px 12px 8px 12px;
  }

  .language-selectors {
    flex-direction: column;
    align-items: stretch;
    padding: 8px 0;
    gap: 6px;
  }

  .language-selectors .language-arrow {
    display: none;
  }

  .language-select {
    width: 100%;
    min-width: 0;
  }

  .conversation-content {
    padding: 0 12px 12px;
  }
}

/* Large-display layout (desktop) */
@media (min-width: 1024px) {
  /* Two-column layout for original/translation blocks */
  .translation-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "selectors selectors"
      "original  translation";
    grid-column-gap: 16px;
    grid-row-gap: 12px;
    align-items: start;
  }

  .translation-body .language-selectors { grid-area: selectors; justify-content: center; }
  .translation-body .original-section     { grid-area: original; }
  .translation-body .translation-section  { grid-area: translation; }

  /* Improve visual balance on large screens */
  .original-text,
  .translated-text {
    min-height: 110px;
  }

  /* Visually separate conversation area from the top grid */
  .conversation-content {
    border-top: 1px solid #e5e7eb;
  }
}

/* Translation Conversation Styles (Slice 2) */
.translation-display {
  padding: 20px;
}

.translation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e5e7eb;
}

.language-pair {
  font-weight: 600;
  color: #374151;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  text-decoration: none;
}

.modal-close:hover {
  color: #374151;
  background-color: #f3f4f6;
  border-radius: 4px;
}

.translation-content {
  margin-bottom: 20px;
}

.original-text, .translated-text {
  margin-bottom: 15px;
}

.original-text label, .translated-text label {
  display: block;
  font-weight: 600;
  margin-bottom: 5px;
  color: #374151;
  font-size: 0.875rem;
}

.original-text p, .translated-text p {
  margin: 0;
  padding: 10px;
  background-color: #f9fafb;
  border-left: 3px solid #3b82f6;
  border-radius: 4px;
  color: #1f2937;
}

.conversation-history {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  background-color: white;
  margin: 0;
  min-height: 0;
}

.message {
  margin-bottom: 15px;
  padding: 12px;
  border-radius: 8px;
  max-width: 85%;
}

.message-user {
  background-color: #3b82f6;
  color: white;
  margin-left: auto;
  text-align: right;
}

.message-assistant {
  background-color: #ffffff;
  color: #1f2937;
  border: 1px solid #d1d5db;
  margin-right: auto;
}

.message-role {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 5px;
  opacity: 0.8;
}

.message-content {
  line-height: 1.5;
}

.message-content p {
  margin: 0 0 8px 0;
}

.message-content p:last-child {
  margin-bottom: 0;
}

/* Input form sits at the bottom INSIDE the modal */
.conversation-form {
  position: static;
  width: 100%;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom) + var(--chat-bottom-offset, 0px));
  background-color: #f8f9fa;
  border-top: 1px solid #e5e7eb;
  border-radius: 0 0 12px 12px; /* match modal corners at bottom */
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: none;
}

.conversation-input {
  border-top: 1px solid #e5e7eb;
  padding-top: 20px;
}

.translation-question-input {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.875rem;
  resize: vertical;
  margin-bottom: 10px;
}

.translation-question-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.translation-question-input:disabled {
  background-color: #f3f4f6;
  cursor: not-allowed;
}

.conversation-actions {
  display: flex;
  justify-content: flex-end;
}

.btn.btn-primary {
  background-color: #3b82f6;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.875rem;
}

.btn.btn-primary:hover:not(:disabled) {
  background-color: #2563eb;
}

.btn.btn-primary:disabled {
  background-color: #9ca3af;
  cursor: not-allowed;
}

/* Typing Indicator Styles */
.typing-indicator {
  opacity: 1;
  transition: opacity 0.3s ease;
}

.typing-indicator.fade-out {
  opacity: 0;
}

.typing-animation {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #6b7280;
  font-style: italic;
}

.typing-text {
  font-size: 0.875rem;
}

.typing-dots {
  display: flex;
  gap: 2px;
  align-items: center;
}

.typing-dots .dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: #6b7280;
  animation: typing-bounce 1.4s infinite;
}

.typing-dots .dot:nth-child(1) {
  animation-delay: 0s;
}

.typing-dots .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* Typing indicator specific styling for assistant messages */
.message.message-assistant.typing-indicator {
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  opacity: 0.9;
  animation: fade-in 0.3s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 0.9;
    transform: translateY(0);
  }
}

/* Prevent horizontal scrolling in modal */
.translation-modal-content * {
  box-sizing: border-box;
}

.translation-modal-content {
  overflow-x: hidden;
}

/* Ensure text content doesn't cause horizontal overflow */
.original-text,
.translation-section p,
.message-content {
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

/* Auto-hiding navigation styles */
.navigation-bar {
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
  will-change: transform, opacity;
  transform: translateY(0);
  opacity: 1;
}

.navigation-bar.nav-hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

/* Bottom navigation (footer) slides down instead of up */
.reader-footer.navigation-bar.nav-hidden {
  transform: translateY(100%);
}

/* Navigation bars overlay content instead of taking space */
.reader-header,
.reader-footer {
  z-index: 20;
  position: fixed;
  left: 0;
  right: 0;
}

.reader-header {
  top: 0;
}

.reader-footer {
  bottom: 0;
}

/* Font Size Panel Styles */
.font-size-control {
  position: relative;
  display: inline-block;
}

.font-size-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 8px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 80px;
}

.font-size-panel.hidden {
  display: none;
}

.size-option {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: #374151;
  text-align: center;
  transition: background-color 0.15s, border-color 0.15s;
}

.size-option:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.size-option.is-active {
  background: #667eea;
  border-color: #667eea;
  color: #fff;
}

.size-option.is-active:hover {
  background: #5a67d8;
  border-color: #5a67d8;
}

@media (max-width: 768px) {
  .font-size-panel {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
  }
}

/* Form divider */
.form-divider {
  text-align: center;
  margin: 24px 0;
  position: relative;
}

.form-divider span {
  background: #f5f5f5;
  padding: 0 16px;
  color: #6b7280;
  font-size: 0.875rem;
  position: relative;
  z-index: 1;
}

.form-divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: #e5e7eb;
}

/* Book card states */
.book-card-wrapper {
  position: relative;
}

/* Overlay container — covers full book cover */
.book-offline-download {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

/* Corner badges (downloaded checkmark, retry icon) */
.book-offline-badge {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  color: #10b981;
  pointer-events: auto;
}

.book-offline-badge svg {
  width: 16px;
  height: 16px;
}

.book-offline-badge--retry {
  color: #ef4444;
}

/* Download prompt overlay (not_downloaded / update_available) */
.book-download-prompt {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  color: white;
  pointer-events: auto;
}

.book-download-prompt svg {
  width: 36px;
  height: 36px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

/* Progress ring overlay (downloading) */
.book-download-progress {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  background: rgba(0, 0, 0, 0.55);
}

.book-download-ring {
  width: 72px;
  height: 72px;
}

.book-download-ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 8;
}

.book-download-ring-fill {
  fill: none;
  stroke: white;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 251.3px;
  stroke-dashoffset: calc(251.3px * (1 - var(--download-progress, 0) / 100));
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 0.2s ease;
}

.book-download-progress-text {
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* State-driven visibility */
.book-offline-download[data-offline-download-state="downloaded"] .book-offline-badge--downloaded {
  display: inline-flex;
}

.book-offline-download[data-offline-download-state="failed"] .book-offline-badge--retry {
  display: inline-flex;
}

.book-offline-download[data-offline-download-state="not_downloaded"] .book-download-prompt,
.book-offline-download[data-offline-download-state="update_available"] .book-download-prompt {
  display: flex;
}

.book-offline-download[data-offline-download-state="downloading"] .book-download-progress {
  display: flex;
}

.book-card--downloading,
.book-card--failed {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  background: white;
  border-radius: 8px;
  border: 2px solid #e5e7eb;
}

.book-card--downloading {
  border-color: #3b82f6;
  background: #eff6ff;
}

.book-card--failed {
  border-color: #ef4444;
  background: #fef2f2;
}

.book-status {
  margin-top: 8px;
  font-size: 0.875rem;
  color: #3b82f6;
  font-weight: 500;
}

.book-error {
  margin-top: 8px;
  font-size: 0.875rem;
  color: #ef4444;
  text-align: center;
}

.book-actions {
  margin-top: 12px;
}

.book-placeholder--loading .spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.book-placeholder--error {
  font-size: 3rem;
}

.error-message {
  color: #ef4444;
  font-size: 0.875rem;
  margin-top: 4px;
}
