:root {
  --paper: #fdf4f8;
  --paper-deep: #fbe6f0;
  --card: #fffafc;
  --ink: #4a2b3c;
  --muted: #946e84;
  --faint: #c4a3b7;
  --line: #f2d5e3;
  --accent: #e35f8c;
  --accent-dark: #c43c6d;
  --accent-soft: #fde6f0;
  --gold: #d18a5c;
  --green: #4f9d78;
  --shadow: 0 14px 36px rgba(190, 80, 130, .13);
  --radius: 18px;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --serif: "Songti SC", "STSong", "SimSun", "Noto Serif SC", Georgia, serif;
  --dream: linear-gradient(135deg, #fff0f6 0%, #fde4ef 48%, #f3e8ff 100%);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  background-image:
    radial-gradient(circle at 8% 4%, rgba(255, 205, 228, .55), transparent 32%),
    radial-gradient(circle at 92% 12%, rgba(226, 208, 255, .42), transparent 30%),
    radial-gradient(circle at 50% 100%, rgba(255, 224, 238, .35), transparent 45%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 245, 250, .92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 20px rgba(190, 80, 130, .06);
}
.header-inner {
  max-width: 1180px; margin: 0 auto; padding: 12px 22px;
  display: flex; align-items: center; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #f486ad, #d9538a); color: #fff;
  font-family: var(--serif); font-size: 21px; font-weight: 700;
  box-shadow: 0 5px 14px rgba(227, 95, 140, .32);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-family: var(--serif); font-size: 19px; letter-spacing: 2px; }
.brand-text small { color: var(--muted); font-size: 11px; margin-top: 3px; }

.search-wrap {
  position: relative; flex: 1 1 auto; max-width: 520px;
  display: flex; align-items: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 0 14px; height: 40px;
  transition: border-color .2s, box-shadow .2s;
}
.search-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(227, 95, 140, .14); }
.search-icon { color: var(--faint); font-size: 22px; line-height: 1; }
.search-wrap input {
  flex: 1; border: 0; outline: 0; background: transparent;
  padding: 0 8px; color: var(--ink); font-size: 14px;
}
.search-wrap input::placeholder { color: var(--faint); }
.search-clear { border: 0; background: transparent; color: var(--muted); font-size: 20px; padding: 0 2px; }

.header-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.ghost-btn, .primary-btn, .soft-btn, .icon-btn {
  border-radius: 9px; padding: 9px 15px; font-size: 13px;
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  transition: all .18s;
}
.ghost-btn:hover, .soft-btn:hover { background: var(--paper-deep); border-color: #f0bed3; }
.role-nav { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.role-nav[hidden] { display: none; }
.role-link {
  display: inline-flex; align-items: center; padding: 7px 14px;
  border-radius: 999px; font-size: 13px; font-weight: 600; text-decoration: none;
  color: #d24b80; background: linear-gradient(140deg, #fff0f6, #ffdff0);
  border: 1px solid #f6c6dd; transition: all .18s ease; white-space: nowrap;
}
.role-link:hover { background: linear-gradient(140deg, #ffe3ef, #ffcfe6); border-color: #edaecb; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(227, 95, 140, .18); }
.role-link-solid { color: #fff; background: linear-gradient(140deg, #f08ab5, #e35f8c); border-color: transparent; }
.role-link-solid:hover { background: linear-gradient(140deg, #ec7fae, #d94e7e); border-color: transparent; }
.primary-btn {
  border-color: var(--accent); background: linear-gradient(135deg, #f075a1, #d9538a); color: #fff;
  font-weight: 600; box-shadow: 0 5px 14px rgba(227, 95, 140, .28);
}
.primary-btn:hover { background: var(--accent-dark); transform: translateY(-1px); }
.soft-btn { background: var(--accent-soft); border-color: #f5c8da; color: var(--accent-dark); }
.icon-btn { padding: 6px 10px; }

main { min-height: calc(100vh - 170px); }
#app > section { max-width: 1180px; margin: 0 auto; padding: 30px 22px 60px; }
.boot-state { max-width: 1180px; margin: 80px auto; text-align: center; color: var(--muted); }
.boot-spinner {
  width: 26px; height: 26px; margin: 0 auto 14px;
  border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 首页 */
.dream-banner {
  position: relative; overflow: hidden; text-align: center;
  background: var(--dream); border: 1px solid #f7d3e4;
  border-radius: 22px; padding: 42px 22px 38px; margin-bottom: 34px;
  box-shadow: 0 14px 38px rgba(220, 120, 165, .14);
}
.dream-banner::before, .dream-banner::after {
  content: ""; position: absolute; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.7), transparent 70%);
}
.dream-banner::before { width: 220px; height: 220px; top: -110px; left: -60px; }
.dream-banner::after { width: 260px; height: 260px; bottom: -150px; right: -50px; }
.dream-banner-inner { position: relative; z-index: 2; }
.dream-banner .eyebrow, .section-title .eyebrow {
  display: inline-block; color: var(--accent-dark); font-size: 12px;
  letter-spacing: 3px; font-weight: 700; margin-bottom: 10px;
}
.dream-banner h1 {
  font-family: var(--serif); font-size: clamp(28px, 4vw, 42px);
  margin: 0 0 12px; line-height: 1.3; letter-spacing: 2px;
  background: linear-gradient(100deg, #d9538a, #b07bc9 60%, #e884a8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.dream-banner p { margin: 0; color: var(--muted); font-size: 14px; }
.dream-sparkle {
  position: absolute; z-index: 1; color: #f5a9c8; font-size: 22px;
  animation: float 4s ease-in-out infinite; user-select: none;
}
.dream-sparkle.sp1 { top: 18%; left: 12%; animation-delay: 0s; }
.dream-sparkle.sp2 { top: 28%; right: 15%; font-size: 28px; animation-delay: .6s; color: #d8b4f0; }
.dream-sparkle.sp3 { bottom: 18%; left: 22%; font-size: 18px; animation-delay: 1.2s; }
.dream-sparkle.sp4 { bottom: 26%; right: 10%; animation-delay: 1.8s; }
.dream-sparkle.sp5 { top: 12%; left: 48%; font-size: 16px; animation-delay: 2.4s; color: #f7c1d8; }
@keyframes float { 0%, 100% { transform: translateY(0); opacity: .75; } 50% { transform: translateY(-9px); opacity: 1; } }

.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.section-title h2 { font-family: var(--serif); font-size: 24px; margin: 0; letter-spacing: 1px; }
.section-title p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-chip {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 999px; padding: 6px 14px; font-size: 13px;
  transition: all .18s;
}
.filter-chip:hover { border-color: #f0a9c6; color: var(--accent-dark); }
.filter-chip.active {
  background: linear-gradient(135deg, #f075a1, #d9538a); color: #fff; border-color: transparent;
  box-shadow: 0 4px 12px rgba(227, 95, 140, .26);
}

.story-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 20px; }
.story-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: 0 4px 16px rgba(190, 80, 130, .06);
  transition: transform .2s, box-shadow .2s, border-color .2s;
  display: flex; flex-direction: column;
}
.story-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: #f4bcd3; }
.story-card .cover { width: 100%; aspect-ratio: 3 / 4; position: relative; }
.cover {
  width: 100%; aspect-ratio: 3 / 4;
  display: grid; place-items: center; position: relative; overflow: hidden;
  background: linear-gradient(150deg, #f7c8dd, #d97da6);
}
.cover::after {
  content: ""; position: absolute; inset: 8px;
  border: 1px solid rgba(255,255,255,.42); border-radius: 6px;
}
.cover-emoji { font-size: 62px; filter: drop-shadow(0 6px 12px rgba(0,0,0,.2)); z-index: 1; }
.cover img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.cover-badge {
  position: absolute; top: 14px; left: 14px; z-index: 2;
  background: rgba(255, 250, 252, .94); color: var(--accent-dark);
  font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 700;
}
.cover-unlocked {
  position: absolute; right: 14px; top: 14px; z-index: 2;
  background: var(--green); color: #fff; font-size: 11px; padding: 3px 9px; border-radius: 999px;
}
.story-card-body { padding: 15px 16px 17px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.story-card h3 {
  font-family: var(--serif); font-size: 17px; line-height: 1.45; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 49px;
}
.story-card .intro {
  color: var(--muted); font-size: 13px; line-height: 1.7;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.story-card .card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 6px; }
.tag { font-size: 11px; color: var(--accent-dark); background: var(--accent-soft); padding: 3px 9px; border-radius: 999px; }
.card-foot span { font-size: 11px; color: var(--faint); }
.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); border: 1px dashed #f0bdd3; border-radius: var(--radius); background: rgba(255,255,255,.5); }

/* 详情页 */
.detail-wrap { display: grid; grid-template-columns: 270px 1fr; gap: 34px; }
.detail-cover { width: 100%; aspect-ratio: 3 / 4; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.detail-info h1 { font-family: var(--serif); font-size: clamp(26px, 3.5vw, 38px); margin: 4px 0 12px; line-height: 1.35; }
.detail-info .intro { color: #4a443c; font-size: 15px; line-height: 2; max-width: 720px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 22px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 9px; margin: 16px 0 20px; }
.meta-pill { border: 1px solid var(--line); border-radius: 999px; padding: 5px 13px; font-size: 12px; color: var(--muted); background: var(--card); }
.detail-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.locked-note {
  border-left: 3px solid var(--accent); background: #fff0f6; padding: 12px 15px;
  border-radius: 0 8px 8px 0; color: #985f7b; font-size: 13px; max-width: 720px;
}
.chapter-preview { margin-top: 28px; }
.chapter-preview h3 { font-family: var(--serif); font-size: 19px; margin: 0 0 12px; }
.chapter-preview ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.chapter-preview li {
  border: 1px solid var(--line); background: var(--card); border-radius: 8px;
  padding: 8px 12px; font-size: 12px; color: var(--muted);
}

/* 阅读器 */
.reader-shell { max-width: 1180px; margin: 0 auto; padding: 24px 22px 70px; }
.reader-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.reader-bar h2 { font-family: var(--serif); font-size: 20px; margin: 0; }
.reader-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.reader-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 22px; align-items: start; }
.chapter-panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; max-height: 70vh; overflow: auto; position: sticky; top: 78px;
}
.chapter-panel h3 { font-size: 13px; color: var(--muted); margin: 0 0 10px; letter-spacing: 1px; }
.chapter-list { display: flex; flex-direction: column; gap: 3px; }
.chapter-list button {
  text-align: left; border: 0; background: transparent; padding: 8px 10px;
  border-radius: 7px; font-size: 13px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chapter-list button:hover { background: var(--paper-deep); }
.chapter-list button.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 700; }
.reader-paper {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(24px, 5vw, 56px); min-height: 60vh; box-shadow: var(--shadow);
}
.reader-paper.sepia { background: #f9ecdf; border-color: #efd8c4; }
.reader-paper.night { background: #23211e; border-color: #34312c; color: #d8d2c7; }
.reader-paper h1 { font-family: var(--serif); font-size: clamp(22px, 3vw, 30px); text-align: center; margin: 0 0 28px; }
.reader-paper h2 { font-family: var(--serif); font-size: 19px; margin: 34px 0 18px; padding-bottom: 8px; border-bottom: 1px solid rgba(120,100,80,.18); }
.reader-paper p {
  font-family: var(--serif); font-size: var(--read-size, 18px); line-height: var(--read-leading, 2);
  margin: 0 0 1em; text-indent: 2em; letter-spacing: .3px;
}
.reader-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); }

/* 面板 / 表格 */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px; box-shadow: 0 3px 12px rgba(190, 80, 130, .05);
}
.panel h2, .panel h3 { font-family: var(--serif); margin: 0 0 14px; }
.panel h2 { font-size: 21px; }
.panel h3 { font-size: 17px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; display: flex; flex-direction: column; gap: 4px;
}
.stat b { font-size: 25px; font-family: var(--serif); color: var(--accent); }
.stat span { font-size: 12px; color: var(--muted); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: var(--paper); }
tr:last-child td { border-bottom: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; background: #fff; color: var(--ink); outline: none;
}
.field textarea { min-height: 100px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(227,95,140,.1); }
.form-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.7; }
.code-box {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--paper); border: 1px dashed var(--line);
  border-radius: 10px; padding: 12px 14px; margin: 10px 0 16px;
}
.code-box code { font-size: 16px; font-weight: 700; letter-spacing: 1px; color: var(--accent); word-break: break-all; }
.status-pill { font-size: 11px; padding: 3px 8px; border-radius: 999px; }
.status-on { background: #e5f2e9; color: var(--green); }
.status-off { background: #fde6f0; color: var(--accent-dark); }
.status-warn { background: #fbf0d9; color: #8a6420; }

/* 弹层 */
.modal-mask {
  position: fixed; inset: 0; z-index: 80; background: rgba(74, 43, 60, .45);
  display: grid; place-items: center; padding: 18px;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(520px, 100%); max-height: 90vh; overflow: auto;
  background: var(--card); border-radius: 16px; padding: 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.24);
}
.modal.wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { font-family: var(--serif); font-size: 22px; margin: 0; }
.modal-close { border: 0; background: transparent; font-size: 24px; color: var(--muted); line-height: 1; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { border: 0; background: transparent; padding: 9px 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.link-row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.link-row input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: var(--paper); }
.wechat-btn { border-color: #2f9e57; color: #2f9e57; }

.toast-root { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: linear-gradient(135deg, #d9538a, #b5478c); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.18); animation: rise .2s ease;
}
.toast.error { background: var(--accent-dark); }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }

@media (max-width: 900px) {
  .dream-banner { padding: 34px 18px 30px; }
  .detail-wrap { grid-template-columns: 180px 1fr; gap: 20px; }
  .reader-layout { grid-template-columns: 1fr; }
  .chapter-panel { position: static; max-height: 240px; }
}
@media (max-width: 680px) {
  .header-inner { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .brand-text small { display: none; }
  .search-wrap { order: 3; flex-basis: 100%; max-width: none; }
  .header-actions { margin-left: auto; }
  #app > section { padding: 20px 14px 46px; }
  .dream-banner { padding: 30px 16px 26px; border-radius: 18px; }
  .dream-sparkle.sp1, .dream-sparkle.sp4 { display: none; }
  .detail-wrap { grid-template-columns: 1fr; }
  .detail-cover { width: 170px; }
  .story-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .story-card h3 { font-size: 14px; min-height: 40px; }
  .story-card .intro { font-size: 12px; -webkit-line-clamp: 2; }
  .reader-shell { padding: 16px 12px 50px; }
  .reader-paper { padding: 20px 16px; }
  .reader-paper p { font-size: 17px; }
  .brand-text strong { font-size: 17px; }
  .header-actions .ghost-btn { display: none; }
  .role-link { padding: 6px 10px; font-size: 12px; }
}
