* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
*:focus { outline: none; -webkit-box-shadow: none; box-shadow: none; }
:root { --theme-color-1: #fff; --theme-color-2: #fff; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #fff;
  color: #222;
}
.container { max-width: 1600px; margin: 0 auto; padding: 24px 16px 60px; }
.hidden { display: none !important; }

.topbar {
  background: var(--theme-color-1);
  border-bottom: 1px solid #eee;
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  max-width: 1600px; margin: 0 auto; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.topbar-title-row {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
}
.site-title { font-size: 28px; font-weight: 700; color: #222; text-decoration: none; }
.topbar-hint { font-size: 14px; color: #fff; }
.topbar-actions {
  display: flex; align-items: center; justify-content: space-evenly;
  gap: 8px; flex-wrap: wrap;
  width: 100%;
}
.mode-label { font-size: 13px; color: #fff; }

.btn {
  border: 1px solid #fff; background: var(--theme-color-1); padding: 6px 14px;
  border-radius: 6px; cursor: pointer; font-size: 14px; color: #333;
}
.btn:hover { background: #f0f0f0; }
.btn-primary { background: #000; color: #fff; border-color: #000; }
.btn-primary:hover { background: #333; }
.btn-danger { color: #d33; border-color: #d33; }
.btn-danger:hover { background: #fff0f0; }
.detail-actions .btn { background: var(--theme-color-2); }
#loginBtn { color: #fff; background: #000; border-color: #000; }

/* 帖子列表 */
.post-card {
  background: var(--theme-color-2); border: 1px solid #eee; border-radius: 8px;
  padding: 16px 18px; margin-bottom: 14px; cursor: pointer;
}
.post-card:hover { border-color: #ccc; }
.post-card h2 { margin: 0 0 6px; font-size: 18px; }
.post-meta { font-size: 12px; color: #999; margin-bottom: 8px; }
.post-summary {
  font-size: 14px;
  color: #555;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-thumbs-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(8, 1fr); /* 电脑端：每个格子 = 卡片宽度的 1/8 */
  gap: 6px;
}
.post-thumbs-cell {
  position: relative;
  width: 100%;
  padding-top: 100%; /* 1:1 正方形 */
  background: #f2f2f2;
  border-radius: 6px;
  overflow: hidden;
  box-sizing: border-box;
  grid-column: span 1; /* 默认占 1 列 */
}
.post-thumbs-cell img {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover; /* 1:1 裁剪填充，不拉伸变形 */
  display: block;
}
.post-thumbs-plus {
  background: #e5e5e5;
}
.post-thumbs-plus-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.post-thumbs-plus-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 18px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
/* 手机端回退到 3 列，保持视觉舒适 */
@media (max-width: 640px) {
  .post-thumbs-grid { grid-template-columns: repeat(3, 1fr); }
}
.vote-controls { display: flex; align-items: center; gap: 5px; margin-top: 14px; }
.vote-btn { min-width: 36px; padding: 4px 7px; font-size: 16px; line-height: 1.2; background: var(--theme-color-2); }
.vote-btn.active { border-color: #3a6ff7; background: #eaf0ff; }
.vote-down.active { border-color: #d86a6a; background: #fff0f0; }
.vote-btn:disabled { cursor: wait; opacity: .65; }
.vote-count { min-width: 12px; margin-right: 5px; color: #777; font-size: 13px; }
.reaction-controls { display: flex; align-items: center; gap: 5px; margin-top: 8px; flex-wrap: wrap; }
.reaction-btn { min-width: 36px; padding: 4px 7px; font-size: 16px; line-height: 1.2; background: var(--theme-color-2); }
.reaction-btn.active { background: #fffbe4; }
.reaction-hug.active { border-color: #d6ad00; background: #fff6bd; }
.reaction-devil.active { border-color: #8f58c5; background: #f1e6ff; }
.reaction-heart.active { border-color: #d65b5b; background: #fff0f0; }
.reaction-sleep.active { border-color: #4d88d8; background: #eaf3ff; }
.reaction-frog.active { border-color: #4e9a57; background: #e9f8ea; }
.reaction-count { min-width: 12px; margin-right: 5px; color: #777; font-size: 13px; }

/* 网页桌宠 */
.desktop-pet {
  position: fixed; right: 24px; top: calc(50% - 58px); z-index: 30;
  width: 110px; cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: none;
  --pet-rotation: 0deg; --pet-scale: 1;
  transform: translateZ(0) rotate(var(--pet-rotation)) scale(var(--pet-scale));
  transform-origin: center bottom;
  transition: left .22s cubic-bezier(.2, .9, .3, 1.15), top .22s cubic-bezier(.2, .9, .3, 1.15), transform .2s ease;
}
.desktop-pet:active, .desktop-pet:focus { background: transparent; outline: none; -webkit-box-shadow: none; box-shadow: none; }
.pet-animation { position: relative; animation: pet-float 3.2s ease-in-out infinite; -webkit-tap-highlight-color: transparent; }
.pet-image { display: block; width: 100%; height: auto; pointer-events: none; filter: drop-shadow(0 7px 6px rgba(0, 0, 0, .18)); -webkit-user-drag: none; }
.desktop-pet:hover { --pet-scale: 1.04; }
.desktop-pet.is-dragging { cursor: grabbing; --pet-scale: .94; transition: none; }
.desktop-pet.is-dragging .pet-animation { animation-play-state: paused; }
@keyframes pet-float {
  0%, 100% { transform: translateY(0) scaleY(1); }
  50% { transform: translateY(-8px) scaleY(1.015); }
}
@media (max-width: 640px) {
  .desktop-pet { width: 80px; right: 14px; top: calc(50% - 47px); }
}

/* 桌宠搜索框 */
.pet-search-box {
  position: fixed; z-index: 31;
  width: 320px;
  background: var(--theme-color-1);
  border: 2px solid #000;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.pet-search-box::after {
  content: '';
  position: absolute;
  width: 0; height: 0;
  border: 8px solid transparent;
}
.pet-search-box.arrow-right::after {
  right: -16px; top: 40px;
  border-left-color: #000;
}
.pet-search-box.arrow-left::after {
  left: -16px; top: 40px;
  border-right-color: #000;
}
.pet-search-box.arrow-top::after {
  top: -16px; left: 40px;
  border-bottom-color: #000;
}
.pet-search-box.arrow-bottom::after {
  bottom: -16px; left: 40px;
  border-top-color: #000;
}
.pet-search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pet-search-input {
  width: 100%;
  padding: 8px 48px 8px 12px;
  border: 2px solid #fff;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  background: var(--theme-color-1);
  color: #fff;
}
.pet-search-input:focus {
  border-color: #fff;
}
.pet-search-count {
  position: absolute;
  right: 10px;
  font-size: 11px;
  color: #fff;
  pointer-events: none;
}
.pet-search-records {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #fff;
}
.pet-search-records-title {
  font-size: 12px;
  color: #fff;
  margin-bottom: 6px;
}
.pet-search-records-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pet-search-record-item {
  background: var(--theme-color-1);
  border: 1px solid #000;
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  color: #333;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}
.pet-search-record-item:hover {
  background: #f0f0f0;
}
.pet-search-record-item:active { background: var(--theme-color-1); }
.pet-search-results {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #fff;
  max-height: 280px;
  overflow-y: auto;
}
.pet-search-result-item {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  border-bottom: 1px solid #f0f0f0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}
.pet-search-result-item:last-child {
  border-bottom: none;
}
.pet-search-result-item:hover {
  background: #f0f0f0;
}
.pet-search-result-item:active { background: transparent; }
.pet-search-result-empty {
  padding: 12px 10px;
  font-size: 13px;
  color: #fff;
  text-align: center;
}
.desktop-pet.search-open {
  cursor: pointer;
}
.desktop-pet.search-open.is-dragging {
  cursor: pointer;
}
@media (max-width: 640px) {
  .pet-search-box { width: 260px; }
}

/* PC 显示 4 行 */
@media (min-width: 769px) {
  .post-summary {
    -webkit-line-clamp: 4;
    line-clamp: 4;
  }
}

/* 手机显示 3 行 */
@media (max-width: 768px) {
  .post-summary {
    -webkit-line-clamp: 3;
    line-clamp: 3;
  }
}
.empty-tip { text-align: center; color: #999; padding: 60px 0; }

/* 帖子详情 */
.post-detail { background: var(--theme-color-2); border: 1px solid #eee; border-radius: 8px; padding: 24px; }
.post-detail h1 { margin-top: 0; }
.post-content { line-height: 1.8; font-size: 15px; word-break: break-word; }
.post-content img { max-width: 100%; border-radius: 6px; margin: 8px 0; }
.post-content a { color: #3a6ff7; }
.detail-actions { margin-top: 20px; display: flex; gap: 8px; }
.back-link { display: inline-block; margin-bottom: 14px; color: #666; text-decoration: none; font-size: 14px; }

/* 编辑器 */
.editor-box { background: var(--theme-color-2); border: 1px solid #eee; border-radius: 8px; padding: 20px; }
.editor-box input[type=text] {
  width: 100%; font-size: 20px; padding: 8px 0; border: none; border-bottom: 1px solid #eee;
  margin-bottom: 12px; outline: none;
}
.toolbar { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar button {
  border: 1px solid #fff; background: #fafafa; padding: 5px 10px; border-radius: 5px; cursor: pointer; font-size: 13px;
}
.toolbar button:hover { background: #eee; }
.editable {
  min-height: 260px; border: 1px solid #ddd; border-radius: 6px; padding: 12px;
  outline: none; line-height: 1.7; font-size: 15px;
}
.editable img { max-width: 100%; border-radius: 4px; vertical-align: middle; }
.editable img.editor-img-selected {
  outline: 2px dashed #3a6ff7;
  outline-offset: 2px;
}

/* 编辑器图片：四角拖拽缩放柄（永久锁定比例） */
.editor-img-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
}
.editor-img-wrap .editor-img-selected {
  /* outline 画在 wrap 上，避免图片本身被影响 */
}
.editor-img-handle {
  position: absolute;
  width: 14px; height: 14px;
  background: #fff;
  border: 2px solid #3a6ff7;
  border-radius: 50%;
  z-index: 5;
  box-sizing: border-box;
}
.editor-img-handle:hover { background: #3a6ff7; }
.editor-img-handle.nw { top: -7px; left: -7px; cursor: nwse-resize; }
.editor-img-handle.ne { top: -7px; right: -7px; cursor: nesw-resize; }
.editor-img-handle.sw { bottom: -7px; left: -7px; cursor: nesw-resize; }
.editor-img-handle.se { bottom: -7px; right: -7px; cursor: nwse-resize; }

/* 编辑器图片尺寸调整面板（简化版：只有快捷按钮 + 删除 + 关闭） */
.editor-img-toolbar {
  position: fixed; z-index: 120;
  background: #2a2a2a; color: #eee;
  border-radius: 8px; padding: 8px 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  font-size: 13px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  max-width: 420px;
}
.editor-img-toolbar .eit-hint { color: #bbb; font-size: 12px; padding: 0 4px; }
.editor-img-toolbar .eit-btn {
  border: 1px solid #555; background: #3a3a3a; color: #eee;
  padding: 4px 10px; border-radius: 4px; cursor: pointer;
  font-size: 12px;
}
.editor-img-toolbar .eit-btn:hover { background: #4a4a4a; }
.editor-img-toolbar .eit-divider {
  width: 1px; height: 18px; background: #555; margin: 0 2px;
}
.editor-img-toolbar .eit-close {
  background: transparent; border: none; color: #bbb;
  cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px;
}
.editor-img-toolbar .eit-close:hover { color: #fff; }
@media (max-width: 640px) {
  .editor-img-toolbar { max-width: calc(100vw - 24px); padding: 6px 8px; }
  .editor-img-toolbar .eit-btn { padding: 4px 8px; font-size: 11px; }
}
.editor-actions { margin-top: 14px; display: flex; gap: 8px; }

/* 弹窗 */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-box {
  background: var(--theme-color-1); border-radius: 10px; padding: 22px; width: 320px;
}
.modal-box h3 { margin-top: 0; }
.modal-box input {
  width: 100%; padding: 8px 10px; margin-bottom: 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.error { color: #d33; font-size: 13px; margin-bottom: 8px; }

.footer {
  background: var(--theme-color-1);
  border-top: 1px solid #eee;
  padding: 16px 0;
  margin-top: 40px;
}
.footer-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 16px;
  text-align: center;
}
.footer-row {
  margin: 0;
  font-size: 13px;
  color: #fff;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.footer-sep { color: #ccc; padding: 0 2px; }
.beian-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  line-height: 1;
}
.beian-link:hover { color: #666; text-decoration: underline; }
.police-beian-icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  object-fit: contain;
  vertical-align: middle;
}

/* 背景 */
body {
  position: relative;
  min-height: 100vh;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: var(--wallpaper-image, none);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  opacity: 0.5;
}

.appearance-controls {
  position: fixed; right: 24px; bottom: 72px; z-index: 20;
  display: flex; flex-direction: column; gap: 8px;
}
.appearance-controls .btn { min-width: 94px; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }
.modal-hint { margin: -8px 0 14px; color: #777; font-size: 13px; line-height: 1.5; }
.appearance-modal-box { width: min(500px, calc(100vw - 32px)); }
.wallpaper-list { display: grid; gap: 10px; margin-top: 16px; }
.wallpaper-item {
  display: flex; flex-direction: column; border: 1px solid #e6e6e6; border-radius: 7px; padding: 8px;
  cursor: pointer; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
}
.wallpaper-item.active { border-color: #000; }
.wallpaper-item-top { display: flex; gap: 10px; align-items: center; }
.wallpaper-preview { width: 100px; height: 62px; object-fit: cover; border-radius: 4px; pointer-events: none; }
.wallpaper-info { flex: 1; min-width: 0; pointer-events: none; }
.wallpaper-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.wallpaper-status { color: #000; font-size: 12px; margin-top: 3px; }
.wallpaper-actions { display: flex; gap: 6px; }
.wallpaper-color-editor { display: none; margin-top: 10px; padding-top: 10px; border-top: 1px dashed #e0e0e0; }
.wallpaper-color-editor.open { display: flex; flex-direction: column; gap: 8px; }
.wallpaper-color-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #555; }
.wallpaper-color-row input[type=color] { width: 36px; height: 28px; border: 1px solid #ddd; border-radius: 4px; padding: 0; cursor: pointer; }
.wallpaper-color-row .color-hex { font-size: 12px; color: #999; }
@media (max-width: 640px) { .appearance-controls { right: 16px; bottom: 56px; } }

/* 桌宠点击菜单 */
.pet-menu {
  position: fixed; z-index: 31;
  background: var(--theme-color-1);
  border: 1px solid #fff;
  border-radius: 10px;
  padding: 8px;
  display: flex; gap: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.pet-menu-btn {
  border: 1px solid #fff; background: var(--theme-color-1);
  padding: 8px 16px; border-radius: 6px; cursor: pointer;
  font-size: 14px; color: #333;
  -webkit-tap-highlight-color: transparent;
}
.pet-menu-btn:hover { background: #f0f0f0; }

/* 项目分享浮层（贴桌宠，与搜索框同款样式） */
.pet-links-box {
  position: fixed; z-index: 31;
  width: 320px;
  background: var(--theme-color-1);
  border: 2px solid #000;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.pet-links-title { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: #fff; }
.projects-list { display: flex; flex-direction: column; gap: 6px; margin: 0; max-height: 240px; overflow-y: auto; }
.projects-empty { text-align: center; color: #fff; padding: 18px 0; font-size: 13px; }
.project-item {
  background: var(--theme-color-2); border: 1px solid #eee;
  border-radius: 6px; padding: 6px 8px;
}
.project-name { font-size: 13px; font-weight: 600; color: #222; margin-bottom: 4px; word-break: break-word; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.project-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* 轻量 toast */
.toast {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8); color: #fff;
  padding: 8px 16px; border-radius: 6px;
  font-size: 13px; z-index: 200; max-width: 80vw; text-align: center;
  -webkit-tap-highlight-color: transparent;
}
@media (max-width: 640px) {
  .toast { max-width: 90vw; font-size: 12px; }
}
@media (max-width: 640px) {
  .pet-links-box { width: 280px; max-height: 60vh; }
}
