/* =========================================================
 * MangaShot · style.css  漫画风 · 手机+电脑响应式
 * ========================================================= */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f4f4f6;
  --card: #ffffff;
  --ink: #1a1b1e;
  --ink2: #5b6068;
  --ink3: #9aa0a8;
  --line: #e5e7eb;
  --red: #e5484d;
  --red-d: #c73a3f;
  --red-bg: #fef2f2;
  --dark: #141518;
  --shadow: 0 2px 10px rgba(0,0,0,.06);
  --radius: 12px;
}
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px; line-height: 1.6;
  padding-bottom: 90px;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: 14px; color: var(--ink); }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.96); backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--dark);
}
.topbar-in {
  max-width: 1280px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 14px;
}
.brand { flex: 0 0 auto; line-height: 1.25; }
.brand .name { font-size: 22px; font-weight: 800; letter-spacing: .5px; color: var(--dark); }
.brand .name b { color: var(--red); }
.brand .quote { font-size: 12px; color: var(--ink3); max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.searchbox { flex: 1; display: flex; max-width: 520px; margin: 0 auto; }
.searchbox input {
  flex: 1; border: 2px solid var(--dark); border-right: none; border-radius: 999px 0 0 999px;
  padding: 8px 16px; outline: none; background: #fff;
}
.searchbox button {
  background: var(--dark); color: #fff; padding: 0 20px;
  border-radius: 0 999px 999px 0; font-weight: 600; border: 2px solid var(--dark);
}
.searchbox button:hover { background: var(--red); border-color: var(--red); }
.top-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }
.friend-btn {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  border: 2px solid var(--dark); border-radius: 999px; padding: 6px 14px; font-weight: 600; background: #fff;
}
.friend-btn:hover { background: var(--dark); color: #fff; }
.dot {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.avatar-wrap { position: relative; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--dark); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; border: 2px solid var(--dark);
}
.avatar:hover { background: var(--red); border-color: var(--red); }
.login-btn { border: 2px solid var(--dark); border-radius: 999px; padding: 7px 16px; font-weight: 600; background: var(--dark); color: #fff; }
.login-btn:hover { background: var(--red); border-color: var(--red); }
.avatar-menu {
  position: absolute; right: 0; top: 46px; width: 180px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.12); overflow: hidden; z-index: 60;
}
.avatar-menu button {
  display: flex; width: 100%; align-items: center; gap: 8px; padding: 11px 16px; font-size: 14px; text-align: left;
}
.avatar-menu button:hover { background: var(--red-bg); color: var(--red); }
.avatar-menu hr { border: none; border-top: 1px solid var(--line); }

/* ---------- 主体布局 ---------- */
.layout { max-width: 1280px; margin: 18px auto 0; padding: 0 16px; display: flex; gap: 18px; align-items: flex-start; }
.sidebar { flex: 0 0 200px; position: sticky; top: 76px; }
.side-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.side-card h3 { font-size: 14px; padding: 12px 14px 8px; border-bottom: 2px solid var(--dark); }
.rank-item { display: flex; gap: 10px; padding: 8px 12px; align-items: center; cursor: pointer; }
.rank-item:hover { background: var(--red-bg); }
.rank-no { flex: 0 0 22px; height: 22px; border-radius: 6px; background: #f1f2f4; color: var(--ink2); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.rank-item:nth-child(2) .rank-no, .rank-item:nth-child(3) .rank-no, .rank-item:nth-child(4) .rank-no { background: var(--red); color: #fff; }
.rank-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: #eee; flex: 0 0 auto; }
.rank-info { min-width: 0; }
.rank-title { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-count { font-size: 11px; color: var(--ink3); }
.main { flex: 1; min-width: 0; }

/* ---------- 分类栏与筛选 ---------- */
.catbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.ratio-toggle {
  border: 2px solid var(--dark); background: var(--dark); color: #fff;
  border-radius: 999px; padding: 7px 16px; font-weight: 700;
}
.ratio-toggle:hover { background: var(--red); border-color: var(--red); }
.cat-chip {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 16px; font-weight: 600; color: var(--ink2);
}
.cat-chip:hover { border-color: var(--dark); color: var(--dark); }
.cat-chip.on { background: var(--red); border-color: var(--red); color: #fff; }
.filter-panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.filter-group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 5px 0; }
.filter-group .gname { flex: 0 0 62px; font-size: 12px; color: var(--ink3); font-weight: 600; }
.f-chip { border: 1px solid var(--line); border-radius: 6px; padding: 3px 10px; font-size: 12.5px; background: #fafafa; color: var(--ink2); }
.f-chip:hover { border-color: var(--red); color: var(--red); }
.f-chip.on { background: var(--red); border-color: var(--red); color: #fff; }
.active-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.af-chip { background: var(--dark); color: #fff; border-radius: 6px; padding: 3px 10px; font-size: 12.5px; display: inline-flex; gap: 6px; align-items: center; }
.af-chip b { cursor: pointer; color: #ffb3b5; }
.af-clear { color: var(--ink3); font-size: 12.5px; text-decoration: underline; }
.result-meta { color: var(--ink3); font-size: 12.5px; margin: 0 2px 10px; }

/* ---------- 图库网格 ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.img-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); cursor: pointer; transition: transform .15s, box-shadow .15s; }
.img-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.img-card .thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: #eceef1; }
.img-card .thumb.v { aspect-ratio: 9/13; }
.img-card .body { padding: 10px 12px 12px; }
.img-card .ttl { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-card .badges { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0; }
.badge { font-size: 11px; border-radius: 4px; padding: 1px 6px; background: #f1f2f4; color: var(--ink2); }
.badge.r { background: var(--red-bg); color: var(--red); }
.img-card .stats { display: flex; gap: 10px; font-size: 12px; color: var(--ink3); }
.empty { text-align: center; color: var(--ink3); padding: 60px 0; grid-column: 1/-1; }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* ---------- 上传浮动圆钮 ---------- */
.fab {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 55;
  width: 68px; height: 68px; border-radius: 50%;
  background: var(--red); color: #fff; border: 3px solid #fff;
  box-shadow: 0 6px 24px rgba(229,72,77,.45);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; line-height: 1.2;
}
.fab:hover { background: var(--red-d); transform: translateX(-50%) scale(1.06); }
.fab .plus { font-size: 22px; line-height: 1; }

/* ---------- 弹窗 ---------- */
.mask { position: fixed; inset: 0; background: rgba(15,16,18,.55); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; padding: 22px 24px; }
.modal.lg { max-width: 860px; }
.modal h3 { font-size: 17px; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 2px solid var(--dark); }
.modal .close-x { float: right; font-size: 20px; color: var(--ink3); line-height: 1; }
.modal .close-x:hover { color: var(--red); }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12.5px; color: var(--ink2); margin-bottom: 4px; font-weight: 600; }
.form-row input[type=text], .form-row input[type=password], .form-row input[type=number], .form-row textarea, .form-row select {
  width: 100%; border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 12px; outline: none; background: #fff;
}
.form-row input:focus, .form-row textarea:focus { border-color: var(--dark); }
.form-row textarea { min-height: 72px; resize: vertical; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 8px; padding: 9px 18px; font-weight: 600; font-size: 14px; border: 1.5px solid var(--dark); background: #fff; color: var(--dark); }
.btn:hover { background: var(--dark); color: #fff; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-d); }
.btn.ghost { border-color: var(--line); color: var(--ink2); }
.btn.sm { padding: 5px 12px; font-size: 12.5px; border-radius: 6px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 10px; margin-top: 16px; }
.msg-line { font-size: 13px; margin: 8px 0; min-height: 18px; }
.msg-line.err { color: var(--red); }
.msg-line.ok { color: #1a9e50; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 16px; border: 2px solid var(--dark); border-radius: 10px; overflow: hidden; }
.auth-tabs button { flex: 1; padding: 9px; font-weight: 700; background: #fff; }
.auth-tabs button.on { background: var(--dark); color: #fff; }

/* ---------- 图片详情 ---------- */
.detail { display: flex; gap: 20px; }
.detail .pic { flex: 1; min-width: 0; }
.detail .pic img { width: 100%; border-radius: 10px; background: #eceef1; }
.detail .side { flex: 0 0 260px; }
.detail .side .ttl { font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.field { display: flex; font-size: 13px; padding: 4px 0; }
.field .k { flex: 0 0 76px; color: var(--ink3); }
.field .v { flex: 1; }
.detail-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.icon-btn { border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 14px; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; background: #fff; }
.icon-btn:hover { border-color: var(--red); color: var(--red); }
.icon-btn.on { background: var(--red); border-color: var(--red); color: #fff; }

/* ---------- 视图面板（收藏/历史/上传/分组） ---------- */
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2 { font-size: 18px; }
.back-link { color: var(--ink3); font-size: 13px; }
.back-link:hover { color: var(--red); }
.folder-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.mini-card { display: flex; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; align-items: center; }
.mini-card img { width: 88px; height: 56px; object-fit: cover; border-radius: 6px; background: #eceef1; }
.mini-card .inf { flex: 1; min-width: 0; }
.mini-card .t { font-size: 13.5px; font-weight: 600; }
.mini-card .s { font-size: 12px; color: var(--ink3); }
.sg-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }

/* ---------- 提示词区域 ---------- */
.prompts { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin: 22px 0 10px; }
.prompts .p-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.prompts .p-head h3 { font-size: 16px; margin-right: 6px; }
.p-tab { border: 2px solid var(--dark); padding: 5px 18px; font-weight: 700; background: #fff; border-radius: 8px; }
.p-tab.on { background: var(--dark); color: #fff; }
.dev-entry { margin-left: auto; font-size: 12.5px; color: var(--ink3); text-decoration: underline; }
.dev-entry:hover { color: var(--red); }
.p-cats { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.p-content { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-height: 140px; background: #fbfbfd; font-size: 13.5px; white-space: pre-wrap; }
.p-content[contenteditable="true"] { background: #fff; outline: none; }
.p-content[contenteditable="true"]:focus { border-color: var(--dark); }
.p-tools { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.p-tools button { border: 1px solid var(--line); border-radius: 6px; padding: 3px 10px; font-size: 12.5px; background: #fff; font-weight: 600; }
.p-tools button:hover { border-color: var(--dark); }
.save-tip { font-size: 12px; color: #1a9e50; margin-left: 8px; }

/* ---------- 开发者面板 ---------- */
.dev-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.dev-sec textarea { width: 100%; min-height: 180px; border: 1.5px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.dev-user { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.dev-user .inf { flex: 1; }
.dev-user .nm { font-weight: 700; }
.dev-user .ac { font-size: 12px; color: var(--ink3); }
.quote-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.quote-row input { flex: 1; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.switch { position: relative; width: 46px; height: 24px; border-radius: 12px; background: #d4d7dc; transition: .2s; flex: 0 0 auto; }
.switch.on { background: #1a9e50; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; }
.switch.on::after { left: 25px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%);
  background: var(--dark); color: #fff; padding: 10px 20px; border-radius: 999px;
  font-size: 13.5px; z-index: 99; box-shadow: 0 6px 20px rgba(0,0,0,.3);
}

/* ---------- 好友页 ---------- */
.f-layout { max-width: 1100px; margin: 0 auto; display: flex; height: calc(100vh - 60px); }
.f-side { flex: 0 0 300px; border-right: 1px solid var(--line); background: #fff; display: flex; flex-direction: column; }
.f-tabs { display: flex; border-bottom: 1px solid var(--line); }
.f-tabs button { flex: 1; padding: 12px; font-weight: 700; color: var(--ink2); border-bottom: 2px solid transparent; }
.f-tabs button.on { color: var(--red); border-bottom-color: var(--red); }
.f-search { padding: 10px; border-bottom: 1px solid var(--line); }
.f-search input { width: 100%; border: 1.5px solid var(--line); border-radius: 8px; padding: 7px 12px; }
.f-list { flex: 1; overflow-y: auto; }
.f-item { display: flex; gap: 10px; padding: 11px 14px; align-items: center; cursor: pointer; border-bottom: 1px solid #f3f4f6; }
.f-item:hover, .f-item.on { background: var(--red-bg); }
.f-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--dark); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto; }
.f-item .inf { flex: 1; min-width: 0; }
.f-item .nm { font-weight: 600; font-size: 14px; }
.f-item .sub { font-size: 12px; color: var(--ink3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-badge { background: var(--red); color: #fff; border-radius: 9px; min-width: 18px; height: 18px; font-size: 11px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.f-main { flex: 1; display: flex; flex-direction: column; background: #f7f7f9; min-width: 0; }
.chat-head { padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.chat-head .nm { font-weight: 700; font-size: 15px; }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.bubble-row { display: flex; }
.bubble-row.me { justify-content: flex-end; }
.bubble { max-width: 70%; padding: 9px 13px; border-radius: 14px; background: #fff; box-shadow: var(--shadow); font-size: 14px; word-break: break-word; }
.bubble-row.me .bubble { background: var(--red); color: #fff; border-radius: 14px 14px 4px 14px; }
.bubble-row.other .bubble { border-radius: 14px 14px 14px 4px; }
.bubble-time { font-size: 11px; color: var(--ink3); text-align: center; }
.chat-input { padding: 12px; background: #fff; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.chat-input input { flex: 1; border: 1.5px solid var(--line); border-radius: 999px; padding: 9px 16px; outline: none; }
.chat-input input:focus { border-color: var(--dark); }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--ink3); gap: 8px; }
.f-topbar { background: var(--dark); color: #fff; padding: 0 16px; height: 60px; display: flex; align-items: center; gap: 14px; }
.f-topbar .name { font-size: 18px; font-weight: 800; }
.f-topbar .name b { color: var(--red); }
.f-topbar a.back { color: #cfd2d8; font-size: 13px; margin-left: auto; }
.f-topbar a.back:hover { color: #fff; }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .layout { flex-direction: column; }
  .sidebar { position: static; flex: none; width: 100%; order: 2; }
  .main { width: 100%; order: 1; }
  .side-card .rank-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .brand .quote { max-width: 160px; }
  .f-side { flex: 0 0 260px; }
}
@media (max-width: 640px) {
  .topbar-in { flex-wrap: wrap; gap: 8px; }
  .searchbox { order: 3; flex: 1 0 100%; max-width: none; }
  .brand .quote { max-width: 120px; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .detail { flex-direction: column; }
  .detail .side { flex: none; }
  .f-layout { flex-direction: column; height: calc(100vh - 60px); }
  .f-side { flex: none; width: 100%; height: 44%; border-right: none; border-bottom: 1px solid var(--line); }
  .f-main { height: 56%; }
  .modal { padding: 18px 16px; }
  .filter-group .gname { flex-basis: 100%; }
}
