:root {
  --bg-primary: #faf9f7;
  --bg-secondary: #f4f1ec;
  --bg-card: #ffffff;
  --text-primary: #2c2c2c;
  --text-secondary: #666666;
  --text-muted: #999999;
  --accent: #e07a5f;
  --accent-light: #f4a261;
  --border: #e8e4df;
  --shadow: rgba(0, 0, 0, 0.04);
  --shadow-hover: rgba(0, 0, 0, 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

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

body {
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.92);
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-family: "Noto Serif SC", serif;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
}

.logo-text {
  font-family: "Noto Serif SC", serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.search-box {
  flex: 1;
  max-width: 520px;
  position: relative;
}

.search-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 12px 16px 12px 44px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-card);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--text-muted);
}

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

.btn {
  border: none;
  border-radius: 100px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.btn-primary {
  background: var(--text-primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: #444444;
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.75;
  cursor: default;
}

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

.btn-ghost:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.btn[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.65;
}

.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.hero {
  text-align: center;
  padding: 40px 0 52px;
}

.hero-title {
  font-family: "Noto Serif SC", serif;
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}

.hero-subtitle {
  max-width: 620px;
  margin: 0 auto;
  font-size: 16px;
  color: var(--text-secondary);
}

.hero-stats {
  margin-top: 30px;
  display: flex;
  justify-content: center;
  gap: 48px;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-family: "Noto Serif SC", serif;
  font-size: 32px;
  font-weight: 600;
  color: var(--accent);
}

.stat-label {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.filter-tabs {
  display: flex;
  gap: 8px;
}

.filter-tab {
  border: none;
  border-radius: 100px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-tab:hover:not(:disabled) {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.filter-tab.active {
  background: var(--text-primary);
  color: #ffffff;
}

.filter-tab[aria-selected="true"] {
  background: var(--text-primary);
  color: #ffffff;
}

.filter-tab:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.filter-info {
  font-size: 14px;
  color: var(--text-muted);
}

.masonry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

@media (min-width: 1200px) {
  .masonry-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 900px) and (max-width: 1199px) {
  .masonry-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 600px) and (max-width: 899px) {
  .masonry-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 599px) {
  .masonry-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow);
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px var(--shadow-hover);
}

.card-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #f5f0e8 0%, #e8e0d5 100%);
}

.card-image-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-image-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Noto Serif SC", serif;
  font-size: 56px;
  color: rgba(0, 0, 0, 0.1);
}

.card-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(4px);
}

.card-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-title {
  font-family: "Noto Serif SC", serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-author {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.card-summary {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 16px;
  flex: 1;
}

.card-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-date {
  font-size: 12px;
  color: var(--text-muted);
}

.card-action {
  padding: 8px 14px;
  border-radius: 100px;
  font-size: 13px;
  color: var(--text-primary);
  text-decoration: none;
  background: var(--bg-secondary);
  transition: all 0.2s ease;
}

.card-action:hover {
  background: var(--text-primary);
  color: #ffffff;
}

.card-action.is-disabled {
  background: #ece9e4;
  color: #9d968c;
  pointer-events: none;
}

.empty-state {
  text-align: center;
  padding: 80px 24px;
}

.empty-state.is-error .empty-icon {
  background: #fce9e9;
  color: #993333;
}

.empty-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Noto Serif SC", serif;
  font-size: 32px;
  color: var(--text-secondary);
}

.empty-title {
  font-family: "Noto Serif SC", serif;
  font-size: 20px;
  margin-bottom: 8px;
}

.empty-desc {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 620px;
  margin: 0 auto;
}

.chapters-view {
  max-width: 800px;
  margin: 0 auto;
}

.chapters-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.chapters-book-title {
  font-family: "Noto Serif SC", serif;
  font-size: 22px;
  font-weight: 600;
}

.chapters-book-author {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.chapters-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chapter-item {
  display: block;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-primary);
  font-size: 15px;
  transition: background 0.15s ease;
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
}

.chapter-item:hover {
  background: var(--bg-secondary);
}

.chapter-index {
  color: var(--text-muted);
  font-size: 13px;
  margin-right: 12px;
  min-width: 36px;
  display: inline-block;
}

.reader-view {
  max-width: 720px;
  margin: 0 auto;
}

.reader-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.reader-chapter-title {
  font-family: "Noto Serif SC", serif;
  font-size: 18px;
  font-weight: 600;
  flex: 1;
}

.reader-book-title {
  font-size: 13px;
  color: var(--text-muted);
}

.reader-content {
  font-family: "Noto Serif SC", serif;
  font-size: 17px;
  line-height: 2;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  padding: 0 0 40px;
  min-height: 60vh;
}

.reader-nav {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 32px 0 16px;
  border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
    gap: 14px;
  }

  .search-box {
    order: 3;
    max-width: none;
    flex-basis: 100%;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .hero-stats {
    gap: 26px;
    flex-wrap: wrap;
  }

  .filter-bar {
    flex-direction: column;
    align-items: flex-start;
  }
}
