/* 鲁社长的读书会 - 主题样式 */
:root {
  --color-bg: #f5f0e8;
  --color-bg-alt: #ebe3d5;
  --color-surface: #ffffff;
  --color-primary: #8b4513;
  --color-primary-dark: #6b3410;
  --color-primary-light: #c4956a;
  --color-text: #2c1810;
  --color-text-secondary: #7a6a5c;
  --color-border: #d4c5b0;
  --color-accent: #c0392b;
  --color-success: #27ae60;
  --font-heading: 'Georgia', 'Noto Serif SC', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-lg: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ==================== Header ==================== */
.site-header {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: white;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .logo {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: white;
}

.site-header .logo svg { width: 28px; height: 28px; }

.site-header .nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.site-header .nav-links a,
.site-header .nav-links button {
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: background 0.2s;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.site-header .nav-links a:hover,
.site-header .nav-links button:hover {
  background: rgba(255,255,255,0.15);
  color: white;
}

.reader-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.reader-header .back-home-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-primary-dark);
  font-weight: 700;
  font-size: 1rem;
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  white-space: nowrap;
}

.reader-header .back-home-btn:hover {
  background: #fff8f0;
  color: var(--color-primary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  transform: translateY(-1px);
}

.reader-header .back-home-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.18);
}

.reader-header .reader-title {
  font-size: 0.95rem;
  opacity: 0.9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ==================== Login Page ==================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-bg) 0%, var(--color-bg-alt) 100%);
}

.login-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-card h1 {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  color: var(--color-primary);
  margin-bottom: 4px;
}

.login-card .subtitle {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.login-card .form-group {
  margin-bottom: 20px;
  text-align: left;
}

.login-card label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text);
}

.login-card input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color 0.2s;
  background: var(--color-bg);
  color: var(--color-text);
}

.login-card input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: white;
}

.btn {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  width: 100%;
  padding: 12px;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--color-bg-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-border);
}

.btn-danger {
  background: #e74c3c;
  color: white;
}

.btn-danger:hover {
  background: #c0392b;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.login-card .error-msg {
  color: var(--color-accent);
  font-size: 0.85rem;
  margin-top: 12px;
  display: none;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  background: var(--color-bg);
  padding: 4px;
  border-radius: var(--radius);
}

.auth-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--color-surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.auth-hint {
  text-align: left;
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  background: var(--color-bg);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0 0 16px;
  line-height: 1.5;
}

/* ==================== Bookshelf ==================== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.page-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  margin-bottom: 8px;
  color: var(--color-primary);
}

.page-subtitle {
  color: var(--color-text-secondary);
  margin-bottom: 24px;
}

.auto-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 1px 8px;
  border-radius: 20px;
  background: #e8f5e9;
  color: #2e7d32;
  margin-left: 8px;
  vertical-align: middle;
}

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.book-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  border: 1px solid var(--color-border);
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.book-card .cover {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--color-bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  font-size: 3rem;
}

.book-card .cover-placeholder {
  width: 100%;
  height: 200px;
  background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-primary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 3rem;
  font-family: var(--font-heading);
}

.book-card .info {
  padding: 16px;
}

.book-card .info h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  margin-bottom: 4px;
  color: var(--color-text);
  line-height: 1.3;
}

.book-card .info .author {
  color: var(--color-text-secondary);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.book-card .info .meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.book-card .info .meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== 大书架（整页） ===== */
.bookshelf-page {
  background:
    radial-gradient(ellipse 90% 60% at 50% 0%, rgba(139, 69, 19, 0.1), transparent),
    var(--color-bg);
  overflow: hidden;
}

.bookshelf-page .bookshelf-layout {
  max-width: 1400px;
  height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  padding: 12px 20px 16px;
  margin: 0 auto;
  overflow: hidden;
}

.bookshelf-toolbar {
  flex-shrink: 0;
  margin-bottom: 10px !important;
}

.bookshelf-toolbar .page-title {
  font-size: 1.35rem;
}

.bookshelf-toolbar .page-subtitle {
  font-size: 0.8rem;
  margin-bottom: 0 !important;
}

.bookshelf-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.bookshelf-stage .loading-center,
.bookshelf-stage .empty-state {
  flex: 1;
  padding: 40px 16px;
}

.big-bookshelf {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  padding: 14px;
  background:
    linear-gradient(180deg, #d4b896 0%, #b8956a 8%, #a67c52 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    inset 0 -4px 12px rgba(0, 0, 0, 0.15),
    0 8px 28px rgba(44, 24, 16, 0.18);
}

.big-bookshelf-frame {
  position: absolute;
  inset: 8px;
  border: 2px solid rgba(107, 52, 16, 0.25);
  border-radius: calc(var(--radius-lg) - 4px);
  pointer-events: none;
}

.shelf-grid {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 10px;
}

.shelf-compartment {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(255, 248, 240, 0.55);
  border: 1px solid rgba(107, 52, 16, 0.18);
  border-radius: 8px;
  padding: 8px 10px 0;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.shelf-compartment.drag-over {
  border-color: var(--color-primary);
  background: rgba(255, 255, 255, 0.75);
  box-shadow: inset 0 0 0 2px rgba(139, 69, 19, 0.35);
}

.shelf-compartment.expanded .shelf-compartment-books {
  flex-wrap: wrap;
  align-content: flex-start;
  overflow-y: auto;
}

.shelf-compartment-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.shelf-compartment-name {
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-primary-dark);
}

.shelf-compartment-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  background: rgba(255, 255, 255, 0.7);
  padding: 2px 8px;
  border-radius: 10px;
}

.shelf-compartment-books {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 12px;
  padding: 4px 6px 0;
  overflow: hidden;
}

.shelf-compartment-plank {
  flex-shrink: 0;
  height: 10px;
  margin: 0 -10px;
  margin-top: 4px;
  background: linear-gradient(180deg, #c9a87c 0%, #9a7048 55%, #7d5a38 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -2px 4px rgba(0, 0, 0, 0.2);
  border-radius: 0 0 6px 6px;
}

.shelf-show-more {
  flex-shrink: 0;
  align-self: flex-start;
  margin: 4px 0 6px;
  padding: 3px 10px;
  border: none;
  border-radius: 12px;
  background: rgba(139, 69, 19, 0.12);
  color: var(--color-primary);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.shelf-show-more:hover {
  background: rgba(139, 69, 19, 0.22);
}

.shelf-show-less {
  background: rgba(0, 0, 0, 0.06);
  color: var(--color-text-secondary);
}

/* 平放书籍（立体封面） */
.shelf-flat {
  position: relative;
  flex-shrink: 0;
  width: 112px;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.34, 1.2, 0.64, 1), filter 0.2s;
  filter: drop-shadow(0 6px 10px rgba(44, 24, 16, 0.22));
}

.shelf-flat[draggable="true"] {
  cursor: grab;
}

.shelf-flat[draggable="true"]:active {
  cursor: grabbing;
}

.shelf-flat:hover {
  transform: translateY(-8px) scale(1.03);
  z-index: 4;
  filter: drop-shadow(0 14px 18px rgba(44, 24, 16, 0.32));
}

.shelf-flat.dragging {
  opacity: 0.5;
  transform: scale(0.94);
}

.shelf-flat-stack {
  position: relative;
  padding-right: 7px;
  padding-bottom: 7px;
}

.shelf-flat-pages {
  position: absolute;
  right: 0;
  bottom: 0;
  width: calc(100% - 5px);
  height: calc(100% - 5px);
  border-radius: 2px 4px 3px 2px;
  background:
    repeating-linear-gradient(
      180deg,
      #f8f4ec 0px,
      #f8f4ec 2px,
      #e8e0d4 2px,
      #e8e0d4 3px
    );
  box-shadow:
    2px 3px 6px rgba(0, 0, 0, 0.18),
    inset -1px 0 0 rgba(0, 0, 0, 0.06);
}

.shelf-flat-cover {
  position: relative;
  z-index: 1;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 3px 5px 4px 3px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 0 0 1px rgba(107, 52, 16, 0.2),
    1px 2px 0 rgba(255, 255, 255, 0.25) inset,
    3px 5px 12px rgba(44, 24, 16, 0.25);
}

.shelf-flat-cover::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.22) 0%,
    transparent 35%,
    transparent 65%,
    rgba(0, 0, 0, 0.08) 100%
  );
  pointer-events: none;
  z-index: 2;
}

.shelf-flat-cover.has-image .shelf-flat-letter {
  display: none;
}

.shelf-flat-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.shelf-flat-letter {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.35);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 1;
}

.shelf-flat-cover-title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 72%;
  z-index: 3;
  padding: 10px 6px 8px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(0, 0, 0, 0.5) 40%,
    rgba(0, 0, 0, 0.85) 100%
  );
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.35;
  color: #fff;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
  word-break: break-word;
}

.shelf-flat-cover:not(.has-image) .shelf-flat-cover-title {
  top: 0;
  max-height: none;
  padding: 12px 8px;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.12) 0%,
    rgba(0, 0, 0, 0.45) 100%
  );
  -webkit-line-clamp: 6;
}

.shelf-flat-score {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 4;
  font-size: 0.58rem;
  font-weight: 700;
  color: #8b6914;
  background: rgba(255, 248, 220, 0.95);
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.book-card.compact {
  cursor: grab;
  display: flex;
  gap: 0;
  padding: 0;
  align-items: stretch;
  overflow: hidden;
}

.book-card.compact:active {
  cursor: grabbing;
}

.book-card-main {
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: center;
  flex: 1;
  min-width: 0;
  padding: 10px;
  border-right: 1px solid var(--color-border);
}

.book-highlight-panel {
  width: 42%;
  min-width: 130px;
  max-width: 200px;
  padding: 8px 10px;
  background: linear-gradient(180deg, rgba(139, 69, 19, 0.04) 0%, transparent 100%);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.highlight-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--color-primary);
  letter-spacing: 0.02em;
}

.highlight-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.highlight-item + .highlight-item {
  padding-top: 8px;
  border-top: 1px dashed var(--color-border);
}

.highlight-content {
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--color-text);
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.highlight-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.65rem;
  color: var(--color-text-secondary);
}

.highlight-author {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.highlight-likes {
  flex-shrink: 0;
  color: var(--color-primary);
}

.highlight-empty {
  font-size: 0.72rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
  flex: 1;
  display: flex;
  align-items: center;
}

.book-card.compact.dragging {
  opacity: 0.45;
}

.book-card.compact .cover,
.book-card.compact .cover-placeholder,
.book-card-main .cover,
.book-card-main .cover-placeholder {
  width: 48px;
  height: 64px;
  flex-shrink: 0;
  border-radius: 4px;
  font-size: 1.2rem;
}

.book-card.compact .info,
.book-card-main .info {
  padding: 0;
  flex: 1;
  min-width: 0;
}

.book-card.compact .info h3,
.book-card-main .info h3 {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-card.compact .info .author,
.book-card-main .info .author {
  font-size: 0.75rem;
  margin-bottom: 0;
}

.book-comment-badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--color-text-secondary);
  background: var(--color-bg-alt);
  padding: 1px 6px;
  border-radius: 10px;
}

.book-card.minimal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}

.book-card.minimal:hover {
  background: var(--color-bg-alt);
}

.book-card.minimal.dragging {
  opacity: 0.45;
}

.book-card.minimal .book-title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-card.minimal .book-recommend {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--color-primary);
}

.book-recommend-stars {
  letter-spacing: 1px;
  font-size: 0.75rem;
  line-height: 1;
}

.book-recommend-value {
  font-weight: 700;
  min-width: 1ch;
  text-align: right;
}

.book-recommend-empty {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

.book-comments-panel {
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-alt);
  padding: 8px 10px 10px;
}

.comments-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.comments-panel-count {
  font-size: 0.72rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.comments-panel-link {
  font-size: 0.72rem;
  color: var(--color-primary);
  text-decoration: none;
}

.comments-panel-link:hover {
  text-decoration: underline;
}

.comments-panel-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-comment {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px;
}

.panel-comment-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.panel-comment-author {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text);
}

.panel-comment-page {
  font-size: 0.68rem;
  color: var(--color-primary);
  background: rgba(0, 0, 0, 0.04);
  padding: 1px 5px;
  border-radius: 4px;
}

.panel-comment-time {
  font-size: 0.68rem;
  color: var(--color-text-secondary);
  margin-left: auto;
}

.panel-comment-content {
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--color-text);
  word-break: break-word;
}

.panel-comment-replies {
  margin-top: 6px;
  padding-left: 8px;
  border-left: 2px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.panel-comment-reply {
  font-size: 0.72rem;
  line-height: 1.4;
}

.panel-comment-reply .reply-author {
  font-weight: 600;
  margin-right: 4px;
}

.panel-comment-reply .reply-content {
  color: var(--color-text-secondary);
}

.panel-comment-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.panel-comment-actions .like-btn,
.panel-comment-actions .reply-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  color: var(--color-text-secondary);
  opacity: 0.85;
  transition: opacity 0.2s, background 0.2s, color 0.2s;
}

.panel-comment-actions .like-btn:hover,
.panel-comment-actions .reply-btn:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.05);
}

.panel-comment-actions .like-btn.liked {
  color: var(--color-primary);
  opacity: 1;
}

.panel-reply-form {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-reply-form .panel-reply-name,
.panel-reply-form .panel-reply-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-family: inherit;
  resize: vertical;
}

.panel-reply-form .panel-reply-input:focus,
.panel-reply-form .panel-reply-name:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* ==================== Book Detail Page ==================== */
.book-detail-page {
  max-width: 960px;
  padding-top: 24px;
  padding-bottom: 48px;
}

.book-detail-hero {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 28px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.book-detail-cover img,
.book-detail-cover .cover-placeholder {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.book-detail-cover .cover-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 3rem;
  color: var(--color-primary);
  background: var(--color-bg-alt);
}

.book-detail-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  line-height: 1.3;
  margin-bottom: 8px;
}

.book-detail-author {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.book-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.book-detail-tag {
  font-size: 0.78rem;
  color: var(--color-text-secondary);
  background: var(--color-bg-alt);
  padding: 4px 10px;
  border-radius: 20px;
}

.book-detail-desc {
  font-size: 0.92rem;
  line-height: 1.7;
  margin-bottom: 16px;
  color: var(--color-text);
}

.book-detail-meta {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 16px;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-bottom: 20px;
}

.book-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.book-detail-actions .btn {
  text-decoration: none;
}

.book-detail-comments {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.book-detail-comments-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.book-detail-comments-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.book-detail-comments-header h2 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  margin: 0;
}

.book-detail-comments-title span,
.comments-mode-label {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.book-detail-comments-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.comments-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.comments-page-info {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  min-width: 72px;
  text-align: center;
}

.comments-pagination .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.book-detail-comment-form {
  margin-bottom: 20px;
}

.book-detail-login-prompt {
  margin-bottom: 20px;
  padding: 20px;
  text-align: center;
  background: var(--color-bg);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
}

.book-detail-login-prompt p {
  margin: 0 0 12px;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

.book-detail-empty-comments {
  text-align: center;
  padding: 32px 16px;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .book-detail-hero {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .book-detail-cover {
    max-width: 160px;
    margin: 0 auto;
  }

  .book-detail-meta {
    grid-template-columns: 1fr;
  }
}

.book-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.book-card-actions button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  opacity: 0.5;
  transition: opacity 0.2s, background 0.2s;
}

.book-card-actions button:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

.book-more-menu {
  position: relative;
}

.book-more-menu .more-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.2s, background 0.2s;
}

.book-more-menu .more-btn:hover,
.book-more-menu.open .more-btn {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

.book-more-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  min-width: 120px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 20;
  overflow: hidden;
}

.book-more-menu.open .book-more-dropdown {
  display: block;
}

.book-more-dropdown a,
.book-more-dropdown button {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  text-align: left;
  font-size: 0.85rem;
  color: var(--color-text);
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}

.book-more-dropdown a:hover,
.book-more-dropdown button:hover {
  background: var(--color-bg-alt);
}

.book-more-dropdown .menu-delete {
  color: var(--color-accent);
  border-top: 1px solid var(--color-border);
}

.book-more-dropdown .menu-delete:hover {
  background: rgba(231, 76, 60, 0.08);
}

.book-more-dropdown .menu-download[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.category-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.category-tab {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.category-tab:hover {
  border-color: var(--color-primary);
}

.category-tab.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.delete-modal .modal-content {
  max-width: 400px;
  width: 90%;
}

.delete-modal input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-top: 8px;
  font-size: 0.95rem;
}

.delete-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.category-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.category-tag-option {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.category-tag-option.selected {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.category-tag-option.auto-hint {
  border-style: dashed;
  opacity: 0.85;
}

/* ==================== Search & Toolbar ==================== */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 400px;
}

.search-box input {
  flex: 1;
  padding: 8px 14px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: var(--color-surface);
  color: var(--color-text);
}

.search-box input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.search-box button {
  padding: 8px 16px;
}

/* ==================== Reader Page ==================== */
.reader-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 0;
  height: calc(100vh - 60px);
}

.reader-main {
  display: flex;
  flex-direction: column;
  background: #3c3c3c;
  position: relative;
  overflow: hidden;
}

.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #2c2c2c;
  color: #ccc;
  font-size: 0.85rem;
}

.reader-toolbar .page-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reader-toolbar .page-info input {
  width: 60px;
  padding: 4px 8px;
  border: 1px solid #555;
  border-radius: 4px;
  background: #444;
  color: white;
  text-align: center;
  font-size: 0.85rem;
}

.reader-toolbar button {
  background: #555;
  color: #ccc;
  border: none;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.reader-toolbar button:hover {
  background: #666;
  color: white;
}

.pdf-container {
  flex: 1;
  overflow: auto;
  padding: 16px;
}

.pdf-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding-bottom: 24px;
}

.pdf-page canvas {
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.reader-sidebar {
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-tabs button {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.sidebar-tabs button.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* ==================== Comments ==================== */
.comment-form {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.comment-form textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  resize: vertical;
  font-family: inherit;
  margin-bottom: 8px;
  background: var(--color-bg);
  color: var(--color-text);
}

.comment-form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  background: white;
}

.comment-form .form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.comment-form .form-row label {
  font-size: 0.85rem;
  font-weight: 600;
}

.comment-form .form-row input[type="number"] {
  width: 80px;
  padding: 6px 8px;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.85rem;
}

.comment-form .screenshot-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.comment-form .screenshot-area .preview {
  max-width: 120px;
  max-height: 80px;
  border-radius: 4px;
  display: none;
}

.comment-item {
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: var(--color-bg);
}

.comment-item .header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.8rem;
}

.comment-item .header .user {
  font-weight: 600;
  color: var(--color-primary);
}

.comment-item .header .page-tag {
  background: var(--color-primary-light);
  color: white;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
}

.comment-item .header .time {
  color: var(--color-text-secondary);
}

.comment-item .content {
  font-size: 0.9rem;
  margin-bottom: 8px;
  line-height: 1.5;
}

.comment-item .screenshot {
  max-width: 100%;
  max-height: 200px;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.2s;
}

.comment-item .screenshot:hover {
  transform: scale(1.02);
}

.comment-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.like-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  transition: color 0.2s, background 0.2s;
}

.like-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.like-btn.liked {
  color: var(--color-primary);
}

.reply-toggle-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 0;
}

.reply-toggle-btn:hover {
  text-decoration: underline;
}

.comment-replies {
  margin-top: 10px;
  padding-left: 12px;
  border-left: 2px solid var(--color-border);
}

.comment-reply {
  padding: 8px 0;
}

.comment-reply + .comment-reply {
  border-top: 1px solid var(--color-border);
}

.comment-reply .reply-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  margin-bottom: 4px;
}

.comment-reply .reply-header .user {
  font-weight: 600;
  color: var(--color-primary);
}

.comment-reply .reply-header .time {
  color: var(--color-text-secondary);
}

.comment-reply .reply-content {
  font-size: 0.85rem;
  line-height: 1.5;
}

.reply-form {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--color-border);
}

.reply-form .reply-display-name {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.reply-form .reply-content-input {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.85rem;
  resize: vertical;
  font-family: inherit;
  margin-bottom: 6px;
}

.comment-form .form-row input[type="text"] {
  padding: 6px 8px;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.85rem;
}

/* ==================== Upload Page ==================== */
.upload-form {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 32px;
  max-width: 600px;
  margin: 0 auto;
  border: 1px solid var(--color-border);
}

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

.upload-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text);
}

.upload-form input,
.upload-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: inherit;
}

.upload-form input:focus,
.upload-form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  background: white;
}

.upload-form textarea {
  min-height: 100px;
  resize: vertical;
}

.upload-form .file-input {
  border: 2px dashed var(--color-border);
  padding: 24px;
  text-align: center;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  background: var(--color-bg);
}

.upload-form .file-input:hover {
  border-color: var(--color-primary);
  background: var(--color-bg-alt);
}

.upload-form .file-input .icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.upload-form .file-input .hint {
  color: var(--color-text-secondary);
  font-size: 0.85rem;
}

.upload-form .progress-bar {
  width: 100%;
  height: 8px;
  background: var(--color-border);
  border-radius: 4px;
  margin-top: 12px;
  overflow: hidden;
  display: none;
}

.upload-form .progress-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
  border-radius: 4px;
  transition: width 0.15s ease-out;
  width: 0%;
}

.upload-panel {
  display: none;
  text-align: center;
  padding: 32px 16px;
}

.upload-panel.active {
  display: block;
}

.upload-panel .upload-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.upload-panel .upload-filename {
  font-weight: 600;
  margin-bottom: 4px;
  word-break: break-all;
}

.upload-panel .upload-stage {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.upload-panel .progress-percent {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
  font-family: var(--font-heading);
  margin-top: 8px;
}

.upload-success {
  display: none;
  text-align: center;
  padding: 32px 16px;
}

.upload-success.active {
  display: block;
}

.upload-success .success-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.upload-success .success-title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  color: var(--color-success);
  margin-bottom: 8px;
}

.upload-success .success-meta {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.upload-success .success-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.upload-form-body.hidden {
  display: none;
}

.upload-form-wide {
  max-width: 720px;
}

.batch-queue {
  margin-bottom: 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  overflow: hidden;
}

.batch-queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.85rem;
  font-weight: 600;
}

.batch-file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
}

.batch-file-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
}

.batch-file-item:last-child {
  border-bottom: none;
}

.batch-file-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.format-badge {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--color-primary);
  color: white;
}

.batch-title-input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.9rem;
}

.batch-file-size {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.batch-file-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.batch-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-remove-btn {
  margin-left: auto;
  flex-shrink: 0;
  border: none;
  background: none;
  color: var(--color-accent);
  cursor: pointer;
  font-size: 0.8rem;
}

.batch-result-list {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  text-align: left;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.batch-result-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.batch-result-list li.fail .batch-result-status {
  color: var(--color-accent);
}

.batch-result-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-result-status {
  flex-shrink: 0;
  font-size: 0.85rem;
}

.optional-fields {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0;
  margin-bottom: 20px;
  background: var(--color-bg);
}

.optional-fields summary {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  user-select: none;
  list-style: none;
}

.optional-fields summary::-webkit-details-marker {
  display: none;
}

.optional-fields summary::before {
  content: '▸ ';
}

.optional-fields[open] summary::before {
  content: '▾ ';
}

.optional-fields .optional-inner {
  padding: 0 16px 16px;
  border-top: 1px solid var(--color-border);
}

.title-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.title-preview .title-text {
  flex: 1;
  font-weight: 600;
  font-family: var(--font-heading);
}

.title-preview .title-edit {
  font-size: 0.8rem;
  color: var(--color-primary);
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  white-space: nowrap;
}

.title-preview.editing {
  display: none;
}

/* ==================== Modal ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content img {
  max-width: 100%;
  border-radius: var(--radius);
}

.modal-close {
  float: right;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-secondary);
}

/* ==================== Empty State ==================== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--color-text-secondary);
}

.empty-state .icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: var(--color-text);
}

/* ==================== Toast Notification ==================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--color-text);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { background: var(--color-success); }
.toast.error { background: var(--color-accent); }

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
  .reader-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .reader-sidebar {
    max-height: 50vh;
    border-left: none;
    border-top: 1px solid var(--color-border);
  }

  .books-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
  }

  .book-card .cover,
  .book-card .cover-placeholder {
    height: 140px;
  }

  .container { padding: 16px; }
  .login-card { margin: 16px; }

  .bookshelf-page .bookshelf-layout {
    height: auto;
    min-height: calc(100vh - 60px);
    overflow: visible;
  }

  .shelf-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, minmax(160px, 1fr));
  }

  .shelf-flat {
    width: 96px;
  }

  .shelf-flat-cover-title {
    font-size: 0.65rem;
    -webkit-line-clamp: 3;
  }
}

/* ==================== Loading Spinner ==================== */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}

/* ==================== Admin Panel ==================== */
.admin-layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.admin-header {
  margin-bottom: 24px;
}

.admin-header h1 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  color: var(--color-primary);
  margin-bottom: 4px;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.admin-tab {
  padding: 8px 16px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  transition: all 0.2s;
}

.admin-tab:hover {
  border-color: var(--color-primary-light);
  color: var(--color-primary);
}

.admin-tab.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.admin-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 999px;
  background: #e74c3c;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}

.admin-tab.active .admin-tab-badge {
  background: #fff;
  color: var(--color-primary);
}

.access-request-highlight td {
  background: rgba(139, 69, 19, 0.12) !important;
  animation: access-request-pulse 1.2s ease-in-out 2;
}

@keyframes access-request-pulse {
  0%, 100% { background: rgba(139, 69, 19, 0.12); }
  50% { background: rgba(139, 69, 19, 0.22); }
}

.admin-notify-wrap {
  position: relative;
}

.admin-notify-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
  color: white;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.admin-notify-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.admin-notify-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #e74c3c;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.admin-notify-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(320px, calc(100vw - 32px));
  max-height: 360px;
  overflow: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
}

.admin-notify-head {
  padding: 12px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-primary-dark);
  border-bottom: 1px solid var(--color-border);
}

.admin-notify-list {
  display: flex;
  flex-direction: column;
}

.admin-notify-item {
  display: block;
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--color-border);
  transition: background 0.15s;
}

.admin-notify-item:last-child {
  border-bottom: none;
}

.admin-notify-item:hover {
  background: var(--color-bg);
}

.admin-notify-item-title {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.4;
  margin-bottom: 4px;
}

.admin-notify-item-body {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  line-height: 1.45;
  margin-bottom: 4px;
}

.admin-notify-item-time {
  display: block;
  font-size: 0.72rem;
  color: var(--color-text-secondary);
}

.admin-notify-empty {
  padding: 20px 14px;
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  text-align: center;
}

.admin-notify-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 300;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--color-primary-dark);
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  transition: opacity 0.2s, transform 0.2s;
}

.admin-notify-toast:hover {
  background: var(--color-primary);
  color: #fff;
}

.admin-notify-toast[hidden] {
  display: none;
}

.admin-panel {
  display: none;
}

.admin-panel.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

.stat-card .label {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-primary);
  font-family: var(--font-heading);
}

.admin-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  margin-bottom: 20px;
}

.admin-card h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: var(--color-text);
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.admin-table th {
  color: var(--color-text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover td {
  background: var(--color-bg);
}

.admin-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--color-bg-alt);
  color: var(--color-text-secondary);
}

.admin-badge.admin {
  background: rgba(139, 69, 19, 0.12);
  color: var(--color-primary);
}

.daily-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 120px;
  padding-top: 8px;
}

.daily-bar {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.daily-bar .bar {
  width: 100%;
  max-width: 48px;
  background: linear-gradient(180deg, var(--color-primary-light), var(--color-primary));
  border-radius: 4px 4px 0 0;
  min-height: 4px;
}

.daily-bar .day {
  font-size: 0.7rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.admin-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.admin-toolbar input {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: inherit;
}

.admin-toolbar .admin-select {
  min-width: 140px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
}

.btn-danger {
  background: var(--color-accent);
  color: white;
  border: none;
}

.btn-danger:hover {
  filter: brightness(0.92);
}

.btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==================== Forum / 交流广场 ==================== */
.forum-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100vh;
  overflow: hidden;
}

.forum-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1200px;
  min-height: 0;
  overflow-y: auto;
}

.forum-toolbar {
  margin-bottom: 8px;
}

.forum-field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.forum-category-picker {
  margin-bottom: 12px;
}

.forum-category-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(139, 69, 19, 0.1);
  color: var(--color-primary);
  font-size: 0.75rem;
  font-weight: 600;
}

.forum-post-head {
  margin-bottom: 10px;
}

.forum-post-head .forum-post-title {
  margin-top: 8px;
  margin-bottom: 0;
}

.forum-thread-meta .forum-category-badge {
  flex-shrink: 0;
}

.forum-toolbar .page-subtitle {
  margin-bottom: 0;
}

.forum-posts-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.forum-posts-area .forum-thread-list,
.forum-posts-area .forum-empty-state,
.forum-posts-area .empty-state {
  flex: 1;
  width: 100%;
}

.forum-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  padding: 14px 22px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  font-size: 1rem;
  border: none;
}

.forum-compose-overlay .forum-compose-modal {
  max-width: 640px;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.forum-compose-overlay .forum-compose.card {
  margin-bottom: 0;
  box-shadow: var(--shadow-lg);
}

.forum-compose-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.forum-compose-head .forum-compose-title {
  margin-bottom: 0;
}

.forum-compose.card,
.forum-thread-list.card,
.forum-post-card,
.forum-replies-section,
.forum-empty-state.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.forum-compose.card,
.forum-post-card,
.forum-replies-section {
  padding: 20px 24px;
}

.forum-compose-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  margin-bottom: 12px;
  color: var(--color-primary-dark);
}

.forum-login-hint {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

.forum-login-hint a {
  color: var(--color-primary);
  font-weight: 600;
}

.forum-input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  margin-bottom: 10px;
  font-family: inherit;
}

.forum-input:focus,
.forum-textarea:focus {
  outline: none;
  border-color: var(--color-primary-light);
}

.forum-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
  line-height: 1.5;
}

.forum-compose-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.forum-compose-tip {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  flex: 1;
}

.forum-file-btn {
  cursor: pointer;
}

.forum-image-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.forum-image-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
}

.forum-image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.forum-image-pending {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  color: white;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.forum-image-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.forum-thread-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.forum-thread-item {
  display: flex;
  align-items: stretch;
  gap: 16px;
  padding: 18px 20px;
  text-decoration: none;
  color: inherit;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.forum-thread-item:hover {
  background: var(--color-bg);
  border-color: var(--color-primary-light);
  box-shadow: var(--shadow-md);
}

.forum-thread-main {
  flex: 1;
  min-width: 0;
}

.forum-thread-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--color-text);
  line-height: 1.4;
}

.forum-thread-preview {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
  line-height: 1.45;
}

.forum-thread-meta {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.forum-thread-meta .author {
  color: var(--color-primary);
  font-weight: 600;
}

.forum-thread-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.forum-post-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  line-height: 1.35;
  margin-bottom: 10px;
}

.forum-post-meta {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.forum-post-meta .author {
  color: var(--color-primary);
  font-weight: 600;
}

.forum-post-content {
  font-size: 0.95rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.forum-post-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.forum-post-images img {
  max-width: 100%;
  max-height: 280px;
  border-radius: var(--radius);
  cursor: pointer;
  object-fit: cover;
}

.forum-replies-heading {
  font-size: 0.95rem;
  margin-bottom: 12px;
  color: var(--color-primary-dark);
}

.forum-replies-list {
  border-top: 1px solid var(--color-border);
}

.forum-reply-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.forum-reply-item:last-child {
  border-bottom: none;
}

.forum-reply-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  margin-bottom: 6px;
  gap: 8px;
}

.forum-reply-header .author {
  font-weight: 600;
  color: var(--color-primary);
}

.forum-reply-header .time {
  color: var(--color-text-secondary);
}

.forum-reply-content {
  font-size: 0.9rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.forum-reply-image {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius);
  margin-top: 8px;
  cursor: pointer;
}

.forum-empty-replies {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  padding: 8px 0;
}

.forum-reply-bar {
  flex-shrink: 0;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  padding: 12px 24px calc(16px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 640px) {
  .forum-fab {
    right: 16px;
    bottom: 16px;
    padding: 12px 18px;
  }

  .forum-reply-bar {
    max-width: none;
    border-radius: 0;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  }
}

.social-links a {
  color: var(--color-primary);
  text-decoration: none;
}

.social-links a:hover {
  text-decoration: underline;
}

/* ==================== 首页横幅通知 ==================== */
.site-banner {
  background: linear-gradient(135deg, #fff8e7 0%, #fef3d9 100%);
  border-bottom: 1px solid #e8d5a8;
  color: #4a3f2a;
}

.site-banner-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.site-banner-content {
  flex: 1;
  min-width: 0;
}

.site-banner-title {
  margin: 0 0 8px;
  font-weight: 700;
  font-size: 1rem;
}

.site-banner-list {
  margin: 0;
  padding-left: 1.2em;
  font-size: 0.92rem;
  line-height: 1.65;
}

.site-banner-list li + li {
  margin-top: 4px;
}

.site-banner-list a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

.site-banner-list a:hover {
  text-decoration: underline;
}

.site-banner-list code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
}

.site-banner-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  color: #6b5a3e;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}

.site-banner-close:hover {
  background: rgba(0, 0, 0, 0.12);
}

@media (max-width: 640px) {
  .site-banner-inner {
    padding: 12px 16px;
  }

  .site-banner-list {
    font-size: 0.86rem;
  }
}

/* ==================== 打赏 / Telegram 联系作者 ==================== */
.coffee-support-fab {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 85;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, #6f4e37 0%, #4a3228 100%);
  color: #fff8f0;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(74, 50, 40, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}

.coffee-support-fab:hover {
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(74, 50, 40, 0.45);
}

.coffee-support-fab-icon {
  font-size: 1.15rem;
  line-height: 1;
}

@media (max-width: 640px) {
  .coffee-support-fab {
    left: 16px;
    bottom: 16px;
    padding: 10px 14px;
    font-size: 0.85rem;
  }

  .coffee-support-fab-text {
    max-width: 7em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.book-lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--color-accent);
  background: rgba(139, 69, 19, 0.08);
  padding: 2px 8px;
  border-radius: 999px;
}

.book-card .book-lock-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
}

.book-card .cover-wrap {
  position: relative;
}

.book-access-gate {
  margin: 16px 0;
  padding: 20px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-alt);
}

.book-access-gate p {
  margin: 0 0 12px;
  color: var(--color-text-secondary);
  font-size: 0.95rem;
}

.book-access-hint {
  font-size: 0.85rem !important;
  color: var(--color-text-secondary);
  opacity: 0.9;
}

.book-access-screen {
  min-height: 50vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.book-access-screen-inner {
  max-width: 480px;
  width: 100%;
  text-align: center;
  padding: 32px 24px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-alt);
}

.admin-password-modal .modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-password-modal label {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

.admin-password-modal input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.admin-password-modal .hint {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.admin-share-actions,
.admin-row-actions {
  white-space: nowrap;
}

.admin-share-actions .btn,
.admin-row-actions .btn {
  margin: 2px 0;
}

.admin-share-actions .btn + .btn {
  margin-left: 4px;
}
