/* 睦琦的说说 · Pages 壳 v2（与原站前台对齐）
   口径：主栏桌面 840px 居中、卡片圆角玻璃面、站蓝 #4a90d9、深色适配、封面 16:10 */
:root {
  --bg: #f2f4f9;
  --card: rgba(255, 255, 255, 0.88);
  --text: #2b3452;
  --muted: #7a869e;
  --line: rgba(82, 95, 127, 0.14);
  --blue: #4a90d9;
  --chip: rgba(74, 144, 217, 0.12);
  --shadow: 0 10px 30px rgba(43, 52, 82, 0.10);
  --danger: #d9534f;
  --input-bg: rgba(255, 255, 255, 0.75);
}
html[data-theme="dark"] {
  --bg: #141a26;
  --card: rgba(30, 40, 54, 0.92);
  --text: #e8edf5;
  --muted: #93a1b8;
  --line: rgba(232, 237, 245, 0.14);
  --chip: rgba(74, 144, 217, 0.22);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --input-bg: rgba(20, 26, 38, 0.8);
}
* { box-sizing: border-box; }
html { background: var(--bg); color-scheme: light; } /* 沉浸式：回弹/状态栏区域与页面同底色 */
html[data-theme="dark"] { color-scheme: dark; }
/* 关键：hidden 属性必须压过 .modal/.lightbox/.user-chip 等的 display 设置，
   否则蒙版层会一打开页面就常驻、关不掉（v2 首版实测踩坑） */
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px; line-height: 1.65;
}
a { color: var(--blue); text-decoration: none; }
button { font-family: inherit; }
input, textarea {
  width: 100%; padding: 9px 12px; margin: 5px 0;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--input-bg); color: var(--text); font-size: 15px; font-family: inherit;
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, textarea:focus { outline: 2px solid var(--chip); border-color: var(--blue); }
.spacer { flex: 1; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  /* 沉浸式状态栏：顶栏背景向上吃满刘海/状态栏区域，内容用安全区避让 */
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--card); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); font-weight: 700; font-size: 18px; white-space: nowrap; }
.search-form { flex: 0 1 220px; }
.search-form input { margin: 0; border-radius: 999px; padding: 6px 14px; }
.top-btn {
  border: 1px solid var(--line); background: transparent; color: var(--text);
  border-radius: 999px; padding: 5px 13px; cursor: pointer; font-size: 14px; white-space: nowrap;
}
.top-btn.primary, .btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }

/* 亮/暗切换开关（仿参考图：黄轨道＋太阳圆钮，暗色滑到右边变月亮） */
.theme-switch {
  position: relative; flex: none;
  width: 56px; height: 30px; border-radius: 999px;
  border: 1px solid var(--line); background: #f9e29c;
  cursor: pointer; padding: 0; transition: background 0.25s;
}
html[data-theme="dark"] .theme-switch { background: #333d5c; }
.theme-switch .ts-knob {
  position: absolute; top: 2px; left: 2px;
  width: 24px; height: 24px; border-radius: 50%;
  background: #f6b73c; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.25s, background 0.25s;
}
html[data-theme="dark"] .theme-switch .ts-knob { transform: translateX(26px); background: #8fa3c8; }
.theme-switch .ts-knob svg { width: 15px; height: 15px; }
.theme-switch .ic-moon { display: none; }
html[data-theme="dark"] .theme-switch .ic-sun { display: none; }
html[data-theme="dark"] .theme-switch .ic-moon { display: block; }

/* 内联 SVG 图标（不用 emoji） */
.icon { width: 16px; height: 16px; vertical-align: -3px; }
.act-btn, .tool-btn { display: inline-flex; align-items: center; gap: 5px; }
.btn .icon { vertical-align: -3px; margin-right: 2px; }
.comment .c-like .icon { width: 12px; height: 12px; vertical-align: -2px; }
.actions > span { display: inline-flex; align-items: center; gap: 5px; }
.user-chip { position: relative; display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.user-chip img { width: 28px; height: 28px; border-radius: 50%; }
.user-chip .user-menu {
  position: absolute; right: 0; top: 36px; z-index: 40;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px;
}
.user-menu button { border: 0; background: transparent; color: var(--text); padding: 6px 12px; cursor: pointer; white-space: nowrap; }

.column { max-width: 840px; margin: 0 auto; padding: 16px 12px 40px; }
.view-heading { font-size: 17px; margin: 4px 2px 12px; }
.status { color: var(--muted); text-align: center; padding: 28px 0; }
.status.error { color: var(--danger); }

/* 卡片 */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--shadow);
  padding: 18px 18px 14px; margin-bottom: 16px; color: var(--text);
}
.card-link { display: block; }
.card h2 { font-size: 18px; margin: 0 0 6px; line-height: 1.45; color: var(--text); }
.card .meta { color: var(--muted); font-size: 13px; margin-bottom: 8px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.card .excerpt { margin: 0; color: var(--text); }
.card .actions {
  display: flex; gap: 16px; align-items: center;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line);
  font-size: 14px; color: var(--muted);
}
.act-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; padding: 2px 4px; }
.act-btn.liked { color: var(--danger); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tag { font-size: 12px; color: var(--blue); background: var(--chip); border-radius: 999px; padding: 2px 10px; border: 1px solid transparent; }
button.tag { cursor: pointer; }
button.tag.selected { background: var(--blue); color: #fff; }

/* 轮播（负边距抵消卡片内边距，使图片上/左/右三边白边等宽，与原站定版一致） */
.carousel { position: relative; margin: -8px -8px 14px; border-radius: 16px; overflow: hidden; background: var(--line); }
.carousel img.stage {
  display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; cursor: zoom-in;
}
.car-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, 0.38); color: #fff; font-size: 18px; cursor: pointer; line-height: 1;
}
.car-prev { left: 8px; } .car-next { right: 8px; }
.car-count {
  position: absolute; right: 10px; bottom: 8px;
  background: rgba(0, 0, 0, 0.45); color: #fff;
  font-size: 12px; border-radius: 999px; padding: 1px 9px;
}
.single-cover { margin: -8px -8px 14px; }
.single-cover img {
  display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover;
  border-radius: 16px; cursor: zoom-in; background: var(--line);
}

/* 按钮与表单 */
.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 7px 20px; font-size: 15px; cursor: pointer;
}
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.wide { width: 100%; margin-top: 8px; }
.form-row { display: flex; gap: 8px; align-items: center; }
.form-row input { flex: 1; }
.form-msg { min-height: 1.2em; font-size: 14px; color: var(--muted); margin: 6px 0 0; }
.form-msg.error { color: var(--danger); }
.form-msg.ok { color: #3a9e4f; }

.loadmore-wrap { text-align: center; }
.load-more {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 9px 26px; font-size: 15px; cursor: pointer;
}
.back-link { display: inline-block; margin: 4px 0 12px; font-size: 15px; }

/* 详情 */
.detail-card h1 { font-size: 21px; margin: 0 0 8px; line-height: 1.5; }
.detail-body { word-break: break-word; }
.detail-body img { max-width: 100%; height: auto; border-radius: 14px; display: block; margin: 10px auto; }
.detail-body iframe { max-width: 100%; width: 100%; aspect-ratio: 16 / 9; height: auto; border: 0; border-radius: 14px; }
.detail-body a { word-break: break-all; }
.open-origin { display: inline-block; margin-top: 12px; font-size: 14px; }

/* 评论 */
.comments-title { margin: 0 0 10px; font-size: 16px; }
.comment { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.comment:first-of-type { border-top: 0; }
.comment img.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; }
.comment .c-body { flex: 1; min-width: 0; }
.comment .c-head { font-size: 13px; color: var(--muted); display: flex; gap: 10px; align-items: baseline; }
.comment .c-head b { color: var(--text); font-size: 14px; }
.comment .c-text { margin: 2px 0 0; word-break: break-word; white-space: pre-wrap; }
.comment .c-reply { border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 13px; padding: 0; }
.comment.depth-1 { margin-left: 24px; }
.comment.depth-2 { margin-left: 44px; }
.comment-form { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.reply-hint { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.reply-hint button { border: 0; background: transparent; color: var(--blue); cursor: pointer; }
.emoji-row { font-size: 17px; }
.emoji-row button { border: 0; background: transparent; cursor: pointer; font-size: 17px; padding: 2px; }

/* 发表 */
.publish-card h3 { margin: 0 0 8px; }
.tool-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.tool-btn {
  border: 1px solid var(--line); background: transparent; color: var(--text);
  border-radius: 999px; padding: 5px 13px; cursor: pointer; font-size: 14px;
}
.tags-panel { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 10px; }
.media-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; cursor: pointer; border: 1px solid var(--line); }
.media-grid img:active { transform: scale(0.97); }
.comment .c-like { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0; }
.comment .c-like.liked { color: var(--danger); }

/* 登录卡 */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 14, 22, 0.5); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-card {
  position: relative; width: 100%; max-width: 360px;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow); padding: 20px;
}
.modal-close {
  position: absolute; right: 12px; top: 10px;
  border: 0; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer;
}
.auth-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.auth-tabs button {
  flex: 1; border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 6px 0; cursor: pointer; font-size: 14px;
}
.auth-tabs button.active { background: var(--blue); border-color: var(--blue); color: #fff; }

/* 灯箱 */
.lightbox {
  position: fixed; inset: 0; z-index: 70; background: rgba(5, 8, 14, 0.94);
  display: flex; align-items: center; justify-content: center;
}
.lightbox img { max-width: 96vw; max-height: 92vh; object-fit: contain; }
.lb-btn {
  position: absolute; border: 0; background: rgba(255, 255, 255, 0.12); color: #fff;
  width: 40px; height: 40px; border-radius: 50%; font-size: 20px; cursor: pointer;
}
.lb-close { right: 14px; top: 14px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
.lb-count { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); color: #fff; font-size: 13px; }

/* v3：首页弹窗 sheet（详情/发表不离页） */
.sheet-modal { align-items: flex-start; padding: 10px; }
.sheet {
  position: relative; width: 100%; max-width: 800px; margin: 0 auto;
  max-height: 96dvh; overflow-y: auto; overscroll-behavior: contain;
  padding: 2px;
}
.sheet.narrow { max-width: 720px; }
.sheet .card:last-child { margin-bottom: 4px; }
.sheet-close {
  position: sticky; top: 6px; z-index: 6; display: block;
  width: 36px; height: 36px; margin-left: auto; margin-bottom: -36px;
  border: 0; border-radius: 50%;
  background: rgba(20, 26, 38, 0.55); color: #fff; font-size: 15px; cursor: pointer;
  backdrop-filter: blur(4px);
}
.open-zone { cursor: pointer; }
.expand-btn {
  border: 0; background: transparent; color: var(--blue);
  cursor: pointer; font-size: 14px; padding: 6px 0 0;
}
.full-body { margin-top: 4px; }
.carousel, .single-cover { touch-action: pan-y; } /* 横划给 JS 切图，竖划照常滚页 */
.lightbox { touch-action: none; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 80;
  background: rgba(20, 26, 38, 0.92); color: #fff;
  border-radius: 999px; padding: 9px 20px; font-size: 14px; box-shadow: var(--shadow);
}

.foot { color: var(--muted); font-size: 13px; text-align: center; margin-top: 28px; line-height: 1.8; }

@media (max-width: 560px) {
  .sheet-modal { padding: 6px; }
  .sheet { max-height: 97dvh; }
  .column { padding: 12px 8px 32px; }
  .card { padding: 14px 14px 12px; border-radius: 18px; }
  .carousel, .single-cover { margin: -6px -6px 12px; }
  .search-form { flex-basis: 120px; }
  .brand { font-size: 16px; }
}
