/* 拆书笔记 · 个人知识库 —— v2 视觉升级（深色模式 / 渐变封面 / 毛玻璃顶栏） */
:root {
  --bg: #f4f5fa;
  --panel: #ffffff;
  --sidebar: #fafafd;
  --line: #e5e8f1;
  --line-soft: #eef0f7;
  --text: #1e222b;
  --muted: #8a92a3;
  --brand: #3867d6;
  --brand-2: #6a4fd8;
  --brand-soft: #eef2ff;
  --ok: #2f9e63;
  --warn: #c98a2d;
  --danger: #d64545;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20, 24, 40, .06), 0 4px 14px rgba(20, 24, 40, .04);
  --shadow-lg: 0 12px 40px rgba(20, 24, 40, .16);
  --topbar-blur: rgba(255, 255, 255, .72);
  --note-bg: #f8f9fd;
  --input-bg: #f2f3f9;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15161b;
    --panel: #1d1f26;
    --sidebar: #191b21;
    --line: #2b2e39;
    --line-soft: #232630;
    --text: #e7e9f0;
    --muted: #8e96a8;
    --brand: #6d8df0;
    --brand-2: #9d7bf5;
    --brand-soft: #232c49;
    --ok: #43b879;
    --warn: #d9a24b;
    --danger: #e06c6c;
    --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 4px 14px rgba(0, 0, 0, .25);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
    --topbar-blur: rgba(29, 31, 38, .78);
    --note-bg: #191b22;
    --input-bg: #23252e;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ---------- 顶栏（毛玻璃） ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 10px 18px;
  background: var(--topbar-blur); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 700; white-space: nowrap; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px; box-shadow: 0 3px 8px rgba(56, 103, 214, .35);
}
.brand small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 2px; }
.search { flex: 1; max-width: 420px; position: relative; }
.search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); opacity: .55; font-size: 13px; }
.search .kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 6px; background: var(--panel); pointer-events: none;
}
.search input {
  width: 100%; padding: 8px 42px 8px 32px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--input-bg); font-size: 13px; outline: none; color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.search input:focus { border-color: var(--brand); background: var(--panel); box-shadow: 0 0 0 3px var(--brand-soft); }
.actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 7px 12px; border-radius: 9px; font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: all .15s; box-shadow: var(--shadow);
}
.btn:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent; color: #fff; box-shadow: 0 3px 10px rgba(56, 103, 214, .3);
}
.btn.primary:hover { color: #fff; opacity: .92; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.btn.ghost:hover { color: var(--brand); transform: none; }
.btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.icon-btn {
  display: none; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  width: 34px; height: 34px; border-radius: 9px; font-size: 16px; cursor: pointer; flex: none;
}

/* ---------- 存储状态条 ---------- */
.storage-bar {
  padding: 5px 18px; font-size: 12px; color: var(--muted); background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.storage-bar.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--panel)); }
.storage-bar.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--panel)); }

/* ---------- 三栏主体 ---------- */
.app { display: flex; height: calc(100vh - 96px); min-height: 480px; }

/* 左侧导航 */
.sidebar {
  width: 286px; min-width: 286px; background: var(--sidebar);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  transition: transform .25s ease;
}
.nav-scroll { flex: 1; overflow-y: auto; padding: 12px 10px; scrollbar-width: thin; }
.sidebar-foot {
  padding: 9px 14px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  color: var(--muted); font-size: 12px;
}
.link-btn { border: none; background: none; color: var(--brand); cursor: pointer; font-size: 12px; }
.link-btn:hover { text-decoration: underline; }

/* 树形导航 */
.nav-item {
  display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 9px;
  cursor: pointer; user-select: none; color: var(--text); font-size: 13px;
  transition: background .12s;
}
.nav-item:hover { background: var(--line-soft); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-item .arrow { width: 14px; text-align: center; font-size: 10px; color: var(--muted); transition: transform .15s; flex: none; }
.nav-item.open .arrow { transform: rotate(90deg); }
.nav-item .count {
  margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 400;
  background: var(--line-soft); border-radius: 20px; padding: 0 8px; min-width: 20px; text-align: center;
}
.nav-item.active .count { background: var(--brand-soft); color: var(--brand); }
.nav-item .cover-mini { width: 22px; text-align: center; flex: none; font-size: 15px; }

.nav-group { margin: 3px 0; }
.nav-group > .nav-item { font-weight: 600; margin-top: 4px; color: var(--text); }
.nav-children { padding-left: 14px; border-left: 1px dashed var(--line); margin-left: 14px; display: none; }
.nav-group.open > .nav-children { display: block; }

.nav-book {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 9px;
  cursor: pointer; font-size: 13px; margin: 1px 0; transition: background .12s;
}
.nav-book:hover { background: var(--line-soft); }
.nav-book.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-book .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-book .arrow { width: 14px; text-align: center; font-size: 10px; color: var(--muted); flex: none; }
.nav-book.open .arrow { transform: rotate(90deg); }
.nav-book .count { color: var(--muted); font-size: 11px; }
.nav-book .cover-mini {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px;
  border: 1px solid var(--line); background: var(--line-soft);
}
.nav-book .cover-mini.g0, .nav-book .cover-mini.g1, .nav-book .cover-mini.g2, .nav-book .cover-mini.g3,
.nav-book .cover-mini.g4, .nav-book .cover-mini.g5, .nav-book .cover-mini.g6, .nav-book .cover-mini.g7 {
  border: none; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}

/* 书的笔记子节点 */
.nav-sub { padding-left: 24px; display: none; }
.nav-book.open + .nav-sub { display: block; }
.nav-sub-item {
  padding: 5px 10px; font-size: 12px; color: var(--muted); border-radius: 7px; cursor: pointer;
  display: flex; gap: 7px; align-items: center; transition: background .12s;
}
.nav-sub-item:hover { background: var(--line-soft); color: var(--text); }
.nav-sub-item.active { color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.nav-empty { padding: 20px 10px; color: var(--muted); font-size: 13px; text-align: center; line-height: 2; }

/* 移动端抽屉 */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(10, 12, 20, .4); z-index: 24;
}

/* 右侧主区 */
.main { flex: 1; overflow-y: auto; padding: 24px 30px 48px; background: var(--panel); scrollbar-width: thin; }

.welcome { max-width: 560px; margin: 10vh auto 0; text-align: center; }
.welcome .big { font-size: 56px; line-height: 1; }
.welcome h2 { margin: 14px 0 8px; font-size: 20px; }
.welcome p { color: var(--muted); margin-bottom: 26px; }
.welcome .hint-keys { display: flex; gap: 10px; justify-content: center; color: var(--muted); font-size: 12px; margin-top: 18px; flex-wrap: wrap; }
.welcome .hint-keys b {
  border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; background: var(--input-bg); font-weight: 400; color: var(--text);
}

/* 拖拽上传 */
.dropzone {
  border: 2px dashed var(--line); border-radius: 14px; padding: 26px; text-align: center;
  color: var(--muted); background: var(--note-bg); cursor: pointer; transition: all .2s;
}
.dropzone.drag { border-color: var(--brand); background: var(--brand-soft); transform: scale(1.01); }

/* ---------- 详情页 ---------- */
.detail { max-width: 900px; margin: 0 auto; animation: fade .22s; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

.detail-head {
  display: flex; gap: 20px; align-items: flex-start; padding: 22px 24px; border-radius: 16px;
  background: linear-gradient(160deg, var(--brand-soft), transparent 65%);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.cover.big { width: 84px; height: 112px; font-size: 44px; border-radius: 10px; box-shadow: 0 6px 18px rgba(20, 24, 40, .18); }
.cover {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; font-size: 18px; flex: none;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
/* 渐变封面（JS 按书名/category 哈希分配 g0-g7） */
.g0 { background: linear-gradient(135deg, #667eea, #764ba2); }
.g1 { background: linear-gradient(135deg, #f093fb, #f5576c); }
.g2 { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.g3 { background: linear-gradient(135deg, #43e97b, #38f9d7); }
.g4 { background: linear-gradient(135deg, #fa709a, #fee140); }
.g5 { background: linear-gradient(135deg, #a18cd1, #fbc2eb); }
.g6 { background: linear-gradient(135deg, #f6d365, #fda085); }
.g7 { background: linear-gradient(135deg, #30cfd0, #330867); }
.cover.g0, .cover.g1, .cover.g2, .cover.g3, .cover.g4, .cover.g5, .cover.g6, .cover.g7 { border: none; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.25); }

.book-meta { flex: 1; min-width: 0; }
.book-meta h2 { margin: 3px 0 4px; font-size: 21px; line-height: 1.4; }
.book-meta .author { color: var(--muted); margin-bottom: 6px; }
.crumb { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.crumb .link-crumb { color: var(--brand); cursor: pointer; }
.crumb .link-crumb:hover { text-decoration: underline; }
.meta-line { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.head-actions { display: flex; flex-direction: column; gap: 8px; }

.tag {
  background: var(--brand-soft); color: var(--brand); padding: 2px 10px; border-radius: 20px; font-size: 12px;
}
.badge { color: var(--muted); font-size: 12px; }

/* Tabs */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin: 18px 0 0; overflow-x: auto; }
.tab {
  padding: 10px 14px; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap;
  border-radius: 9px 9px 0 0; margin-bottom: -1px; border-bottom: 2px solid transparent; transition: all .15s;
}
.tab:hover { color: var(--text); background: var(--line-soft); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

#detail-panels .panel { display: none; padding: 18px 2px 6px; }
#detail-panels .panel.active { display: block; }
.edit-bar { margin-bottom: 10px; }
.note-body {
  white-space: pre-wrap; word-break: break-word; font-size: 15px; line-height: 1.9; color: #2f333d;
  background: linear-gradient(180deg, #fcfcff 0%, #f6f8fd 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 30px 34px; box-shadow: var(--shadow);
}
.note-body .layer-title { font-weight: 700; color: var(--brand); margin-bottom: 10px; font-size: 14px; }
/* Markdown 富文本排版（五层笔记）—— 留白充足、读着不累 */
.note-body.md {
  font-size: 15px; line-height: 1.95; color: #2f333d;
  background: linear-gradient(180deg, #fcfcff 0%, #f6f8fd 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 30px 32px 36px; box-shadow: var(--shadow);
}
.note-body.md h1, .note-body.md h2, .note-body.md h3, .note-body.md h4 {
  line-height: 1.5; color: var(--text); font-weight: 700;
}
.note-body.md h1 { font-size: 19px; margin: 1.4em 0 .7em; }
.note-body.md h2 {
  font-size: 17.5px; margin: 1.7em 0 .8em; padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}
.note-body.md h3 { font-size: 16px; color: var(--brand); margin: 1.5em 0 .6em; }
.note-body.md h4 { font-size: 14.5px; margin: 1.3em 0 .5em; color: #42485a; }
.note-body.md p { margin: 0 0 1.1em; }
.note-body.md strong { color: var(--brand); font-weight: 700; }
.note-body.md ul, .note-body.md ol { margin: .8em 0 1.1em; padding-left: 1.7em; }
.note-body.md li { margin: .42em 0; }
.note-body.md blockquote {
  margin: 1.1em 0; padding: 11px 16px; border-left: 3px solid var(--brand);
  background: var(--brand-soft); border-radius: 0 10px 10px 0; color: #44506b; line-height: 1.85;
}
.note-body.md code {
  background: var(--input-bg); padding: 2px 6px; border-radius: 5px; font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.note-body.md pre {
  background: var(--input-bg); padding: 12px; border-radius: 8px; overflow-x: auto;
  border: 1px solid var(--line);
}
.note-body.md pre code { background: none; padding: 0; }
.note-body.md table {
  display: block; width: 100%; overflow-x: auto; border-collapse: collapse;
  margin: 1em 0; font-size: 13.5px; white-space: nowrap;
}
.note-body.md th, .note-body.md td { border: 1px solid var(--line); padding: 7px 12px; text-align: left; }
.note-body.md th { background: var(--line-soft); font-weight: 700; }
.note-body.md hr { border: none; border-top: 1px solid var(--line); margin: 1.4em 0; }
.note-body.md a { color: var(--brand); text-decoration: underline; }
/* 移动端笔记优化 */
@media (max-width: 640px) {
  .note-body.md { font-size: 14.5px; padding: 18px 16px 22px; }
  .note-body.md table { font-size: 12.5px; }
  .note-body.md th, .note-body.md td { padding: 5px 8px; }
  .note-body.md h2 { font-size: 16px; }
  .reader { font-size: 16px; padding: 22px 18px 28px; }
  .book-page { font-size: 16px; padding: 22px 18px 28px; line-height: 1.9; }
}
.note-edit {
  width: 100%; min-height: 260px; border: 1px solid var(--brand); border-radius: var(--radius);
  padding: 12px; font-size: 13.5px; font-family: inherit; line-height: 1.7; outline: none;
  background: var(--panel); color: var(--text); box-shadow: 0 0 0 3px var(--brand-soft);
}
/* 正文（小说/文章）—— 书页式舒适排版 */
.reader {
  max-width: 42em; margin: 0 auto;
  font-family: "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", "宋体", serif;
  font-size: 17px; line-height: 1.95; color: #2b2b2b;
  background: linear-gradient(180deg, #fffdf8 0%, #fdf9f0 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 34px 42px 44px; box-shadow: var(--shadow);
  word-break: break-word;
}
.reader p { margin: 0 0 1.15em; text-indent: 2em; }
.reader p:first-child { text-indent: 0; }
.reader .reader-empty-p { color: var(--muted); text-align: center; text-indent: 0; padding: 24px 0; }
/* 暗色模式下的书页底色微调 */
@media (prefers-color-scheme: dark) {
  .reader { background: linear-gradient(180deg, #20222a 0%, #1b1d24 100%); color: #d7dae3; border-color: var(--line); }
}

/* ---------- 心得栏 ---------- */
.reflection { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 20px; }
.reflection-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.reflection-head h3 { margin: 0; font-size: 15px; }
.reflection-head .hint { color: var(--muted); font-size: 12px; }
.reflection-form { display: flex; gap: 8px; align-items: flex-start; }
.reflection-form textarea {
  flex: 1; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px;
  font-family: inherit; font-size: 13.5px; resize: vertical; outline: none; min-height: 46px;
  background: var(--input-bg); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.reflection-form textarea:focus { border-color: var(--brand); background: var(--panel); box-shadow: 0 0 0 3px var(--brand-soft); }
.reflection-list { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.reflection-item {
  background: var(--note-bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow); border-left: 3px solid var(--brand);
}
.reflection-item .text { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; }
.reflection-item .foot {
  display: flex; justify-content: space-between; align-items: center; margin-top: 8px;
  color: var(--muted); font-size: 12px;
}
.reflection-item .del { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 12px; padding: 2px 6px; border-radius: 6px; }
.reflection-item .del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.reflection-empty { color: var(--muted); font-size: 13px; }

/* ---------- 在线阅读器 ---------- */
#reader-box { display: flex; flex-direction: column; gap: 12px; }
.reader-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); box-shadow: var(--shadow); position: sticky; top: 0; z-index: 5;
}
.rt-group { display: flex; align-items: center; gap: 6px; }
.rt-btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 7px; min-width: 28px; height: 28px; cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.rt-btn:hover { border-color: var(--brand); color: var(--brand); }
.rt-btn.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.rt-size { font-size: 12px; color: var(--muted); min-width: 34px; text-align: center; }
.rt-ch { font-size: 12px; color: var(--muted); }
.book-page {
  max-width: 720px; margin: 0 auto; padding: 34px 38px 42px; border-radius: 12px;
  border: 1px solid var(--line); box-shadow: var(--shadow); line-height: 2;
  word-break: break-word;
  font-family: "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", "宋体", serif;
}
.book-page h1, .book-page h2, .book-page h3 { line-height: 1.5; margin: 1.2em 0 .6em; }
.book-page p { margin: 0 0 1.15em; text-indent: 2em; }
.book-page p:first-child { text-indent: 0; }
.book-page img { max-width: 100%; height: auto; border-radius: 6px; }
.reader-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; }
.reader-nav .btn:disabled { opacity: .4; cursor: not-allowed; }
.pdf-viewer { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: 12px; background: #525659; }
.reader-empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- 弹窗 ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(10, 12, 20, .45); display: none;
  align-items: center; justify-content: center; z-index: 50; backdrop-filter: blur(2px);
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--panel); border-radius: 16px; padding: 24px; width: min(480px, 92vw);
  max-height: 86vh; overflow-y: auto; box-shadow: var(--shadow-lg); border: 1px solid var(--line);
}
.modal h3 { margin: 0 0 16px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; font-size: 13px;
  outline: none; font-family: inherit; background: var(--input-bg); color: var(--text);
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #232733; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 99; max-width: 86vw;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 35;
    transform: translateX(-100%); box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .sidebar-overlay { z-index: 34; }
  .icon-btn { display: inline-flex; align-items: center; justify-content: center; }
  .main { padding: 16px; }
  .detail-head { flex-wrap: wrap; padding: 16px; }
}
@media (max-width: 640px) {
  .topbar { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .brand small { display: none; }
  .search { max-width: none; order: 3; flex-basis: 100%; }
  .actions { margin-left: auto; gap: 6px; }
  .actions .btn { padding: 6px 9px; font-size: 12px; }
  .cover.big { width: 64px; height: 86px; font-size: 34px; }
  .book-meta h2 { font-size: 17px; }
  .reflection-form { flex-direction: column; }
  .reflection-form .btn { align-self: flex-end; }
}
