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

body {
  font-family: "Noto Serif SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* 通用布局组件 */
.layout {
  display: flex;
  gap: 20px;
  flex-direction: column;
  height: calc(100vh - 80px);
}

/* 内容区域 */
.content {
  flex: 1;
  min-width: 0;
  background: var(--card-bg);
  border-radius: 10px;
  padding: 30px;
  box-shadow: var(--shadow);
  overflow-y: auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

.content-title {
  text-align: center;
  margin-bottom: 30px;
  font-size: 1.8em;
  color: var(--text-color);
}

.content-text {
  font-size: 18px;
  line-height: 2;
  letter-spacing: 0.05em;
  padding: 0 20px 40px;
  flex: 1;
  color: var(--text-color);
}

.content-text p {
  margin-bottom: 1.5em;
  text-indent: 2em;
}

.content-text::selection {
  background: var(--active-bg);
  color: var(--active-color);
}

/* 按钮样式 */
button {
  padding: 8px 20px;
  background-color: #2c3e50;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
}

button:hover {
  background-color: #34495e;
  transform: translateY(-2px);
}

button:disabled {
  background-color: #ccc;
  cursor: not-allowed;
  transform: none;
}

.nav-buttons {
  display: flex;
  justify-content: space-between;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

/* 阅读模式优化 */
@media (min-width: 768px) {
  .content-text {
    max-width: 800px;
    margin: 0 auto;
  }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
  body {
    background-color: #1a1a1a;
    color: #e0e0e0;
  }

  .header {
    background-color: #2c3e50;
  }

  .chapters,
  .content,
  .file-input {
    background-color: #2d2d2d;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  }

  .chapter-item {
    border-bottom-color: #3d3d3d;
  }

  .chapter-item:hover {
    background-color: #3d3d3d;
  }

  .chapter-item.active {
    background-color: #364f6b;
    color: #fff;
  }

  .content-text {
    color: #e0e0e0;
  }

  .content-title {
    color: #fff;
  }

  button {
    background-color: #364f6b;
  }

  button:hover {
    background-color: #446688;
  }
}

/* 加载指示器 */
.loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* 动画与过渡 */
.header,
.content,
.chapters,
.file-input,
.function-buttons,
.chapter-item,
.bookmark-item,
.delete-btn,
.search-result,
.theme-option,
.recent-item,
.recent-list,
.fullscreen-mode .function-buttons,
.fullscreen-mode .content {
  transition: all 0.3s ease;
}

/* 提示与通知 */
.shortcut-tip {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(44, 62, 80, 0.9);
  color: white;
  padding: 10px 15px;
  border-radius: 5px;
  font-size: 0.9rem;
  z-index: 1000;
  display: none;
  animation: fadeInOut 5s ease-in-out;
}

@keyframes fadeInOut {
  0% {
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  90% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

/* 进度提示 */
.progress-tip {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: 5px;
  height: 30px;
  width: 100%;
  background: var(--card-bg);
  padding: 2px 15px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  font-size: 0.9em;
  opacity: 0.3;
  transition: opacity 0.3s ease;
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
}

.progress-tip:hover {
  opacity: 0.8;
}

.progress-tip-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-bar {
  width: 100px;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--active-color);
  transition: width 0.3s ease;
}

/* 功能按钮 */
.function-buttons {
  position: fixed;
  right: 0px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1100;
  background: var(--card-bg);
  padding: 10px;
  border-radius: 10px 0 0 10px;
  box-shadow: var(--shadow);
}

.function-btn {
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-color);
  border-radius: 8px;
  position: relative;
}

.function-btn:hover {
  background: var(--hover-bg);
  transform: scale(1.1);
}

.function-btn:active {
  transform: scale(0.95);
}

.function-btn::after {
  content: attr(title);
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--card-bg);
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 0.9em;
  white-space: nowrap;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.function-btn:hover::after {
  opacity: 1;
  visibility: visible;
}

/* 侧边栏样式 */
.sidebar {
  position: fixed;
  right: -320px;
  top: 0;
  width: 320px;
  height: 100vh;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.sidebar.active {
  right: 0;
}

.sidebar.active + .function-buttons {
  right: 320px;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  max-height: calc(100vh - 60px);
}

.sidebar-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-color);
  padding: 5px;
}

.sidebar-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  background: var(--bg-color);
  color: var(--text-color);
  margin-bottom: 10px;
}

.sidebar-btn {
  padding: 8px 15px;
  background: var(--active-color);
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1099;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

.sidebar-panel {
  display: none;
}

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

/* 设置面板 */
.settings-group {
  margin-bottom: 20px;
  padding: 15px;
  background: var(--hover-bg);
  border-radius: 8px;
}

.settings-group h4 {
  margin: 0 0 15px 0;
  color: var(--text-color);
  font-size: 1.1em;
}

.setting-item {
  margin-bottom: 15px;
}

.setting-item:last-child {
  margin-bottom: 0;
}

.setting-item label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-color);
}

.setting-item input[type="range"] {
  width: 100%;
  margin: 8px 0;
}

.setting-item select {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-color);
  color: var(--text-color);
}

/* 统计项 */
.stats-container {
  padding: 20px;
}

.stats-item {
  background: var(--hover-bg);
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
}

.stats-item h4 {
  margin: 0 0 10px 0;
  color: var(--text-color);
  font-size: 1.1em;
}

.stats-value {
  font-size: 1.5em;
  color: var(--active-color);
  margin-bottom: 5px;
}

.stats-detail {
  font-size: 0.9em;
  color: var(--text-color);
  opacity: 0.8;
}

/* 空状态提示 */
.empty-message {
  text-align: center;
  padding: 20px;
  color: var(--text-color);
  opacity: 0.7;
}

/* 删除按钮 */
.delete-btn {
  background: none;
  border: none;
  padding: 5px;
  margin-left: 10px;
  cursor: pointer;
  color: var(--text-color);
  opacity: 0.5;
  transition: opacity 0.3s ease;
  flex-shrink: 0;
}

.delete-btn:hover {
  opacity: 1;
  color: #dc3545;
}

.delete-btn svg {
  width: 16px;
  height: 16px;
}

/* 最近项与章节项 */
.recent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  margin: 5px 0;
  background: var(--hover-bg);
  border-radius: 5px;
  max-width: 100%;
  cursor: pointer;
}

.recent-item:hover {
  transform: scale(0.95);
  background: var(--active-bg);
}

.recent-item-info {
  flex: 1;
  min-width: 0;
  margin-right: 10px;
}

.recent-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
}

.recent-item-time,
.recent-item-file,
.bookmark-time {
  font-size: 0.8em;
  color: var(--text-color);
  opacity: 0.7;
}

.recent-item-file {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-item-content {
  flex: 1;
  display: flex;
  justify-content: space-between;
  cursor: pointer;
  flex-direction: column;
}

/* 章节列表样式 */
.chapter-list {
  list-style: none;
}

.chapter-item {
  padding: 12px 15px;
  margin: 5px 0;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 5px;
  background: var(--hover-bg);
}

.chapter-item:hover {
  background: var(--active-bg);
  transform: scale(0.95);
}

.chapter-item.active {
  background: var(--active-color);
  color: white;
}

/* 搜索结果 */
.search-results,
.bookmarks-list,
.recent-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

.search-result {
  padding: 10px;
  margin: 5px 0;
  border-radius: 5px;
  background: var(--hover-bg);
  cursor: pointer;
  transition: all 0.3s ease;
}

.search-result:hover {
  background: var(--active-bg);
  transform: scale(0.95);
}

.result-title {
  font-weight: bold;
  margin-bottom: 5px;
}

.result-preview {
  font-size: 0.9em;
  margin-bottom: 5px;
  opacity: 0.8;
}

.result-count {
  font-size: 0.8em;
  color: var(--active-color);
}

/* 书签 */
.bookmark-item {
  display: flex;
  align-items: center;
  padding: 10px;
  margin: 5px 0;
  background: var(--hover-bg);
  border-radius: 5px;
}

.bookmark-item:hover {
  background: var(--active-bg);
  transform: scale(0.95);
}

.bookmark-content {
  flex: 1;
  cursor: pointer;
}

.bookmark-title {
  font-weight: bold;
  margin-bottom: 5px;
}

/* 主题样式 */
.theme-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 15px;
  padding: 15px;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  background: var(--hover-bg);
}

.theme-option:hover {
  transform: translateY(-2px);
  background: var(--active-bg);
}

.theme-option.active {
  background: var(--active-color);
  color: white;
}

.theme-sample {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
}

/* 全屏模式 */
.fullscreen-mode {
  overflow: hidden;
}

.fullscreen-mode .header,
.fullscreen-mode .chapters,
.fullscreen-mode .function-buttons,
.fullscreen-mode .reading-settings {
  display: none;
}

.fullscreen-mode .function-buttons {
  opacity: 0.2;
  transform: translateY(-50%) scale(0.9);
}

.fullscreen-mode .function-buttons:hover {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

.fullscreen-mode .content {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px;
  border-radius: 0;
  min-height: 100vh;
  background: var(--bg-color);
}

.fullscreen-mode .content-text {
  font-size: 1.2em;
  line-height: 2;
}

/* 侧边栏文件输入 */
.file-input-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 15px;
}

.file-input-wrapper {
  text-align: center;
  padding: 25px;
  border: 2px dashed var(--border-color);
  border-radius: 10px;
  background: var(--hover-bg);
  transition: all 0.3s ease;
}

.file-input-wrapper:hover {
  border-color: var(--active-color);
  background: var(--active-bg);
}

.file-hint {
  margin-top: 10px;
  font-size: 0.9em;
  color: var(--text-color);
  opacity: 0.8;
}

#sidebarFileInput {
  width: 100%;
  padding: 10px;
  background: transparent;
  color: var(--text-color);
  border: none;
  cursor: pointer;
}

#sidebarFileInput::-webkit-file-upload-button {
  background: var(--active-color);
  color: white;
  padding: 8px 16px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

#sidebarFileInput::-webkit-file-upload-button:hover {
  background: var(--hover-bg);
  color: var(--active-color);
}

@media screen and (max-width: 768px) {
  #fullscreenButton {
    display: none;
  }
  .container {
    padding: 60px 10px 0;
  }
  .layout {
    gap: 6px;
  }
  .content {
    padding: 6px;
  }
  .content-title {
    font-size: 1.4em;
  }
  .content-text {
    padding: 0 6px 40px;
  }
  .nav-buttons {
    border-top: none;
    padding-top: 0px;
    gap: 20px;
  }
  .nav-buttons button {
    width: 100%;
    padding: 6px;
    border-radius: 0;
    background-color: #26211d;
  }
  .sidebar {
    font-size: 14px;
    width: 240px;
    right: -240px;
    padding-top: 40px;
  }
  .sidebar-content {
    padding: 6px;
  }
  .progress-tip {
    top: 40px;
    font-size: 12px;
    gap: 8px;
    padding: 2px 6px;
    height: 20px;
  }
  .function-buttons {
    flex-direction: row;
    top: 0;
    right: auto;
    transform: none;
    width: 100%;
    padding: 3px;
    justify-content: center;
  }
  .function-btn {
    width: 34px;
    height: 34px;
  }
  .function-btn::after {
    display: none; /* 隐藏提示框 */
  }
  .sidebar.active + .function-buttons {
    right: 0px;
  }
}
