/* 漫库 style.css —— 合并原 style.css 全部规则并补齐阅读器/修图/好友样式 */
:root {
  --blue: #007bff; --blue-d: #0056b3;
  --green: #28a745; --amber: #ffc107; --red: #dc3545; --grey: #6c757d;
  --bg: #f4f4f9; --ink: #22252c; --muted: #6b7280; --line: #e3e5ec;
  --paper: #fffdf5; --card: #ffffff; --bar: #333333; --radius: 10px;
  --shadow: 0 4px 14px rgba(20, 24, 40, .09);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', 'Microsoft YaHei', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg); color: var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
img { max-width: 100%; display: block; }
a { color: var(--blue); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .6rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* ---------- 顶栏 / 底栏 ---------- */
.topbar {
  background: var(--bar); color: #fff; padding: .7rem 1rem;
  display: flex; align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 40;
}
.brand { color: #fff; font-weight: 700; font-size: 1.15rem; letter-spacing: 1px; }
.topnav { display: flex; gap: .35rem; flex: 1; flex-wrap: wrap; }
.topnav a { color: #dfe3ea; padding: .3rem .6rem; border-radius: 6px; font-size: .92rem; }
.topnav a.on, .topnav a:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.topuser { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.topuser .who { color: #ffd479; }
.footbar { text-align: center; color: var(--muted); font-size: .78rem; padding: 1.2rem .6rem 2rem; }

/* ---------- 通用控件 ---------- */
.btn {
  border: 0; border-radius: 6px; padding: .55rem .95rem; cursor: pointer;
  background: var(--grey); color: #fff; font-size: .92rem; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: .25rem;
}
.btn:hover { filter: brightness(1.07); }
.btn.blue { background: var(--blue); } .btn.green { background: var(--green); }
.btn.amber { background: var(--amber); color: #222; } .btn.red { background: var(--red); }
.btn.grey { background: var(--grey); }
.btn.ghost { background: transparent; color: inherit; border: 1px solid currentColor; }
.btn.tiny { padding: .28rem .55rem; font-size: .8rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.grow { flex: 1; }
.row { display: flex; gap: .5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
input, select, textarea {
  font-family: inherit; font-size: .95rem; padding: .55rem .7rem;
  border: 1px solid #ccd1da; border-radius: 6px; background: #fff; color: var(--ink);
}
input[type=range] { padding: 0; }
input[type=color] { padding: 0; width: 2.2rem; height: 2.1rem; border-radius: 6px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(0, 123, 255, .35); }
.form label { display: block; margin-bottom: .6rem; font-size: .9rem; color: #3d4350; }
.form input, .form select, .form textarea { width: 100%; margin-top: .25rem; }
.switch { display: flex; align-items: center; gap: .4rem; font-size: .88rem; }
.switch input { width: auto; margin: 0; }
.pill { background: var(--blue); color: #fff; border-radius: 99px; padding: .05rem .5rem; font-size: .75rem; }
.hint { color: var(--muted); font-size: .82rem; line-height: 1.6; }
.error { color: var(--red); font-size: .85rem; min-height: 1.1rem; }
.empty { color: var(--muted); text-align: center; padding: 1.5rem; }

/* ---------- 页面容器 ---------- */
.view { min-height: 70vh; }
.page { max-width: 1080px; margin: 1.4rem auto; padding: 0 1rem; }
.page.wide { max-width: 1240px; }
.page.narrow { max-width: 520px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.panel {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem; margin-bottom: 1.2rem;
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.form.two { display: grid; grid-template-columns: 1fr 1fr; gap: .2rem .9rem; }
.form.two .span2 { grid-column: 1 / -1; }

/* ---------- 首页 ---------- */
.hero { text-align: center; padding: 1.2rem 0 .8rem; }
.hero h1 { font-size: 2rem; margin: 0; letter-spacing: 4px; }
.hero-sub { color: var(--muted); font-size: .9rem; }
.hero-note { color: var(--blue); font-size: .85rem; }
.filterbar { display: flex; gap: .5rem; margin-bottom: .7rem; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip {
  border: 1px solid var(--line); background: #fff; color: #4a5060;
  padding: .35rem .8rem; border-radius: 99px; cursor: pointer; font-size: .85rem;
}
.chip.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column;
}
.card .cover { position: relative; aspect-ratio: 3 / 4; background: #dfe3ea; display: block; }
.card .cover img { width: 100%; height: 100%; object-fit: cover; }
.card .badge {
  position: absolute; right: .4rem; bottom: .4rem; background: rgba(0, 0, 0, .62);
  color: #fff; font-size: .72rem; padding: .12rem .45rem; border-radius: 4px;
}
.card .badge.lock { left: .4rem; right: auto; background: rgba(220, 53, 69, .85); }
.card h3.title { font-size: 1rem; margin: .6rem .7rem .2rem; }
.card .meta, .card .desc { margin: 0 .7rem; color: var(--muted); font-size: .8rem; }
.card .desc { margin-top: .3rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .tags { margin: .45rem .7rem 0; display: flex; gap: .3rem; flex-wrap: wrap; }
.card .tags span { background: #eef2ff; color: #3b5bdb; font-size: .72rem; padding: .1rem .4rem; border-radius: 4px; }
.card-actions { display: flex; gap: .35rem; padding: .7rem; margin-top: auto; flex-wrap: wrap; }
.card-actions .btn { flex: 1; padding: .4rem .5rem; font-size: .82rem; }

/* ---------- 编辑/发布页 ---------- */
.edit-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.pages-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.pages-head h3 { margin: 0; }
.page-list { list-style: none; margin: .8rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .8rem; }
.page-item {
  display: grid; grid-template-columns: 74px 1fr; gap: .7rem; align-items: start;
  border: 1px solid var(--line); border-radius: 8px; padding: .6rem; background: #fbfbfe;
}
.page-item.is-cover { border-color: var(--amber); box-shadow: 0 0 0 2px rgba(255, 193, 7, .25); }
.page-item .thumb { width: 74px; height: 100px; overflow: hidden; border-radius: 6px; background: #e6e9f0; display: flex; align-items: center; justify-content: center; font-size: .75rem; color: var(--muted); }
.page-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.page-item .line1 { display: flex; gap: .4rem; align-items: center; }
.page-item .pno { font-size: .82rem; color: var(--blue); min-width: 2.6rem; }
.page-item .ptitle { flex: 1; font-size: .82rem; padding: .25rem .4rem; }
.page-item .psize { margin: .3rem 0 0; font-size: .74rem; color: var(--muted); }
.page-item .ptext { width: 100%; font-size: .82rem; margin-top: .3rem; }
.page-tools { grid-column: 1 / -1; display: flex; gap: .3rem; flex-wrap: wrap; }
.seed-list { list-style: none; padding: 0; margin: .6rem 0 0; display: flex; gap: .4rem; flex-wrap: wrap; }
.seed-list li { background: #eef2ff; border-radius: 99px; padding: .25rem .6rem; font-size: .8rem; display: flex; gap: .4rem; align-items: center; }
.seed-list button { border: 0; background: none; cursor: pointer; color: var(--red); }
.mine-list { list-style: none; padding: 0; margin: 0; }
.mine-list li { display: flex; align-items: center; gap: .7rem; padding: .6rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.mine-list .name { font-weight: 600; flex: 1; min-width: 8rem; }
.mine-list small { color: var(--muted); }
.acct { font-size: .9rem; margin-bottom: .7rem; }

/* ---------- 好友 ---------- */
.user-list, .req-list, .fr-list { list-style: none; padding: 0; margin: .6rem 0 0; }
.user-list li, .req-list li, .fr-list li {
  display: flex; align-items: center; gap: .5rem; padding: .5rem .2rem;
  border-bottom: 1px dashed var(--line); font-size: .9rem; flex-wrap: wrap;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%; color: #fff; display: grid; place-items: center;
  font-size: .8rem; flex: none; background: var(--blue);
}
.fr-list .nick { flex: 1; }
.req-list .empty-li, .fr-list .empty-li, .user-list .empty-li { color: var(--muted); font-size: .8rem; border: 0; }

/* ---------- 阅读器 ---------- */
.reader { background: #14161c; min-height: calc(100vh - 96px); color: #e8eaf0; }
.reader-bar {
  display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem;
  background: #1c1f27; position: sticky; top: 56px; z-index: 30;
}
.reader-bar .r-title { flex: 1; font-weight: 600; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader .shield { position: absolute; inset: 0; z-index: 4; background: transparent; }
.stage {
  position: relative; max-width: 980px; margin: 0 auto; padding: .4rem;
  min-height: 56vh; display: flex; justify-content: center; align-items: flex-start;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.page-canvas { max-width: 100%; height: auto; border-radius: 4px; box-shadow: 0 6px 22px rgba(0, 0, 0, .5); touch-action: pan-y; }
.page-canvas.sepia { filter: sepia(.28) saturate(.9) brightness(.97); }
.page-text {
  background: var(--paper); color: #242424; padding: 1.6rem; border-radius: 6px;
  font-size: 1.15rem; line-height: 1.9; width: 100%; max-width: 720px; user-select: none;
}
.page-text h3 { margin-top: 0; }
.stage-loading { position: absolute; inset: 0; display: grid; place-items: center; color: #9aa2b1; font-size: .85rem; pointer-events: none; opacity: 0; transition: opacity .15s; }
.stage-loading.on { opacity: 1; }
.screenshot-guard { position: absolute; inset: 0; background: #14161c; color: #9aa2b1; display: grid; place-items: center; z-index: 9; font-size: .9rem; }
.flip {
  position: absolute; top: 0; bottom: 0; width: 22%; z-index: 6; display: grid; place-items: center;
  color: rgba(255, 255, 255, .18); font-size: 2rem; cursor: pointer; opacity: 0; transition: opacity .2s;
}
.flip.left { left: 0; } .flip.right { right: 0; }
.stage:hover .flip, .flip.show { opacity: 1; }
.dm-layer { position: absolute; inset: .4rem; overflow: hidden; pointer-events: none; z-index: 5; }
.dm {
  position: absolute; white-space: nowrap; font-weight: 700; font-size: 1.05rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .85); will-change: transform;
}
.dm.scroll { animation-name: dmScroll; animation-timing-function: linear; animation-fill-mode: forwards; }
.dm.top, .dm.bottom { animation-name: dmBlink; animation-timing-function: linear; animation-fill-mode: forwards; }
.dm.self { color: #6cc4ff; }
.dm.friend::after { content: '好友'; font-size: .6rem; background: rgba(255, 193, 7, .8); color: #222; border-radius: 3px; padding: 0 .2rem; margin-left: .3rem; vertical-align: .1rem; }
@keyframes dmScroll { from { transform: translateX(100%); } to { transform: translateX(-110vw); } }
@keyframes dmBlink { 0% { opacity: 0; } 12% { opacity: 1; } 88% { opacity: 1; } 100% { opacity: 0; } }
.reader-dock { max-width: 980px; margin: 0 auto; padding: .6rem .8rem 1.4rem; display: grid; gap: .5rem; }
.dock-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.page-info { font-variant-numeric: tabular-nums; color: #cbd2de; font-size: .9rem; min-width: 5rem; }
.jump { width: 4.5rem; padding: .3rem .4rem; }
.tip { color: #8f98a8; font-size: .76rem; flex: 1; min-width: 10rem; }
.dm-send { display: flex; gap: .4rem; align-items: center; }
.dm-send input.grow { background: #262a33; border-color: #3a4150; color: #eef1f6; }
.dm-send select { background: #262a33; border-color: #3a4150; color: #eef1f6; }
.reader-menu {
  max-width: 980px; margin: 0 auto 1.5rem; background: #1c1f27; border: 1px solid #2b303a;
  border-radius: 10px; padding: 1rem;
}
.reader-menu h3 { color: #e8eaf0; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .5rem .9rem; margin-bottom: .8rem; }
.reader-menu .switch { color: #cbd2de; }
.reader-menu label { color: #cbd2de; font-size: .84rem; display: flex; flex-direction: column; gap: .2rem; }
.kstate { font-size: .78rem; color: #ffb84d; }
.tiny-input { width: 4.5rem; padding: .25rem .4rem; }

/* ---------- 修图工作台 ---------- */
.editor {
  position: fixed; inset: 0; z-index: 60; background: #1b1e25; color: #e8eaf0;
  display: flex; flex-direction: column;
}
.ed-bar { display: flex; align-items: center; gap: .8rem; padding: .5rem .8rem; background: #23262f; flex-wrap: wrap; }
.ed-tools { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.ed-tools button {
  border: 1px solid #3a404d; background: #2b303a; color: #dbe0ea; border-radius: 6px;
  padding: .3rem .6rem; font-size: .8rem; cursor: pointer;
}
.ed-tools button.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.ed-body { flex: 1; display: grid; grid-template-columns: 250px 1fr; min-height: 0; }
.ed-props { background: #23262f; padding: .8rem; overflow: auto; border-right: 1px solid #2f343e; }
.ed-props h4 { margin: .9rem 0 .35rem; font-size: .82rem; color: #9fb0cc; }
.ed-props h4:first-child { margin-top: 0; }
.ed-props .grp { display: grid; gap: .45rem; }
.ed-props label { font-size: .78rem; color: #cbd2de; display: flex; justify-content: space-between; align-items: center; gap: .4rem; }
.ed-props input[type=range] { flex: 1; max-width: 130px; }
.ed-props input[type=color] { width: 2rem; height: 1.6rem; }
.ed-props input[type=number], .ed-props input[type=text] { width: 100%; background: #2b303a; color: #e8eaf0; border-color: #3a404d; padding: .25rem .4rem; }
.ed-props .switch { color: #cbd2de; }
.ed-stage { overflow: auto; display: grid; place-items: center; padding: 1rem; background: repeating-conic-gradient(#252932 0% 25%, #1f2229 0% 50%) 50% / 22px 22px; }
.ed-stage canvas { box-shadow: 0 8px 26px rgba(0, 0, 0, .55); cursor: crosshair; touch-action: none; max-width: none; }
.crop-box { position: absolute; border: 1px dashed #fff; }

/* ---------- 弹层 / 提示 ---------- */
.toasts { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 90; display: grid; gap: .4rem; justify-items: center; }
.toast {
  background: rgba(28, 31, 39, .94); color: #fff; padding: .55rem 1rem; border-radius: 99px;
  font-size: .87rem; box-shadow: var(--shadow); animation: pop .18s ease-out; max-width: 88vw;
}
.toast.bad { background: rgba(220, 53, 69, .95); }
.toast.good { background: rgba(40, 167, 69, .95); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.modal { position: fixed; inset: 0; background: rgba(12, 14, 18, .6); z-index: 80; display: grid; place-items: center; padding: 1rem; }
.modal-box { background: #fff; color: var(--ink); border-radius: 12px; width: min(520px, 94vw); max-height: 88vh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--line); font-weight: 600; }
.modal-head .x { border: 0; background: none; font-size: 1.1rem; cursor: pointer; color: var(--muted); }
.modal-body { padding: 1rem; overflow: auto; }
.modal-foot { padding: .8rem 1rem; display: flex; justify-content: flex-end; gap: .5rem; border-top: 1px solid var(--line); }

/* ---------- 移动端 ---------- */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: .5rem; }
  .topnav { order: 3; width: 100%; }
  .two-col, .form.two { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; }
  .flip { width: 32%; opacity: 1; font-size: 1.4rem; }
  .dm { font-size: .92rem; }
  .page-list { grid-template-columns: 1fr; }
  .reader-bar { top: 0; }
  .ed-body { grid-template-columns: 1fr; grid-template-rows: 1fr 210px; }
  .ed-props { border-right: 0; border-top: 1px solid #2f343e; order: 2; }
  .ed-stage { order: 1; }
  .ed-tools { order: 5; width: 100%; }
  .tip { display: none; }
  .hero h1 { font-size: 1.6rem; letter-spacing: 2px; }
}
