/* ===== tokens ===== */
:root {
  --navy: #004387;
  --navy-deep: #002d5c;
  --navy-ink: #08172b;
  --gold: #c7a763;
  --gold-soft: #e6d5bb;
  --blue-light: #ebf2fa;
  --blue-mist: #bcd3eb;
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #1c2b3a;
  --ink-2: #5a6b7d;
  --ink-3: #93a3b3;
  --line: #e3eaf2;
  --danger: #b3382c;
  --ok: #2e7d32;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(0, 45, 92, 0.08);
  --shadow-lg: 0 8px 28px rgba(0, 45, 92, 0.16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg);
  font-size: 15px; line-height: 1.65;
}
a { color: var(--navy); text-decoration: none; }
img { max-width: 100%; }
textarea, input, button, select { font-family: inherit; font-size: inherit; }

/* ===== topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px; height: 56px;
  background: linear-gradient(135deg, var(--navy-deep), var(--navy) 55%, #0a5aa8);
  box-shadow: 0 2px 10px rgba(0, 45, 92, 0.25);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { height: 26px; }
.brand-app {
  color: var(--gold); font-size: 17px; font-weight: 700; letter-spacing: 2px;
  border-left: 1px solid rgba(255, 255, 255, 0.35); padding-left: 10px; white-space: nowrap;
}
.topnav { display: none; margin-left: auto; gap: 4px; }
.topnav a {
  color: rgba(255, 255, 255, 0.85); padding: 7px 13px; border-radius: 999px;
  font-size: 14px; transition: background 0.15s; white-space: nowrap;
}
.topnav a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.topnav a.active { background: var(--gold); color: var(--navy-ink); font-weight: 600; }
.settings-link {
  margin-left: auto; color: rgba(255, 255, 255, 0.7); font-size: 18px;
  padding: 8px; min-width: 44px; text-align: center;
  background: none; border: 0; cursor: pointer; font-family: inherit; line-height: 1;
}
.settings-link:hover { color: #fff; }
.topnav ~ .settings-link { margin-left: 0; }

/* ===== tabbar（仅手机）===== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--ink-3); font-size: 11px; padding: 4px 0; border-radius: 10px; min-height: 44px;
}
.tabbar a span { font-size: 20px; line-height: 1; }
.tabbar a i { font-style: normal; }
.tabbar a.active { color: var(--navy); font-weight: 600; }

/* ===== layout ===== */
.container { max-width: 1080px; margin: 0 auto; padding: 16px 14px calc(76px + env(safe-area-inset-bottom)); }
body[data-route="/admin"] .container { padding-bottom: 40px; }
.narrow { max-width: 760px; margin: 0 auto; }

/* ===== hero（首页）===== */
.hero {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: var(--navy-deep) url('../assets/campus.png') center/cover no-repeat;
  color: #fff; padding: 44px 24px; text-align: center; margin-bottom: 20px;
}
.hero::before { content: ''; position: absolute; inset: 0; background: linear-gradient(160deg, rgba(0, 45, 92, 0.88), rgba(0, 67, 135, 0.72)); }
.hero > * { position: relative; }
.hero img { height: 34px; opacity: 0.95; }
.hero h1 { margin: 14px 0 6px; font-size: 26px; letter-spacing: 6px; color: var(--gold-soft); }
.hero p { margin: 0; color: rgba(255, 255, 255, 0.82); font-size: 14px; }

/* ===== cards ===== */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 14px; border: 1px solid rgba(227, 234, 242, 0.6);
}
.entry-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 20px; }
.entry {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; border: 1px solid rgba(227, 234, 242, 0.6); transition: transform 0.15s, box-shadow 0.15s;
}
.entry:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.entry-icon {
  width: 64px; height: 64px; flex: none; display: grid; place-items: center;
  background: var(--blue-light); border-radius: 12px; font-size: 30px;
}
.entry h3 { margin: 0 0 4px; font-size: 16px; color: var(--navy); }
.entry p { margin: 0; color: var(--ink-2); font-size: 13.5px; }

/* covenant */
.covenant { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.covenant h2 { margin: 0 0 12px; font-size: 17px; color: var(--navy); display: flex; align-items: center; gap: 8px; }
.covenant ol { margin: 0; padding-left: 22px; color: var(--ink-2); }
.covenant li { margin-bottom: 8px; font-size: 14px; }
.covenant li::marker { color: var(--gold); font-weight: 700; }

/* ===== forms ===== */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="search"], textarea, select {
  width: 100%; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; background: #fbfdfe; color: var(--ink); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s; min-height: 44px;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(0, 67, 135, 0.12); background: #fff; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; color: var(--ink-2); padding: 8px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--navy); flex: none; margin-top: 2px; }
.counter { text-align: right; font-size: 12px; color: var(--ink-3); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--radius-sm); padding: 11px 20px; min-height: 44px;
  font-size: 14.5px; font-weight: 600; cursor: pointer; transition: filter 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { filter: brightness(1.12); }
.btn-gold { background: var(--gold); color: var(--navy-ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink-2); border: 1.5px solid var(--line); }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: 13px; border-radius: 8px; }

/* ===== chips / badges ===== */
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px;
  background: var(--blue-light); color: var(--navy); border-radius: 999px; font-size: 12.5px;
}
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.b-high { background: #fdecea; color: var(--danger); }
.b-watch { background: #faf3e0; color: #9a6d00; }
.b-teacher { background: var(--blue-light); color: var(--navy); }
.b-gold { background: var(--gold-soft); color: #6b5322; }

/* ===== post card ===== */
.post-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 15px;
  background: linear-gradient(135deg, var(--blue-mist), var(--blue-light));
}
.anon-name { font-weight: 600; color: var(--ink-2); font-size: 13.5px; }
.post-time { color: var(--ink-3); font-size: 12.5px; margin-left: auto; }
.post-body { white-space: pre-wrap; word-break: break-word; margin: 6px 0 12px; }
.post-body.removed { color: var(--ink-3); font-style: italic; }
.post-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.react {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; min-height: 36px;
  background: var(--bg); border: 1.5px solid transparent; border-radius: 999px;
  color: var(--ink-2); font-size: 13px; cursor: pointer; transition: all 0.15s;
}
.react:hover { border-color: var(--blue-mist); }
.react.on { background: var(--blue-light); border-color: var(--gold); color: var(--navy); font-weight: 600; }
.act-link { background: none; border: none; color: var(--ink-2); font-size: 13px; cursor: pointer; padding: 8px; min-height: 36px; }
.act-link:hover { color: var(--navy); }
.act-link.danger { color: var(--ink-3); }
.act-link.danger:hover { color: var(--danger); }
.post-actions .ask-flag { margin-left: auto; font-size: 15px; color: var(--navy); }
.fish-meta { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }

/* replies */
.replies { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 12px; }
.reply-item { background: var(--bg); border-radius: var(--radius-sm); padding: 10px 13px; margin-bottom: 8px; }
.reply-meta { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--ink-3); margin-bottom: 3px; }
.reply-text { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.reply-form { display: flex; gap: 8px; margin-top: 10px; }
.reply-form input { flex: 1; min-height: 42px; }

/* ===== thread（回信）===== */
.thread { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.bubble { max-width: 86%; padding: 10px 14px; border-radius: var(--radius); font-size: 14px; }
.bubble.from-counselor { align-self: flex-start; background: var(--blue-light); border-top-left-radius: 4px; }
.bubble.from-student { align-self: flex-end; background: var(--navy); color: #fff; border-top-right-radius: 4px; }
.time-divider {
  align-self: center; font-size: 11.5px; color: var(--ink-3);
  background: rgba(0, 67, 135, 0.06); border-radius: 999px; padding: 3px 10px; margin: 2px 0;
}
.thread-empty { color: var(--ink-3); font-size: 13px; text-align: center; padding: 8px; }
.thread-reply { display: flex; gap: 8px; align-items: flex-end; }
.thread-reply textarea { flex: 1; min-height: 44px; max-height: 120px; resize: none; line-height: 1.5; }

/* ===== gate ===== */
.gate { min-height: 78vh; display: grid; place-items: center; }
.gate-card { background: var(--card); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 36px 28px; width: min(400px, 100%); text-align: center; }
.gate-emblem { font-size: 44px; }
.gate-card h1 { color: var(--navy); letter-spacing: 4px; margin: 10px 0 4px; font-size: 22px; }
.gate-sub { color: var(--ink-2); font-size: 13.5px; margin: 0 0 22px; }
.gate-tip { color: var(--ink-3); font-size: 12.5px; margin-top: 16px; }

/* ===== page head ===== */
.page-head { display: flex; align-items: center; gap: 12px; margin: 6px auto 16px; }
.page-head > div { min-width: 0; }
.page-head .entry-icon { width: 56px; height: 56px; font-size: 28px; }
.page-head h1 { margin: 0; font-size: 19px; color: var(--navy); }
.page-head p { margin: 0; font-size: 13px; color: var(--ink-2); }
.compose-btn { margin-left: auto; flex: none; min-height: 40px; padding: 8px 18px; }

/* ===== admin ===== */
.admin-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.admin-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.admin-tab { flex: 1; text-align: center; padding: 10px; border-radius: var(--radius-sm); background: var(--card); border: 1.5px solid var(--line); color: var(--ink-2); font-weight: 600; cursor: pointer; min-height: 44px; }
.admin-tab.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.inbox-item { border-left: 4px solid var(--blue-mist); }
.inbox-item.lv-high { border-left-color: var(--danger); }
.inbox-item.lv-watch { border-left-color: var(--gold); }
.inbox-item.ask-teacher { border-left-color: var(--navy); }
.inbox-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; font-size: 12.5px; color: var(--ink-3); }
.contact-box { background: var(--bg); border-radius: var(--radius-sm); padding: 10px 13px; font-size: 13.5px; margin: 10px 0; }
.contact-box.none { color: var(--ink-3); }
.contact-box b { color: var(--ink); }
.word-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.word-row .word { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.word-row .spacer { flex: 1; }

/* ===== 聊天 ===== */
.chat-layout { display: grid; grid-template-columns: 1fr; gap: 14px; }
.chat-list-col { min-width: 0; }
.chat-list-item {
  display: flex; gap: 12px; align-items: center; padding: 12px 14px;
  background: var(--card); border-radius: var(--radius-sm); cursor: pointer;
  margin-bottom: 8px; border: 1.5px solid transparent; transition: border-color 0.15s;
}
.chat-list-item:hover, .chat-list-item.active { border-color: var(--navy); }
.chat-avatar {
  width: 44px; height: 44px; border-radius: 10px; background: var(--blue-light);
  display: grid; place-items: center; font-size: 22px; flex: none; overflow: hidden;
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-item-main { flex: 1; min-width: 0; }
.chat-item-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chat-item-name { font-weight: 600; }
.chat-item-time { font-size: 12px; color: var(--ink-3); }
.chat-item-preview { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-dot {
  background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px;
  min-width: 18px; height: 18px; display: inline-grid; place-items: center; padding: 0 5px; flex: none;
}
.chat-thread-panel {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  height: calc(100vh - 220px); min-height: 420px;
}
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.chat-back { padding: 4px 8px; min-height: 0; }
.chat-head-main { min-width: 0; }
.chat-about { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; }
.chat-inputbar { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.chat-inputbar textarea { flex: 1; min-height: 44px; max-height: 120px; resize: none; line-height: 1.5; }
.chat-placeholder .empty { margin: auto; }
.chat-layout.has-thread .chat-list-col { display: none; }
.chat-layout:not(.has-thread) .chat-thread-col { display: none; }
@media (min-width: 1025px) {
  .chat-layout { grid-template-columns: minmax(300px, 360px) 1fr; align-items: start; }
  .chat-layout.has-thread .chat-list-col { display: block; }
  .chat-layout:not(.has-thread) .chat-thread-col { display: block; }
  .chat-layout .sticky-col { position: sticky; top: 72px; }
}

/* ===== 设置弹层 ===== */
.settings-title { margin: 0 0 14px; color: var(--navy); }
.settings-sec { border-top: 1px dashed var(--line); padding: 14px 0; }
.settings-sec .section-title { margin-top: 0; }
.settings-profile { display: flex; gap: 14px; align-items: center; margin-top: 10px; }
.avatar-edit {
  width: 64px; height: 64px; border-radius: 50%; background: var(--blue-light);
  display: grid; place-items: center; font-size: 30px; cursor: pointer; overflow: hidden;
  border: 2px solid var(--blue-mist); flex: none;
}
.avatar-edit img { width: 100%; height: 100%; object-fit: cover; }
.settings-profile-form { flex: 1; display: flex; gap: 8px; }
.settings-profile-form input { min-height: 44px; }

/* ===== 图片九宫格 / 查看器 / compose 图片区 ===== */
.img-grid { display: grid; gap: 6px; margin: 8px 0 12px; }
.img-grid.g1 { grid-template-columns: 1fr; }
.img-grid.g1 img { width: 65%; max-width: 420px; height: auto; border-radius: 10px; display: block; cursor: zoom-in; background: var(--blue-light); }
.img-grid.g2 { grid-template-columns: repeat(2, 1fr); max-width: 75%; }
.img-grid.g3 { grid-template-columns: repeat(3, 1fr); max-width: 100%; }
.img-grid.g2 img, .img-grid.g3 img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: zoom-in; display: block;
}
.viewer { position: fixed; inset: 0; z-index: 95; background: rgba(8, 23, 43, 0.92); display: grid; place-items: center; }
.viewer img { max-width: 92vw; max-height: 88vh; object-fit: contain; border-radius: 6px; }
.viewer .v-nav {
  position: fixed; top: 50%; transform: translateY(-50%); font-size: 44px; color: #fff;
  background: none; border: none; cursor: pointer; opacity: 0.7; padding: 20px; line-height: 1;
}
.viewer .v-prev { left: 8px; }
.viewer .v-next { right: 8px; }
.viewer .v-close { position: fixed; top: 14px; right: 18px; font-size: 28px; color: #fff; background: none; border: none; cursor: pointer; }
.compose-imgs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.compose-imgs .ph { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; }
.compose-imgs .ph img { width: 100%; height: 100%; object-fit: cover; }
.compose-imgs .ph .rm {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.6); color: #fff; border: none; font-size: 11px; cursor: pointer; line-height: 1;
}
.compose-imgs .ph.add {
  border: 1.5px dashed var(--blue-mist); display: grid; place-items: center;
  font-size: 26px; color: var(--ink-3); cursor: pointer; min-height: 0;
}

/* ===== modal / toast ===== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90; background: rgba(8, 23, 43, 0.45);
  display: grid; place-items: center; padding: 20px;
}
.modal { background: var(--card); border-radius: 16px; padding: 24px; width: min(460px, 100%); box-shadow: var(--shadow-lg); max-height: 90vh; overflow: auto; }
.confirm-msg { margin: 0 0 18px; }
.confirm-btns { display: flex; gap: 10px; justify-content: flex-end; }
.toast {
  position: fixed; top: 18px; left: 50%; transform: translate(-50%, -80px); z-index: 99;
  background: var(--navy-ink); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; transition: transform 0.25s; max-width: 86vw; text-align: center;
}
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

.empty { text-align: center; color: var(--ink-3); padding: 44px 0; }
.empty .big { font-size: 40px; display: block; margin-bottom: 8px; }
.section-title { font-size: 15px; font-weight: 700; color: var(--navy); margin: 18px 0 10px; }
.subtle { color: var(--ink-3); font-size: 12.5px; }
.login-row { display: flex; gap: 8px; }
.login-row input, .login-row select { flex: 1; min-width: 0; }
.inline-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.colophon { text-align: center; color: var(--ink-3); font-size: 12px; padding: 26px 0 10px; }

/* ===== 平板 ≥641px ===== */
@media (min-width: 641px) {
  .tabbar { display: none; }
  .topnav { display: flex; }
  .container { padding: 22px 20px 40px; }
  .entry-grid { grid-template-columns: repeat(2, 1fr); }
  .brand img { height: 30px; }
  .hero { padding: 60px 30px; }
  .hero h1 { font-size: 30px; }
  .bubble { max-width: 72%; }
}
/* ===== 桌面 ≥1025px ===== */
@media (min-width: 1025px) {
  .entry-grid { grid-template-columns: repeat(3, 1fr); }
  .container { padding-top: 28px; }
  .hero { padding: 76px 40px; }
  .admin-grid { grid-template-columns: minmax(360px, 420px) 1fr; align-items: start; }
  .admin-grid .sticky { position: sticky; top: 72px; }
}
