/* 校园墙 · 样式（支持深浅色、移动优先、无外部依赖） */

:root {
  --bg: #f8fafc;
  --bg-elev: #ffffff;
  --bg-soft: #f1f5f9;
  --fg: #0f172a;
  --fg-muted: #64748b;
  --fg-dim: #94a3b8;
  --line: #e2e8f0;
  --brand: #4f46e5;
  --brand-soft: #eef2ff;
  --brand-fg: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #059669;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --bg-elev: #131c31;
    --bg-soft: #1a2439;
    --fg: #e8edf7;
    --fg-muted: #94a3b8;
    --fg-dim: #64748b;
    --line: #24304a;
    --brand: #818cf8;
    --brand-soft: #1e1b4b;
    --brand-fg: #0b1120;
    --danger: #f87171;
    --danger-soft: #2a1518;
    --ok: #34d399;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -16px rgba(0, 0, 0, .7);
  }
}

:root[data-theme="light"] {
  --bg: #f8fafc; --bg-elev: #ffffff; --bg-soft: #f1f5f9;
  --fg: #0f172a; --fg-muted: #64748b; --fg-dim: #94a3b8; --line: #e2e8f0;
  --brand: #4f46e5; --brand-soft: #eef2ff; --brand-fg: #ffffff;
  --danger: #dc2626; --danger-soft: #fef2f2;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px -12px rgba(15,23,42,.18);
}

:root[data-theme="dark"] {
  --bg: #0b1120; --bg-elev: #131c31; --bg-soft: #1a2439;
  --fg: #e8edf7; --fg-muted: #94a3b8; --fg-dim: #64748b; --line: #24304a;
  --brand: #818cf8; --brand-soft: #1e1b4b; --brand-fg: #0b1120;
  --danger: #f87171; --danger-soft: #2a1518;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -16px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body { overflow-x: hidden; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; border: none; background: none; }

.app {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 14px calc(96px + var(--safe-b));
  min-height: 100vh;
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 2px 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(var(--bg) 72%, transparent);
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
  font-size: 26px;
  line-height: 1;
  filter: drop-shadow(0 2px 6px rgba(79, 70, 229, .25));
}

.brand-text { min-width: 0; }

.brand-text h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-text p {
  margin: 0;
  font-size: 12px;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions { display: flex; gap: 6px; flex: none; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 16px;
  color: var(--fg-muted);
  background: var(--bg-soft);
  transition: transform .15s, background .15s;
}

.icon-btn:hover { background: var(--line); }
.icon-btn:active { transform: scale(.92); }

/* ---------------- 公告 ---------------- */

.announcement {
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 12px;
  border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
}

/* ---------------- 板块 ---------------- */

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: none;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--fg-muted);
  background: var(--bg-soft);
  white-space: nowrap;
  transition: background .15s, color .15s, transform .1s;
}

.tab:active { transform: scale(.96); }

.tab.active {
  background: var(--brand);
  color: var(--brand-fg);
  box-shadow: 0 4px 14px -6px var(--brand);
}

/* ---------------- 工具条 ---------------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.segmented {
  display: inline-flex;
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.segmented button {
  padding: 5px 16px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--fg-muted);
  font-weight: 500;
  transition: background .15s, color .15s;
}

.segmented button.active {
  background: var(--bg-elev);
  color: var(--fg);
  box-shadow: var(--shadow);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--fg-muted);
  cursor: pointer;
  user-select: none;
}

.toggle input { accent-color: var(--brand); width: 15px; height: 15px; }

/* ---------------- 帖子卡片 ---------------- */

.feed { display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px;
  box-shadow: var(--shadow);
  animation: rise .28s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.card.pinned { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }

.card-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 9px;
  font-size: 12.5px;
  color: var(--fg-muted);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  flex: none;
  background: var(--brand);
}

.card-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.card-meta strong { font-size: 13px; color: var(--fg); font-weight: 600; }
.card-meta span { font-size: 11.5px; color: var(--fg-dim); }

.badge {
  margin-left: auto;
  flex: none;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--fg-muted);
  white-space: nowrap;
}

.badge.pin { background: var(--brand-soft); color: var(--brand); }

.card-body {
  font-size: 15px;
  line-height: 1.68;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.card-body.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 8;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-images {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.card-images.one { grid-template-columns: 1fr; }

.card-images img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  cursor: zoom-in;
}

.card-images.one img { aspect-ratio: 4 / 3; }

.card-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.act {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--fg-muted);
  transition: background .15s, color .15s, transform .1s;
}

.act:hover { background: var(--bg-soft); }
.act:active { transform: scale(.94); }
.act.liked { color: var(--danger); background: var(--danger-soft); }
.act.spacer { margin-left: auto; }

/* ---------------- 空状态 / 加载 ---------------- */

.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--fg-muted);
}

.empty .big { font-size: 44px; margin-bottom: 10px; }
.empty p { margin: 6px 0; font-size: 14px; }

.skeleton {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sk-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-soft) 25%, var(--line) 37%, var(--bg-soft) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite linear;
}

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

.load-more-wrap { display: flex; justify-content: center; margin-top: 16px; }

.ghost-btn {
  padding: 9px 22px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--fg-muted);
  font-size: 13.5px;
  background: var(--bg-elev);
  transition: background .15s;
}

.ghost-btn:hover { background: var(--bg-soft); }
.ghost-btn.small { padding: 6px 14px; font-size: 13px; }

.stats-bar {
  margin-top: 22px;
  padding: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--fg-dim);
  border-top: 1px dashed var(--line);
}

/* ---------------- 浮动按钮 ---------------- */

.fab {
  position: fixed;
  right: max(18px, calc((100vw - 680px) / 2 + 18px));
  bottom: calc(22px + var(--safe-b));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-fg);
  font-size: 28px;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 28px -8px color-mix(in srgb, var(--brand) 75%, transparent);
  z-index: 30;
  transition: transform .16s ease;
}

.fab:hover { transform: scale(1.06); }
.fab:active { transform: scale(.94); }

.admin-entry {
  position: fixed;
  left: max(12px, calc((100vw - 680px) / 2 + 12px));
  bottom: calc(26px + var(--safe-b));
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--fg-dim);
  background: color-mix(in srgb, var(--bg-elev) 80%, transparent);
  border: 1px solid var(--line);
  font-size: 15px;
  z-index: 30;
  opacity: .55;
  transition: opacity .15s;
}

.admin-entry:hover { opacity: 1; }

/* ---------------- 面板 ---------------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet[hidden] { display: none; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, .5);
  backdrop-filter: blur(3px);
  animation: fade .2s ease both;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-elev);
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(18px + var(--safe-b));
  animation: slideUp .26s cubic-bezier(.22, 1, .36, 1) both;
  overscroll-behavior: contain;
}

@keyframes slideUp {
  from { transform: translateY(24px); opacity: .6; }
  to { transform: none; opacity: 1; }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 700; }

.field { margin-bottom: 16px; }

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg-muted);
  margin-bottom: 7px;
}

.field-hint { font-size: 11.5px; color: var(--fg-dim); text-align: right; margin-top: 4px; }

textarea, input[type="text"], input[type="password"] {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  font-size: 14.5px;
  resize: vertical;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

textarea:focus, input[type="text"]:focus, input[type="password"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }

.chip {
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 13px;
  background: var(--bg-soft);
  color: var(--fg-muted);
  border: 1px solid transparent;
  transition: all .15s;
}

.chip.active {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: color-mix(in srgb, var(--brand) 40%, transparent);
  font-weight: 600;
}

.upload-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

.upload-thumb {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-soft);
}

.upload-thumb img { width: 100%; height: 100%; object-fit: cover; }

.upload-thumb button {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(2, 6, 23, .72);
  color: #fff;
  font-size: 11px;
  display: grid;
  place-items: center;
}

.sheet-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.primary-btn {
  margin-left: auto;
  padding: 11px 26px;
  border-radius: 999px;
  background: var(--brand);
  color: var(--brand-fg);
  font-size: 14.5px;
  font-weight: 600;
  transition: opacity .15s, transform .12s;
  white-space: nowrap;
}

.primary-btn:hover { opacity: .9; }
.primary-btn:active { transform: scale(.97); }
.primary-btn:disabled { opacity: .5; cursor: not-allowed; }
.primary-btn.small { padding: 8px 18px; font-size: 13.5px; }

.err { color: var(--danger); font-size: 12.5px; flex: 1; min-height: 18px; }
.muted { color: var(--fg-muted); font-size: 13px; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .92em;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--bg-soft);
}

.inline-row { display: flex; gap: 8px; align-items: center; }
.inline-row input { flex: 1; }

/* ---------------- 详情 ---------------- */

.detail-body { min-height: 80px; }

.comment-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.comment {
  display: flex;
  gap: 9px;
  animation: rise .22s ease both;
}

.comment-main {
  flex: 1;
  min-width: 0;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.comment-main .who {
  font-size: 12px;
  color: var(--fg-muted);
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 3px;
}

.comment-main .who time { color: var(--fg-dim); font-size: 11px; }

.comment-main .text { font-size: 14px; white-space: pre-wrap; word-break: break-word; }

.comment-compose {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  background: var(--bg-elev);
}

.comment-compose input { flex: 1; }
.comment-compose .primary-btn { margin-left: 0; }

/* ---------------- 后台 ---------------- */

.admin-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

.admin-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 9px;
  font-size: 13px;
}

.admin-row .row-text { margin-bottom: 8px; word-break: break-word; }
.admin-row .row-actions { display: flex; gap: 7px; flex-wrap: wrap; }

.mini-btn {
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--bg-soft);
  color: var(--fg-muted);
  border: 1px solid var(--line);
}

.mini-btn:hover { background: var(--line); }
.mini-btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + var(--safe-b));
  transform: translateX(-50%) translateY(10px);
  background: rgba(15, 23, 42, .94);
  color: #f8fafc;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  z-index: 200;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  max-width: 84vw;
  text-align: center;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[hidden] { display: none; }

/* ---------------- 图片查看器 ---------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(2, 6, 23, .93);
  display: grid;
  place-items: center;
  padding: 22px;
  animation: fade .18s both;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  object-fit: contain;
}

@media (min-width: 720px) {
  .app { padding-left: 20px; padding-right: 20px; }
  .sheet { align-items: center; }
  .sheet-panel { border-radius: 20px; max-height: 86vh; animation: fade .2s both; }
  .card-images { grid-template-columns: repeat(3, 1fr); }
  .card-images.one { grid-template-columns: minmax(0, 70%); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
