:root {
  --paper: #fbf8f2;
  --card: #fffdf8;
  --ink: #26221d;
  --sub: #6f675c;
  --faint: #a39a8c;
  --line: #e7e1d4;
  --accent: #8a6a3f;
  --accent-soft: #f1e7d6;
  --danger: #a8453a;
  --ok: #4c7a52;
  --shadow: 0 1px 2px rgba(38, 34, 29, .04), 0 8px 24px rgba(38, 34, 29, .05);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button { font: inherit; cursor: pointer; }

.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

/* ---------- 侧栏 ---------- */
.side {
  background: #f6f1e7; border-right: 1px solid var(--line);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 17px; font-weight: 600;
}
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: 1px; }
.brand-sub { font-size: 11px; color: var(--faint); letter-spacing: .5px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; gap: 10px; align-items: baseline;
  padding: 9px 10px; border-radius: 8px; color: var(--sub); font-size: 13.5px;
}
.nav a i { font-style: normal; font-size: 10px; color: var(--faint); letter-spacing: 1px; width: 16px; }
.nav a:hover { background: rgba(138, 106, 63, .07); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--ink); font-weight: 500; }
.nav a.on i { color: var(--accent); }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; font-size: 11.5px; color: var(--sub); }
.elder-chip { display: flex; gap: 6px; align-items: center; padding: 8px 10px; background: #fffdf8; border: 1px solid var(--line); border-radius: 8px; }
.elder-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex: 0 0 auto; }
.provider-line { color: var(--faint); line-height: 1.5; padding: 0 10px; }
.elder-link { padding: 0 10px; }

/* ---------- 主区 ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(251, 248, 242, .92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 14px 28px; display: flex; align-items: center; gap: 12px;
}
.topbar h1 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: .5px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.view { padding: 22px 28px 64px; max-width: 1180px; width: 100%; }
.loading, .empty { color: var(--faint); padding: 60px 0; text-align: center; }

/* ---------- 通用块 ---------- */
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 4px; font-size: 13px; font-weight: 600; letter-spacing: .3px; }
.card .sub { color: var(--faint); font-size: 11.5px; }
.section-title { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 12px; }
.section-title h2 { font-size: 14px; margin: 0; font-weight: 600; }
.section-title span { color: var(--faint); font-size: 12px; }
.section-title .spacer { flex: 1; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .num { font-size: 24px; font-weight: 600; letter-spacing: .5px; }
.stat .label { font-size: 11.5px; color: var(--faint); }

.muted { color: var(--sub); }
.faint { color: var(--faint); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* ---------- 控件 ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 13px; border-radius: 8px; font-size: 13px;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #78592f; color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--sub); }
.btn.ghost:hover { background: rgba(138, 106, 63, .08); color: var(--ink); }
.btn.danger { color: var(--danger); border-color: #ead4d0; }
.btn.danger:hover { background: #fbf0ee; color: var(--danger); border-color: var(--danger); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary:disabled { background: var(--faint); border-color: var(--faint); }

input[type=text], input[type=number], textarea, select {
  width: 100%; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 106, 63, .1); }
textarea { resize: vertical; min-height: 64px; line-height: 1.7; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--sub); }
.field .hint { font-size: 11px; color: var(--faint); }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { min-width: 0; }

/* ---------- 概览 ---------- */
.hero { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.hero .name { font-size: 22px; font-weight: 600; letter-spacing: 1px; }
.hero .meta { color: var(--sub); font-size: 12.5px; margin-top: 4px; }
.hero .bio { margin-top: 10px; color: var(--sub); max-width: 620px; }
.todo { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.todo:last-child { border-bottom: none; }
.todo .mark { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; font-size: 10px; color: var(--faint); flex: 0 0 auto; }
.todo.done .mark { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent); }
.todo .body { flex: 1; min-width: 0; }
.todo .body b { font-weight: 500; }
.todo .body div { font-size: 11.5px; color: var(--faint); }

/* ---------- 素材 ---------- */
.drop {
  border: 1px dashed #d8cdb9; border-radius: 12px; padding: 26px; text-align: center;
  color: var(--sub); background: #fffcf6; transition: .15s;
}
.drop.hot { border-color: var(--accent); background: var(--accent-soft); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.thumb { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.thumb img { width: 100%; height: 130px; object-fit: cover; display: block; background: #eee; }
.thumb .body { padding: 8px 10px; }
.thumb input { border: none; background: transparent; padding: 2px 0; font-size: 12px; }
.thumb input:focus { box-shadow: none; border-bottom: 1px solid var(--accent); border-radius: 0; }
.thumb .acts { display: flex; gap: 6px; justify-content: flex-end; margin-top: 4px; }
.cover-tag { position: absolute; }
.badge { display: inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }

/* ---------- 脚本 ---------- */
.topic { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.topic .head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.topic .idx { font-size: 11px; color: var(--faint); letter-spacing: 1px; }
.topic .title { font-weight: 600; font-size: 14px; flex: 1; border: none; background: transparent; padding: 2px 4px; }
.topic .title:focus { border-bottom: 1px solid var(--accent); }
.topic .main { font-size: 14px; }
.probes { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.probe { display: grid; grid-template-columns: 96px 1fr 28px; gap: 8px; align-items: center; }
.probe select { font-size: 12px; padding: 5px 6px; }
.probe input { font-size: 12.5px; padding: 6px 8px; }
.x-btn { border: none; background: transparent; color: var(--faint); font-size: 16px; line-height: 1; padding: 4px; }
.x-btn:hover { color: var(--danger); }

/* ---------- 转录 ---------- */
.seg-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.seg-table th { text-align: left; color: var(--faint); font-weight: 400; font-size: 11px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.seg-table td { padding: 7px 8px; border-bottom: 1px solid #f1ece1; vertical-align: top; }
.seg-table tr:hover td { background: #fffaf0; }
.seg-edit { width: 100%; min-height: 44px; font-size: 12.5px; font-family: inherit; line-height: 1.55; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 4px 6px; color: var(--ink); resize: vertical; }
.seg-edit:hover { border-color: var(--line); background: #fffdf7; }
.seg-edit:focus { outline: none; border-color: var(--accent); background: #fffdf8; }
.tag { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; background: #f0ece3; color: var(--sub); }
.tag.ok { background: #eaf1e8; color: var(--ok); }
.tag.warn { background: #fbf0e2; color: #9a6b25; }
.sugg { padding: 10px 0; border-bottom: 1px dashed var(--line); display: grid; gap: 5px; }
.sugg del { color: #9a6b25; background: #fbf0e2; text-decoration: none; border-radius: 3px; padding: 0 2px; }
.sugg ins { color: var(--ok); background: #eaf1e8; text-decoration: none; border-radius: 3px; padding: 0 2px; }
.sugg:last-child { border-bottom: none; }
.turn-row { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.turn-row .q { font-size: 12.5px; color: var(--accent); }
.turn-row textarea { min-height: 56px; }
.audio { height: 32px; vertical-align: middle; }

/* ---------- 成稿 ---------- */
.book-head { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.chapter { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 14px; }
.chapter .ch-head { display: flex; gap: 10px; align-items: center; }
.chapter .ch-head .num { font-size: 10.5px; color: var(--faint); letter-spacing: 2px; }
.chapter .ch-title { font-size: 16px; font-weight: 600; border: none; background: transparent; padding: 2px 4px; }
.chapter .ch-title:focus { border-bottom: 1px solid var(--accent); }
.chapter .lead { width: 100%; margin: 8px 0 4px; font-size: 13px; color: var(--sub); border-style: dashed; }
.para { display: flex; gap: 14px; align-items: flex-start; padding: 10px 0; border-top: 1px dashed #f0ebe0; }
.para .text { flex: 1; font-size: 14.5px; line-height: 1.9; font-family: "Songti SC", "SimSun", serif; }
.para .qrbox { flex: 0 0 auto; text-align: center; width: 78px; }
.para .qrbox img { width: 66px; height: 66px; display: block; }
.para .qrbox .code { font-size: 10px; color: var(--faint); letter-spacing: .5px; }
.para.estimated .qrbox { color: var(--faint); font-size: 10.5px; width: 78px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(8px);
  background: rgba(38, 34, 29, .9); color: #fff; padding: 9px 16px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: 70vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #7d3a33; }

/* ---------- 弹层 ---------- */
.modal { position: fixed; inset: 0; background: rgba(38,34,29,.38); display: grid; place-items: center; z-index: 50; }
.modal .box { background: var(--card); border-radius: 14px; padding: 20px 22px; width: min(520px, 92vw); max-height: 84vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal .box h3 { margin: 0 0 10px; font-size: 15px; }
.modal .box .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 14px 12px; gap: 12px; }
  .side .brand-sub, .side-foot .provider-line { display: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 2px; }
  .nav a { white-space: nowrap; padding: 7px 9px; }
  .nav a i { display: none; }
  .topbar { padding: 12px 16px; }
  .view { padding: 16px 16px 56px; }
  .probe { grid-template-columns: 78px 1fr 28px; }
}
