/* === LightNovel.world — hand-written CSS === */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: calc(100% * var(--font-scale, 1));
  -webkit-text-size-adjust: 100%;
}

html, body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC", -apple-system, BlinkMacSystemFont, sans-serif;
  background: #1e1e1e;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; }
img { max-width: 100%; display: block; }
ul { list-style: none; }

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

/* ── Dark theme (default) ── */
:root {
  --bg: #1e1e1e;
  --text: #b0b0b0;
  --text-muted: #999;
  --card-bg: #252525;
  --border: #3a3a3a;
  --accent: #287157;
  --accent-hover: #1e5a44;
  color-scheme: dark;
}

/* ── Light theme ── */
[data-theme="light"] {
  --bg: #b8b8b8;
  --text: #303030;
  --text-muted: #555;
  --card-bg: #c0c0c0;
  --border: #303030;
  --accent: #1e5a44;
  --accent-hover: #15402f;
  color-scheme: light;
}

[data-theme="light"] html,
[data-theme="light"] body {
  background: #b8b8b8;
  color: #303030;
}

/* ── Header ── */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: .9rem 0;
  margin-bottom: 1.5rem;
}
.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.site-header .logo {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -.5px;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC", -apple-system, BlinkMacSystemFont, sans-serif;
}
.site-header nav {
  display: flex;
  align-items: center;
  gap: .6rem;
}

/* ── Header buttons ── */
.header-btn {
  display: inline-flex;
  align-items: center;
  padding: .35rem .7rem;
  font-size: .82rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.4;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.header-btn:hover { color: var(--accent); border-color: var(--accent); }

.header-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .35rem .5rem;
  font-size: .82rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  transition: color .15s, border-color .15s;
}
.header-icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.header-icon-btn svg { width: 16px; height: 16px; }

.header-btn .btn-icon { width: 16px; height: 16px; flex-shrink: 0; }
.header-btn .btn-label { white-space: nowrap; }

/* ── Dropdown menus ── */
details.dropdown { position: relative; }
details.dropdown > summary {
  list-style: none;
  cursor: pointer;
}
details.dropdown > summary::-webkit-details-marker { display: none; }
details.dropdown > summary::marker { display: none; content: ""; }
details.dropdown > ul {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  min-width: 130px;
  max-width: calc(100vw - 2rem);
  max-height: 60vh;
  overflow-y: auto;
  padding: .3rem 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  z-index: 100;
}
details.dropdown > ul li a {
  display: block;
  padding: .35rem 1rem;
  font-size: .85rem;
  text-decoration: none;
  color: var(--text);
}
details.dropdown > ul li a:hover { background: rgba(40,113,87,.15); color: var(--accent); }

/* fontsize dropdown */
details.fontsize-dropdown > ul { min-width: 100px; }
.fs-active { color: var(--accent) !important; font-weight: 600; }

/* ── Search ── */
.search-bar {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}
.search-bar form {
  display: flex;
  gap: .5rem;
  align-items: center;
}
.search-input {
  max-width: 280px;
  padding: .35rem .6rem;
  font-size: .85rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  outline: none;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

/* ── Filters ── */
.filters {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.filters a {
  font-size: .82rem;
  padding: .25rem .75rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text-muted);
  transition: all .15s;
}
.filters a:hover { color: var(--accent); border-color: var(--accent); }
.filters a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #f0f0f0;
}

/* ── Novel grid ── */
.novel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  margin-top: 1.2rem;
}
.novel-card {
  text-decoration: none;
  color: inherit;
  border-radius: 8px;
  overflow: hidden;
  background: var(--card-bg);
  border: 1px solid var(--border);
  transition: transform .15s;
  display: flex;
  flex-direction: column;
}
.novel-card:hover { transform: translateY(-2px); }
.novel-card img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: #1a1a1a;
}
[data-theme="light"] .novel-card img { background: #ccc; }
.novel-card .info {
  padding: .55rem .65rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.novel-card .info h3 {
  font-size: .82rem;
  margin-bottom: .15rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 600;
}
.novel-card .info .meta {
  font-size: .68rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.novel-card .info .meta-status {
  margin-top: auto;
  padding-top: .25rem;
  text-align: right;
  font-size: .65rem;
}

/* Status badges on cards */
.novel-badge {
  display: inline-block;
  padding: .1rem .45rem;
  font-size: .62rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 10px;
  font-weight: 600;
}
.ongoing-badge {
  display: inline-block;
  padding: .1rem .45rem;
  font-size: .62rem;
  color: var(--text-muted);
  border: 1px solid var(--text-muted);
  border-radius: 10px;
  font-weight: 600;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  justify-content: center;
  gap: .5rem;
  margin-top: 1.5rem;
}
.pagination a {
  padding: .35rem .8rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-decoration: none;
  font-size: .85rem;
  color: var(--text-muted);
  transition: all .15s;
}
.pagination a:hover { color: var(--accent); border-color: var(--accent); }
.pagination a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #f0f0f0;
}

/* ── Novel detail ── */
.novel-detail {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 2rem;
  margin-top: 1.5rem;
}
.novel-detail .cover {
  width: 160px;
  flex-shrink: 0;
}
.novel-detail .cover img { width: 100%; border-radius: 6px; }
.novel-detail .meta-row {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: .5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
}
.novel-detail .meta-row a { color: var(--accent); text-decoration: none; }
.novel-detail .desc {
  font-size: .88rem;
  line-height: 1.7;
  color: var(--text);
}

/* ── Chapter list ── */
.chapter-list {
  columns: 2;
  column-gap: 2rem;
}
.chapter-list li {
  border-bottom: 1px solid var(--border);
  break-inside: avoid;
}
.chapter-list li a {
  display: block;
  padding: .4rem 0;
  font-size: .85rem;
  text-decoration: none;
  color: var(--text);
}
.chapter-list li a:hover { color: var(--accent); }

/* ── Chapter reader ── */
.reader { max-width: 720px; margin: 0 auto; }
.reader .breadcrumb {
  font-size: 1rem;
  text-align: center;
  margin-top: 1rem;
}
.reader .breadcrumb a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.reader .breadcrumb a:hover { color: var(--accent); }

.reader .chapter-title {
  font-size: 1.35rem;
  margin-bottom: .8rem;
  text-align: center;
  color: var(--text);
}

.reader .chapter-nav-top,
.reader .chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.reader .chapter-nav-top { margin-bottom: 1.5rem; }
.reader .chapter-nav {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.reader .chapter-nav-top .nav-left,
.reader .chapter-nav .nav-left { min-width: 80px; text-align: left; }
.reader .chapter-nav-top .nav-right,
.reader .chapter-nav .nav-right { min-width: 80px; text-align: right; }
.reader .chapter-nav-top a,
.reader .chapter-nav a {
  font-size: .85rem;
  padding: .2rem .7rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  text-decoration: none;
  color: var(--text-muted);
  transition: all .15s;
}
.reader .chapter-nav-top a:hover,
.reader .chapter-nav a:hover { color: var(--accent); border-color: var(--accent); }
.reader .chapters-link {
  white-space: nowrap;
}

.reader .chapter-content {
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--text);
}
.reader .chapter-content p {
  margin-bottom: 1rem;
  text-indent: 2em;
}

/* ── Footer ── */
footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-top: 2rem;
  text-align: center;
  font-size: .78rem;
  color: var(--text-muted);
}

/* ── General headings ── */
h2 { font-size: 1.3rem; margin-bottom: .5rem; color: var(--text); }
h4 { font-size: 1rem; margin: 1.5rem 0 .8rem; color: var(--text); }

/* ── Mobile ── */
@media (max-width: 768px) {
  .site-header { padding: .6rem 0; }
  .site-header .container { flex-wrap: wrap; gap: .5rem; }
  .site-header .logo { font-size: 1.1rem; }
  .site-header nav { gap: .35rem; margin-left: auto; }
  .header-btn { font-size: .7rem; padding: .35rem .4rem; }
  .header-btn .btn-label { display: none; }
  .header-icon-btn { padding: .35rem .4rem; }
  .header-icon-btn svg { width: 14px; height: 14px; }
  .novel-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .7rem; }
  .novel-detail { flex-direction: column; }
  .novel-detail .cover { width: 120px; }
  .chapter-list { columns: 1; }
  .reader { padding: 0 .75rem; }
  .search-bar { justify-content: flex-start; }
  .search-input { max-width: none; flex: 1; min-width: 0; }
  .search-bar form { width: 100%; }
  .search-bar form .header-btn { flex-shrink: 0; }
  .pagination { gap: .35rem; flex-wrap: wrap; }
  .pagination a { font-size: .78rem; padding: .3rem .55rem; }
}
