/* ========== 阅读器简洁风格 ========== */

/* 主题变量 */
:root {
  --nt-parchment: #f5f4ed;
  --nt-ivory: #faf9f5;
  --nt-pure-white: #ffffff;
  --nt-warm-sand: #e8e6dc;
  --nt-border-cream: #f0eee6;
  --nt-near-black: #141413;
  --nt-charcoal: #4d4c48;
  --nt-olive-gray: #5e5d59;
  --nt-stone-gray: #87867f;
  --nt-warm-silver: #b0aea5;
  --nt-dark-surface: #30302e;
  --nt-deep-dark: #141413;
  --nt-terracotta: #c96442;
  --nt-coral: #d97757;
  --nt-error: #b53333;
  --nt-serif: Georgia, "Times New Roman", "思源宋体", "SimSun", serif;
  --nt-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

.novel-theme-light {
  --reader-bg: var(--nt-parchment);
  --reader-text: var(--nt-near-black);
  --reader-text-secondary: var(--nt-olive-gray);
  --reader-heading: var(--nt-near-black);
  --reader-border: var(--nt-border-cream);
  --reader-toolbar-bg: rgba(250, 249, 245, 0.95);
  --reader-btn-bg: transparent;
  --reader-btn-hover: var(--nt-warm-sand);
  --reader-link: var(--nt-terracotta);
  --reader-shadow: rgba(20, 20, 19, 0.08);
  --reader-accent: var(--nt-terracotta);
}

.novel-theme-sepia {
  --reader-bg: #ebe8dc;
  --reader-text: #4a463d;
  --reader-text-secondary: #6b6658;
  --reader-heading: #3d3a32;
  --reader-border: #d6d2c4;
  --reader-toolbar-bg: rgba(235, 232, 220, 0.95);
  --reader-btn-bg: transparent;
  --reader-btn-hover: #dcd8c8;
  --reader-link: #9d5a3c;
  --reader-shadow: rgba(61, 58, 50, 0.08);
  --reader-accent: #9d5a3c;
}

.novel-theme-eyecare {
  --reader-bg: #e8ece8;
  --reader-text: #2d3a2d;
  --reader-text-secondary: #5a6a5a;
  --reader-heading: #1a2e1a;
  --reader-border: #c8d4c8;
  --reader-toolbar-bg: rgba(232, 236, 232, 0.95);
  --reader-btn-bg: transparent;
  --reader-btn-hover: #d4dcd4;
  --reader-link: #3d6b4d;
  --reader-shadow: rgba(26, 46, 26, 0.06);
  --reader-accent: #3d6b4d;
}

.novel-theme-dark {
  --reader-bg: #1a1a18;
  --reader-text: #e8e6dc;
  --reader-text-secondary: #9a9890;
  --reader-heading: #f5f4ed;
  --reader-border: #3d3d3a;
  --reader-toolbar-bg: rgba(26, 26, 24, 0.95);
  --reader-btn-bg: transparent;
  --reader-btn-hover: #3d3d3a;
  --reader-link: var(--nt-coral);
  --reader-shadow: rgba(0, 0, 0, 0.3);
  --reader-accent: var(--nt-coral);
}

.novel-theme-paper {
  --reader-bg: #fcfaf6;
  --reader-text: #3d3c3a;
  --reader-text-secondary: #6d6c68;
  --reader-heading: #2a2a28;
  --reader-border: #e8e4d8;
  --reader-toolbar-bg: rgba(252, 250, 246, 0.95);
  --reader-btn-bg: transparent;
  --reader-btn-hover: #f2eee4;
  --reader-link: #8b5a45;
  --reader-shadow: rgba(45, 44, 42, 0.05);
  --reader-accent: #8b5a45;
}

/* 动画 */
@keyframes nt-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes nt-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes nt-slide-down { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ========== 覆盖层 ========== */
#extreme-reader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100dvh;
  background: var(--reader-bg);
  z-index: 999999;
  overflow-y: scroll;
  overflow-x: hidden;
  font-family: var(--nt-serif);
  display: block !important;
  animation: nt-fade-in 0.25s ease-out;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#extreme-reader-overlay::-webkit-scrollbar { width: 6px; }
#extreme-reader-overlay::-webkit-scrollbar-track { background: transparent; }
#extreme-reader-overlay::-webkit-scrollbar-thumb { background: var(--nt-warm-silver); border-radius: 3px; }
#extreme-reader-overlay { scrollbar-width: thin; scrollbar-color: var(--nt-warm-silver) transparent; }

/* ========== 顶部工具栏 ========== */
.reader-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: var(--reader-toolbar-bg);
  border-bottom: 1px solid var(--reader-border);
  z-index: 1000000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  height: 48px;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: transform 0.25s ease-out, opacity 0.25s ease-out;
}

.reader-toolbar.hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.reader-toolbar-left,
.reader-toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 返回按钮 */
.reader-back-button {
  background: transparent;
  color: var(--reader-text-secondary);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.15s ease;
  padding: 0;
}

.reader-back-button:hover {
  background: var(--reader-btn-hover);
  color: var(--reader-text);
}

/* 文章标题 */
.reader-toolbar-title {
  font-family: var(--nt-serif);
  font-size: 14px;
  font-weight: 500;
  color: var(--reader-text);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-left: 4px;
}

/* 工具栏按钮 */
.reader-icon-button {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--reader-btn-bg);
  color: var(--reader-text-secondary);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all 0.15s ease;
  position: relative;
  padding: 0;
}

.reader-icon-button:hover {
  background: var(--reader-btn-hover);
  color: var(--reader-text);
}

.reader-icon-button.active {
  color: var(--reader-accent);
}

/* A⁻ A⁺ 字体按钮 */
.reader-icon-button .font-label {
  font-family: var(--nt-serif);
  font-weight: 600;
  font-size: 16px;
  line-height: 1;
}

.reader-icon-button .font-minus {
  font-size: 10px;
  position: relative;
  top: -3px;
}

.reader-icon-button .font-plus {
  font-size: 10px;
  position: relative;
  top: -5px;
}

/* ========== 进度条 ========== */
.reader-progress-bar {
  position: fixed;
  top: 48px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--reader-border);
  z-index: 999999;
}

.reader-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--reader-accent);
  transition: width 0.15s ease-out;
}

/* ========== 浮动设置面板 ========== */
.reader-settings-panel {
  position: fixed;
  top: 52px;
  right: 16px;
  width: 320px;
  max-height: calc(100dvh - 120px);
  background: var(--reader-bg);
  border: 1px solid var(--reader-border);
  border-radius: 12px;
  box-shadow: 0 8px 32px var(--reader-shadow), 0 0 0 1px rgba(0,0,0,0.03);
  z-index: 1000001;
  overflow-y: auto;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.98);
  transition: all 0.2s ease-out;
  transform-origin: top right;
}

.reader-settings-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* 设置面板分区 */
.settings-section {
  margin-bottom: 16px;
}

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

.settings-section-title {
  font-family: var(--nt-sans);
  font-size: 11px;
  font-weight: 600;
  color: var(--reader-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.settings-divider {
  height: 1px;
  background: var(--reader-border);
  margin: 12px 0;
}

/* 主题选项 */
.theme-options {
  display: flex;
  gap: 6px;
}

.theme-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border: 1px solid var(--reader-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 10px;
  color: var(--reader-text-secondary);
  background: transparent;
}

.theme-option:hover {
  background: var(--reader-btn-hover);
}

.theme-option.active {
  border-color: var(--reader-accent);
  color: var(--reader-accent);
  background: var(--reader-btn-hover);
}

.theme-option i {
  font-size: 16px;
}

/* 字体选项 */
.font-options {
  display: flex;
  gap: 6px;
}

.font-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 1px solid var(--reader-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 14px;
  color: var(--reader-text-secondary);
  background: transparent;
}

.font-option:hover {
  background: var(--reader-btn-hover);
}

.font-option.active {
  border-color: var(--reader-accent);
  color: var(--reader-accent);
  background: var(--reader-btn-hover);
}

/* 滑块 */
.slider-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-control input[type="range"] {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--reader-border);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

.slider-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--reader-accent);
  cursor: pointer;
  border: 2px solid var(--reader-bg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.slider-control input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--reader-accent);
  cursor: pointer;
  border: 2px solid var(--reader-bg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.slider-value {
  font-family: var(--nt-sans);
  font-size: 12px;
  color: var(--reader-text-secondary);
  min-width: 48px;
  text-align: right;
}

/* 对齐选项 */
.align-options {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.align-option {
  width: 36px;
  height: 32px;
  border: 1px solid var(--reader-border);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--reader-text-secondary);
  background: transparent;
  transition: all 0.15s ease;
}

.align-option:hover {
  background: var(--reader-btn-hover);
}

.align-option.active {
  border-color: var(--reader-accent);
  color: var(--reader-accent);
}

/* 复选框 */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--reader-text);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--reader-accent);
}

/* 功能按钮 */
.settings-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--reader-text);
  cursor: pointer;
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--nt-sans);
  transition: background 0.15s ease;
  margin-bottom: 2px;
}

.settings-action-btn:hover {
  background: var(--reader-btn-hover);
}

.settings-action-btn i {
  font-size: 16px;
  color: var(--reader-text-secondary);
}

/* 遮罩层 */
.reader-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1000000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.reader-backdrop.visible {
  opacity: 1;
  visibility: visible;
}

/* ========== 翻译悬浮按钮 ========== */
.reader-translate-fab {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1px solid var(--reader-border);
  border-radius: 20px;
  background: var(--reader-toolbar-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--reader-text);
  cursor: pointer;
  font-size: 13px;
  font-family: var(--nt-sans);
  font-weight: 500;
  z-index: 1000001;
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px var(--reader-shadow);
}

.reader-translate-fab:hover {
  border-color: var(--reader-accent);
  box-shadow: 0 6px 24px var(--reader-shadow);
  transform: translateX(-50%) translateY(-1px);
}

.reader-translate-fab.active {
  border-color: var(--reader-accent);
  color: var(--reader-accent);
}

.reader-translate-fab i {
  font-size: 16px;
}

/* ========== 目录侧边栏 ========== */
.reader-toc-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  max-width: 85%;
  height: 100%;
  background: var(--reader-bg);
  border-right: 1px solid var(--reader-border);
  z-index: 1000002;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  box-shadow: 4px 0 24px var(--reader-shadow);
}

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

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--reader-border);
  position: sticky;
  top: 0;
  background: var(--reader-bg);
}

.toc-title {
  font-weight: 600;
  color: var(--reader-heading);
  font-size: 14px;
}

.toc-close-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--reader-text-secondary);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.toc-close-btn:hover {
  background: var(--reader-btn-hover);
}

.toc-content {
  padding: 8px 0;
}

.toc-item {
  padding: 10px 16px;
  color: var(--reader-text);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  border-left: 2px solid transparent;
  font-size: 13px;
  display: block;
}

.toc-item:hover {
  background: var(--reader-btn-hover);
  border-left-color: var(--reader-accent);
}

.toc-item.active {
  background: var(--reader-btn-hover);
  border-left-color: var(--reader-accent);
  color: var(--reader-accent);
}

.toc-h1 { padding-left: 16px; font-weight: 600; }
.toc-h2 { padding-left: 28px; }
.toc-h3 { padding-left: 40px; }

/* ========== 内容区域 ========== */
.reader-content-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* ========== 文章样式 ========== */
.reader-article {
  font-family: var(--nt-serif);
  font-size: 18px;
  line-height: 1.8;
  color: var(--reader-text);
}

.reader-article h1 {
  font-size: 2em;
  font-weight: 500;
  color: var(--reader-heading);
  margin: 0.6em 0 0.4em;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.reader-article h2 {
  font-size: 1.4em;
  font-weight: 500;
  color: var(--reader-heading);
  margin: 1.2em 0 0.6em;
  line-height: 1.35;
}

.reader-article h3 {
  font-family: var(--nt-sans);
  font-size: 1.15em;
  font-weight: 600;
  color: var(--reader-heading);
  margin: 1em 0 0.5em;
}

.reader-article p {
  margin: 1em 0;
  text-align: justify;
  hyphens: auto;
}

.reader-article a {
  color: var(--reader-link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.reader-article a:hover {
  opacity: 0.8;
}

.reader-article blockquote {
  margin: 1.2em 0;
  padding: 0.8em 1.2em;
  border-left: 3px solid var(--reader-accent);
  background: var(--nt-ivory);
  color: var(--reader-text-secondary);
  font-style: italic;
  border-radius: 0 6px 6px 0;
}

.reader-article img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.2em auto;
  border-radius: 6px;
  cursor: zoom-in;
}

.reader-article pre {
  background: var(--nt-ivory);
  padding: 1em;
  overflow-x: auto;
  border-radius: 8px;
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
  border: 1px solid var(--reader-border);
}

.reader-article code {
  background: var(--nt-ivory);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
}

.reader-article pre code {
  background: none;
  padding: 0;
  border: none;
}

.reader-article ul,
.reader-article ol {
  margin: 0.8em 0;
  padding-left: 1.6em;
}

.reader-article li {
  margin: 0.4em 0;
}

.reader-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  border: 1px solid var(--reader-border);
  font-size: 0.95em;
}

.reader-article th,
.reader-article td {
  border: 1px solid var(--reader-border);
  padding: 0.7em;
  text-align: left;
}

.reader-article th {
  background: var(--reader-btn-hover);
  font-weight: 600;
}

.article-byline {
  text-align: center;
  color: var(--reader-text-secondary);
  font-size: 0.85em;
  margin: 1.5em 0 2em;
  padding: 0.8em;
  border-top: 1px solid var(--reader-border);
}

/* ========== 加载动画 ========== */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  gap: 16px;
}

.loading-spinner {
  position: relative;
  width: 36px;
  height: 36px;
}

.spinner-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 3px solid transparent;
  border-top-color: var(--reader-accent);
  border-radius: 50%;
  animation: nt-spin 0.8s linear infinite;
}

.loading-text {
  font-size: 14px;
  color: var(--reader-text-secondary);
  font-family: var(--nt-sans);
}

/* ========== 通知消息 ========== */
.reader-notification {
  position: fixed;
  top: 60px;
  right: 16px;
  padding: 12px 18px;
  border-radius: 10px;
  color: white;
  z-index: 1000020;
  max-width: 300px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--nt-sans);
  animation: nt-slide-down 0.2s ease-out;
}

.reader-notification-info { background: var(--nt-olive-gray); }
.reader-notification-success { background: #2d6a4f; }
.reader-notification-error { background: var(--nt-error); }
.reader-notification-warning { background: var(--nt-coral); }

/* ========== 图片灯箱 ========== */
.reader-image-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000010;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.reader-image-lightbox.open {
  opacity: 1;
  visibility: visible;
}

.reader-image-lightbox img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

.reader-image-lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

/* ========== 翻译信息 ========== */
.translation-info {
  text-align: center;
  color: var(--reader-text-secondary);
  font-size: 0.9em;
  margin: 2em 0 2.5em;
  padding: 16px 24px;
  background: linear-gradient(180deg, rgba(201, 100, 66, 0.08) 0%, transparent 100%);
  border-radius: 12px;
  border-left: 3px solid var(--reader-accent);
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .reader-toolbar { padding: 0 12px; height: 44px; }
  .reader-progress-bar { top: 44px; }
  .reader-toolbar-title { max-width: 120px; font-size: 13px; }
  .reader-content-container { padding: 20px 16px 60px; }
  .reader-settings-panel { width: calc(100% - 32px); right: 16px; }
  .reader-article { font-size: 17px; }
}

@media (max-width: 480px) {
  .reader-toolbar { padding: 0 8px; }
  .reader-content-container { padding: 16px 12px 50px; }
  .reader-article { font-size: 16px; }
  .reader-article h1 { font-size: 1.5em; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
