/* =========================================================
   电科社空间 · 样式
   ========================================================= */

:root {
  --bg: #f3f4f7;
  --bg-soft: #eceef2;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --line: #e6e8ee;
  --line-strong: #d6d9e2;
  --text: #14171f;
  --text-2: #5f6673;
  --text-3: #8d94a3;
  --brand: #4f46e5;
  --brand-2: #0891b2;
  --brand-soft: rgba(79, 70, 229, 0.09);
  --danger: #e5484d;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.07), 0 1px 3px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, 0.16);
  --ease: cubic-bezier(0.32, 0.72, 0.24, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --bg-soft: #14171d;
    --surface: #171a21;
    --surface-2: #1d212a;
    --line: #262b35;
    --line-strong: #333a47;
    --text: #eef0f4;
    --text-2: #a5adbb;
    --text-3: #6f7788;
    --brand: #818cf8;
    --brand-2: #22d3ee;
    --brand-soft: rgba(129, 140, 248, 0.14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 18px rgba(0, 0, 0, 0.36);
    --shadow-lg: 0 22px 60px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; }
.hidden { display: none !important; }

button, input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 99px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-track { background: transparent; }

/* =========================================================
   登录 / 注册
   ========================================================= */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 18px;
  position: relative;
  overflow: hidden;
}

.auth-glow {
  position: absolute;
  width: 760px;
  height: 760px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, rgba(79, 70, 229, 0.22), transparent 55%),
    radial-gradient(circle at 70% 65%, rgba(8, 145, 178, 0.18), transparent 55%);
  filter: blur(30px);
  top: -240px;
  pointer-events: none;
  animation: floaty 18s ease-in-out infinite;
}

@keyframes floaty {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 30px) scale(1.06); }
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 32px 28px 26px;
  box-shadow: var(--shadow-md);
  animation: rise 0.55s var(--ease) both;
}

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

.auth-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 26px;
}

.auth-brand h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.auth-brand p {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--text-3);
}

.logo-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 13px;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.28);
}
.logo-mark svg { width: 24px; height: 24px; }
.logo-mark.sm { width: 30px; height: 30px; border-radius: 9px; box-shadow: none; }
.logo-mark.sm svg { width: 18px; height: 18px; }

.tabs {
  position: relative;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 12px;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  padding: 9px 0;
  font-size: 14px;
  font-weight: 550;
  color: var(--text-2);
  border-radius: 9px;
  transition: color 0.2s;
  position: relative;
  z-index: 1;
}
.tab.active { color: var(--text); }

.tab-ink {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  background: var(--surface);
  border-radius: 9px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.32s var(--ease);
}
.tab-ink.right { transform: translateX(100%); }

.form { display: flex; flex-direction: column; gap: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-2);
  padding-left: 2px;
}
.field input {
  height: 44px;
  padding: 0 13px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  outline: none;
  font-size: 14.5px;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
}
.field input::placeholder { color: var(--text-3); }
.field input:focus {
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: 0 0 0 3.5px var(--brand-soft);
}

.btn {
  height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 600;
  transition: transform 0.12s var(--ease), opacity 0.18s, background 0.18s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.975); }
.btn.block { width: 100%; margin-top: 4px; }

.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.28);
}
.btn.primary:disabled {
  background: var(--line-strong);
  color: var(--text-3);
  box-shadow: none;
  cursor: not-allowed;
}

.auth-msg {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--danger);
  text-align: center;
}

/* =========================================================
   顶栏
   ========================================================= */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 660px;
  margin: 0 auto;
  height: 58px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
  font-weight: 650;
  font-size: 15.5px;
  letter-spacing: -0.01em;
}

.user-menu { position: relative; }

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0;
  user-select: none;
  transition: transform 0.14s var(--ease), box-shadow 0.2s;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.4px var(--line);
}
.avatar:hover { transform: scale(1.05); }
.avatar.sm { width: 38px; height: 38px; font-size: 15px; border-radius: 50%; }

.dropdown {
  position: absolute;
  right: 0;
  top: 44px;
  min-width: 168px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  animation: pop 0.18s var(--ease);
}

@keyframes pop {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.dropdown-head {
  padding: 9px 11px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.dd-nick { font-size: 13.5px; font-weight: 600; }
.dd-role {
  font-size: 10.5px;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 2px 6px;
  border-radius: 5px;
  font-weight: 600;
}

.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 13.5px;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}
.dropdown-item:hover { background: var(--surface-2); color: var(--text); }

/* =========================================================
   主内容
   ========================================================= */

.feed {
  max-width: 660px;
  margin: 0 auto;
  padding: 18px 16px 90px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* --- 发帖框 --- */

.composer {
  padding: 14px;
  margin-bottom: 16px;
  transition: box-shadow 0.24s, border-color 0.24s;
}
.composer:focus-within {
  border-color: color-mix(in srgb, var(--brand) 42%, var(--line));
  box-shadow: var(--shadow-md);
}

.composer-top { display: flex; gap: 11px; align-items: flex-start; }

#composerText {
  flex: 1;
  min-height: 38px;
  max-height: 260px;
  padding: 8px 0 0;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 15px;
  line-height: 1.6;
}
#composerText::placeholder { color: var(--text-3); }

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

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: var(--text-2);
  transition: background 0.16s, color 0.16s;
  cursor: pointer;
}
.icon-btn:hover { background: var(--brand-soft); color: var(--brand); }
.icon-btn svg { width: 19px; height: 19px; }

.hint { font-size: 12.5px; color: var(--text-3); margin-right: auto; }
.hint.warn { color: var(--danger); }

/* 预览 */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 12px 0 4px;
}
.preview-grid[data-count="1"] { grid-template-columns: 1fr; max-width: 62%; }
.preview-grid[data-count="2"] { grid-template-columns: repeat(2, 1fr); }

.pv-item {
  position: relative;
  border-radius: 11px;
  overflow: hidden;
  background: var(--surface-2);
  aspect-ratio: 1;
}
.preview-grid[data-count="1"] .pv-item { aspect-ratio: auto; }
.preview-grid[data-count="1"] .pv-item img { max-height: 300px; position: static; }

.pv-item img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pv-del {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
  display: grid;
  place-items: center;
  backdrop-filter: blur(4px);
  transition: background 0.15s;
}
.pv-del:hover { background: rgba(0, 0, 0, 0.82); }
.pv-del svg { width: 12px; height: 12px; }

/* --- 帖子 --- */

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

.post {
  padding: 15px;
  animation: rise 0.4s var(--ease) both;
}

.post-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
}
.post-head .avatar { width: 38px; height: 38px; font-size: 15px; box-shadow: none; }
.post-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.post-name {
  font-size: 14px;
  font-weight: 620;
  display: flex;
  align-items: center;
  gap: 5px;
}
.post-time { font-size: 11.5px; color: var(--text-3); }

.badge-admin {
  font-size: 10px;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 1px 5px;
  border-radius: 4px;
}

.post-body {
  font-size: 15px;
  line-height: 1.68;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 4px;
}
.post-body:empty { display: none; }

/* 图片网格 */
.img-grid {
  display: grid;
  gap: 5px;
  margin: 11px 0 2px;
  border-radius: 13px;
  overflow: hidden;
}
.img-grid[data-count="1"] { grid-template-columns: 1fr; max-width: 76%; }
.img-grid[data-count="2"] { grid-template-columns: repeat(2, 1fr); }
.img-grid[data-count="3"] { grid-template-columns: repeat(3, 1fr); }
.img-grid[data-count="4"] { grid-template-columns: repeat(2, 1fr); }
.img-grid[data-count="5"],
.img-grid[data-count="6"],
.img-grid[data-count="7"],
.img-grid[data-count="8"],
.img-grid[data-count="9"] { grid-template-columns: repeat(3, 1fr); }

.img-grid figure {
  margin: 0;
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  cursor: zoom-in;
  border-radius: 8px;
  aspect-ratio: 1;
}
.img-grid[data-count="1"] figure { aspect-ratio: auto; }

.img-grid figure img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.45s var(--ease), opacity 0.4s;
  opacity: 0;
}
.img-grid figure img.loaded { opacity: 1; }
.img-grid figure:hover img { transform: scale(1.035); }

.img-grid[data-count="1"] figure img { position: static; height: auto; max-height: 480px; object-fit: contain; }

/* 操作栏 */
.post-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 11px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.act {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 13px;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}
.act:hover { background: var(--surface-2); color: var(--text); }
.act svg { width: 17px; height: 17px; transition: transform 0.2s var(--ease); }

.act.liked { color: var(--danger); }
.act.liked svg { fill: currentColor; }
.act.pop svg { animation: heartPop 0.4s var(--ease); }

@keyframes heartPop {
  0% { transform: scale(1); }
  35% { transform: scale(1.32); }
  60% { transform: scale(0.92); }
  100% { transform: scale(1); }
}

.act.del { margin-left: auto; color: var(--text-3); }
.act.del:hover { color: var(--danger); background: rgba(229, 72, 77, 0.08); }

/* 评论 */
.comments { margin-top: 8px; display: flex; flex-direction: column; gap: 7px; }

.comment {
  display: flex;
  gap: 8px;
  font-size: 13.5px;
  line-height: 1.55;
  animation: rise 0.3s var(--ease) both;
}
.comment .c-av {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 10.5px;
  font-weight: 650;
}
.comment .c-main { min-width: 0; flex: 1; }
.comment .c-name { font-weight: 620; color: var(--brand); margin-right: 5px; }
.comment .c-text { color: var(--text); word-break: break-word; white-space: pre-wrap; }
.comment .c-time { font-size: 11px; color: var(--text-3); margin-left: 5px; }

.comment-form { display: flex; gap: 8px; margin-top: 9px; }
.comment-form input {
  flex: 1;
  height: 34px;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 99px;
  outline: none;
  font-size: 13.5px;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.comment-form input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.comment-form button {
  height: 34px;
  padding: 0 14px;
  border-radius: 99px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.16s;
}
.comment-form button:hover { background: color-mix(in srgb, var(--brand) 20%, transparent); }

.sentinel { height: 40px; display: grid; place-items: center; }
.sentinel::after {
  content: "";
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--brand);
  animation: spin 0.7s linear infinite;
  opacity: 0;
  transition: opacity 0.2s;
}
.sentinel.loading::after { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}
.empty svg { width: 42px; height: 42px; opacity: 0.45; margin-bottom: 12px; }
.empty p { margin: 0; font-size: 14px; }

/* =========================================================
   灯箱
   ========================================================= */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 10, 14, 0.94);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  animation: fade 0.22s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  animation: zoomIn 0.28s var(--ease);
}
@keyframes zoomIn {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

.lb-close, .lb-nav {
  position: absolute;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transition: background 0.16s, transform 0.16s;
}
.lb-close:hover, .lb-nav:hover { background: rgba(255, 255, 255, 0.22); }
.lb-close { width: 40px; height: 40px; top: 18px; right: 18px; }
.lb-close svg { width: 18px; height: 18px; }
.lb-nav { width: 46px; height: 46px; top: 50%; transform: translateY(-50%); }
.lb-nav:hover { transform: translateY(-50%) scale(1.06); }
.lb-nav svg { width: 22px; height: 22px; }
.lb-nav.prev { left: 14px; }
.lb-nav.next { right: 14px; }
.lb-nav.hidden { display: none; }

.lb-counter {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 12px;
  border-radius: 99px;
}

/* =========================================================
   Toast
   ========================================================= */

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 13.5px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s, transform 0.24s var(--ease);
  z-index: 200;
  box-shadow: var(--shadow-lg);
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* =========================================================
   响应式
   ========================================================= */

@media (max-width: 480px) {
  .feed { padding: 12px 10px 80px; }
  .auth-card { padding: 26px 20px 22px; border-radius: 20px; }
  .post { padding: 13px; border-radius: 15px; }
  .composer { padding: 12px; border-radius: 15px; }
  .img-grid[data-count="1"] { max-width: 88%; }
  .lb-nav { width: 40px; height: 40px; }
  .lb-nav.prev { left: 6px; }
  .lb-nav.next { right: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
