/* 扇贝图书馆 · 共享样式（移动端优先，白底） */
:root {
  --bg: #ffffff;
  --card: #ffffff;
  --ink: #1f2126;
  --muted: #9b9b9b;
  --accent: #d96a58;
  --accent-soft: #faefec;
  --line: #f2f2f2;
  --shadow: 0 1px 4px rgba(0, 0, 0, .05);
  --radius: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6; overscroll-behavior-y: none;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; }
input, textarea, select {
  font-family: inherit; font-size: 1rem; color: var(--ink);
  background: #f7f7f7; border: 1px solid transparent; border-radius: 8px;
  padding: 10px 12px; width: 100%; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); background: #fff; }

.page { max-width: 720px; margin: 0 auto; padding: 0 16px 90px; }
.page.wide { max-width: 1280px; }
.page.profile-page { max-width: 960px; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px); padding: 10px 12px; min-height: 48px;
}
.topbar .back {
  border: none; background: none; font-size: 22px; color: var(--ink);
  padding: 2px 8px; cursor: pointer; line-height: 1;
}
.topbar h1 {
  font-size: 17px; margin: 0; flex: 1; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .logo { color: var(--accent); font-weight: 800; font-size: 20px; letter-spacing: 1px; }
.topbar .home {
  font-size: 20px; padding: 2px 8px; line-height: 1; flex-shrink: 0;
  border: none; background: none; cursor: pointer; color: var(--ink);
}

/* 底部标签栏（App 风格） */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar a {
  flex: 1; text-align: center; padding: 8px 0 6px; color: var(--muted); font-size: 12px;
}
.tabbar a .ico { display: block; font-size: 21px; line-height: 1.2; height: 26px; }
.tabbar a.on { color: var(--accent); font-weight: 600; }
.uic { width: 22px; height: 22px; object-fit: contain; vertical-align: -5px; }
.tabbar .ico .uic { width: 25px; height: 25px; opacity: .55; }
.tabbar a.on .ico .uic { opacity: 1; }
.topbar .home .uic { width: 24px; height: 24px; }

/* 卡片与列表 */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; margin: 12px 0;
}
.book-row { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.book-row:last-child { border-bottom: none; }
.cover {
  width: 96px; height: 132px; border-radius: 4px; object-fit: cover; flex-shrink: 0;
  background: linear-gradient(150deg, #e8e8ea, #cfcfd4);
  display: flex; align-items: center; justify-content: center;
  color: #8a8a92; font-size: 22px; font-weight: 700; text-align: center;
  line-height: 1.35; overflow: hidden;
}
img.cover { padding: 0; border: none; box-shadow: none; }
div.cover { padding: 8px; }
.cover.small { width: 64px; height: 88px; font-size: 15px; }
.book-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.book-info .t { font-size: 16.5px; font-weight: 600; margin-bottom: 2px; }
.book-info .a { color: var(--muted); font-size: 13px; }
.book-info .d {
  color: var(--muted); font-size: 13px; margin-top: 5px; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.book-info .m { color: var(--muted); font-size: 12px; margin-top: 5px; }
.tag {
  display: inline-block; font-size: 11px; color: var(--accent);
  background: var(--accent-soft); border-radius: 4px; padding: 1px 6px; margin-right: 6px;
  vertical-align: 1px;
}

/* 按钮 */
.btn {
  display: inline-block; border: none; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 15px; padding: 10px 22px;
  text-align: center;
}
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.line { background: none; border: 1px solid #e5e5e5; color: var(--ink); }
.btn.block { display: block; width: 100%; }
.btn.sm { padding: 5px 14px; font-size: 13px; }
.btn:disabled { opacity: .5; }

/* 搜索框 */
.searchbox { display: flex; gap: 8px; margin: 10px 0; }
.searchbox input { border-radius: 999px; padding: 9px 18px; }

/* 空态 / 提示 */
.empty { text-align: center; color: var(--muted); padding: 48px 0; font-size: 14px; }
.muted { color: var(--muted); font-size: 13px; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(30, 30, 34, .92); color: #fff; padding: 9px 18px; border-radius: 999px;
  font-size: 14px; z-index: 999; opacity: 0; transition: opacity .25s; pointer-events: none;
  max-width: 80vw; text-align: center;
}
#toast.show { opacity: 1; }

/* 弹层 */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 100;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.sheet-mask.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 101;
  background: var(--card); border-radius: 16px 16px 0 0;
  transform: translateY(105%); transition: transform .25s ease;
  max-height: 78vh; display: flex; flex-direction: column;
  padding-bottom: var(--safe-b);
}
.sheet.show { transform: translateY(0); }
.sheet .sheet-head {
  display: flex; align-items: center; padding: 14px 16px 8px;
  font-weight: 600; font-size: 15px;
}
.sheet .sheet-head .x {
  margin-left: auto; border: none; background: none; font-size: 20px;
  color: var(--muted); cursor: pointer; padding: 0 4px;
}
.sheet .sheet-body { overflow-y: auto; padding: 0 16px 16px; }
@media (min-width: 640px) {
  .sheet { max-width: 640px; left: 50%; transform: translate(-50%, 105%); }
  .sheet.show { transform: translate(-50%, 0); }
}

/* 上传前裁切 */
.imgedit-stage {
  position: relative; overflow: hidden; width: min(100%, 520px);
  margin: 6px auto 12px; background: #f0f0f0; border-radius: 10px;
  touch-action: none;
}
.imgedit-stage img {
  position: absolute; left: 50%; top: 50%; max-width: none; user-select: none;
  transform-origin: center; cursor: grab;
}
.imgedit-stage img.dragging { cursor: grabbing; }
.imgedit-grid {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to right, transparent 33.333%, rgba(255,255,255,.55) 33.333%, rgba(255,255,255,.55) calc(33.333% + 1px), transparent calc(33.333% + 1px), transparent 66.666%, rgba(255,255,255,.55) 66.666%, rgba(255,255,255,.55) calc(66.666% + 1px), transparent calc(66.666% + 1px)),
    linear-gradient(to bottom, transparent 33.333%, rgba(255,255,255,.55) 33.333%, rgba(255,255,255,.55) calc(33.333% + 1px), transparent calc(33.333% + 1px), transparent 66.666%, rgba(255,255,255,.55) 66.666%, rgba(255,255,255,.55) calc(66.666% + 1px), transparent calc(66.666% + 1px));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.7);
}
.imgedit-zoom { display: flex; align-items: center; gap: 10px; }
.imgedit-zoom .lb { width: 44px; font-size: 13px; color: var(--muted); flex-shrink: 0; }
.imgedit-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.imgedit-actions button { flex: 1; }

/* 评论 */
.cmt { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cmt:last-child { border-bottom: none; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; object-fit: cover;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 600;
}
.avatar.sm { width: 26px; height: 26px; font-size: 12px; }
.cmt-main { flex: 1; min-width: 0; }
.cmt-name { font-size: 13px; color: var(--muted); }
.cmt-text { font-size: 15px; margin: 2px 0; word-break: break-word; white-space: pre-wrap; }
.cmt-meta { font-size: 12px; color: var(--muted); display: flex; gap: 14px; }
.cmt-meta button { border: none; background: none; color: var(--muted); font-size: 12px; padding: 0; cursor: pointer; }
.cmt-replies { background: #f8f8f8; border-radius: 8px; padding: 4px 10px; margin-top: 6px; }
.cmt-replies .cmt { padding: 8px 0; }

/* 表单区 */
.field { margin: 14px 0; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field label.cover-edit, .field label.icon-edit { display: inline-block; width: auto; margin-bottom: 0; }
.row2 { display: flex; gap: 10px; }
.row2 > * { flex: 1; }
.u-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.u-row:last-child { border-bottom: none; }

/* 封面网格（番茄书城式：封面 + 标题；书城/书架/个人主页统一） */
.book-grid {
  display: grid; grid-template-columns: repeat(auto-fill, 92px);
  gap: 26px 20px; padding: 10px 0; justify-content: space-between;
}
@media (min-width: 560px) { .book-grid { grid-template-columns: repeat(auto-fill, 112px); gap: 34px 26px; } }
@media (min-width: 1000px) { .book-grid { grid-template-columns: repeat(auto-fill, 122px); gap: 38px 30px; } }
.gitem { display: block; min-width: 0; }
.gitem .cover {
  width: 100%; height: auto; aspect-ratio: 3 / 4; font-size: 18px;
}
.gitem .gt {
  font-size: 15.5px; line-height: 1.45; margin-top: 8px; font-weight: 500;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.gitem .gm {
  font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; align-items: center; gap: 4px;
}
.gitem .gm button {
  border: none; background: none; color: var(--muted); font-size: 12px;
  padding: 0 4px; cursor: pointer; margin-left: auto;
}

/* 个人主页（番茄式：资料信息叠在背景图上，白字 + 暗色遮罩） */
.pf-hero {
  position: relative; margin: 0 -16px; padding: 60px 18px 20px;
  color: #fff;
  background-image: linear-gradient(rgba(18, 21, 28, .28), rgba(18, 21, 28, .58)),
    linear-gradient(135deg, #3d4757, #232a36);
  background-size: cover; background-position: center;
}
.pf-hero .pf-act {
  position: absolute; top: 14px; width: 34px; height: 34px; border-radius: 50%;
  border: none; background: rgba(0, 0, 0, .38); color: #fff;
  font-size: 15px; cursor: pointer; backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.pf-hero .pf-act .uic { width: 20px; height: 20px; vertical-align: 0; }
.pf-head { display: flex; gap: 14px; align-items: center; }
.pf-head .avatar { border: 2px solid rgba(255, 255, 255, .85); box-shadow: 0 1px 8px rgba(0, 0, 0, .25); }
.pf-name { font-size: 21px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.pf-user { font-size: 12.5px; color: rgba(255, 255, 255, .72); }
.pf-bio {
  color: rgba(255, 255, 255, .88); font-size: 13.5px; margin-top: 12px;
  white-space: pre-wrap; text-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
.pf-stats { display: flex; gap: 26px; padding: 14px 2px 2px; }
.pf-stats .st b { font-size: 18px; font-weight: 700; display: block; line-height: 1.2; color: #fff; }
.pf-stats .st span { font-size: 12px; color: rgba(255, 255, 255, .68); }
.btn.onbg {
  background: rgba(255, 255, 255, .16); color: #fff;
  border: 1px solid rgba(255, 255, 255, .55); backdrop-filter: blur(4px);
}
/* 白色圆角内容层压在背景图下缘 */
.pf-sheet {
  position: relative; z-index: 2; background: var(--bg);
  border-radius: 18px 18px 0 0; margin: -16px -16px 0; padding: 2px 16px 10px;
}
.pf-tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); }
.pf-tabs button {
  border: none; background: none; padding: 13px 2px 11px; font-size: 15px;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent;
}
.pf-tabs button.on { color: var(--ink); font-weight: 700; border-bottom-color: var(--accent); }
@media (min-width: 720px) {
  .pf-hero { border-radius: 16px; margin: 10px 0 0; padding-top: 76px; }
  .pf-sheet { margin: -16px 0 0; border-radius: 18px; padding: 2px 18px 10px; }
}

/* 菜单列表（个人页） */
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 15px 2px; border-bottom: 1px solid var(--line);
  border-top: none; border-left: none; border-right: none;
  background: none; font-size: 15.5px; color: var(--ink); cursor: pointer; text-align: left;
}
.menu-item:last-child { border-bottom: none; }
.menu-item .chev { margin-left: auto; color: #ccc; font-size: 16px; }

/* 章节目录 */
.toc-item {
  display: flex; align-items: center; padding: 13px 2px; border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.toc-item:last-child { border-bottom: none; }
.toc-item .w { margin-left: auto; color: var(--muted); font-size: 12px; flex-shrink: 0; }

/* 角色卡 */
.role-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 14px; padding: 10px 0;
}
.role-card {
  display: block; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: #fff;
}
.role-card .pic {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover;
  background: linear-gradient(150deg, #f1f1f2, #d9d9de);
  display: flex; align-items: center; justify-content: center; color: var(--muted);
}
.role-card .rt { font-weight: 600; padding: 8px 8px 0; font-size: 15px; }
.role-card .rm { color: var(--muted); padding: 2px 8px 9px; font-size: 12px; }
.role-ranks { display: grid; gap: 10px; }
.role-rank {
  display: grid; grid-template-columns: 58px 64px 1fr auto; gap: 10px; align-items: center;
  padding: 10px; border: 1px solid var(--line); border-radius: 8px; color: inherit; text-decoration: none;
  background: #fff;
}
.rank-no { font-weight: 800; color: var(--accent); text-align: center; }
.rank-pic {
  width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: #f4f4f4;
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px;
}
.rank-name { font-weight: 700; font-size: 16px; }
.rank-heat { text-align: right; color: var(--accent); min-width: 68px; }
.rank-heat b { display: block; font-size: 18px; }
.rank-heat span { display: block; color: var(--muted); font-size: 12px; }
.role-books { display: grid; gap: 8px; }
.role-book {
  display: flex; gap: 10px; align-items: center; padding: 8px;
  border: 1px solid var(--line); border-radius: 8px; color: inherit; text-decoration: none;
}
.role-relations { display: grid; gap: 8px; }
.role-relation {
  display: flex; gap: 10px; align-items: center; padding: 8px;
  border: 1px solid var(--line); border-radius: 8px; color: inherit; text-decoration: none;
  background: #fff;
}
.role-relation img, .role-relation span {
  width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex-shrink: 0;
  background: #f4f4f4; display: flex; align-items: center; justify-content: center; color: var(--muted);
}
.role-relation b { display: block; color: var(--accent); }
.role-relation small { display: block; color: var(--muted); margin-top: 2px; }
.role-hero {
  position: relative; margin: 12px 0; border-radius: 8px; overflow: hidden;
  background: #f4f4f4; min-height: 320px; display: flex; align-items: center; justify-content: center;
}
.role-hero img { width: 100%; max-height: 70vh; object-fit: contain; display: block; }
.role-danmu {
  position: absolute; inset: 8px 0 48px; pointer-events: none; overflow: hidden;
}
.role-danmu span {
  position: absolute; left: 100%; top: calc(var(--lane) * 20% + 4px);
  white-space: nowrap; max-width: 80%; overflow: hidden; text-overflow: ellipsis;
  padding: 4px 10px; border-radius: 999px; color: #fff;
  background: rgba(30,30,30,.46); text-shadow: 0 1px 2px rgba(0,0,0,.35);
  animation: roleDanmu 11s linear infinite; animation-delay: var(--delay);
}
@keyframes roleDanmu { to { transform: translateX(calc(-100vw - 100%)); } }
.role-hero button {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: rgba(0,0,0,.38); color: #fff; font-size: 22px; cursor: pointer;
}
.role-hero .prev { left: 10px; }
.role-hero .next { right: 10px; }
.gift-row { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0; }
.gift-btn {
  min-width: 86px; border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 8px; text-align: center; cursor: pointer;
}
.gift-btn img { width: 34px; height: 34px; object-fit: contain; display: block; margin: 0 auto 3px; }
.gift-btn .gemo { font-size: 28px; line-height: 34px; display: block; }
