/* ========== 基础 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #7c3aed;
  --primary-light: #a78bfa;
  --pink: #ec4899;
  --blue: #3b82f6;
  --bg-gradient: linear-gradient(135deg, #dbeafe 0%, #e9d5ff 40%, #fce7f3 70%, #fbcfe8 100%);
  --card-bg: rgba(255, 255, 255, 0.85);
  --text: #1e1b4b;
  --text-secondary: #64748b;
  --border: rgba(124, 58, 237, 0.15);
  --shadow: 0 8px 32px rgba(124, 58, 237, 0.12);
  --radius: 16px;
  --nav-h: 56px;
}

html, body {
  height: 100%;
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: #f8fafc;
  overflow-x: hidden;
}

.page {
  display: none;
  min-height: 100%;
}
.page.active {
  display: block;
}

/* ========== 欢迎页 ========== */
#welcome-page {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.gradient-bg {
  position: absolute;
  inset: 0;
  background: var(--bg-gradient);
  z-index: 0;
}

.gradient-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 30%, rgba(167, 139, 250, 0.35), transparent 50%),
              radial-gradient(circle at 80% 70%, rgba(236, 72, 153, 0.25), transparent 50%),
              radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.2), transparent 60%);
  filter: blur(40px);
}

.welcome-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2rem;
  max-width: 420px;
}

.school-logo {
  margin-bottom: 1.5rem;
}

.logo-placeholder {
  width: 140px;
  height: 140px;
  margin: 0 auto;
  border-radius: 50%;
  background: linear-gradient(145deg, #a78bfa, #ec4899);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 40px rgba(124, 58, 237, 0.3);
  color: white;
}

.logo-text {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 2px;
}

.logo-sub {
  font-size: 0.55rem;
  opacity: 0.9;
  margin-top: 4px;
  letter-spacing: 1px;
}

.forum-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  background: linear-gradient(90deg, #7c3aed, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.forum-subtitle {
  color: var(--text-secondary);
  margin-bottom: 2.5rem;
  font-size: 0.95rem;
}

/* ========== 按钮 ========== */
.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  color: white;
  border: none;
  padding: 0.85rem 2.2rem;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(124, 58, 237, 0.45);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-primary.full {
  width: 100%;
  margin-top: 0.5rem;
}

.btn-secondary {
  background: white;
  color: var(--primary);
  border: 1.5px solid var(--primary-light);
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover {
  background: #f5f3ff;
}
.btn-secondary.small, .btn-danger.small {
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
}

.btn-danger {
  background: #fef2f2;
  color: #dc2626;
  border: 1.5px solid #fecaca;
  border-radius: 999px;
  cursor: pointer;
}

/* ========== 弹层 ========== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(30, 27, 75, 0.45);
  backdrop-filter: blur(6px);
}

.modal-box {
  position: relative;
  background: white;
  border-radius: var(--radius);
  width: 100%;
  max-width: 380px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
}

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

.modal-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 12px;
}

.tab {
  flex: 1;
  padding: 0.6rem;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.tab.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.auth-form.hidden {
  display: none;
}

.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.form-group input[type="text"],
.form-group input[type="password"] {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus {
  border-color: var(--primary-light);
}

.email-input-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.email-input-wrap:focus-within {
  border-color: var(--primary-light);
}
.email-input-wrap input {
  border: none !important;
  flex: 1;
  border-radius: 0 !important;
}
.email-suffix {
  padding: 0 0.9rem;
  background: #f8fafc;
  color: var(--text-secondary);
  font-size: 0.9rem;
  white-space: nowrap;
}

.hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
}

.remember {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.error-msg {
  color: #dc2626;
  font-size: 0.85rem;
  margin-top: 0.6rem;
  min-height: 1.2em;
  text-align: center;
}

/* ========== 导航栏 ========== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  gap: 0.5rem;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  transition: background 0.2s;
}
.icon-btn:hover {
  background: #f1f5f9;
}
.icon-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}
.icon-btn.close {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-secondary);
}

.nav-center {
  flex: 1;
  text-align: center;
}
.nav-title {
  font-size: 1.05rem;
  font-weight: 700;
  background: linear-gradient(90deg, #7c3aed, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-box {
  display: none;
}
.search-box input {
  width: 140px;
  padding: 0.4rem 0.7rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 999px;
  font-size: 0.85rem;
  outline: none;
}
.search-box input:focus {
  border-color: var(--primary-light);
}

@media (min-width: 640px) {
  .search-box {
    display: block;
  }
}

.user-area {
  position: relative;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  cursor: pointer;
  border: 2px solid var(--primary-light);
  transition: transform 0.2s;
}
.avatar:hover {
  transform: scale(1.05);
}

.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow);
  min-width: 140px;
  overflow: hidden;
  z-index: 50;
  animation: fadeIn 0.2s ease;
}
.dropdown.hidden {
  display: none;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.dropdown-item {
  padding: 0.7rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}
.dropdown-item:hover {
  background: #f5f3ff;
}
.dropdown-item.danger {
  color: #dc2626;
}
.dropdown-item.danger:hover {
  background: #fef2f2;
}

/* ========== 侧边栏 ========== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  max-width: 85vw;
  height: 100%;
  background: white;
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 4px 0 24px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
}
.sidebar.open {
  transform: translateX(0);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.sidebar-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-header {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.sidebar-nav {
  padding: 0.75rem;
  flex: 1;
  overflow-y: auto;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.15s;
  margin-bottom: 0.25rem;
}
.sidebar-item:hover {
  background: #f5f3ff;
}
.sidebar-item.active {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.12), rgba(236, 72, 153, 0.08));
  color: var(--primary);
  font-weight: 500;
}
.sidebar-item .icon {
  font-size: 1.2rem;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 0.75rem 0;
}

/* ========== 内容区 ========== */
.content {
  min-height: calc(100vh - var(--nav-h));
  padding: 1rem;
  max-width: 960px;
  margin: 0 auto;
}

.content-page {
  display: none;
}
.content-page.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.page-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

/* 贴吧板块 */
.boards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.board-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.board-card:hover {
  border-color: var(--primary-light);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.1);
  transform: translateY(-2px);
}
.board-card .board-icon {
  font-size: 1.8rem;
  margin-bottom: 0.4rem;
}
.board-card .board-name {
  font-weight: 500;
  font-size: 0.9rem;
}
.board-card .board-count {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

.posts-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.post-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  transition: box-shadow 0.2s;
}
.post-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.04);
}
.post-title {
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.post-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* 聊天 */
.chat-container {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--nav-h) - 100px);
  min-height: 400px;
}
.chat-rooms {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.room {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  background: #f1f5f9;
  white-space: nowrap;
  cursor: pointer;
}
.room.active {
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  color: white;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.msg {
  max-width: 80%;
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
}
.msg.system {
  align-self: center;
  background: #f1f5f9;
  color: var(--text-secondary);
  font-size: 0.8rem;
}
.msg.self {
  align-self: flex-end;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  color: white;
}
.msg.other {
  align-self: flex-start;
  background: #f1f5f9;
}
.chat-input-area {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}
.chat-input-area input {
  flex: 1;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 999px;
  outline: none;
  font-size: 0.9rem;
}
.chat-input-area input:focus {
  border-color: var(--primary-light);
}

/* 跳蚤市场 */
.market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}
.empty-tip {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-secondary);
  padding: 3rem 1rem;
}

/* 个人信息 */
.profile-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  text-align: center;
}
.profile-card .big-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin-bottom: 1rem;
  border: 3px solid var(--primary-light);
}
.profile-card .uid {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
}
.profile-card .nickname {
  font-size: 1.2rem;
  font-weight: 600;
}

/* 设置 */
.settings-list {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}
.setting-item:last-child {
  border-bottom: none;
}
.setting-item input {
  width: 140px;
  padding: 0.4rem 0.6rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
}

/* 工具 */
.hidden {
  display: none !important;
}
