* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #f54e00;
  --primary-light: #ff7a3d;
  --gradient: linear-gradient(135deg, #f54e00 0%, #ff7a3d 100%);
  --shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 8px 25px rgba(0, 0, 0, 0.15);
}

body {
  min-height: 100vh;
  padding-bottom: 30px;
  color: #333;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft YaHei", sans-serif;
  background: #f5f5f5;
}

body.locked #searchView,
body.locked #detailView,
body.locked #reader,
body.locked .back-top {
  filter: blur(5px);
  pointer-events: none;
  user-select: none;
}

body.locked::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(255, 255, 255, 0.45);
  pointer-events: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--gradient);
  box-shadow: 0 2px 15px rgba(245, 78, 0, 0.3);
}

.top-bar-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}

.logo-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  color: var(--primary);
  font-weight: 800;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
}

.logo-subtitle {
  font-size: 10px;
  opacity: 0.9;
  letter-spacing: 0.5px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bookshelf-btn {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, 0.2);
  transition: all 0.3s;
}

.bookshelf-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.08);
}

.search-bar {
  display: flex;
  gap: 10px;
}

.source-select {
  min-width: 116px;
  border: 0;
  border-radius: 25px;
  padding: 0 14px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  outline: 0;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.search-input-wrap {
  display: flex;
  flex: 1;
  align-items: center;
  padding: 0 15px;
  border-radius: 25px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.search-symbol {
  color: #999;
  font-size: 16px;
}

.search-input-wrap input {
  flex: 1;
  border: 0;
  outline: 0;
  padding: 10px;
  font-size: 14px;
  background: transparent;
}

.search-btn {
  border: 0;
  border-radius: 25px;
  padding: 10px 20px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  background: #fff;
  transition: all 0.25s;
}

.search-btn:active {
  transform: scale(0.96);
}

.search-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

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

.filter-section {
  margin-bottom: 15px;
}

.filter-row {
  display: flex;
  gap: 10px;
}

.filter-group {
  display: flex;
  border-radius: 25px;
  padding: 4px;
  background: #fff;
  box-shadow: var(--shadow);
}

.filter-group.tab-group {
  flex: 1;
  justify-content: center;
}

.filter-btn {
  border: 0;
  border-radius: 20px;
  padding: 8px 16px;
  color: #666;
  font-size: 13px;
  white-space: nowrap;
  background: transparent;
  transition: all 0.3s;
}

.filter-group.tab-group .filter-btn {
  flex: 1;
}

.filter-btn.active {
  color: #fff;
  background: var(--gradient);
  box-shadow: 0 2px 8px rgba(245, 78, 0, 0.3);
}

.filter-btn:disabled {
  opacity: 0.55;
}

.category-selector {
  margin-bottom: 15px;
  overflow: hidden;
  border-radius: 15px;
  background: #fff;
  box-shadow: var(--shadow);
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
}

.category-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-dot,
.title-dot {
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--gradient);
}

.category-header .title {
  font-size: 14px;
  font-weight: 700;
}

.category-header .current {
  color: var(--primary);
  font-size: 13px;
}

.results-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 5px;
}

.results-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #333;
  font-size: 15px;
  font-weight: 700;
}

.results-count {
  color: #999;
  font-size: 12px;
}

.book-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.book-card {
  display: flex;
  gap: 12px;
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  box-shadow: var(--shadow);
  transition: all 0.3s;
  cursor: pointer;
}

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

.book-cover {
  width: 80px;
  height: 110px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #f0f0f0;
}

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

.book-info {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
}

.book-title {
  display: -webkit-box;
  overflow: hidden;
  margin-bottom: 5px;
  color: #333;
  font-size: 14px;
  font-weight: 700;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 5px;
  color: #999;
  font-size: 12px;
}

.book-desc {
  display: -webkit-box;
  flex: 1;
  overflow: hidden;
  color: #888;
  font-size: 12px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.book-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.book-tag {
  border-radius: 8px;
  padding: 2px 8px;
  color: var(--primary);
  font-size: 10px;
  background: linear-gradient(135deg, #fff5f0 0%, #ffe8dc 100%);
}

.book-tag.status {
  color: #4caf50;
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
}

.loading {
  display: none;
  padding: 40px;
  text-align: center;
}

.spinner,
.mini-spinner {
  display: inline-block;
  border: 3px solid #f0f0f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner {
  width: 35px;
  height: 35px;
  margin-bottom: 10px;
}

.mini-spinner {
  width: 20px;
  height: 20px;
  margin-right: 8px;
  vertical-align: middle;
}

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

.loading-text,
.loading-more span {
  color: #999;
  font-size: 13px;
}

.loading-more {
  display: none;
  padding: 20px;
  text-align: center;
}

.no-results {
  display: none;
  padding: 60px 20px;
  text-align: center;
}

.no-icon {
  margin-bottom: 12px;
  color: #ddd;
  font-size: 50px;
}

.no-results p {
  color: #999;
  font-size: 14px;
}

.back-top {
  position: fixed;
  right: 20px;
  bottom: 25px;
  z-index: 99;
  display: none;
  width: 45px;
  height: 45px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  color: var(--primary);
  font-size: 18px;
  background: #fff;
  box-shadow: var(--shadow-hover);
}

.back-top.show {
  display: flex;
}

.end-tip {
  display: none;
  padding: 20px;
  color: #ccc;
  font-size: 12px;
  text-align: center;
}

.end-tip.show {
  display: block;
}

.pagination {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 18px 0 8px;
}

.page-btn {
  min-width: 38px;
  height: 36px;
  border: 0;
  border-radius: 18px;
  padding: 0 13px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  background: #fff;
  box-shadow: var(--shadow);
}

.page-btn.active {
  color: #fff;
  background: var(--gradient);
}

.page-btn:disabled {
  color: #aaa;
  cursor: not-allowed;
  background: #f3f3f3;
  box-shadow: none;
}

.page-ellipsis {
  min-width: 24px;
  color: #999;
  text-align: center;
}

.page-jump {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  color: #777;
  font-size: 13px;
}

.page-jump input {
  width: 68px;
  height: 36px;
  border: 0;
  border-radius: 18px;
  padding: 0 10px;
  color: #333;
  text-align: center;
  outline: 0;
  background: #fff;
  box-shadow: var(--shadow);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  width: 90%;
  max-width: 350px;
  border-radius: 15px;
  padding: 25px;
  text-align: center;
  background: #fff;
}

.modal-content h3 {
  margin-bottom: 15px;
  color: #333;
  font-size: 16px;
}

.modal-content p {
  margin-bottom: 20px;
  color: #666;
  font-size: 14px;
  line-height: 1.6;
}

.modal-content .modal-sign {
  margin-top: -8px;
  color: var(--primary);
  font-weight: 700;
  text-align: right;
}

.modal-content button {
  border: 0;
  border-radius: 20px;
  padding: 10px 30px;
  color: #fff;
  background: var(--gradient);
}

.password-box {
  display: grid;
  gap: 12px;
}

.password-box input {
  width: 100%;
  height: 42px;
  border: 1px solid #ffe0d2;
  border-radius: 21px;
  padding: 0 16px;
  color: #333;
  outline: 0;
  background: #fff7f2;
}

.password-error {
  margin-top: -8px;
  margin-bottom: 12px !important;
  color: #f44336 !important;
  font-weight: 700;
}

.password-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-content .password-cancel {
  color: var(--primary);
  background: #fff;
  border: 1px solid #ffd2bf;
}

.chapter-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  margin: 16px 0 20px;
  padding-right: 4px;
}

.chapter-picker button {
  min-height: 36px;
  border: 1px solid #ffe0d2;
  border-radius: 9px;
  padding: 7px 10px;
  overflow: hidden;
  color: var(--primary);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #fff7f2;
}

.chapter-picker button:hover {
  color: #fff;
  background: var(--gradient);
}

.reader {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #060606;
}

.reader.open {
  display: grid;
}

.reader-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  padding: 0 24px;
  color: #fff;
  background: #000;
}

.reader-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  background: transparent;
}

.reader-body {
  position: relative;
  overflow: auto;
  padding: 0 12px 28px;
  background: #070707;
}

.reader-page {
  position: fixed;
  top: 72px;
  right: 28px;
  z-index: 4;
  min-width: 44px;
  height: 32px;
  border-radius: 999px;
  padding: 0 10px;
  color: #fff;
  font-size: 13px;
  line-height: 32px;
  text-align: center;
  background: rgba(0, 0, 0, 0.72);
}

.reader-images {
  width: min(808px, 100%);
  margin: 0 auto;
}

.reader-images img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
  background: #111;
}

.reader-actions {
  z-index: 3;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px 18px;
  background: linear-gradient(180deg, rgba(7, 7, 7, 0), rgba(7, 7, 7, 0.96) 18%, #070707);
}

.reader-actions .button {
  flex: 1;
  max-width: 620px;
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(90deg, #506de8, #8351bf);
}

.reader-actions .button:first-child {
  background: linear-gradient(90deg, #293562, #332249);
}

.reader-actions .button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.reader-float {
  position: fixed;
  z-index: 4;
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  font-size: 22px;
  background: #24c58f;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.34);
}

.reader-float-right {
  right: 36px;
  bottom: 76px;
}

@media (max-width: 768px) {
  .book-list {
    grid-template-columns: 1fr;
  }

  .book-cover {
    width: 70px;
    height: 95px;
  }

  .book-title {
    font-size: 13px;
  }

  .filter-btn {
    padding: 7px 12px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .top-bar-content {
    padding: 10px 15px;
  }

  .top-header {
    margin-bottom: 10px;
  }

  .logo-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .logo-title {
    font-size: 15px;
  }

  .logo-subtitle {
    font-size: 9px;
  }

  .container {
    padding: 12px;
  }

  .book-card {
    padding: 10px;
  }

  .book-cover {
    width: 65px;
    height: 90px;
  }

  .search-input-wrap input {
    padding: 8px;
    font-size: 13px;
  }

  .search-btn {
    padding: 8px 16px;
    font-size: 13px;
  }

  .source-select {
    min-width: 98px;
    padding: 0 8px;
    font-size: 12px;
  }

  .reader-bar {
    height: 48px;
    padding: 0 10px;
  }

  .reader-body {
    padding: 0 0 20px;
  }

  .reader-images {
    width: 100%;
  }

  .reader-page {
    top: 56px;
    right: 10px;
    min-width: 38px;
    height: 28px;
    font-size: 12px;
    line-height: 28px;
  }

  .reader-actions {
    gap: 8px;
    padding: 10px 10px 12px;
  }

  .reader-actions .button {
    min-height: 40px;
    padding: 0 10px;
    font-size: 13px;
  }

  .reader-float {
    width: 46px;
    height: 46px;
    font-size: 18px;
  }

  .reader-float-right {
    right: 14px;
    bottom: 64px;
  }
}

body.detail-mode {
  min-height: 100vh;
  background: linear-gradient(135deg, #f54e00 0%, #ff7a3d 50%, #ffb088 100%);
}

body.detail-mode::before {
  content: "";
  position: fixed;
  inset: -50%;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(255,255,255,0.13) 1px, transparent 1px);
  background-size: 50px 50px;
}

.detail-header {
  position: sticky;
  top: 0;
  z-index: 80;
  padding: 18px 28px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.14);
}

.back-link {
  border: 0;
  border-radius: 20px;
  padding: 8px 14px;
  color: var(--primary);
  font-size: 15px;
  font-weight: 700;
  background: transparent;
}

.back-link:hover {
  background: rgba(245, 78, 0, 0.1);
}

.detail-shell {
  position: relative;
  z-index: 1;
  width: min(1360px, calc(100% - 40px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.detail-card,
.catalog-card {
  border-radius: 25px;
  padding: 40px;
  background: #fff;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  position: relative;
}

.catalog-card {
  margin-top: 30px;
}

.detail-card::before,
.catalog-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, #f54e00, #ff6b2c, #ffb088);
}

.detail-info-header {
  display: flex;
  gap: 40px;
  align-items: flex-start;
}

.detail-cover {
  flex: 0 0 auto;
}

.detail-cover img {
  width: 220px;
  height: 300px;
  object-fit: cover;
  border-radius: 15px;
  background: #f2f2f2;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.28);
}

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

.detail-main h1 {
  margin: 4px 0 18px;
  color: var(--primary);
  font-size: 32px;
  line-height: 1.25;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  margin-bottom: 18px;
}

.detail-meta span {
  border-radius: 20px;
  padding: 8px 16px;
  color: #666;
  font-size: 14px;
  background: #f8f9fa;
}

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

.tag {
  border-radius: 20px;
  padding: 7px 18px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  background: linear-gradient(135deg, #f54e00 0%, #ff6b2c 100%);
  box-shadow: 0 3px 10px rgba(245, 78, 0, 0.3);
}

.detail-desc {
  margin-top: 26px;
  border-left: 4px solid var(--primary);
  border-radius: 15px;
  padding: 20px;
  color: #555;
  font-size: 15px;
  line-height: 1.9;
  background: #f8f9fa;
  white-space: pre-wrap;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-top: 26px;
}

.detail-btn {
  min-height: 56px;
  border-radius: 30px;
  padding: 0 34px;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 4px 15px rgba(0,0,0,0.18);
}

.detail-btn.primary {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, #f54e00 0%, #ff6b2c 100%);
}

.detail-btn.ghost {
  border: 2px solid var(--primary);
  color: var(--primary);
  background: #fff;
}

.catalog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 2px solid #f0f0f0;
}

.catalog-head h2 {
  color: #333;
  font-size: 26px;
}

.catalog-head span {
  color: #999;
  font-size: 14px;
}

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

.catalog-item {
  min-height: 46px;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 0 16px;
  overflow: hidden;
  color: #333;
  font-size: 14px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #f8f9fa;
}

.catalog-item:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #fff;
  transform: translateX(4px);
}

.loading-inline {
  padding: 28px;
  color: #999;
  text-align: center;
}

@media (max-width: 768px) {
  .detail-shell {
    width: calc(100% - 24px);
    padding-top: 18px;
  }

  .detail-card,
  .catalog-card {
    border-radius: 18px;
    padding: 20px 15px;
  }

  .detail-info-header {
    gap: 15px;
  }

  .detail-cover img {
    width: 110px;
    height: 150px;
  }

  .detail-main h1 {
    font-size: 20px;
  }

  .detail-meta {
    gap: 8px;
  }

  .detail-meta span {
    padding: 6px 10px;
    font-size: 12px;
  }

  .detail-desc {
    max-height: 180px;
    overflow: auto;
  }

  .detail-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .detail-btn {
    min-height: 46px;
    padding: 0 12px;
    font-size: 14px;
  }

  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}
