:root {
  --bg: #0c0e12;
  --bg-elev: #141820;
  --panel: #171b24;
  --panel-2: #1c2230;
  --ink: #f2ebe0;
  --muted: #8f96a3;
  --line: #2a3140;
  --line-soft: #232936;
  --accent: #e0b03a;
  --accent-2: #c45c26;
  --accent-dim: rgba(224, 176, 58, .14);
  --hot: #e85d4c;
  --ok: #6fbf7a;
  --danger: #e07070;
  --radius: 14px;
  --ui: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
  --serif: "Songti SC", "Source Han Serif SC", "Noto Serif SC", "STSong", serif;
  --shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--ink);
  font-family: var(--ui); line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.bg {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 420px at 8% -8%, #3a2812 0%, transparent 55%),
    radial-gradient(700px 360px at 100% 0%, #152033 0%, transparent 50%),
    radial-gradient(500px 280px at 70% 100%, #1a1510 0%, transparent 45%);
}
.bg::after {
  content: ""; position: absolute; inset: 0; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
header, main { position: relative; z-index: 1; max-width: 920px; margin: 0 auto; padding: 28px 20px 0; }
header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-bottom: 8px; }
.brand { display: flex; gap: 14px; align-items: center; min-width: 0; }
.mark {
  width: 46px; height: 46px; flex-shrink: 0;
  border: 1px solid var(--accent); color: var(--accent);
  border-radius: 12px; display: grid; place-items: center;
  font-family: var(--serif); font-size: 22px; font-weight: 700;
  background: var(--accent-dim);
}
h1 {
  margin: 0; font-family: var(--serif); font-size: 26px;
  letter-spacing: .14em; font-weight: 600;
}
header p, .hint, .logline {
  color: var(--muted); font-size: 13px; margin: 4px 0 0;
}
.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 22px 20px; margin: 16px 0;
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  margin-bottom: 16px;
}
h2 {
  margin: 0 0 16px; font-family: var(--serif); font-size: 17px;
  letter-spacing: .16em; font-weight: 600;
}
.panel-head h2 { margin: 0; }
.field { margin-bottom: 16px; }
label { display: block; margin-bottom: 8px; font-size: 13px; color: #c8c2b6; letter-spacing: .04em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: rgba(255,255,255,.02); color: var(--ink);
  padding: 7px 12px; cursor: pointer; font-size: 13px; border-radius: 999px;
  transition: border-color .15s, background .15s, transform .1s;
}
.chip:hover { border-color: #5a4a28; background: var(--accent-dim); }
.chip:active { transform: scale(.98); }
.chip.on {
  background: linear-gradient(90deg, var(--accent), var(--accent-2)) !important;
  color: #1a1406 !important;
  border-color: transparent !important;
  font-weight: 700;
  box-shadow: 0 0 0 1px rgba(224, 176, 58, .35);
}
.chip .hot { color: var(--hot); font-size: 10px; margin-left: 4px; font-weight: 700; }
.chip.on .hot { color: #6a180e; }
input, textarea {
  width: 100%; background: #10141c; color: var(--ink); border: 1px solid var(--line);
  padding: 11px 12px; font-size: 14px; border-radius: 10px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
  border-color: #6a5520; box-shadow: 0 0 0 3px var(--accent-dim);
}
textarea { resize: vertical; line-height: 1.75; min-height: 72px; }
.primary, a.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #1a1406; border: 0; padding: 11px 18px; font-weight: 700; cursor: pointer;
  letter-spacing: .08em; border-radius: 10px; text-decoration: none; font-size: 14px;
  transition: filter .15s, transform .1s, opacity .15s;
}
.primary:hover:not(:disabled), a.primary:hover { filter: brightness(1.05); }
.primary:active:not(:disabled) { transform: translateY(1px); }
.primary:disabled { opacity: .5; cursor: wait; }
.ghost, .copy-btn {
  color: var(--accent); background: transparent; border: 1px solid #5a4718;
  padding: 7px 12px; cursor: pointer; font-size: 12px; border-radius: 8px;
  text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.ghost:hover, .copy-btn:hover:not(:disabled) { background: var(--accent-dim); border-color: #7a6428; }
.copy-btn:disabled { opacity: .4; cursor: not-allowed; }
.hidden { display: none !important; }
.title-row { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
#title { font-size: 20px; font-family: var(--serif); letter-spacing: .08em; }
.selling { padding-left: 18px; color: #d7c8a6; font-size: 13px; margin: 8px 0 12px; }
.rec {
  border: 1px dashed #4a3d22; padding: 12px 14px; margin: 12px 0; color: #e6d3a3;
  font-size: 13px; line-height: 1.75; border-radius: 10px; background: rgba(224,176,58,.05);
}
.range { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.range input { width: 96px; }
.range span, .range label { color: var(--muted); margin: 0; }
.status {
  font-size: 13px; color: var(--ok); margin-bottom: 12px;
  padding: 10px 12px; border-radius: 10px; background: rgba(111,191,122,.08);
  border: 1px solid rgba(111,191,122,.2);
}
.status.warn { color: #e6c07a; background: rgba(224,176,58,.08); border-color: rgba(224,176,58,.25); }
.status.err { color: var(--danger); background: rgba(224,112,112,.08); border-color: rgba(224,112,112,.25); }
.download { color: var(--accent); font-size: 13px; text-decoration: none; }
.download:hover { text-decoration: underline; }
.back {
  color: var(--muted); text-decoration: none; font-size: 13px;
  padding: 8px 10px; border-radius: 8px;
}
.back:hover { color: var(--accent); background: rgba(255,255,255,.03); }
.result-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 4px; }

/* 书架 */
.shelf-toolbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-bottom: 4px;
}
.shelf-count { color: var(--muted); font-size: 12px; }
.work-list { display: flex; flex-direction: column; gap: 10px; }
.work-item {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: start;
  padding: 16px; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(255,255,255,.015);
  transition: border-color .15s, background .15s, transform .15s;
}
.work-item:hover {
  border-color: #5a4a28; background: var(--accent-dim);
  transform: translateY(-1px);
}
.work-title {
  font-family: var(--serif); font-size: 19px; letter-spacing: .08em; line-height: 1.35;
}
.work-ch {
  color: var(--accent); font-size: 12px; white-space: nowrap;
  padding: 4px 8px; border-radius: 999px; background: rgba(224,176,58,.1);
  border: 1px solid rgba(224,176,58,.2);
}
.work-meta { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.work-links { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.work-links a,
.work-links .linkish {
  color: var(--ink); text-decoration: none; font-size: 13px;
  background: #12161f; border: 1px solid var(--line); padding: 7px 12px;
  border-radius: 8px; cursor: pointer; font-family: inherit;
  transition: border-color .15s, color .15s;
}
.work-links a:hover,
.work-links .linkish:hover { border-color: var(--accent); color: var(--accent); }
.work-links .linkish.primary-lite {
  background: var(--accent-dim); border-color: #5a4718; color: var(--accent); font-weight: 650;
}
.work-links .linkish.danger {
  color: var(--danger); border-color: rgba(224,112,112,.35); background: rgba(224,112,112,.06);
}
.work-links .linkish.danger:hover {
  color: #ff8f8f; border-color: rgba(224,112,112,.55); background: rgba(224,112,112,.12);
}

/* 骨架 / 空态 */
.skeleton { display: flex; flex-direction: column; gap: 10px; }
.sk {
  height: 72px; border-radius: 12px; border: 1px solid var(--line-soft);
  background: linear-gradient(90deg, #151922 0%, #1c2230 45%, #151922 100%);
  background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.empty {
  text-align: center; padding: 36px 16px; color: var(--muted); font-size: 14px;
  border: 1px dashed var(--line); border-radius: 12px;
}
.empty a { color: var(--accent); }

/* 步骤条 */
.steps {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; position: relative; z-index: 1;
  max-width: 920px; margin-left: auto; margin-right: auto; padding: 0 20px;
}
.step {
  font-size: 12px; color: var(--muted); padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255,255,255,.02);
}
.step.on { color: var(--accent); border-color: #5a4718; background: var(--accent-dim); }
.step.done { color: var(--ok); border-color: rgba(111,191,122,.3); }

/* toast */
.app-toast, .copy-toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: #243028; color: var(--ok); border: 1px solid #3d5a38;
  padding: 10px 16px; font-size: 13px; z-index: 120; border-radius: 999px;
  box-shadow: var(--shadow); pointer-events: none;
}
.app-toast.err { background: #302424; color: var(--danger); border-color: #5a3d3d; }

/* 弹窗读书 */
body.modal-open { overflow: hidden; }
.reader-modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.reader-modal.hidden { display: none; }
.reader-modal-backdrop { position: absolute; inset: 0; background: rgba(4, 5, 8, .78); backdrop-filter: blur(6px); }
.reader-modal-panel {
  position: relative; z-index: 1; width: min(1120px, 100%);
  height: min(880px, calc(100vh - 40px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  display: flex; flex-direction: column; min-height: 0; box-shadow: var(--shadow);
  overflow: hidden; animation: pop .18s ease-out;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: none; }
}
.reader-modal-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 16px 18px; border-bottom: 1px solid var(--line); flex-shrink: 0;
  background: #141820;
}
.reader-modal-head h2 {
  margin: 0; font-family: var(--serif); font-size: 20px; letter-spacing: .1em;
}
.reader-modal-body {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 250px minmax(0, 1fr);
}
.reader-modal-body .toc {
  position: static; max-height: none; height: 100%; margin: 0;
  border-right: 1px solid var(--line); padding: 12px; background: #12161e;
  display: flex; flex-direction: column; min-height: 0;
}
.toc-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  margin-bottom: 10px; flex-shrink: 0;
}
.toc-list {
  overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 4px;
}
.toc-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left; cursor: pointer;
  background: transparent; border: 1px solid transparent; color: var(--ink);
  padding: 10px; font-size: 13px; border-radius: 8px;
}
.toc-item:hover { border-color: var(--line); background: #1a1f2a; }
.toc-item.on { border-color: #5a4718; background: var(--accent-dim); }
.toc-no { color: var(--muted); font-size: 11px; }
.toc-name { line-height: 1.4; }
.reader-modal-body .reader-pane {
  position: static; max-height: none; height: 100%; margin: 0; border: 0;
  padding: 14px 18px; background: transparent;
  display: flex; flex-direction: column; min-height: 0;
}
.reader-toolbar {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  margin-bottom: 12px; flex-shrink: 0;
}
.chapter-title-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-width: 0; flex: 1;
}
.chapter-title-row h2, .chapter-title-row h3 {
  margin: 0; font-family: var(--serif); font-size: 18px; letter-spacing: .06em; line-height: 1.35;
}
.reader-body-text {
  flex: 1; overflow: auto; white-space: pre-wrap;
  line-height: 1.95; font-size: 17px; padding-right: 6px;
  font-family: var(--serif); color: #efe8dc;
}
.reader-modal .copy-toast { bottom: 28px; }

@media (max-width: 860px) {
  .reader-modal { padding: 8px; }
  .reader-modal-panel { height: calc(100vh - 16px); border-radius: 12px; }
  .reader-modal-body { grid-template-columns: 1fr; grid-template-rows: 170px 1fr; }
  .reader-modal-body .toc { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 640px) {
  header { flex-direction: column; align-items: flex-start; }
  .title-row { flex-direction: column; align-items: stretch; }
  h1 { font-size: 22px; }
}
