/* ==========================================================================
   {{ site_name }} 前端样式
   设计参考：Emil Kowalski《Skills for Designers and Engineers》
   - 克制的层次：中性色 + 半透明材质 + 极轻边框，不靠重色块分区
   - 动效只服务反馈：自定义 ease-out、按压 scale(.97)、入场 scale(.95)+opacity
   - 移动端优先：16px 输入字号、dvh、safe-area、tap-highlight 清除
   - 尊重 prefers-reduced-motion / reduced-transparency / contrast
   ========================================================================== */

:root {
  /* 中性色阶：暖灰而非冷蓝，长时间阅读更柔和 */
  --bg: #fbfbfa;
  --surface: #ffffff;
  --surface-2: #f4f4f2;
  --surface-3: #ececea;
  --border: rgba(17, 17, 19, .09);
  --border-strong: rgba(17, 17, 19, .16);
  --text: #131316;
  --text-soft: #55555e;
  --muted: #8a8a94;

  /* 主色采用近黑，强调色只用于链接与焦点 */
  --primary: #111114;
  --primary-hover: #2a2a30;
  --on-primary: #fbfbfa;
  --accent: #5b5bd6;
  --primary-soft: rgba(91, 91, 214, .10);
  --danger: #d92d20;
  --danger-soft: rgba(217, 45, 32, .10);
  --ok: #0f7b4f;
  --ok-soft: rgba(15, 123, 79, .10);
  --warn: #a15c00;
  --warn-soft: rgba(161, 92, 0, .10);

  --radius: 8px;
  --radius-sm: 6px;
  --radius-xs: 5px;

  --shadow-xs: 0 1px 2px rgba(16, 16, 20, .04);
  --shadow-sm: 0 1px 2px rgba(16, 16, 20, .05), 0 2px 8px rgba(16, 16, 20, .04);
  --shadow-md: 0 2px 6px rgba(16, 16, 20, .05), 0 12px 28px rgba(16, 16, 20, .08);
  --shadow-lg: 0 24px 64px rgba(16, 16, 20, .18);

  /* 强 ease-out：起步快、收尾稳，UI 反馈的标准曲线 */
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);

  --cols: 4;
  --maxw: 1200px;
}

/* 深色模式由 html[data-theme="dark"] 控制，浏览器端脚本在首屏渲染前写入，
   因此在清理旧 localStorage 或禁用 JS 时回落为浅色，不会闪白。 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0f;
  --surface: #161618;
  --surface-2: #1d1d21;
  --surface-3: #26262b;
  --border: rgba(255, 255, 255, .10);
  --border-strong: rgba(255, 255, 255, .18);
  --text: #f2f2f4;
  --text-soft: #b4b4bd;
  --muted: #8b8b95;
  --primary: #f2f2f4;
  --primary-hover: #ffffff;
  --on-primary: #101013;
  --accent: #8f8ff0;
  --primary-soft: rgba(143, 143, 240, .14);
  --danger: #ff6b5e;
  --danger-soft: rgba(255, 107, 94, .14);
  --ok: #4ade9f;
  --ok-soft: rgba(74, 222, 159, .12);
  --warn: #f2b45c;
  --warn-soft: rgba(242, 180, 92, .12);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5), 0 2px 10px rgba(0, 0, 0, .35);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, .45), 0 16px 36px rgba(0, 0, 0, .5);
  --shadow-lg: 0 28px 72px rgba(0, 0, 0, .7);
}

/* ------------------------------ 主题配色 --------------------------------
   仅覆盖品牌色与页面底色；文字、圆角、间距沿用基础设计语言。
   深色版本使用更亮的品牌色，配深色前景，保证对比度。 */
:root[data-accent="sakura"] {
  --accent: #c2255c;
  --primary: #b3255c;
  --primary-hover: #971b4c;
  --primary-soft: rgba(194, 37, 92, .10);
  --bg: #fdf7f9;
  --surface-2: #f7eff2;
  --surface-3: #f1e6ea;
  --border: rgba(96, 20, 48, .10);
  --border-strong: rgba(96, 20, 48, .18);
}
:root[data-accent="ocean"] {
  --accent: #1c7ed6;
  --primary: #125c9e;
  --primary-hover: #0e4a80;
  --primary-soft: rgba(28, 126, 214, .11);
  --bg: #f5f9fd;
  --surface-2: #eef4fa;
  --surface-3: #e3edf7;
  --border: rgba(18, 54, 86, .10);
  --border-strong: rgba(18, 54, 86, .18);
}
:root[data-accent="forest"] {
  --accent: #2f9e44;
  --primary: #1e6b3a;
  --primary-hover: #17552e;
  --primary-soft: rgba(47, 158, 68, .11);
  --bg: #f6faf6;
  --surface-2: #eef6ef;
  --surface-3: #e2efe4;
  --border: rgba(24, 64, 36, .10);
  --border-strong: rgba(24, 64, 36, .18);
}
:root[data-accent="amber"] {
  --accent: #d9480f;
  --primary: #a04a00;
  --primary-hover: #853d00;
  --primary-soft: rgba(217, 72, 15, .11);
  --bg: #fdf9f3;
  --surface-2: #f8f1e7;
  --surface-3: #f2e6d5;
  --border: rgba(92, 50, 10, .10);
  --border-strong: rgba(92, 50, 10, .18);
}
:root[data-theme="dark"][data-accent="sakura"] {
  --accent: #ff9ec0;
  --primary: #f78fb3;
  --primary-hover: #ffb3cd;
  --on-primary: #2a0f1a;
  --primary-soft: rgba(247, 143, 179, .16);
  --bg: #120e10;
  --surface: #1a1517;
  --surface-2: #241d20;
  --surface-3: #2e2529;
  --border: rgba(255, 255, 255, .10);
  --border-strong: rgba(255, 255, 255, .18);
}
:root[data-theme="dark"][data-accent="ocean"] {
  --accent: #4dabf7;
  --primary: #6cb6ff;
  --primary-hover: #8fc8ff;
  --on-primary: #0a1825;
  --primary-soft: rgba(77, 171, 247, .16);
  --bg: #0c1116;
  --surface: #141a20;
  --surface-2: #1a2229;
  --surface-3: #232d36;
  --border: rgba(255, 255, 255, .10);
  --border-strong: rgba(255, 255, 255, .18);
}
:root[data-theme="dark"][data-accent="forest"] {
  --accent: #51cf66;
  --primary: #6ed99a;
  --primary-hover: #8ce6b0;
  --on-primary: #08160d;
  --primary-soft: rgba(81, 207, 102, .15);
  --bg: #0c110d;
  --surface: #141a15;
  --surface-2: #1a211b;
  --surface-3: #232c24;
  --border: rgba(255, 255, 255, .10);
  --border-strong: rgba(255, 255, 255, .18);
}
:root[data-theme="dark"][data-accent="amber"] {
  --accent: #ffa94d;
  --primary: #f2b45c;
  --primary-hover: #f7c47c;
  --on-primary: #1f1205;
  --primary-soft: rgba(255, 169, 77, .15);
  --bg: #120f0a;
  --surface: #1a1610;
  --surface-2: #221c14;
  --surface-3: #2c241a;
  --border: rgba(255, 255, 255, .10);
  --border-strong: rgba(255, 255, 255, .18);
}

* { box-sizing: border-box; }
html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 15px;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; letter-spacing: -.018em; font-weight: 650; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .875em; }

::selection { background: var(--primary); color: var(--bg); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

button, a, [role="button"], .tappable { touch-action: manipulation; }

/* ------------------------------- 顶栏 -----------------------------------
   半透明材质：内容从其下方滚过，而不是被一条实心横条切断。 */
.topbar {
  position: sticky; top: 0; z-index: 50;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--surface) 74%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 16px;
  padding: 9px 16px;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 650; font-size: 16px; letter-spacing: -.02em;
  white-space: nowrap; flex-shrink: 0;
}
.brand-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--primary); color: var(--bg);
  font-size: 14px; line-height: 1;
}
.brand:hover { color: var(--text); }

.search-form { flex: 1; display: flex; max-width: 420px; position: relative; }
.search-form input {
  flex: 1; width: 100%;
  padding: 9px 38px 9px 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font-size: 14px; font-family: inherit; outline: none;
  transition: background 160ms var(--ease-out), border-color 160ms var(--ease-out),
    box-shadow 160ms var(--ease-out);
}
.search-form input::placeholder { color: var(--muted); }
.search-form input:focus {
  background: var(--surface);
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.search-form button {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: var(--radius-xs); background: transparent;
  color: var(--muted); cursor: pointer;
  transition: color 140ms var(--ease-out), background 140ms var(--ease-out),
    transform 100ms var(--ease-out);
}
.search-form button:hover { color: var(--text); background: var(--surface-3); }
.search-form button:active { transform: translateY(-50%) scale(.94); }

.nav { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.nav-link {
  padding: 7px 11px; border-radius: var(--radius-xs);
  font-size: 14px; color: var(--text-soft);
  position: relative; white-space: nowrap;
  transition: color 140ms var(--ease-out), background 140ms var(--ease-out);
}
.nav-link.admin { color: var(--danger); font-weight: 600; }
.nav-link.review { color: var(--warn); font-weight: 600; }
.nav-link.user {
  display: flex; align-items: center; gap: 7px;
  font-weight: 600; color: var(--text);
}
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 5px; margin-left: 5px;
  background: var(--danger); color: #fff;
  border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 1;
}
.menu-toggle {
  display: none; width: 38px; height: 38px;
  align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-xs); color: var(--text);
  font-size: 17px; cursor: pointer;
  transition: transform 100ms var(--ease-out), background 140ms var(--ease-out);
}
.menu-toggle:active { transform: scale(.95); }
.avatar-xs {
  width: 22px; height: 22px; border-radius: 999px;
  object-fit: cover; background: var(--surface-3);
}

/* ------------------------------ 主题切换 -------------------------------- */
.theme-picker { position: relative; display: flex; align-items: center; }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0;
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-xs); color: var(--text-soft);
  cursor: pointer;
  transition: transform 100ms var(--ease-out), color 140ms var(--ease-out),
    background 140ms var(--ease-out), border-color 140ms var(--ease-out);
}
.theme-toggle:hover { color: var(--text); background: var(--surface-2); border-color: var(--border-strong); }
.theme-toggle:active { transform: scale(.95); }
.theme-toggle[aria-expanded="true"] { color: var(--text); background: var(--surface-2); border-color: var(--border-strong); }
.theme-panel {
  position: absolute; top: calc(100% + 9px); right: 0; z-index: 80;
  width: 268px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  animation: theme-in 160ms var(--ease-out);
}
@keyframes theme-in {
  from { opacity: 0; transform: translateY(-5px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.theme-group + .theme-group { margin-top: 13px; }
.theme-label {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  color: var(--muted); margin-bottom: 6px;
}
.theme-modes {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px;
  padding: 3px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px;
}
.theme-modes button {
  border: 0; background: transparent; color: var(--text-soft);
  font: inherit; font-size: 12.5px; padding: 6px 0;
  border-radius: 4px; cursor: pointer;
  transition: background 140ms var(--ease-out), color 140ms var(--ease-out);
}
.theme-modes button:hover { color: var(--text); }
.theme-modes button.is-active {
  background: var(--surface); color: var(--text);
  font-weight: 600; box-shadow: var(--shadow-xs);
}
.theme-swatches { display: flex; align-items: center; gap: 9px; padding: 2px 0 1px; }
.theme-swatch {
  position: relative; width: 30px; height: 30px; padding: 0;
  border-radius: 50%; border: 0; cursor: pointer;
  background: var(--sw); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);
  transition: transform 120ms var(--ease-out);
}
.theme-swatch:hover { transform: scale(1.08); }
.theme-swatch:active { transform: scale(.96); }
.theme-swatch.is-active::after {
  content: ""; position: absolute; inset: -4px;
  border: 2px solid var(--text); border-radius: 50%;
}
.theme-swatch-name {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.theme-hint { margin: 10px 0 0; font-size: 11px; color: var(--muted); }

/* ------------------------------- 布局 -----------------------------------
   大标题负字距、正文舒适行高，来自 Apple 字体排版原则。 */
.container { max-width: var(--maxw); margin: 0 auto; padding: 26px 16px 64px; }
.section-title {
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 700; letter-spacing: -.03em; line-height: 1.12;
}
.section-title.small { font-size: 19px; margin-top: 30px; letter-spacing: -.02em; }
.section-sub { color: var(--muted); margin: 6px 0 22px; font-size: 14px; }
.footer {
  max-width: var(--maxw); margin: 0 auto;
  padding: 22px 16px calc(40px + env(safe-area-inset-bottom));
  color: var(--muted); font-size: 13px;
  display: flex; gap: 18px; border-top: 1px solid var(--border);
}
.footer-stats {
  margin-left: auto; display: flex; gap: 14px;
  font-variant-numeric: tabular-nums;
}
.footer-stats strong { color: var(--text-soft); font-weight: 600; }
.muted { color: var(--muted); }
.grow { flex: 1; min-width: 0; }
.inline { display: inline; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ------------------------------- 信息流 --------------------------------- */
.feed-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.feed-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.segmented {
  display: inline-flex; background: var(--surface-2);
  border-radius: var(--radius-sm); padding: 3px;
  border: 1px solid var(--border);
}
.seg {
  padding: 6px 12px; border-radius: 5px; font-size: 13px;
  color: var(--text-soft);
  transition: color 140ms var(--ease-out), background 140ms var(--ease-out);
}
.seg:hover { color: var(--text); }
.seg.active {
  background: var(--surface); color: var(--text);
  font-weight: 600; box-shadow: var(--shadow-xs);
}
.col-control { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.col-control .col-label { margin-right: 3px; }
.col-control button {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-xs); width: 28px; height: 28px;
  color: var(--text-soft); cursor: pointer; font-family: inherit;
  transition: transform 100ms var(--ease-out), background 140ms var(--ease-out),
    color 140ms var(--ease-out), border-color 140ms var(--ease-out);
}
.col-control button:active { transform: scale(.94); }
.col-control button.active {
  background: var(--primary); color: var(--bg); border-color: var(--primary);
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 18px;
}

/* 卡片：极轻阴影 + 发丝边框；只有细指针设备才做悬停位移 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out),
    border-color 200ms var(--ease-out);
  animation: card-in 340ms var(--ease-out) both;
}
.card:nth-child(2) { animation-delay: 30ms; }
.card:nth-child(3) { animation-delay: 60ms; }
.card:nth-child(4) { animation-delay: 90ms; }
.card:nth-child(5) { animation-delay: 120ms; }
.card:nth-child(6) { animation-delay: 150ms; }
.card:nth-child(7) { animation-delay: 180ms; }
.card:nth-child(8) { animation-delay: 210ms; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.card-link { display: block; }
.card-thumb {
  position: relative; aspect-ratio: 4 / 3;
  background: var(--surface-2); overflow: hidden;
}
.card-thumb img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 400ms var(--ease-out);
}
.thumb-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px;
}
.img-count {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(0, 0, 0, .55); color: #fff;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  font-size: 11px; padding: 2px 7px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.card-body { padding: 11px 13px 13px; }
.card-title {
  font-size: 14.5px; font-weight: 600; letter-spacing: -.012em;
  margin: 0 0 8px; line-height: 1.35;
  overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-clamp: 2;
}
.card-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); flex-wrap: wrap;
}
.card-meta .author {
  color: var(--text-soft); font-weight: 500; max-width: 45%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-meta .stats { margin-left: auto; font-variant-numeric: tabular-nums; }
.sentinel { min-height: 68px; display: flex; align-items: center; justify-content: center; margin-top: 22px; }
.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--text); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.end-note { color: var(--muted); font-size: 13px; }

/* ------------------------------- 面板 ----------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px; margin-bottom: 18px;
  box-shadow: var(--shadow-xs);
}
.panel-title { font-size: 16px; font-weight: 650; letter-spacing: -.015em; margin-bottom: 14px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }

/* 审计日志：筛选工具栏、动作徽章与表格排版 */
.audit-toolbar { justify-content: space-between; }
.audit-filter, .audit-download { margin: 0; gap: 8px; align-items: center; }
.audit-filter select, .audit-download input { width: auto; }
.audit-download input { max-width: 88px; }
.audit-table th, .audit-table td { vertical-align: top; }
.audit-time, .audit-ip { white-space: nowrap; }
.audit-time { font-variant-numeric: tabular-nums; color: var(--muted); }
.audit-act {
  display: inline-block; padding: 2px 8px;
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  background: var(--surface-2); font-size: 12px; font-weight: 600;
}
.audit-group { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.audit-detail { color: var(--muted); word-break: break-word; }

/* ------------------------------- 按钮 -----------------------------------
   反馈发生在按下瞬间（:active），而不是点击结束。 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 8px 14px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font-size: 14px; font-family: inherit; font-weight: 500; line-height: 1.2;
  cursor: pointer; white-space: nowrap;
  transition: transform 140ms var(--ease-out), background 140ms var(--ease-out),
    color 140ms var(--ease-out), border-color 140ms var(--ease-out),
    box-shadow 140ms var(--ease-out);
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--primary); color: var(--on-primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .10), var(--shadow-xs);
}
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }
:root[data-theme="dark"] .btn-primary {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .20), var(--shadow-xs);
}
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text-soft); }
.btn-ghost.active, .btn-ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { color: #fff; filter: brightness(.94); }
.btn-sm { min-height: 30px; padding: 5px 10px; font-size: 13px; border-radius: var(--radius-xs); }
.btn-block { width: 100%; }
.btn-like.active { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn[disabled]:active { transform: none; }
.link-btn {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 13px; padding: 3px 6px;
  border-radius: 4px; font-family: inherit;
  transition: color 140ms var(--ease-out), background 140ms var(--ease-out);
}
.link-btn:hover { color: var(--text); background: var(--surface-2); }

/* ------------------------------- 表单 ----------------------------------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-soft); }
input[type=text], input[type=search], input[type=number], input[type=file],
input[type=password], textarea, select {
  font-family: inherit; font-size: 16px;
  padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  outline: none; width: 100%;
  transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out),
    background 160ms var(--ease-out);
}
@media (min-width: 721px) {
  input[type=text], input[type=search], input[type=number], input[type=file],
  input[type=password], textarea, select { font-size: 14px; }
}
textarea { resize: vertical; min-height: 72px; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, textarea:focus, select:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.checkbox input { width: auto; }
.search-inline input { max-width: 260px; }

/* 文件选择控件与其它输入框保持同一视觉语言 */
input[type=file] {
  padding: 5px 6px; min-height: 39px; cursor: pointer;
  color: var(--muted); font-size: 13px;
}
input[type=file]::file-selector-button {
  margin-right: 10px; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  background: var(--surface-2); color: var(--text);
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background 140ms var(--ease-out), border-color 140ms var(--ease-out),
    transform 100ms var(--ease-out);
}
input[type=file]::file-selector-button:hover { background: var(--surface-3); }
input[type=file]::file-selector-button:active { transform: scale(.96); }

/* ------------------------------- 认证页 --------------------------------- */
.auth-wrap { display: flex; justify-content: center; padding: 40px 0; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 30px; max-width: 460px; width: 100%;
  box-shadow: var(--shadow-sm);
}
.auth-title { font-size: 24px; letter-spacing: -.025em; }
.auth-sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.auth-note {
  margin-top: 20px; font-size: 13px; color: var(--text-soft);
  border-top: 1px dashed var(--border); padding-top: 16px;
}
.identity-hint {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 13px;
  font-size: 13px; margin-bottom: 16px;
}
.auth-tabs { display: flex; width: 100%; margin-bottom: 18px; }
.auth-tabs .seg {
  flex: 1; text-align: center; border: 0; background: transparent;
  font-family: inherit; font-size: 13px; cursor: pointer;
}
.auth-pane[hidden] { display: none; }

/* ------------------------------- 帖子详情 ------------------------------- */
.post-title {
  font-size: clamp(24px, 3.4vw, 34px);
  font-weight: 700; letter-spacing: -.03em; line-height: 1.14;
  margin-bottom: 12px;
}
.post-meta {
  display: flex; align-items: center; gap: 14px;
  color: var(--muted); font-size: 13px; margin-bottom: 20px; flex-wrap: wrap;
}
.author-chip { display: flex; align-items: center; gap: 10px; }
.author-chip small { display: block; color: var(--muted); }
.avatar-sm {
  width: 38px; height: 38px; border-radius: 999px;
  object-fit: cover; background: var(--surface-3);
}
.avatar-lg {
  width: 96px; height: 96px; border-radius: 999px;
  object-fit: cover; background: var(--surface-3);
  border: 4px solid var(--surface);
  box-shadow: var(--shadow-sm);
}
.gallery { display: grid; gap: 8px; margin-bottom: 20px; }
.gallery-1 { grid-template-columns: 1fr; }
.gallery-2 { grid-template-columns: repeat(2, 1fr); }
.gallery-3, .gallery-4 { grid-template-columns: repeat(2, 1fr); }
.gallery-item {
  border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.gallery-item img { width: 100%; height: 100%; object-fit: cover; max-height: 460px; }
.post-body {
  white-space: pre-wrap; word-wrap: break-word;
  font-size: 16px; line-height: 1.75; margin-bottom: 22px;
  color: var(--text);
}
.post-actions {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 12px 0; margin-bottom: 24px;
}
.status-banner {
  background: var(--surface-2);
  border-left: 3px solid var(--muted);
  padding: 11px 14px; border-radius: var(--radius-xs);
  font-size: 13px; margin-bottom: 16px;
}
.status-rejected, .status-removed, .status-report_hidden { border-left-color: var(--danger); }
.status-pending, .status-appealed { border-left-color: var(--warn); }
.status-approved { border-left-color: var(--ok); }

/* 帖子上的审核员编号：只展示编号，不暴露账号 */
.review-no {
  display: inline-flex; align-items: center; padding: 1px 6px;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface-2); color: var(--muted);
  font-size: 11px; font-variant-numeric: tabular-nums;
}

/* IP 归属地：帖子、评论、个人主页统一使用轻量文字标签 */
.ip-loc { color: var(--muted); font-size: 11px; white-space: nowrap; }
.profile-handle .ip-loc { margin-left: 6px; }

/* ------------------------------- 评论 ----------------------------------- */
.comments-title { font-size: 17px; letter-spacing: -.02em; margin-bottom: 14px; }
.comment-form { display: flex; gap: 10px; margin-bottom: 22px; }
.comment-input-wrap { flex: 1; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.comment-input { width: 100%; }
.comment-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 18px; }
.comment { display: flex; gap: 10px; }
.comment-main { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.comment-head .time { font-size: 12px; }
.comment-body { white-space: pre-wrap; word-wrap: break-word; margin: 2px 0 4px; line-height: 1.6; }
.comment-foot { display: flex; gap: 2px; }
.comment-replies {
  list-style: none; padding: 12px 0 0 10px; margin: 8px 0 0;
  border-left: 2px solid var(--border);
  display: flex; flex-direction: column; gap: 12px;
}

/* ------------------------------- 个人页 --------------------------------- */
.profile-hero {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; margin-bottom: 24px;
  box-shadow: var(--shadow-xs);
}
.profile-banner {
  height: 168px; background-size: cover; background-position: center;
  background-color: var(--surface-2);
}
.profile-head {
  display: flex; gap: 16px; padding: 0 22px 22px;
  margin-top: -48px; align-items: flex-start; flex-wrap: wrap;
}
.profile-info { flex: 1; min-width: 200px; margin-top: 54px; }
.profile-name {
  font-size: 22px; letter-spacing: -.025em;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.profile-handle { color: var(--muted); font-size: 14px; }
.profile-bio { margin: 8px 0; white-space: pre-wrap; color: var(--text-soft); }
.profile-stats { display: flex; gap: 20px; font-size: 14px; color: var(--muted); }
.profile-stats strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.profile-actions { display: flex; gap: 8px; margin-top: 54px; flex-wrap: wrap; }
.avatar-preview img { width: 72px; height: 72px; border-radius: 999px; object-fit: cover; }
.form-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }

.tag {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-soft);
  border: 1px solid var(--border);
}
.tag-admin, .tag-banned { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag-mod, .tag-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }

/* ------------------------------- 等级 / 标签 ----------------------------- */
.level-badge {
  display: inline-flex; align-items: center;
  padding: 1px 6px; border-radius: 4px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border); font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.level-badge.is-high { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-soft);
  border: 1px solid var(--border); font-size: 12px; line-height: 1.6;
  white-space: nowrap;
  transition: border-color 160ms var(--ease-out), color 160ms var(--ease-out);
}
.tag-chip:hover { border-color: var(--border-strong); color: var(--text); }
.tag-chip.active { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.chip-count { font-size: 10.5px; color: var(--muted); }
.card-tags { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 6px; }
.card-tags .tag-chip { font-size: 11px; padding: 1px 7px; }
.post-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tag-strip {
  display: flex; gap: 8px; align-items: center;
  overflow-x: auto; padding: 2px 0 12px; margin-bottom: 8px;
  scrollbar-width: none;
}
.tag-strip::-webkit-scrollbar { display: none; }
.tag-strip-label { flex: none; font-size: 12px; color: var(--muted); }
.filter-note {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px; font-size: 13.5px; color: var(--muted);
}
.level-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  margin-bottom: 24px; box-shadow: var(--shadow-xs);
}
.level-card-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.level-card-lv {
  font-size: 22px; font-weight: 700; letter-spacing: -.02em;
  color: var(--primary); white-space: nowrap;
}
.level-card-body { min-width: 180px; }
.level-card-title { font-size: 15px; }
.level-card-xp {
  font-size: 12px; color: var(--muted); margin: 2px 0 6px;
  font-variant-numeric: tabular-nums;
}
.level-progress {
  height: 6px; border-radius: 999px; background: var(--surface-2);
  overflow: hidden; border: 1px solid var(--border);
}
.level-progress span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.tag-cloud-wrap { margin-bottom: 20px; }
.tag-cloud { display: flex; gap: 8px; flex-wrap: wrap; }
.ranking-list { list-style: none; display: flex; flex-direction: column; gap: 8px; padding: 0; }
.ranking-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
}
.ranking-pos {
  width: 28px; text-align: center; font-weight: 700;
  color: var(--muted); font-variant-numeric: tabular-nums;
}
.ranking-row:nth-child(-n+3) .ranking-pos { color: var(--primary); }
.ranking-user { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.ranking-xp { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.xp-rules { padding-left: 20px; line-height: 2; color: var(--text-soft); }

@media (max-width: 720px) {
  .level-card { flex-direction: column; align-items: flex-start; }
  .card-tags .tag-chip:nth-child(n+3) { display: none; }
}

/* ------------------------------- 私信 ----------------------------------- */
.chat {
  display: flex; flex-direction: column;
  height: calc(100dvh - 190px); min-height: 320px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.chat-head a { display: flex; align-items: center; gap: 10px; }
.chat-body {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.bubble { max-width: 72%; padding: 9px 13px; border-radius: 10px; font-size: 14px; line-height: 1.5; }
.bubble.mine {
  align-self: flex-end; background: var(--primary); color: var(--on-primary);
  border-bottom-right-radius: 3px;
}
.bubble.theirs {
  align-self: flex-start; background: var(--surface-2);
  color: var(--text); border-bottom-left-radius: 3px;
  border: 1px solid var(--border);
}
.bubble-text { white-space: pre-wrap; word-wrap: break-word; }
.bubble-time { font-size: 11px; opacity: .65; margin-top: 4px; }
.chat-form {
  display: flex; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--border); align-items: flex-end;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.chat-form textarea { min-height: 44px; }
.chat-locked {
  padding: 14px 16px; border-top: 1px solid var(--border);
  background: var(--warn-soft); color: var(--warn); font-size: 14px;
}

/* ------------------------------- 列表/表格 ------------------------------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  transition: border-color 160ms var(--ease-out), background 160ms var(--ease-out);
}
.list-row.link:hover { border-color: var(--border-strong); }
.row-title { font-weight: 600; }
.row-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.user-list { display: flex; flex-direction: column; gap: 8px; }
.user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color 160ms var(--ease-out);
}
.user-row:hover { border-color: var(--border-strong); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td {
  text-align: left; padding: 11px 12px;
  border-bottom: 1px solid var(--border); vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table th {
  color: var(--muted); font-weight: 600; background: var(--surface-2);
  font-size: 12px; letter-spacing: .01em;
}
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.thumb-mini img {
  width: 54px; height: 40px; object-fit: cover;
  border-radius: 4px; margin-top: 4px; border: 1px solid var(--border);
}

/* ------------------------------- 后台 ----------------------------------- */
.admin-shell { display: grid; grid-template-columns: 196px 1fr; gap: 24px; }
.admin-nav {
  display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 74px; align-self: start;
}
.admin-nav a {
  padding: 9px 12px; border-radius: var(--radius-xs);
  color: var(--text-soft); font-size: 14px;
  transition: background 140ms var(--ease-out), color 140ms var(--ease-out);
}
.admin-nav a:hover { background: var(--surface-2); color: var(--text); }
.admin-main { min-width: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; text-align: center;
  box-shadow: var(--shadow-xs);
}
.stat-num {
  display: block; font-size: 26px; font-weight: 700;
  letter-spacing: -.03em; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-label { color: var(--muted); font-size: 13px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
.key-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-xs);
}
.pem, .code-block {
  background: #0f1117; color: #d7e0ff; padding: 14px;
  border-radius: var(--radius-sm); overflow-x: auto;
  font-size: 12px; white-space: pre-wrap; word-break: break-all; line-height: 1.55;
  border: 1px solid rgba(255, 255, 255, .06);
}
.key-meta { display: flex; flex-direction: column; gap: 4px; font-size: 14px; margin-bottom: 14px; }
.review-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------- 提示/其他 ------------------------------- */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash {
  padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: 14px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  animation: card-in 260ms var(--ease-out) both;
}
.flash-success { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.flash-warning { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.flash-info { background: var(--primary-soft); color: var(--accent); border-color: transparent; }
.alert { padding: 14px; border-radius: var(--radius-sm); margin-bottom: 16px; }
.alert-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.empty {
  text-align: center; padding: 52px 16px; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.empty-inline { color: var(--muted); font-size: 13px; }
.pager { text-align: center; margin-top: 22px; }
.sentinel .spinner { margin: 0 auto; }
.preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.preview img {
  width: 100%; height: 90px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--border);
}
.error-page { text-align: center; padding: 72px 16px; }
.error-code {
  font-size: clamp(56px, 12vw, 84px); font-weight: 750;
  letter-spacing: -.05em; line-height: 1;
  color: var(--text); margin-bottom: 8px;
}
.prose p { color: var(--text-soft); }
mark {
  background: color-mix(in srgb, var(--warn) 22%, transparent);
  color: var(--text); padding: 0 2px; border-radius: 3px;
}

/* ------------------------------- 举报弹窗 -------------------------------
   弹窗不做位移动画，只做透明度 + 轻微缩放（scale 从 .96 开始，而非 0）。 */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(10, 10, 12, .48);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: scrim-in 180ms var(--ease-out) both;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 24px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
  animation: modal-in 220ms var(--ease-out) both;
  transform-origin: center;
}
.modal-card h3 { margin-bottom: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: scale(.96) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ------------------------------- 公告栏 --------------------------------- */
.announcement-card { max-width: 520px; }
.announcement-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.announcement-head h3 { margin: 0; }
.announcement-close {
  width: 30px; height: 30px; flex: none;
  border: 0; border-radius: 50%; background: transparent;
  color: var(--muted); font-size: 20px; line-height: 1;
  cursor: pointer; transition: background 140ms var(--ease-out), color 140ms var(--ease-out);
}
.announcement-close:hover { background: var(--surface-2); color: var(--text); }
.announcement-list { max-height: 60vh; overflow-y: auto; margin-top: 8px; }
.announcement-item { padding: 14px 0; }
.announcement-item + .announcement-item { border-top: 1px solid var(--border); }
.announcement-item h4 { margin-bottom: 6px; font-size: 15px; }
.announcement-item time { display: block; margin-top: 8px; font-size: 12px; color: var(--muted); }
.announcement-body {
  white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: 14px; line-height: 1.65; color: var(--text-soft);
}
.announcement-preview {
  max-width: 420px; margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px;
}
.announcement-public { margin-bottom: 16px; }
.announcement-public-head {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: 6px 12px; margin-bottom: 8px;
}
.announcement-public-head h2 { margin: 0; font-size: 18px; }

/* ------------------------------- 响应式 --------------------------------- */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 14px; }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-nav {
    position: static; flex-direction: row; overflow-x: auto;
    padding-bottom: 4px; gap: 4px;
    scrollbar-width: none;
  }
  .admin-nav::-webkit-scrollbar { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; gap: 10px; padding: 8px 12px; }
  .theme-picker { margin-left: auto; }
  .theme-panel {
    position: fixed; top: 102px; left: 12px; right: 12px; width: auto;
  }
  .menu-toggle { display: inline-flex; margin-left: 0; }
  .nav {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    opacity: 0; visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out),
      visibility 0s linear 180ms;
  }
  body.nav-open .nav {
    opacity: 1; visibility: visible; transform: translateY(0);
    transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out),
      visibility 0s linear 0s;
  }
  .search-form { order: 3; flex-basis: 100%; max-width: none; }
  /* 窄屏固定两列，隐藏列数控件以免与实际布局不一致 */
  .col-control { display: none; }
  .nav-link { padding: 11px 12px; border-radius: var(--radius-xs); }
  .nav-link:active { background: var(--surface-2); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 12px; }
  .post-title { font-size: 23px; }
  .gallery-3, .gallery-4 { grid-template-columns: repeat(2, 1fr); }
  .chat { height: calc(100dvh - 168px); }
  .profile-actions, .profile-info { margin-top: 14px; }
  .profile-head { margin-top: -38px; padding: 0 16px 18px; }
  .container { padding: 20px 12px 56px; }
  .panel { padding: 18px; }
  .footer { padding-left: 12px; padding-right: 12px; flex-wrap: wrap; }
  .footer-stats { margin-left: 0; width: 100%; gap: 12px; }
}
@media (max-width: 420px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; }
  .card-title { font-size: 13px; }
  .card-body { padding: 9px 10px 11px; }
  .container { padding: 16px 10px 52px; }
  .btn { padding: 8px 12px; }
}

/* ------------------------------- 可访问性偏好 ---------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .card, .flash, .modal, .modal-card { animation: none !important; }
  .card:hover { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar, .modal, .nav {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    background: var(--surface) !important;
  }
}
@media (prefers-contrast: more) {
  :root { --border: rgba(17, 17, 19, .35); --border-strong: rgba(17, 17, 19, .55); }
}

/* 仅在精确指针设备上做悬停位移，避免触屏「粘住」hover 状态 */
@media (hover: hover) and (pointer: fine) {
  .card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
  }
  .card:hover .card-thumb img { transform: scale(1.025); }
  .nav-link:hover { background: var(--surface-2); color: var(--text); }
  .list-row.link:hover { background: var(--surface-2); }
}

/* ------------------------------- 聊天室 ----------------------------------
   参考 nnhaowu.com 聊天室：整行浅色气泡 + 头像在侧、昵称在上、正文无边框；
   每位发言者按 id 固定分配一种柔和的底色，视觉上形成连续的对话流。 */
.chat-room { padding: 0; overflow: hidden; }
.chat-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.chat-toolbar-title { font-weight: 600; }
.chat-list {
  height: min(62vh, 600px); min-height: 340px; overflow-y: auto;
  padding: 10px 10px 14px; display: flex; flex-direction: column; gap: 3px;
  overscroll-behavior: contain;
}
.chat-loading { text-align: center; font-size: 12px; padding-bottom: 4px; }
.chat-empty { margin: auto; text-align: center; }
.chat-item {
  position: relative;
  display: flex; align-items: flex-start; gap: 9px;
  padding: 7px 9px; border-radius: 4px;
  background: var(--chat-tint, transparent);
}
/* 每位发言者一种固定的柔和底色（按 author_id % 6） */
.chat-tone-0 { --chat-tint: rgba(232, 121, 169, .13); }
.chat-tone-1 { --chat-tint: rgba(46, 182, 125, .12); }
.chat-tone-2 { --chat-tint: rgba(84, 125, 220, .11); }
.chat-tone-3 { --chat-tint: rgba(212, 160, 49, .13); }
.chat-tone-4 { --chat-tint: rgba(139, 110, 224, .11); }
.chat-tone-5 { --chat-tint: rgba(120, 130, 150, .10); }
.chat-avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
  flex: 0 0 auto; background: var(--surface-3);
}
.chat-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: flex-start;
}
.chat-meta {
  display: flex; align-items: center; gap: 7px; margin-bottom: 1px;
  font-size: 12px; color: var(--muted); flex-wrap: wrap;
}
.chat-name { color: var(--text-soft); font-weight: 600; font-size: 13px; text-decoration: none; }
.chat-name:hover { color: var(--accent); }
.chat-meta time { font-size: 11px; font-variant-numeric: tabular-nums; }
.chat-report {
  position: absolute; top: 6px; right: 9px;
  border: 0; background: transparent; padding: 0;
  font-size: 11px; color: var(--muted); cursor: pointer;
  opacity: 0; transition: opacity 140ms var(--ease-out), color 140ms var(--ease-out);
}
.chat-item.is-self .chat-report { right: auto; left: 9px; }
.chat-item:hover .chat-report,
.chat-report:focus-visible { opacity: .75; }
.chat-report:hover { color: var(--danger); opacity: 1; }
@media (hover: none) { .chat-report { opacity: .55; } }
.chat-bubble {
  padding: 0; border: 0; background: none;
  font-size: 15px; line-height: 1.5; color: var(--text);
  word-break: break-word; white-space: normal;
}
.chat-item.is-self { flex-direction: row-reverse; }
.chat-item.is-self .chat-main { align-items: flex-end; text-align: right; }
.chat-item.is-self .chat-meta { flex-direction: row-reverse; }
.chat-image { display: inline-block; margin-top: 5px; }
.chat-image img {
  max-width: min(300px, 60vw); max-height: 240px; display: block;
  border-radius: 6px; border: 1px solid var(--border);
}
.chat-composer { border-top: 1px solid var(--border); padding: 12px 16px; background: var(--surface); }
.chat-composer-row { display: flex; gap: 10px; align-items: flex-end; }
.chat-composer textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 140px;
  padding: 10px 13px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface-2);
  color: var(--text); font: inherit; line-height: 1.5;
}
.chat-composer textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--primary-soft);
}
.chat-composer-tools {
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
  font-size: 12px; flex-wrap: wrap;
}
.chat-file-btn { cursor: pointer; }
.chat-preview {
  width: 56px; height: 56px; object-fit: cover;
  border-radius: var(--radius-xs); border: 1px solid var(--border);
}
.chat-composer .btn[disabled] { opacity: .5; cursor: not-allowed; }

@media (max-width: 720px) {
  .chat-list { height: calc(100dvh - 330px); min-height: 260px; padding: 8px 8px 12px; }
  .chat-item { padding: 6px 7px; gap: 8px; }
  .chat-avatar { width: 34px; height: 34px; }
}
