/* IcefieldIgloo 冰原雪屋 — 轻量样式，手机优先 */
:root {
  --bg: #f4f8fb;
  --surface: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --ice-50: #f0f9ff;
  --ice-100: #e0f2fe;
  --ice-300: #7dd3fc;
  --ice-500: #38bdf8;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;
  --danger: #dc2626;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(15, 40, 70, 0.08), 0 4px 14px rgba(15, 40, 70, 0.06);
  --topbar-h: 58px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.warn { color: var(--danger); }

/* ===== 顶栏 ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.logo { width: 34px; height: 34px; flex: none; }
.brand-name { font-size: 19px; font-weight: 800; letter-spacing: 0.2px; color: var(--blue-800); }
.top-actions { display: flex; align-items: center; gap: 8px; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 999px;
  padding: 8px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
  white-space: nowrap; text-decoration: none; color: inherit; background: none;
  font-family: inherit;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--blue-700); color: #fff; box-shadow: 0 2px 8px rgba(29, 78, 216, 0.28); }
.btn-primary:hover { background: var(--blue-800); }
.btn-outline { border-color: var(--ice-500); color: var(--blue-700); background: #fff; }
.btn-outline:hover { background: var(--ice-50); }
.btn-ghost { color: var(--blue-700); }
.btn-ghost:hover { background: var(--ice-100); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.94); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; border-radius: var(--radius-sm); }
.btn-ic { font-size: 15px; line-height: 1; }
.btn-post { padding: 8px 14px; }

/* ===== 布局 ===== */
.layout { max-width: 1180px; margin: 0 auto; padding: 16px 14px 90px; }
.sidenav { display: none; }
.infopanel { display: none; }
.content { min-width: 0; }
.view-title { font-size: 20px; margin: 4px 2px 12px; }

/* ===== 帖子流 ===== */
.feed { display: flex; flex-direction: column; gap: 14px; }
.post {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow);
  animation: rise 0.25s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.post-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--ice-300), var(--blue-700));
  color: #fff; font-weight: 700; font-size: 16px;
}
.post-meta { flex: 1; min-width: 0; }
.post-author { font-weight: 700; font-size: 15px; }
.post-sub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--ice-100); color: var(--blue-800);
  border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 500;
}
.post-actions { display: flex; gap: 4px; }
.icon-btn {
  border: none; background: none; cursor: pointer; font-size: 15px;
  padding: 6px 8px; border-radius: 8px; color: var(--muted);
  transition: background 0.15s ease;
}
.icon-btn:hover { background: var(--ice-100); color: var(--blue-700); }
.icon-btn.danger:hover { background: #fee2e2; color: var(--danger); }
.post-content {
  font-size: 15px; white-space: pre-wrap; word-break: break-word; margin: 6px 0 10px;
}
/* 图片网格 */
.img-grid { display: grid; gap: 6px; border-radius: var(--radius-sm); overflow: hidden; }
.img-grid.n1 { grid-template-columns: 1fr; }
.img-grid.n2 { grid-template-columns: 1fr 1fr; }
.img-grid.n3 { grid-template-columns: 1fr 1fr 1fr; }
.img-grid.n4 { grid-template-columns: 1fr 1fr; }
.img-grid.n9 { grid-template-columns: 1fr 1fr 1fr; }
.img-grid img {
  width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in;
  background: var(--ice-50);
}
.img-grid.n1 img { max-height: 420px; object-fit: contain; background: #0b0f19; }
.img-grid.n2 img, .img-grid.n3 img, .img-grid.n4 img, .img-grid.n9 img { aspect-ratio: 1; }

/* ===== 状态区 ===== */
.feed-foot { padding: 18px 0 8px; text-align: center; }
.state { color: var(--muted); font-size: 14px; padding: 18px 10px; }
.state-error { color: var(--danger); }
.spinner {
  display: inline-block; width: 16px; height: 16px; margin-right: 8px; vertical-align: -3px;
  border: 2px solid var(--ice-300); border-top-color: var(--blue-700);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 卡片（右侧栏） ===== */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.card h3 { margin: 0 0 8px; font-size: 15px; }
.card p, .card ul { margin: 0; font-size: 13.5px; color: var(--muted); }
.card ul { padding-left: 18px; }
.card li { margin: 4px 0; }

/* ===== 悬浮发帖按钮（手机） ===== */
.fab {
  position: fixed; right: 18px; bottom: calc(20px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--blue-700); color: #fff; font-size: 30px; line-height: 1;
  box-shadow: 0 6px 18px rgba(29, 78, 216, 0.4);
  transition: transform 0.12s ease, background 0.15s ease; z-index: 60;
  display: flex; align-items: center; justify-content: center;
}
.fab:hover { background: var(--blue-800); }
.fab:active { transform: scale(0.92); }

/* ===== 弹窗 ===== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 30, 55, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border-radius: 20px 20px 0 0;
  width: 100%; max-width: 440px; max-height: 92dvh; overflow-y: auto;
  padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
  position: relative;
  animation: slideup 0.22s ease;
}
@keyframes slideup { from { transform: translateY(30px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal-close {
  position: absolute; top: 12px; right: 12px; border: none; background: var(--ice-50);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 14px; color: var(--muted);
}
.modal-close:hover { background: var(--ice-100); color: var(--ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; background: var(--ice-50); border-radius: 999px; padding: 4px; }
.tab {
  flex: 1; border: none; background: none; cursor: pointer; padding: 9px;
  border-radius: 999px; font-size: 15px; font-weight: 600; color: var(--muted); font-family: inherit;
}
.tab.active { background: #fff; color: var(--blue-700); box-shadow: var(--shadow); }

/* ===== 表单 ===== */
.field { display: block; margin-bottom: 13px; }
.field > span { display: flex; justify-content: space-between; align-items: baseline; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.field .count { font-style: normal; font-weight: 400; color: var(--muted); font-size: 12px; }
.field input, .field textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; font-size: 15px; font-family: inherit; color: var(--ink);
  background: #fff; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--ice-500); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}
.field textarea { resize: vertical; min-height: 110px; line-height: 1.6; }
.form-error {
  background: #fef2f2; border: 1px solid #fecaca; color: var(--danger);
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13.5px; margin-bottom: 12px;
}
.turnstile-wrap { margin: 6px 0 14px; min-height: 65px; display: flex; justify-content: center; }

/* 发帖图片 */
.img-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.img-pick { cursor: pointer; }
#img-preview .thumb { position: relative; border-radius: var(--radius-sm); overflow: hidden; }
#img-preview { grid-template-columns: repeat(3, 1fr); }
#img-preview img { aspect-ratio: 1; cursor: default; }
.thumb .remove {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%;
  border: none; background: rgba(15, 23, 42, 0.65); color: #fff; cursor: pointer; font-size: 13px;
}
.thumb .prog {
  position: absolute; inset: auto 0 0 0; height: 5px; background: rgba(255, 255, 255, 0.4);
}
.thumb .prog i { display: block; height: 100%; width: 0; background: var(--ice-500); transition: width 0.15s; }
.thumb.uploading img { opacity: 0.55; }

/* 图片查看器 */
.lightbox { position: relative; max-width: 94vw; max-height: 90dvh; }
.lightbox img { max-width: 94vw; max-height: 86dvh; border-radius: var(--radius-sm); display: block; }
.lightbox-close { background: rgba(255, 255, 255, 0.9); }

/* ===== Toast ===== */
.toasts {
  position: fixed; z-index: 200; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px; align-items: center;
  width: min(92vw, 380px); pointer-events: none;
}
.toast {
  pointer-events: auto; width: 100%;
  background: #0f2440; color: #f0f9ff; border-radius: var(--radius);
  padding: 13px 15px; box-shadow: 0 8px 24px rgba(15, 36, 64, 0.35);
  display: flex; gap: 10px; align-items: flex-start;
  animation: toastin 0.3s ease;
}
@keyframes toastin { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.toast.out { opacity: 0; transform: translateY(10px); transition: all 0.25s ease; }
.toast .t-body { flex: 1; min-width: 0; }
.toast .t-title { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.toast .t-text { font-size: 13.5px; opacity: 0.92; line-height: 1.55; }
.toast .t-close { border: none; background: none; color: #bae6fd; cursor: pointer; font-size: 14px; padding: 2px 6px; }
.toast-success { background: #14532d; }
.toast-error { background: #7f1d1d; }
.toast-welcome { background: linear-gradient(135deg, #1e3a8a, #0f2440); border: 1px solid rgba(125, 211, 252, 0.35); }

/* 用户 chip */
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-chip .avatar { width: 32px; height: 32px; font-size: 14px; }
.user-chip .username { font-size: 14px; font-weight: 600; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.admin-badge { font-size: 11px; font-weight: 700; color: #fff; background: linear-gradient(120deg, #1d4ed8, #38bdf8); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }

/* ===== 桌面端 ===== */
@media (min-width: 1024px) {
  .layout {
    display: grid; grid-template-columns: 210px minmax(0, 620px) 280px;
    gap: 22px; align-items: start; padding-top: 22px;
  }
  .sidenav {
    display: flex; flex-direction: column; gap: 4px; position: sticky; top: calc(var(--topbar-h) + 22px);
  }
  .nav-item {
    display: flex; align-items: center; gap: 11px; border: none; background: none; cursor: pointer;
    padding: 11px 14px; border-radius: var(--radius-sm); font-size: 15px; font-weight: 600;
    color: var(--muted); font-family: inherit; text-align: left; width: 100%;
    transition: background 0.15s ease, color 0.15s ease;
  }
  .nav-item:hover { background: var(--ice-100); color: var(--blue-700); }
  .nav-item.active { background: var(--ice-100); color: var(--blue-700); }
  .nav-ic { font-size: 18px; }
  .infopanel { display: block; position: sticky; top: calc(var(--topbar-h) + 22px); }
  .fab { display: none; }
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: 20px; max-height: 90vh; }
  .modal-wide { max-width: 560px; }
  .toasts { left: auto; right: 24px; transform: none; align-items: flex-end; }
  .content { max-width: 620px; margin: 0 auto; width: 100%; }
}
.modal-small { max-width: 360px; }
@media (min-width: 1024px) {
  .modal-small { max-width: 400px; }
}
