/* ============ 墨阁 · 书卷风样式 ============ */
:root {
  --bg: #f6f2ea;
  --panel: #fffdf8;
  --paper: #fbf8f1;
  --ink: #2c2a26;
  --ink-2: #6b6558;
  --line: #e4dccc;
  --accent: #9a3b26;        /* 朱砂红 */
  --accent-soft: #f3e2dc;
  --gold: #b8860b;
  --ok: #3a7d44;
  --warn: #b07d1e;
  --danger: #a83232;
  --shadow: 0 2px 12px rgba(60, 45, 20, .08);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #201e1a;
    --panel: #2a2723;
    --paper: #262320;
    --ink: #e8e2d5;
    --ink-2: #a39b8a;
    --line: #3d382f;
    --accent: #d4694e;
    --accent-soft: #40302b;
    --shadow: 0 2px 12px rgba(0, 0, 0, .35);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[v-cloak] { display: none; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg); color: var(--ink);
  font-size: 14px;
}
#app { height: 100vh; display: flex; flex-direction: column; }

button { font-family: inherit; cursor: pointer; }
input, textarea, select {
  font-family: inherit; font-size: 14px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 10px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.6; }
textarea.mono { font-family: Consolas, monospace; font-size: 12px; }
label { display: block; margin: 12px 0 6px; font-weight: 600; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 14px; margin-bottom: 6px; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; line-height: 1.6; }

/* ---- 按钮 ---- */
.btn {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  padding: 8px 16px; border-radius: 8px; font-size: 14px;
  text-decoration: none; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); color: #fff; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn.tiny { padding: 2px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- 顶部导航 ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 54px; flex-shrink: 0;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-size: 19px; font-weight: 700; cursor: pointer; letter-spacing: 2px; }
.brand-sub { font-size: 12px; color: var(--ink-2); font-weight: 400; letter-spacing: 0; margin-left: 8px; }
.tabs { display: flex; gap: 4px; }
.tabs button {
  background: none; border: none; padding: 8px 16px; font-size: 14px;
  color: var(--ink-2); border-radius: 8px;
}
.tabs button.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* ---- 书架 ---- */
.shelf { flex: 1; overflow-y: auto; padding: 28px 40px; max-width: 1200px; margin: 0 auto; width: 100%; }
.shelf-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.empty-shelf { text-align: center; padding: 80px 0; font-size: 16px; }
.empty-shelf .muted { margin-top: 8px; font-size: 13px; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.book-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: all .2s; box-shadow: var(--shadow);
}
.book-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.book-cover {
  height: 120px; padding: 16px; display: flex; flex-direction: column; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, #6d2818 100%);
  color: #fdf6ec; text-align: center;
}
.book-title { font-size: 18px; font-weight: 700; font-family: "SimSun", serif; letter-spacing: 1px; }
.book-genre { font-size: 12px; opacity: .8; }
.book-info { padding: 12px 14px; }
.book-status { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.book-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }

.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress .bar { height: 100%; background: linear-gradient(90deg, var(--gold), var(--accent)); transition: width .5s; }
.progress.wide { width: 220px; }

.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: var(--line); color: var(--ink-2); white-space: nowrap;
}
.badge.st-writing, .badge.st-blueprinting { background: #e8f0e9; color: var(--ok); }
.badge.st-completed { background: #e8f0e9; color: var(--ok); }
.badge.st-blueprint_ready { background: #fdf3d9; color: var(--warn); }
.badge.st-paused { background: #fdf3d9; color: var(--warn); }
.badge.st-error { background: #f8e4e4; color: var(--danger); }
@media (prefers-color-scheme: dark) {
  .badge.st-writing, .badge.st-blueprinting, .badge.st-completed { background: #263a2a; }
  .badge.st-blueprint_ready, .badge.st-paused { background: #3d3420; }
  .badge.st-error { background: #402525; }
}

/* ---- 弹窗 ---- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(30, 20, 10, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--panel); border-radius: 14px; padding: 24px 28px;
  width: min(620px, 92vw); max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow);
}
.modal h2 { margin-bottom: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.row { display: flex; gap: 16px; } .col { flex: 1; }

/* ---- 设置 ---- */
.settings { flex: 1; overflow-y: auto; padding: 28px 40px; max-width: 900px; margin: 0 auto; width: 100%; }
.settings > .muted { margin: 6px 0 20px; }
.settings-layout { display: flex; gap: 24px; }
.profile-list { width: 200px; flex-shrink: 0; display: flex; flex-direction: column; gap: 8px; }
.profile-item {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; background: var(--panel);
}
.profile-item.active { border-color: var(--accent); background: var(--accent-soft); }
.profile-form { flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px 24px; }
.settings-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.test-result { margin-top: 12px; color: var(--danger); }
.test-result.ok { color: var(--ok); }

/* ---- 工作台 ---- */
.workbench { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.work-head {
  display: flex; align-items: center; gap: 18px; padding: 10px 20px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.work-title { display: flex; align-items: center; gap: 10px; }
.work-title h1 { font-size: 18px; font-family: "SimSun", serif; }
.work-progress { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.work-actions { display: flex; gap: 8px; }
.error-banner { padding: 10px 20px; background: #f8e4e4; color: var(--danger); font-size: 13px; }
@media (prefers-color-scheme: dark) { .error-banner { background: #402525; } }

.work-body { flex: 1; display: flex; overflow: hidden; }

/* 左：目录 */
.chapter-list {
  width: 230px; flex-shrink: 0; border-right: 1px solid var(--line);
  background: var(--panel); display: flex; flex-direction: column;
}
.panel-title { padding: 12px 16px 8px; font-weight: 700; }
.chapter-scroll { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.chapter-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  border-radius: 6px; cursor: pointer; margin-bottom: 2px;
}
.chapter-item:hover { background: var(--accent-soft); }
.chapter-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chapter-item.flagged .ch-title::after { content: " ⚠️"; }
.ch-idx { font-size: 11px; color: var(--ink-2); min-width: 22px; text-align: right; }
.ch-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.ch-words { flex-shrink: 0; }

/* 中：阅读区 */
.reader { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--paper); }
.reader-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 36px 10px; border-bottom: 1px dashed var(--line);
}
.reader-head h2 { font-family: "SimSun", serif; }
.reader-body {
  flex: 1; overflow-y: auto; padding: 24px 48px 60px;
  font-family: "SimSun", "Noto Serif SC", serif; font-size: 17px; line-height: 2;
  white-space: pre-wrap; max-width: 820px; margin: 0 auto; width: 100%;
}
.reader-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; font-size: 16px;
}
.caret { color: var(--accent); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* 右：信息面板 */
.side-panel {
  width: 320px; flex-shrink: 0; border-left: 1px solid var(--line);
  background: var(--panel); display: flex; flex-direction: column;
}
.panel-tabs { display: flex; border-bottom: 1px solid var(--line); }
.panel-tabs button {
  flex: 1; background: none; border: none; padding: 10px 0; font-size: 13px;
  color: var(--ink-2); border-bottom: 2px solid transparent;
}
.panel-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.panel-content { flex: 1; overflow-y: auto; padding: 14px 16px; }
.bp-block { margin-bottom: 16px; }
.bp-block p { line-height: 1.7; font-size: 13px; }
.tags { margin-top: 4px; }
.tag {
  display: inline-block; font-size: 11px; padding: 1px 8px; margin-right: 6px;
  background: var(--accent-soft); color: var(--accent); border-radius: 8px;
}
.volume-card, .char-card, .outline-card {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px;
  background: var(--paper);
}
.char-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.char-card .state { color: var(--accent); }
.outline-card.done { opacity: .55; }
.outline-card .hook { color: var(--gold); }
.fs-item { display: flex; gap: 6px; margin-bottom: 6px; align-items: baseline; }
.fs-item.resolved { opacity: .5; }
.logs { font-family: Consolas, monospace; }
.log-line { margin-bottom: 4px; word-break: break-all; }

/* ---- 其他 ---- */
.spinner {
  width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 22px; border-radius: 20px;
  font-size: 13px; z-index: 200; box-shadow: var(--shadow);
}

/* 窄屏：右侧面板改为抽屉，浮动按钮唤出（不再直接隐藏） */
.panel-fab {
  display: none; position: fixed; right: 16px; bottom: 20px; z-index: 95;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--accent); color: #fff; font-size: 19px; box-shadow: var(--shadow);
  align-items: center; justify-content: center;
}
@media (max-width: 900px) {
  .side-panel {
    position: fixed; top: 54px; right: 0; bottom: 0; width: min(320px, 88vw);
    transform: translateX(105%); transition: transform .25s ease; z-index: 90;
    box-shadow: -6px 0 18px rgba(40, 25, 10, .18); border-left: 1px solid var(--line);
  }
  .side-panel.open { transform: translateX(0); }
  .panel-fab { display: flex; }
  .chapter-list { width: 170px; }
  .reader-body { padding: 20px 24px 40px; }
}

/* ============ 多租户：登录 / 点数 / 管理（单机模式不渲染这些节点） ============ */
.auth-mask {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.auth-card {
  width: min(400px, 92vw);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 36px 32px;
}
.auth-card h1 { text-align: center; margin-bottom: 8px; }
.auth-card > p.muted { text-align: center; margin-bottom: 12px; }
.auth-switch { text-align: center; margin-top: 14px; }
.auth-switch a { color: var(--accent); cursor: pointer; }
.btn.wide { width: 100%; justify-content: center; margin-top: 18px; }

.user-box { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-email { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.points-badge {
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 4px 12px; font-weight: 600; font-size: 13px;
  white-space: nowrap;
}

.modal.narrow { width: min(420px, 92vw); }

.admin-grid { display: flex; flex-direction: column; gap: 18px; max-width: 860px; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td {
  text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line);
}
.admin-table th { color: var(--ink-2); font-size: 12px; font-weight: 600; }
.admin-table .mono { font-family: Consolas, monospace; }

.pw-block { max-width: 560px; margin-top: 18px; }

/* ---- 订阅 / 价目 ---- */
.points-badge.expired { background: var(--line); color: var(--ink-2); }
.price-row { display: flex; gap: 12px; margin: 8px 0 12px; }
.price-card {
  flex: 1; text-align: center; padding: 12px 8px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.price-card .price { font-size: 22px; font-weight: 700; color: var(--accent); }

/* ---- 社区 ---- */
.post-row { cursor: pointer; transition: border-color .15s; }
.post-row:hover { border-color: var(--accent); }
.post-body { white-space: pre-wrap; line-height: 1.8; text-indent: 0; }
.reply-item { border-top: 1px solid var(--line); padding: 8px 0; }

/* ---- 管理统计 / 站点设置 / 公告 / 引导 ---- */
.stat-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 18px; }
.stat-card {
  flex: 1; min-width: 90px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 6px; display: flex; flex-direction: column; gap: 2px;
}
.stat-card b { font-size: 20px; color: var(--accent); }
.stat-card span { font-size: 12px; color: var(--ink-2); }
.announcement {
  background: var(--accent-soft); color: var(--ink);
  padding: 8px 24px; font-size: 13px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.admin-table tr.banned td { opacity: .55; }
.onboard {
  margin-top: 16px; text-align: left; display: inline-block;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 20px;
}
.onboard p { margin: 6px 0; }
.auth-foot { text-align: center; margin-top: 12px; line-height: 1.8; }
.auth-foot a { color: var(--accent); text-decoration: none; }
