/* ── Ohara · Design tokens ─────────────────────────────────── */
:root {
  --ink:        #e9e4da;
  --ink-dim:    #9a9286;
  --ink-faint:  #4a4540;
  --bg:         #111010;
  --bg-card:    #1a1917;
  --bg-hover:   #222120;
  --border:     #2a2825;
  --gold:       #c9a84c;
  --gold-dim:   #7a6230;
  --red:        #c0392b;

  --font-ui:    'Georgia', 'Times New Roman', serif;
  --font-read:  'Georgia', 'Palatino Linotype', serif;
  --font-mono:  'Courier New', monospace;

  --r:          6px;
  --r-lg:       12px;

  --max-prose:  680px;
  --max-site:   1200px;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 18px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ── Header ─────────────────────────────────────────────────── */
.site-header {
  border-bottom: 1px solid var(--border);
  background: #0c0b0b;
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header .inner {
  max-width: var(--max-site);
  margin: 0 auto;
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}
.logo svg { width: 22px; height: 22px; }
.header-tagline {
  font-size: .78rem;
  color: var(--ink-dim);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.breadcrumb {
  font-size: .82rem;
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb a:hover { color: var(--gold); }
.breadcrumb .sep { color: var(--ink-faint); }

/* ── Layout containers ──────────────────────────────────────── */
.container {
  max-width: var(--max-site);
  margin: 0 auto;
  padding: 0 24px;
}
.prose-container {
  max-width: var(--max-prose);
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Index page ─────────────────────────────────────────────── */
.page-hero {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--border);
}
.page-hero h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.15;
}
.page-hero h1 span { color: var(--gold); }
.page-hero p { margin-top: 8px; color: var(--ink-dim); font-size: .9rem; }

.stats-bar {
  padding: 14px 0;
  font-size: .82rem;
  color: var(--ink-dim);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 20px;
}
.stats-bar strong { color: var(--ink); }

.novel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  padding: 32px 0 64px;
}

.novel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .18s, transform .18s, box-shadow .18s;
  display: flex;
  flex-direction: column;
}
.novel-card:hover {
  border-color: var(--gold-dim);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.novel-card-cover {
  aspect-ratio: 2 / 3;
  background: var(--bg-hover);
  overflow: hidden;
  position: relative;
}
.novel-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s;
}
.novel-card:hover .novel-card-cover img { transform: scale(1.04); }
.novel-card-cover .cover-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: linear-gradient(135deg, #1e1b14 0%, #2a2518 100%);
}
.novel-card-body { padding: 14px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.novel-card-title {
  font-size: .9rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.novel-card-meta {
  font-size: .75rem;
  color: var(--ink-dim);
  margin-top: auto;
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .7rem;
  letter-spacing: .04em;
  font-weight: 600;
}
.badge-gold { background: rgba(201,168,76,.15); color: var(--gold); border: 1px solid rgba(201,168,76,.3); }

/* ── Novel detail page ──────────────────────────────────────── */
.novel-hero {
  padding: 40px 0 32px;
  display: flex;
  gap: 32px;
  align-items: flex-start;
}
.novel-hero-cover {
  flex-shrink: 0;
  width: 160px;
  aspect-ratio: 2 / 3;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-hover);
}
.novel-hero-cover img { width: 100%; height: 100%; object-fit: cover; }
.novel-hero-cover .cover-fallback {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 4rem;
  background: linear-gradient(135deg, #1e1b14 0%, #2a2518 100%);
}
.novel-hero-info { flex: 1; min-width: 0; }
.novel-hero-title {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
}
.novel-hero-meta {
  margin-top: 10px;
  font-size: .83rem;
  color: var(--ink-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.novel-hero-meta span strong { color: var(--ink); }
.btn-start {
  margin-top: 20px;
  display: inline-block;
  padding: 11px 26px;
  background: var(--gold);
  color: #0c0b0b;
  border-radius: var(--r);
  font-weight: 700;
  font-size: .9rem;
  letter-spacing: .03em;
  transition: opacity .15s;
}
.btn-start:hover { opacity: .88; }

.chapter-list-section { padding: 28px 0 64px; }
.section-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.chapter-list { list-style: none; }
.chapter-item {
  border-bottom: 1px solid var(--border);
}
.chapter-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 8px;
  font-size: .88rem;
  color: var(--ink-dim);
  transition: background .12s, color .12s;
  border-radius: var(--r);
}
.chapter-link:hover { background: var(--bg-hover); color: var(--ink); }
.chapter-num {
  flex-shrink: 0;
  width: 46px;
  font-size: .75rem;
  color: var(--gold-dim);
  font-family: var(--font-mono);
  font-weight: 700;
}
.chapter-title-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Pagination for chapter list */
.list-pagination {
  display: flex;
  gap: 8px;
  padding: 20px 0;
  flex-wrap: wrap;
}
.page-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-card);
  color: var(--ink-dim);
  font-size: .82rem;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.page-btn:hover, .page-btn.active {
  border-color: var(--gold-dim);
  color: var(--gold);
  background: rgba(201,168,76,.05);
}

/* ── Chapter reader ─────────────────────────────────────────── */
.reader-header {
  border-bottom: 1px solid var(--border);
  background: #0c0b0b;
  position: sticky;
  top: 58px;
  z-index: 90;
}
.reader-header-inner {
  max-width: var(--max-prose);
  margin: 0 auto;
  padding: 0 24px;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .8rem;
  color: var(--ink-dim);
}
.reader-progress {
  margin-left: auto;
  font-size: .75rem;
  color: var(--ink-faint);
  font-family: var(--font-mono);
}

.chapter-content-area {
  padding: 48px 0 32px;
}
.chapter-title-heading {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.chapter-section-divider {
  text-align: center;
  padding: 28px 0 20px;
  color: var(--ink-faint);
  font-size: .8rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.chapter-section-divider::before,
.chapter-section-divider::after {
  content: '';
  display: inline-block;
  width: 40px;
  height: 1px;
  background: var(--border);
  vertical-align: middle;
  margin: 0 12px;
}
.chapter-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold-dim);
  margin: 40px 0 16px;
}

.chapter-prose {
  font-family: var(--font-read);
  font-size: 1.08rem;
  line-height: 1.9;
  color: var(--ink);
}
.chapter-prose p {
  margin-bottom: 1.4em;
  text-align: justify;
  hyphens: auto;
}

/* ── Chapter navigation ─────────────────────────────────────── */
.chapter-nav {
  padding: 40px 0 64px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
}
.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-card);
  color: var(--ink-dim);
  font-size: .88rem;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.nav-btn:hover:not(:disabled) {
  border-color: var(--gold-dim);
  color: var(--ink);
  background: var(--bg-hover);
}
.nav-btn:disabled { opacity: .3; cursor: not-allowed; }
.nav-btn.prev { text-align: left; }
.nav-btn.next { text-align: right; margin-left: auto; justify-content: flex-end; }
.nav-btn.merge {
  background: rgba(201,168,76,.1);
  border-color: var(--gold-dim);
  color: var(--gold);
  font-weight: 600;
  padding: 12px 18px;
  white-space: nowrap;
}
.nav-btn.merge:hover:not(:disabled) {
  background: rgba(201,168,76,.2);
  border-color: var(--gold);
}
.nav-btn-label { font-size: .7rem; color: var(--ink-faint); display: block; line-height: 1; margin-bottom: 2px; }

/* ── States ─────────────────────────────────────────────────── */
.state-loading, .state-error, .state-empty {
  text-align: center;
  padding: 80px 24px;
  color: var(--ink-dim);
}
.state-loading::after {
  content: '';
  display: inline-block;
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-left: 12px;
  vertical-align: middle;
}
.state-error { color: var(--red); }
.state-empty p { margin-top: 8px; font-size: .85rem; font-family: var(--font-mono); color: var(--ink-faint); }

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

.hidden { display: none !important; }

/* ── Search / filter ────────────────────────────────────────── */
.search-bar {
  padding: 20px 0 0;
  display: flex;
  gap: 10px;
}
.search-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 14px;
  color: var(--ink);
  font-family: inherit;
  font-size: .88rem;
  outline: none;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--gold-dim); }
.search-input::placeholder { color: var(--ink-faint); }

/* ── Stars & Progress ───────────────────────────────────────── */
.stars {
  display: flex;
  gap: 3px;
  margin-top: 10px;
}
.star {
  font-size: 1.3rem;
  color: var(--ink-faint);
  cursor: pointer;
  transition: color .12s, transform .12s;
  line-height: 1;
}
.star:hover, .star.filled { color: var(--gold); }
.star:hover { transform: scale(1.15); }

.progress-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  background: rgba(201,168,76,.1);
  color: var(--gold);
  border: 1px solid rgba(201,168,76,.2);
  margin-top: 4px;
}
.progress-badge svg { width: 11px; height: 11px; }

.btn-continue {
  display: inline-block;
  margin-top: 14px;
  padding: 10px 22px;
  background: rgba(201,168,76,.15);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  border-radius: var(--r);
  font-weight: 700;
  font-size: .88rem;
  cursor: pointer;
  transition: background .15s;
  font-family: inherit;
}
.btn-continue:hover { background: rgba(201,168,76,.28); }

/* ── Tags ───────────────────────────────────────────────────── */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .04em;
  background: rgba(201,168,76,.1);
  color: var(--gold);
  border: 1px solid rgba(201,168,76,.25);
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.tag:hover { background: rgba(201,168,76,.22); border-color: var(--gold); }
.tag.active { background: rgba(201,168,76,.3); border-color: var(--gold); }

/* Tag filter bar */
.tag-filter {
  padding: 12px 0 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.tag-filter-label {
  font-size: .75rem;
  color: var(--ink-faint);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-right: 4px;
}
.tag-clear {
  font-size: .75rem;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  font-family: inherit;
  transition: color .15s;
}
.tag-clear:hover { color: var(--ink); border-color: var(--ink-faint); }

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  text-align: center;
  font-size: .76rem;
  color: var(--ink-faint);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  html { font-size: 16px; }
  .container, .prose-container { padding: 0 16px; }
  .novel-hero { flex-direction: column; }
  .novel-hero-cover { width: 120px; }
  .chapter-nav { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; }
  .nav-btn.merge { grid-column: 1 / -1; width: 100%; justify-content: center; }
  .novel-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
}

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