/* ============================================================
   app.css — 小程序风格网站样式层
   更新页面外观只需修改本文件，数据层 data/ 保持不动
   ============================================================ */
:root {
  --primary: #1a7aff;
  --primary-light: #e8f1ff;
  --success: #07c160;
  --success-light: #e6f9ee;
  --warn: #ff9f0a;
  --danger: #fa5151;
  --gray: #8a8f99;
  --gray-light: #f5f6f7;
  --border: #ececf0;
  --text: #1a1a1f;
  --text-2: #5c6068;
  --card-radius: 16rpx;
  --tabbar-h: 56px;
  --navbar-h: 48px;
  font-size: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--gray-light);
  color: var(--text);
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
}

/* ===== 顶部标题栏 ===== */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--navbar-h);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  z-index: 100;
  max-width: 720px;
  margin: 0 auto;
}
.navbar .back {
  position: absolute;
  left: 12px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
  cursor: pointer;
  border: none; background: none;
  font-size: 20px;
}
.navbar .nav-right {
  position: absolute;
  right: 14px;
}

/* ===== 内容区 ===== */
.page {
  padding: calc(var(--navbar-h) + 12px) 14px calc(var(--tabbar-h) + 16px);
  display: none;
}
.page.active { display: block; }

/* ===== 底部导航 ===== */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--tabbar-h);
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  max-width: 720px;
  margin: 0 auto;
}
.tabbar .tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--gray);
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
}
.tabbar .tab.active { color: var(--primary); }
.tabbar .tab svg { width: 22px; height: 22px; }

/* ===== 通用卡片 ===== */
.card {
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.card-title.collapsible {
  cursor: pointer;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.card-title .chev { font-size: 12px; color: var(--gray); transition: transform .2s ease; flex: none; }
.card-title.collapsible.open .chev { transform: rotate(180deg); }
.field-list.hidden { display: none; }

/* ===== 状态标签 ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge.signing { background: var(--success-light); color: var(--success); }
.badge.upcoming { background: var(--primary-light); color: var(--primary); }
.badge.closed { background: #f0f0f2; color: var(--gray); }
.badge.ended { background: #f7f7f9; color: #b0b3ba; }
.badge.past { background: #f2ede4; color: #9a7b4f; }
.badge.ai {
  background: linear-gradient(135deg, #6a5cff, #4b7bff);
  color: #fff;
}

/* ===== 首页统计 ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.stat-box {
  background: #fff;
  border-radius: 14px;
  padding: 12px 8px;
  text-align: center;
}
a.stat-box { text-decoration: none; color: inherit; display: block; transition: transform .15s, box-shadow .15s; }
a.stat-box:active { transform: scale(0.97); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.stat-box .num { font-size: 24px; font-weight: 700; color: var(--primary); }
.stat-box .num.green { color: var(--success); }
.stat-box .num.gray { color: var(--gray); }
.stat-box .label { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ===== 分类图标格 ===== */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.cat-item {
  background: #fff;
  border-radius: 12px;
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  border: none;
  font-family: inherit;
}
.cat-item svg { width: 26px; height: 26px; color: var(--primary); }
.cat-item .cat-count { color: var(--gray); font-size: 10px; }

/* ===== 竞赛列表 ===== */
.contest-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  cursor: pointer;
}
.contest-card .head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.contest-card .name { font-size: 15px; font-weight: 600; line-height: 1.4; }
.contest-card .meta {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 8px;
  line-height: 1.8;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.contest-card .meta .tag { color: var(--gray); }
.contest-card .tag-official {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--primary-light);
  color: var(--primary);
}
.contest-card .foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--gray);
}
.contest-card .deadline strong { color: var(--danger); font-weight: 600; }
.contest-card .ai-badge { font-size: 10px; }

/* ===== 筛选区 ===== */
.filter-bar {
  position: sticky;
  top: var(--navbar-h);
  background: var(--gray-light);
  padding: 8px 0 10px;
  z-index: 50;
}
.search-box {
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 8px;
  gap: 6px;
  border: 1px solid var(--border);
}
.search-box svg { width: 16px; height: 16px; color: var(--gray); flex-shrink: 0; }
.search-box input {
  border: none; outline: none; flex: 1;
  font-size: 14px; background: transparent; color: var(--text);
  font-family: inherit;
}
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 5px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--gray);
}
.filter-row select {
  border: none; background: #fff; padding: 4px 8px;
  border-radius: 8px; font-size: 12px; color: var(--text);
  font-family: inherit;
}

/* ===== 详情页 ===== */
.detail-hero {
  background: linear-gradient(135deg, #1a7aff, #4b7bff);
  color: #fff;
  border-radius: 16px;
  padding: 18px 16px;
  margin-bottom: 12px;
}
.detail-hero .d-name { font-size: 19px; font-weight: 700; line-height: 1.4; }
.detail-hero .d-org { font-size: 13px; opacity: 0.92; margin-top: 6px; }
.detail-hero .d-badges { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.detail-wl-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  background: #fff8ec;
  border: 1px solid #f0dfc0;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.6;
  color: #8a6d3b;
}
.wl-arrow { color: var(--gray); font-size: 18px; align-self: center; padding-left: 4px; }
.wl-season {
  margin: 12px 0;
  padding: 12px 14px;
  background: #eef7f0;
  border: 1px solid #d4e8da;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.6;
  color: #2f6b45;
}
.wl-season-past { background: #fff8ec; border-color: #f0dfc0; color: #8a6d3b; }
.wl-season-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--success);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  margin-right: 6px;
}
.wl-season-past .wl-season-tag { background: #c79a4e; }

.field-list .field-row {
  display: flex;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.6;
}
.field-list .field-row:last-child { border-bottom: none; }
.field-list .f-label {
  width: 84px;
  flex-shrink: 0;
  color: var(--gray);
}
.field-list .f-value { flex: 1; color: var(--text); word-break: break-all; }
.field-list .f-value a { color: var(--primary); text-decoration: none; }

/* AI 专家分析板块 */
.analysis-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.analysis-head .badge.ai { font-size: 12px; padding: 3px 10px; }
.analysis-head .note { font-size: 11px; color: var(--gray); }
.analysis-block { margin-bottom: 12px; }
.analysis-block .a-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 6px;
}
.analysis-block .a-text { font-size: 13px; line-height: 1.8; color: var(--text-2); }
.prep-item {
  background: #fafbfc;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.prep-item .p-label { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.prep-item .p-text { font-size: 13px; line-height: 1.7; color: var(--text-2); }

/* ===== 收藏 ===== */
.btn-fav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-2);
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.btn-fav.faved { border-color: var(--danger); color: var(--danger); }
.btn-fav svg { width: 16px; height: 16px; }
.action-row { display: flex; justify-content: flex-end; margin-bottom: 12px; }

/* ===== 设置/通用 ===== */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.setting-row:last-child { border-bottom: none; }
.setting-row .s-label { color: var(--text); }
.setting-row .s-value { color: var(--gray); font-size: 13px; }
.empty {
  text-align: center;
  color: var(--gray);
  padding: 60px 20px;
  font-size: 14px;
  line-height: 2;
}
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 14px 2px 10px;
}
.notice, .disclaimer {
  background: var(--primary-light);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  color: #2c5db8;
  line-height: 1.7;
  margin-bottom: 12px;
}
.disclaimer { color: var(--gray); }

/* ===== 响应式 ===== */
@media (min-width: 721px) {
  body { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* ===== 白名单入口模块 ===== */
.wl-entry {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, #2B6FF3 0%, #1A52D4 100%);
  border-radius: 14px; padding: 14px 16px; margin-bottom: 14px;
  text-decoration: none; color: #fff; transition: transform .15s;
}
.wl-entry:active { transform: scale(0.98); }
.wl-entry-left { flex: 1; min-width: 0; }
.wl-entry-badge {
  display: inline-block; font-size: 11px; background: rgba(255,255,255,.2);
  padding: 2px 8px; border-radius: 4px; margin-bottom: 6px;
}
.wl-entry-title { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.wl-entry-desc { font-size: 12px; opacity: .85; }
.wl-entry-arrow { font-size: 22px; opacity: .7; margin-left: 8px; }

/* ===== 白名单页面 ===== */
.wl-hero {
  background: linear-gradient(135deg, #2B6FF3 0%, #1A52D4 100%);
  color: #fff; padding: 20px 16px; border-radius: 0 0 16px 16px; margin-bottom: 14px;
}
.wl-badge {
  display: inline-block; font-size: 11px; background: rgba(255,255,255,.2);
  padding: 3px 10px; border-radius: 4px; margin-bottom: 10px;
}
.wl-title { font-size: 18px; font-weight: 700; line-height: 1.4; margin-bottom: 8px; }
.wl-sub { font-size: 13px; opacity: .9; margin-bottom: 4px; }
.wl-period { font-size: 12px; opacity: .75; }
.wl-intro {
  background: #fff; border-radius: 12px; padding: 14px 16px; margin-bottom: 14px;
}
.wl-intro-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.wl-intro p { font-size: 13px; line-height: 1.7; color: var(--text-2); margin: 0 0 8px; }
.wl-doc { font-size: 12px; color: var(--text-3); }
.wl-cat { margin-bottom: 14px; }
.wl-cat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px 8px;
}
.wl-cat-name { font-size: 14px; font-weight: 600; color: var(--text); }
.wl-cat-count { font-size: 12px; color: var(--primary); }
.wl-list { background: #fff; border-radius: 12px; overflow: hidden; }
.wl-item {
  display: flex; padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.wl-item:last-child { border-bottom: none; }
.wl-no {
  width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%;
  background: #F0F6FF; color: var(--primary); font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; margin-right: 10px;
}
.wl-body { flex: 1; min-width: 0; }
.wl-name { font-size: 14px; font-weight: 500; color: var(--text); line-height: 1.4; margin-bottom: 4px; }
.wl-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--text-2); }
.wl-org { color: var(--text-2); }
.wl-stage { color: var(--primary); }
.wl-tip {
  font-size: 12px; color: var(--text-3); line-height: 1.6; padding: 12px 16px;
  background: #FFFBE6; border-radius: 10px; margin-top: 4px;
}

/* ===== 在线咨询（AI 问答） ===== */
#ai-chat-card { padding: 14px 16px 16px; }
.chat-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.chat-title { font-size: 15px; font-weight: 700; }
.chat-sub { font-size: 11px; color: var(--gray); }
.chat-msgs {
  display: flex; flex-direction: column; gap: 10px;
  height: 232px; overflow-y: auto;
  background: #fafbfc; border: 1px solid var(--border);
  border-radius: 12px; padding: 12px;
  scrollbar-width: thin;
}
.chat-empty {
  margin: auto; text-align: center; color: var(--gray);
  font-size: 13px; line-height: 1.7; padding: 8px;
}
.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-msg.ai { justify-content: flex-start; }
.chat-bubble {
  max-width: 84%; padding: 9px 12px; border-radius: 12px;
  font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word;
}
.chat-msg.user .chat-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.ai .chat-bubble { background: #fff; border: 1px solid var(--border); color: var(--text); border-bottom-left-radius: 4px; }
.chat-loading { display: flex; gap: 4px; align-items: center; min-width: 34px; justify-content: center; }
.chat-loading span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--gray);
  animation: chatBlink 1.2s infinite ease-in-out;
}
.chat-loading span:nth-child(2) { animation-delay: 0.2s; }
.chat-loading span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatBlink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.chat-quick {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 4px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chat-quick::-webkit-scrollbar { display: none; }
.q-chip {
  flex: 0 0 auto; border: 1px solid var(--border); background: #fff;
  color: var(--text-2); font-size: 12.5px; padding: 6px 12px;
  border-radius: 16px; cursor: pointer; transition: all 0.15s;
}
.q-chip:active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.chat-input { display: flex; gap: 8px; margin-top: 8px; }
.chat-input input {
  flex: 1; border: 1px solid var(--border); border-radius: 18px;
  padding: 9px 14px; font-size: 14px; outline: none; background: #fff;
}
.chat-input input:focus { border-color: var(--primary); }
.chat-input input:disabled { background: var(--gray-light); color: var(--gray); }
.chat-input button {
  border: none; border-radius: 18px; padding: 0 18px;
  background: var(--primary); color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.chat-input button:disabled { background: var(--gray); cursor: not-allowed; }

/* ===== AI 咨询配置表单 ===== */
.ai-config { padding: 2px 0 0; }
.cfg-label { display: block; font-size: 13px; color: var(--text-2); margin: 12px 0 6px; }
.cfg-input {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; outline: none; background: #fff;
}
.cfg-input:focus { border-color: var(--primary); }
.cfg-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8f99' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
  padding-right: 32px; cursor: pointer;
}

.ai-config-tip {
  margin-top: 10px; font-size: 12px; color: var(--gray); line-height: 1.65;
  background: var(--primary-light); border-radius: 8px; padding: 8px 10px;
}
.ai-config-actions { display: flex; flex-wrap: nowrap; gap: 8px; margin-top: 14px; }
.ai-config-actions .btn-primary, .ai-config-actions .btn-ghost {
  flex: 1 1 0; min-width: 0; padding: 8px 6px;
  font-size: clamp(12px, 3.4vw, 14px); overflow: hidden; text-overflow: ellipsis;
}
.btn-primary, .btn-ghost {
  border-radius: 18px; padding: 8px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; border: none; }
.btn-ghost { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-primary:active, .btn-ghost:active { opacity: 0.8; }
.cfg-msg { margin-top: 10px; font-size: 12.5px; color: var(--danger); min-height: 18px; }
.cfg-msg.ok { color: var(--success); }

/* ===== 首页品牌条（K12Ace） ===== */
.brand-hero {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border-radius: 14px; padding: 12px 14px; margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.brand-logo { width: 44px; height: 44px; border-radius: 11px; flex: 0 0 auto; display: block; }
.brand-text { min-width: 0; }
.brand-name { font-size: 17px; font-weight: 800; letter-spacing: 0.3px; line-height: 1.2; color: var(--text); }
.brand-sub { font-size: 12px; color: var(--gray); line-height: 1.5; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; }
