:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --line: #dfe5ed;
  --accent: #2557d6;
  --accent-soft: #eaf0ff;
  --ink: #172033;
  --ink-2: #4d5b70;
  --ink-3: #748197;
  --amber: #a8640a;
  --green: #18794e;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 20px 96px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 14px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent);
  display: grid; place-items: center; color: #fff; font-size: 15px;
}
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.text-link { color: var(--ink-2); font-size: 13px; font-weight: 700; }
.text-link:hover { color: var(--accent); }

/* ---------- 头部 ---------- */
.hero { padding: 26px 6px 8px; }
.hero h1 { margin: 0 0 8px; font-size: 30px; line-height: 1.2; letter-spacing: -.4px; }
.hero h1 .hl { color: var(--accent); }
.hero p { margin: 0; color: var(--ink-2); font-size: 14.5px; max-width: 640px; }
.ask-action { margin-top: 14px; padding: 10px 15px; border: 0; border-radius: var(--radius-sm); color: #fff; background: var(--accent); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.ask-action:focus-visible { outline: 3px solid #9ab5f8; outline-offset: 2px; }

/* ---------- 搜索 ---------- */
.search {
  margin-top: 18px; display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-md);
  background: var(--surface); border: 1px solid var(--line);
}
.search svg { flex: none; color: var(--ink-3); }
.search input { flex: 1; border: 0; background: transparent; outline: none; font-size: 15px; color: var(--ink); }
.search input::placeholder { color: var(--ink-3); }

/* ---------- 实时更新提示条 ---------- */
.live-bar {
  display: none; align-items: center; gap: 10px; margin: 14px 2px 0;
  padding: 10px 14px; border-radius: var(--radius-md);
  background: rgba(0,122,255,.12); border: 1px solid rgba(0,122,255,.28);
  color: #075BD0; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; text-align: left;
  animation: liveIn .35s ease;
}
.live-bar.show { display: flex; }
.live-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(0,122,255,.18); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes liveIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- 校园动态 ---------- */
.activity-stream { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; margin-top: 14px; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.activity-stream[hidden] { display: none; }
.activity-stream__label { color: var(--ink-2); font-size: 12px; font-weight: 700; white-space: nowrap; }
.activity-stream__viewport { min-width: 0; overflow: hidden; }
.activity-stream__track { display: flex; width: max-content; animation: activityMarquee 42s linear infinite; }
.activity-stream__group { display: flex; flex: none; gap: 9px; padding-right: 9px; }
.activity-chip { flex: none; max-width: min(460px, 70vw); overflow: hidden; padding: 6px 9px; border: 0; border-radius: 999px; color: var(--ink-2); background: var(--surface-muted); font: inherit; font-size: 12px; line-height: 1.35; text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.activity-chip:hover { color: var(--accent); background: var(--accent-soft); }
.activity-chip:focus-visible, .activity-stream__pause:focus-visible { outline: 3px solid #9ab5f8; outline-offset: 2px; }
.activity-stream__pause { border: 0; padding: 5px 7px; border-radius: var(--radius-sm); color: var(--accent); background: transparent; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.activity-stream__pause:hover { background: var(--accent-soft); }
.activity-stream:hover .activity-stream__track, .activity-stream:focus-within .activity-stream__track, .activity-stream.is-paused .activity-stream__track { animation-play-state: paused; }
@keyframes activityMarquee { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .activity-stream__track { animation: none; } .activity-stream__group[aria-hidden="true"] { display: none; } }

.list-error { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 8px 6px 0; padding: 12px 14px; border: 1px solid #e5c8c8; border-radius: var(--radius-md); background: #fff8f8; color: #984949; font-size: 13px; line-height: 1.45; }
.list-error[hidden] { display: none; }
.list-error button { flex: none; border: 1px solid #d7b0b0; border-radius: var(--radius-sm); padding: 7px 10px; background: #fff; color: #843e3e; font: inherit; font-weight: 700; cursor: pointer; }

/* ---------- 筛选 chips ---------- */
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 4px 12px; }
.section-title h2 { margin: 0; font-size: 17px; letter-spacing: .2px; }
.section-title .hint { font-size: 12.5px; color: var(--ink-3); }

.chips { display: flex; gap: 9px; flex-wrap: wrap; }
.chip {
  padding: 8px 15px; border-radius: 999px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); transition: .16s; user-select: none;
}
.chip:hover { background: var(--surface-muted); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(0,122,255,.32); }
.chip:focus-visible, .text-link:focus-visible, .list-error button:focus-visible { outline: 3px solid #9ab5f8; outline-offset: 2px; }
.chip .n { font-size: 11.5px; opacity: .72; margin-left: 5px; }

.cat-scroll { display: flex; gap: 9px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.cat-scroll::-webkit-scrollbar { display: none; }
.cat-scroll .chip { flex: none; }

/* ---------- 已核实资料 ---------- */
.library-section { margin-top: 24px; }
.library-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 720px) { .library-grid { grid-template-columns: 1fr; } }
.library-card { padding: 16px 17px; border: 1px solid #b9dcca; border-radius: var(--radius-lg); background: #f8fcfa; }
.library-card__head { display: flex; align-items: center; gap: 8px; }
.official-mark { color: var(--green); font-size: 12px; font-weight: 700; }
.library-card h3 { margin: 11px 0 7px; font-size: 15.5px; line-height: 1.45; }
.library-card p { display: -webkit-box; margin: 0; overflow: hidden; color: var(--ink-2); font-size: 13.5px; line-height: 1.65; white-space: pre-wrap; -webkit-box-orient: vertical; -webkit-line-clamp: 5; }
.library-card__source { margin-top: 12px; color: var(--ink-3); font-size: 12px; }
.library-error { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 12px; padding: 12px 14px; border: 1px solid #e5c8c8; border-radius: var(--radius-md); background: #fff8f8; color: #984949; font-size: 13px; }
.library-error[hidden] { display: none; }
.library-error button { flex: none; border: 1px solid #d7b0b0; border-radius: var(--radius-sm); padding: 7px 10px; background: #fff; color: #843e3e; font: inherit; font-weight: 700; cursor: pointer; }
.profile-link { border: 0; padding: 0; background: transparent; cursor: pointer; font: inherit; }
.leaderboard-section { margin-top: 28px; }
.leaderboard { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.rank-row { display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: start; gap: 6px 9px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.rank-row strong { padding-top: 1px; color: var(--accent); font-variant-numeric: tabular-nums; }.rank-row__identity { display: flex; align-items: center; gap: 7px; min-width: 0; }.rank-row__identity > span { overflow: hidden; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }.rank-row__honors { display: inline-flex; flex: none; gap: 4px; min-width: 0; }.rank-row small { grid-column: 2 / -1; color: var(--ink-3); font-size: 11px; }
.honor-mark { display: inline-flex; align-items: center; max-width: 132px; overflow: hidden; padding: 2px 7px; border-radius: 999px; font-size: 10px; font-weight: 700; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }.honor-mark.auto { margin-left: 5px; color: #17623e; background: #e3f5ea; }.honor-mark.manual { margin-left: 5px; color: #7b4d00; background: #fff4d6; }.rank-row__honors .honor-mark { margin-left: 0; }
.profile-stats { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 14px; }.profile-stats strong { width: 100%; font-size: 18px; }.profile-stats span { padding: 6px 9px; border-radius: var(--radius-sm); color: var(--ink-2); background: var(--surface-muted); font-size: 12px; }.profile-honor { display: grid; gap: 3px; margin: 10px 0; padding: 12px 13px; border: 1px solid #b8e1ca; border-radius: var(--radius-md); background: #f2fbf6; }.profile-honor.manual { border-color: #efd89e; background: #fffaf0; }.profile-honor > span, .profile-honor small { color: var(--ink-3); font-size: 12px; }.profile-honor strong { color: #17623e; font-size: 14px; }.profile-honor.manual strong { color: #7b4d00; }
@media (max-width: 720px) { .leaderboard { grid-template-columns: 1fr; } }

/* ---------- 卡片 ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 720px) { .grid { grid-template-columns: 1fr; } }

.card {
  position: relative; width: 100%; padding: 16px 17px; border-radius: var(--radius-lg); text-align: left; font: inherit;
  background: var(--surface); border: 1px solid var(--line); cursor: pointer;
  transition: border-color .16s ease, background .16s ease;
}
.card:hover { background: var(--surface-muted); border-color: #bfcbe0; }
.card.featured { border-color: #aebee1; }
.card .q { font-size: 15.5px; font-weight: 650; line-height: 1.45; color: var(--ink); }
.card .meta { display: flex; align-items: center; gap: 8px; margin-top: 13px; flex-wrap: wrap; }
.tag {
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-muted); color: var(--ink-2); border: 1px solid var(--line);
}
.tag.cat { background: rgba(0,122,255,.1); color: #075BD0; border-color: rgba(0,122,255,.22); }
.count-badge {
  margin-left: auto; font-size: 12px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); padding: 3px 10px; border-radius: 999px;
}

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.status .s-dot { width: 7px; height: 7px; border-radius: 50%; }
.status.open { color: var(--accent); } .status.open .s-dot { background: var(--accent); }
.status.answered { color: var(--amber); } .status.answered .s-dot { background: var(--amber); }
.status.resolved { color: var(--green); } .status.resolved .s-dot { background: var(--green); }

.asker { font-size: 12px; color: var(--ink-3); }

/* ---------- 空态 ---------- */
.empty { text-align: center; padding: 54px 20px; color: var(--ink-3); }

/* ---------- 弹层 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60; display: none;
  align-items: flex-start; justify-content: center; padding: 40px 16px;
  background: rgba(20, 26, 58, 0.34); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  overflow-y: auto;
}
.overlay.show { display: flex; }
.panel {
  width: min(680px, 100%); border-radius: 24px; padding: 24px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(20,26,58,.34);
  animation: panelIn .26s cubic-bezier(.16,1,.3,1);
}
@keyframes panelIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-head h3 { margin: 0; font-size: 19px; line-height: 1.4; }
.panel-head .close { flex: none; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-muted); cursor: pointer; color: var(--ink-2); }
.panel .q-meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 18px; }

.answers { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.answer {
  padding: 14px 15px; border-radius: var(--radius-md);
  background: var(--surface-muted); border: 1px solid var(--line);
}
.answer.verified { background: rgba(43,182,115,.1); border-color: rgba(43,182,115,.3); }
.answer .who { font-size: 12px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; display: flex; align-items: center; gap: 7px; }
.answer .who .v { font-size: 10.5px; font-weight: 700; color: var(--green); background: rgba(43,182,115,.16); padding: 1px 7px; border-radius: 999px; }
.answer .body { font-size: 14.5px; line-height: 1.6; color: var(--ink); white-space: pre-wrap; }
.answer.pending .body { color: var(--ink-3); font-style: italic; }

.reply { border-top: 1px solid var(--line); padding-top: 16px; }
.reply textarea {
  width: 100%; min-height: 76px; resize: vertical; border-radius: var(--radius-md);
  border: 1px solid var(--line); background: var(--surface); padding: 12px 14px;
  font: inherit; font-size: 14.5px; color: var(--ink); outline: none;
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; clip-path: inset(50%); }
.answer-media { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.answer-media__add { padding: 7px 10px; font-size: 12px; }
.answer-media__preview { position: relative; width: 54px; height: 54px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-muted); }
.answer-media__preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.answer-media__preview button { position: absolute; top: 2px; right: 2px; border: 0; border-radius: 4px; padding: 2px 4px; color: #843e3e; background: rgba(255,255,255,.94); font-size: 10px; font-weight: 700; cursor: pointer; }
.answer-images { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.answer-images a { display: block; min-width: 0; overflow: hidden; aspect-ratio: 1; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-muted); }
.answer-images img { display: block; width: 100%; height: 100%; object-fit: cover; }
.reply textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.reply .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.reply .note { font-size: 12px; color: var(--ink-3); }
.btn {
  border: 0; border-radius: 12px; padding: 11px 20px; font-size: 14.5px; font-weight: 700; cursor: pointer;
  background: var(--accent); color: #fff; box-shadow: 0 8px 18px rgba(0,122,255,.32); transition: .16s;
}
.btn:hover { filter: brightness(1.05); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: var(--surface-muted); color: var(--ink-2); box-shadow: none; border: 1px solid var(--line); }

/* ---------- 提问表单 ---------- */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-2); margin-bottom: 7px; }
.field input, .field textarea, .field select {
  width: 100%; border-radius: var(--radius-md); border: 1px solid var(--line);
  background: var(--surface); padding: 11px 13px; font: inherit; font-size: 14.5px; color: var(--ink); outline: none;
}
.field textarea { min-height: 92px; resize: vertical; }
.field-meta { margin-top: 6px; color: var(--ink-3); font-size: 12px; text-align: right; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cat-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.cat-pick .opt { padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer; background: var(--surface-muted); border: 1px solid var(--line); color: var(--ink-2); }
.cat-pick .opt.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.locked-note { display: grid; gap: 5px; margin-top: 18px; padding: 14px 15px; border: 1px solid #b8e1ca; border-radius: var(--radius-md); background: #f2fbf6; color: #256443; font-size: 13px; line-height: 1.55; }
.locked-note strong { color: var(--green); }
.follow-ups { display: grid; gap: 10px; margin: 18px 0; }
.follow-ups h4 { margin: 0; color: var(--ink); font-size: 14px; }
.follow-up { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-muted); }
.follow-up small { color: var(--ink-3); font-size: 12px; }
.follow-up p { margin: 6px 0 0; color: var(--ink-2); font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.follow-up-composer { display: grid; gap: 9px; margin: 18px 0; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.follow-up-composer label { color: var(--ink-2); font-size: 13px; font-weight: 700; }
.follow-up-composer textarea { min-height: 72px; }
.detail-error { display: grid; gap: 16px; color: var(--ink-2); font-size: 14px; line-height: 1.6; }
.detail-error p { margin: 0; }
.detail-error .btn { justify-self: start; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px);
  z-index: 80; padding: 11px 20px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  background: rgba(27,31,59,.92); color: #fff; opacity: 0; pointer-events: none; transition: .25s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.footer { text-align: center; color: var(--ink-3); font-size: 12.5px; margin-top: 40px; }
@media (max-width: 540px) { .activity-stream { gap: 7px; padding: 8px 9px; } .activity-stream__label, .activity-stream__pause { font-size: 11px; } .activity-chip { max-width: 58vw; font-size: 11px; } }
