:root {
  --bg: #fdf9f3;
  --paper: #fffdf9;
  --sidebar-bg: #f6f0e8;
  --ink: #4a4038;
  --ink-soft: #7a6f64;
  --accent: #c98b8b;      /* 柔玫瑰 */
  --accent-2: #9db8a0;    /* 抹茶绿 */
  --accent-3: #d9b382;    /* 奶咖 */
  --line: #ece2d6;
  --shadow: 0 8px 30px rgba(150, 120, 90, 0.12);
  --radius: 16px;
  --sidebar-w: 280px;
  --font-scale: 1;
}

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

body {
  font-family: "Noto Serif SC", "Songti SC", serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(201,139,139,.08), transparent 40%),
    radial-gradient(circle at 88% 92%, rgba(157,184,160,.10), transparent 42%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: rgba(253, 249, 243, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { flex: 1; display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.novel-name {
  font-family: "Ma Shan Zheng", "Noto Serif SC", serif;
  font-size: 22px;
  color: var(--accent);
  letter-spacing: 2px;
  white-space: nowrap;
}
.chapter-now {
  font-size: 14px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-right { display: flex; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: none; border-radius: 12px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: .2s;
}
.icon-btn:hover { background: rgba(201,139,139,.12); color: var(--accent); }

/* ---------- 布局 ---------- */
.layout { display: flex; position: relative; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  height: calc(100vh - 58px);
  position: sticky;
  top: 58px;
  display: flex;
  flex-direction: column;
  transition: margin-left .32s cubic-bezier(.4,0,.2,1), opacity .3s;
  overflow: hidden;
}
body.sidebar-collapsed .sidebar { margin-left: calc(var(--sidebar-w) * -1); }

.sidebar-head { padding: 16px 16px 8px; }
.side-cover {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  height: 128px;
  box-shadow: var(--shadow);
}
.side-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.side-cover-mask {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(74,64,56,.05), rgba(74,64,56,.62));
}
.side-cover-text { position: absolute; left: 16px; bottom: 12px; color: #fff; }
.side-cover-text h1 {
  font-family: "Ma Shan Zheng", serif;
  font-size: 30px; letter-spacing: 3px;
  text-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.side-cover-text p { font-size: 12px; opacity: .9; margin-top: 2px; }

.chapter-search { padding: 8px 16px 10px; }
.chapter-search input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--ink);
  font-family: inherit;
  outline: none;
  transition: .2s;
}
.chapter-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201,139,139,.15); }

.chapter-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-3) transparent;
}
.chapter-list::-webkit-scrollbar { width: 7px; }
.chapter-list::-webkit-scrollbar-thumb { background: #e3d3bf; border-radius: 8px; }
.chapter-list::-webkit-scrollbar-thumb:hover { background: var(--accent-3); }

.chap-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink-soft);
  transition: .18s;
  border: 1px solid transparent;
}
.chap-item:hover { background: #fff; color: var(--ink); }
.chap-item.active {
  background: linear-gradient(90deg, rgba(201,139,139,.16), rgba(201,139,139,.04));
  color: var(--accent);
  border-color: rgba(201,139,139,.25);
  font-weight: 600;
}
.chap-idx {
  flex-shrink: 0;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: rgba(157,184,160,.18);
  color: var(--accent-2);
  font-size: 12px;
  font-family: "Noto Serif SC";
}
.chap-item.active .chap-idx { background: var(--accent); color: #fff; }
.chap-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 遮罩 ---------- */
.backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(74,64,56,.35);
  z-index: 30;
}

/* ---------- 阅读区 ---------- */
.reader {
  flex: 1;
  min-width: 0;
  padding: 32px 24px 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.page {
  width: 100%;
  max-width: 760px;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--line);
}

/* 章节头图 */
.chapter-hero {
  position: relative;
  height: 200px;
  overflow: hidden;
}
.chapter-hero img { width: 100%; height: 100%; object-fit: cover; display: block; filter: saturate(1.05); }
.hero-mask { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,253,249,0) 30%, rgba(255,253,249,.9) 100%); }
.hero-caption {
  position: absolute; left: 0; right: 0; bottom: 16px;
  text-align: center;
}
.hero-label {
  display: inline-block;
  font-size: 13px; letter-spacing: 3px;
  color: var(--accent);
  padding: 3px 14px;
  background: rgba(255,255,255,.7);
  border-radius: 20px;
  backdrop-filter: blur(4px);
}
.hero-title {
  display: block;
  margin-top: 8px;
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 1px;
}

/* 正文 */
.content {
  padding: 34px 44px 40px;
  font-size: calc(17.5px * var(--font-scale));
  line-height: 2.05;
  letter-spacing: .4px;
  color: var(--ink);
  min-height: 300px;
}
.content p { margin: 0 0 1.15em; text-indent: 2em; }
.content p.first-line::first-letter { }
.content .inline-illo {
  display: block;
  margin: 26px auto;
  max-width: 78%;
  max-height: 46vh;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(150,120,90,.18);
  text-indent: 0;
}
.content .illo-wrap { text-align: center; text-indent: 0; margin: 8px 0 26px; }
.content .illo-wrap figcaption { font-size: 12px; color: var(--ink-soft); margin-top: 6px; font-style: italic; }
.chapter-end {
  text-align: center;
  color: var(--accent-2);
  letter-spacing: 6px;
  margin: 30px 0 6px;
  text-indent: 0 !important;
}

/* 翻页 */
.pager {
  width: 100%;
  max-width: 760px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 22px;
  gap: 12px;
}
.page-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 24px;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(150,120,90,.08);
  transition: .2s;
}
.page-btn:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-indicator { font-size: 13px; color: var(--ink-soft); letter-spacing: 1px; }

/* 页脚 */
.site-footer { margin-top: 40px; text-align: center; font-size: 13px; color: var(--ink-soft); }
.site-footer a { text-decoration: none; }

/* 加载 */
.loading {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 100;
  color: var(--ink-soft);
  font-size: 14px; letter-spacing: 2px;
  transition: opacity .4s;
}
.loading.hide { opacity: 0; pointer-events: none; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 内容淡入 */
.page-fade { animation: fade .4s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    top: 58px; left: 0;
    z-index: 35;
    box-shadow: var(--shadow);
    margin-left: 0;
  }
  body:not(.sidebar-open) .sidebar { margin-left: calc(var(--sidebar-w) * -1); }
  body.sidebar-open .backdrop { display: block; }
  .content { padding: 26px 22px 32px; font-size: calc(16.5px * var(--font-scale)); }
  .content .inline-illo { max-width: 92%; }
  .reader { padding: 20px 12px 50px; }
  .chapter-hero { height: 160px; }
  .hero-title { font-size: 19px; }
}
