:root {
  --bg: #0c0e14;
  --panel: #151823;
  --panel-2: #1c2030;
  --line: #2a2f42;
  --text: #e7e9f0;
  --muted: #9aa0b5;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --gold: #ffcb47;
  --green: #36d399;
  --red: #ff6b6b;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px; line-height: 1.7;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #151823, #181a2b);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  font-size: 26px; color: var(--accent);
  text-shadow: 0 0 14px rgba(124,92,255,.7);
}
.topbar h1 { margin: 0; font-size: 19px; letter-spacing: 1px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.live-badge {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  color: var(--muted); background: var(--panel); border: 1px solid var(--line);
  padding: 7px 13px; border-radius: 999px;
}
.dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 10px var(--green); animation: pulse 1.6s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

.layout {
  display: grid; grid-template-columns: 300px 1fr 340px;
  gap: 16px; padding: 16px; max-width: 1500px; margin: 0 auto; align-items: start;
}
.col-left, .col-right { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 86px; }
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px;
}
.panel h2 { margin: 0 0 12px; font-size: 15px; color: #fff; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.field select, .field input, .hc-form textarea, .para-pop-add input, #genInstruction {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 9px 11px; font-size: 14px; font-family: inherit; width: 100%;
}
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }

button { cursor: pointer; border: none; border-radius: 9px; font-size: 14px; padding: 10px 14px; font-family: inherit; transition: .15s; }
.primary { background: linear-gradient(90deg, var(--accent), #9b7bff); color: #fff; font-weight: 600; }
.primary:hover { filter: brightness(1.1); }
.primary:disabled, .ghost:disabled { opacity: .45; cursor: not-allowed; }
.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.ghost:hover { border-color: var(--accent); }
.full { width: 100%; margin-top: 6px; }

.chapter-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; max-height: 52vh; overflow: auto; }
.chapter-list li {
  padding: 9px 11px; border-radius: 9px; background: var(--panel-2);
  border: 1px solid transparent; cursor: pointer; font-size: 13.5px;
}
.chapter-list li:hover { border-color: var(--accent); }
.chapter-list li.active { border-color: var(--accent); background: #221d3a; }
.chapter-list .cl-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.tag-writing { color: var(--accent-2); }
.author-badge {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: rgba(124,92,255,.18); color: #c9bcff; border: 1px solid rgba(124,92,255,.4);
}

.reader { min-height: 60vh; }
.reader-head { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 14px; }
.reader-head h2 { margin: 0 0 6px; font-size: 22px; }
.chapter-meta { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.chapter-body { font-size: 16px; }
.chapter-body p { margin: 0 0 16px; }
.chapter-body p.para { cursor: pointer; border-left: 3px solid transparent; padding-left: 12px; transition: .15s; border-radius: 4px; }
.chapter-body p.para:hover { border-left-color: var(--accent); background: rgba(124,92,255,.06); }
.chapter-body p.para.has-comment { border-left-color: var(--gold); }
.placeholder { color: var(--muted); }
.writing-cursor::after { content: "▋"; color: var(--accent-2); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.rating-avg { font-size: 34px; font-weight: 700; color: var(--gold); }
.rating-avg small { font-size: 14px; color: var(--muted); font-weight: 400; }
.rating-dist { display: flex; flex-direction: column; gap: 5px; margin: 10px 0; }
.rating-dist .row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.rating-dist .bar { flex: 1; height: 8px; background: var(--panel-2); border-radius: 6px; overflow: hidden; }
.rating-dist .bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #ff9b3d); }

.comment-list { display: flex; flex-direction: column; gap: 11px; max-height: 46vh; overflow: auto; }
.comment {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13.5px;
}
.comment .c-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.comment .c-name { font-weight: 600; color: #d9d3ff; }
.comment .c-name.human { color: var(--accent-2); }
.comment .c-persona { color: var(--muted); font-size: 11.5px; }
.comment .c-stars { color: var(--gold); font-size: 12px; }
.comment .c-text { color: var(--text); }
.comment .c-time { color: var(--muted); font-size: 11px; }
.empty { color: var(--muted); font-size: 13px; }

.human-comment summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.hc-form { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.stars { display: flex; gap: 4px; font-size: 22px; color: #3a3f55; }
.stars span { cursor: pointer; }
.stars span.on { color: var(--gold); }

.para-pop {
  position: fixed; right: 22px; bottom: 22px; width: 380px; max-height: 70vh;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6); display: flex; flex-direction: column; z-index: 40; overflow: hidden;
}
.para-pop.hidden, .toast.hidden { display: none; }
.para-pop-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
.para-pop-head button { background: none; color: var(--muted); padding: 2px 8px; }
.para-pop-body { padding: 12px 14px; overflow: auto; display: flex; flex-direction: column; gap: 9px; }
.para-pop-add { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.para-pop-add input { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--accent); color: var(--text);
  padding: 11px 18px; border-radius: 999px; font-size: 13.5px; z-index: 50;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}

@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .col-left, .col-right { position: static; }
}
