/* =============================================================
   校园恋爱匹配平台 · 样式
   说明：不引任何 CDN，离线可用；不使用内联脚本（配合严格 CSP）
   ============================================================= */

:root {
  --bg: #f7f7f9;
  --card: #ffffff;
  --text: #1a1a1f;
  --text-soft: #565660;
  --text-mute: #8b8b96;
  --line: #e7e7ec;
  --line-soft: #f0f0f4;
  --accent: #e11d48;
  --accent-soft: #fdf2f4;
  --accent-dark: #be123c;
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --err: #b91c1c;
  --err-soft: #fef2f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(16, 16, 20, .06), 0 8px 24px -12px rgba(16, 16, 20, .12);
  --maxw: 780px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.7;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 布局 ---------- */

.site-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); font-size: 20px; }
.brand-text { font-size: 15px; }

.site-nav { display: flex; align-items: center; gap: 16px; font-size: 14px; flex-wrap: wrap; }
.site-nav a { color: var(--text-soft); }
.site-nav a:hover { color: var(--accent); text-decoration: none; }
.nav-cta {
  padding: 6px 14px; border-radius: 999px;
  background: var(--accent); color: #fff !important;
}
.nav-cta:hover { background: var(--accent-dark); }

.inline-form { display: inline; }
.link-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; color: var(--text-soft);
}
.link-btn:hover { color: var(--accent); }

.env-banner {
  background: var(--warn-soft);
  border-bottom: 1px solid #fde68a;
  color: var(--warn);
  font-size: 13px;
  padding: 8px 20px;
  text-align: center;
}

.site-main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--card);
  padding: 28px 20px;
  margin-top: 40px;
}
.footer-inner { max-width: var(--maxw); margin: 0 auto; }
/* 页脚导航：字号比正文小一档、间距放宽，避免看起来像正文里混进一堆链接 */
.footer-links { margin: 0 0 14px; font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.footer-links a { color: var(--text-soft); }
.footer-links a:hover { color: var(--accent); }
.footer-sep { color: var(--line); }
.footer-note { margin: 0 0 6px; font-size: 12px; color: var(--text-mute); line-height: 1.7; }
.footer-legal { margin: 12px 0 0; font-size: 12px; color: var(--text-mute); display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- 卡片 ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-tight { padding: 16px; }
.card h2 { margin: 0 0 12px; font-size: 18px; }
.card h3 { margin: 20px 0 8px; font-size: 15px; }
.card p:last-child { margin-bottom: 0; }

/* ---------- 排版 ---------- */

h1 { font-size: 26px; line-height: 1.4; margin: 0 0 12px; letter-spacing: -.01em; }
h2 { font-size: 19px; margin: 28px 0 10px; }
h3 { font-size: 16px; margin: 22px 0 8px; }

.display-title { font-size: 30px; line-height: 1.35; margin: 0 0 14px; letter-spacing: -.02em; }
.lede { font-size: 16px; color: var(--text-soft); margin: 0 0 22px; }
.muted { color: var(--text-mute); }
.soft { color: var(--text-soft); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.big-num { font-size: 28px; font-weight: 700; }

.hero {
  text-align: center;
  padding: 20px 0 8px;
}
.hero .badge-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 20px; }

/* ---------- 徽标 / 标签 ---------- */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--line-soft);
  color: var(--text-soft);
  white-space: nowrap;
}
.badge-accent { background: var(--accent-soft); color: var(--accent-dark); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-err { background: var(--err-soft); color: var(--err); }

/* ---------- 表单 ---------- */

label { display: block; font-size: 14px; font-weight: 550; margin-bottom: 6px; }

input[type=text], input[type=email], input[type=tel], input[type=number],
input[type=password], input[type=date], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: #b6b6c0; }

.field { margin-bottom: 16px; }
.field-hint { font-size: 12px; color: var(--text-mute); margin: 6px 0 0; }

/* ---------- 联系方式编辑器（类型下拉 + 值，可多行） ----------
   三处共用（注册第二步 / 隐私控制中心 / 联系方式页），见 partials/contact_rows.html。
   布局用 grid：类型列固定宽度，值列自适应，删除按钮固定在右侧。 */
.contact-rows { display: flex; flex-direction: column; gap: 8px; }
.contact-row {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 8px;
  align-items: center;
}
.contact-row select,
.contact-row input { width: 100%; margin: 0; }
.contact-row .btn { white-space: nowrap; }

@media (max-width: 520px) {
  /* 窄屏：类型与值各占一行，删除按钮右对齐，避免输入框被挤到只剩几个字符 */
  .contact-row { grid-template-columns: 1fr auto; }
  .contact-row select { grid-column: 1 / -1; }
}

/* ---------- 邮箱「固定后缀」输入框 ----------
   学号输入框 + 固定的 @域名 后缀拼成一个整体。
   后缀是纯展示（域名由服务端拼接），因此用 pointer-events:none
   避免用户误以为可以点击编辑。 */
.input-suffix { display: flex; align-items: stretch; }
.input-suffix input {
  flex: 1 1 auto;
  min-width: 0;              /* 允许 input 收缩，否则长后缀会把布局撑破 */
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.input-suffix .suffix {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-left: none;
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
  background: #f5f5f8;
  color: var(--text-mute);
  font-size: 14px;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}
/* 聚焦时让后缀边框也跟着变色，视觉上是一个整体 */
.input-suffix input:focus + .suffix { border-color: var(--accent); }

/* ---------- 输入格式即时校验提示（app.js 动态写入） ----------
   .field-error 默认隐藏，JS 写入文字后自动显示（内容为空则收起），
   因此不需要 JS 去操作 display，避免出现「残留一个空提示块」。 */
.field-error {
  display: none;
  font-size: 12px;
  color: var(--err);
  margin: 6px 0 0;
}
.field-error:not(:empty) { display: block; }
input.input-invalid { border-color: var(--err); }
.input-suffix input.input-invalid + .suffix { border-color: var(--err); }

.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  text-align: center;
  transition: background .15s;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { display: block; width: 100%; }
.btn-ghost {
  background: #fff; color: var(--text-soft); border-color: var(--line);
}
.btn-ghost:hover { background: var(--line-soft); color: var(--text); }
.btn-danger { background: var(--err); }
.btn-danger:hover { background: #991b1b; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* 选项卡片（问卷） */
.option-list { display: flex; flex-direction: column; gap: 8px; }
.option {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: #fff;
  margin-bottom: 0;
  font-weight: 400;
}
.option:hover { border-color: #d4d4dd; background: #fcfcfd; }
.option input { margin: 3px 0 0; flex: 0 0 auto; accent-color: var(--accent); }
.option span { flex: 1; }
.option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.option-multi:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* 勾选确认 */
.check-row {
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 400;
}
.check-row input { margin: 4px 0 0; flex: 0 0 auto; accent-color: var(--accent); }
.check-row label { margin: 0; font-weight: 400; }

/* 横向单选组（如「希望匹配到的对象」）。
   做成卡片式按钮而不是原生 radio 列表：三个选项是平级的、
   选中的那个需要一眼看出来，原生圆点在小屏上太细。 */
.radio-row { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-item {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: 14px; font-weight: 400; margin: 0;
  background: var(--card);
}
.radio-item:hover { border-color: var(--accent); }
.radio-item input { margin: 0; flex: 0 0 auto; accent-color: var(--accent); }
/* 选中态：靠 :has() 给整块加高亮（现代浏览器均支持；
   不支持的浏览器只是少了高亮，圆点仍能正确显示选中状态） */
.radio-item:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft, #fdf2f4);
  color: var(--accent-dark);
  font-weight: 600;
}

/* ---------- 提示条 ---------- */

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-err { background: var(--err-soft); color: var(--err); border-color: #fecaca; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: #bbf7d0; }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.alert-info { background: #f0f6ff; color: #1d4ed8; border-color: #bfdbfe; }

/* ---------- 步骤条 ---------- */

.steps { display: flex; gap: 0; margin: 0 0 24px; counter-reset: step; }
.step {
  flex: 1; text-align: center; position: relative;
  font-size: 12px; color: var(--text-mute);
  padding-top: 30px;
}
.step::before {
  counter-increment: step;
  content: counter(step);
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 24px; height: 24px; line-height: 24px;
  border-radius: 50%;
  background: var(--line-soft); color: var(--text-mute);
  font-size: 12px; font-weight: 600;
}
.step.done::before { background: var(--ok); color: #fff; }
.step.active::before { background: var(--accent); color: #fff; }
.step.active { color: var(--accent); font-weight: 600; }
.step.done { color: var(--ok); }
.step:not(:last-child)::after {
  content: ''; position: absolute; top: 11px; left: calc(50% + 16px);
  right: calc(-50% + 16px); height: 1px; background: var(--line);
}
.step.done:not(:last-child)::after { background: #bbf7d0; }

/* ---------- 进度条 ---------- */

.progress-wrap { margin: 0 0 18px; }
.progress-bar {
  height: 6px; background: var(--line-soft); border-radius: 999px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--accent); border-radius: 999px;
  transition: width .3s ease;
}
.progress-text { font-size: 12px; color: var(--text-mute); margin-top: 6px; }

/* ---------- 倒计时 ---------- */

.countdown {
  display: flex; gap: 8px; justify-content: center;
  margin: 18px 0 0;
}
.countdown-cell {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  min-width: 62px;
  text-align: center;
}
.countdown-num { font-size: 22px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.countdown-unit { font-size: 11px; color: var(--text-mute); }

/* ---------- 信息表 ---------- */

.info-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.info-table th, .info-table td {
  text-align: left; padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
.info-table th { color: var(--text-soft); font-weight: 550; width: 38%; }
.info-table tr:last-child th, .info-table tr:last-child td { border-bottom: none; }

/* ---------- 匹配结果 ---------- */

.match-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.match-head {
  background: linear-gradient(135deg, var(--accent-soft), #fff);
  padding: 22px;
  border-bottom: 1px solid var(--line);
}
.match-score { font-size: 34px; font-weight: 750; color: var(--accent); line-height: 1.1; }
.match-score-label { font-size: 12px; color: var(--text-mute); }
.match-name { font-size: 20px; font-weight: 650; margin: 12px 0 4px; }
.match-body { padding: 20px 22px; }

.reason-list { list-style: none; padding: 0; margin: 0; }
.reason-list li {
  position: relative;
  padding: 10px 0 10px 24px;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
  line-height: 1.7;
}
.reason-list li:last-child { border-bottom: none; }
.reason-list li::before {
  content: '✦';
  position: absolute; left: 2px; top: 10px;
  color: var(--accent); font-size: 12px;
}

.contact-box {
  background: var(--ok-soft);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 16px;
}
.contact-box .contact-item { font-size: 15px; margin: 6px 0; }
.contact-box .contact-label { color: var(--text-soft); font-size: 13px; }

.locked-box {
  background: var(--line-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-soft);
  text-align: center;
}

/* ---------- 破冰任务卡 ---------- */

.task-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.task {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.task-day {
  flex: 0 0 34px;
  font-size: 12px; font-weight: 700; color: var(--accent);
  padding-top: 2px;
}
.task-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.task-detail { font-size: 13px; color: var(--text-soft); }

/* ---------- 运营后台 ---------- */

body.admin { background: #f4f4f7; }
body.admin .site-main { max-width: 1060px; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.stat-num { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-mute); margin-top: 4px; }
.stat-warn .stat-num { color: var(--warn); }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 6px 14px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line);
  font-size: 13px; color: var(--text-soft);
}
.tab:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td {
  padding: 9px 10px; border-bottom: 1px solid var(--line-soft);
  text-align: left; vertical-align: top;
}
table.data th { color: var(--text-soft); font-weight: 600; background: #fafafb; }
table.data tr:hover td { background: #fcfcfd; }
.table-wrap { overflow-x: auto; }

.rule-list { list-style: none; padding: 0; margin: 0; }
.rule-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--radius-sm);
  margin-bottom: 6px; font-size: 13px;
}
.rule-pass { background: var(--ok-soft); }
.rule-fail { background: var(--err-soft); }
.rule-icon { flex: 0 0 16px; font-weight: 700; }
.rule-pass .rule-icon { color: var(--ok); }
.rule-fail .rule-icon { color: var(--err); }

/* ---------- 主栏 + 侧栏（后台核验详情页） ----------

   用途：左边是要动手填的表单，右边是「填表时的参考依据」（规则引擎判定）。
   运营的动线是「打开学信网查询页 → 对照着往表单里逐项填」，
   判定结果需要在**整个填表过程中始终可见**，滚到哪儿都在手边。

   ★ 光有 position: sticky 是不够的 ★
     这是最容易做错的一点：sticky 元素一旦**比视口还高**，
     贴住顶部之后它的下半部分就永远看不到、也滚不到 —— 越是想「固定」，
     越是看不到全貌。规则条目一多（5-8 条，窄栏里每条还要折两三行）
     就会撞上这个问题。
     所以这里给侧栏加了「视口高度上限 + 内部滚动」：
       · 侧栏整体不超出视口（max-height）
       · 结论那一条固定在面板顶部，永远可见
       · 只有判定明细列表自己滚动（overscroll-behavior 防止滚到底把整页带走）
     这样「结论永远在手边、明细也能看全」两件事同时成立。

   ★ min-width 陷阱 ★
     栅格里的 minmax(0, 1fr) 那个 0 不能省：默认的 min-width:auto 会让
     表格 / 长文本把栅格撑破，表现是页面横向溢出。
*/
.detail-layout {
  display: grid;
  /* 侧栏宽度可伸缩：空间够时 264px，不够时缩到 208px 也不塌成单栏。
     写死 264px 的话，中等宽度的窗口只能靠断点降级成单栏 ——
     而「降级成单栏」在人眼里就是「侧栏又跑到下面去了」。 */
  grid-template-columns: minmax(0, 1fr) minmax(208px, 264px);
  gap: 18px;
  align-items: start;
}
.detail-side {
  position: sticky;
  /* 避开顶部那条 sticky 的站点头（高约 49px），留一点呼吸空间 */
  top: 66px;
  /* 视口高度上限：64px 底部留白 + 66px 顶部偏移 */
  max-height: calc(100vh - 130px);
  display: flex;
  flex-direction: column;
}
.detail-side .card {
  display: flex;
  flex-direction: column;
  /* min-height:0 是关键：不加的话内部滚动区无法被压缩，
     面板还是会被内容撑高，sticky 的老问题原样复现。 */
  min-height: 0;
  margin-bottom: 0;
  padding: 16px;
}
.detail-side .rule-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
}
/* 窄栏里条目要更紧凑，否则三两条就占满一屏 */
.detail-side .rule-item { padding: 8px 10px; font-size: 12px; border-radius: 6px; }
.detail-side .rule-icon { flex: 0 0 14px; }

@media (max-width: 720px) {
  /* 窄屏堆叠成单栏：手机上看两栏没法用，也就不需要「固定」了。

     ★ 断点为什么一路从 960 降到 720 ★
       最初定的 960 太高了：很多人的浏览器窗口（或 125% 缩放的笔记本）
       实际 CSS 宽度就落在 800-950 之间，会莫名其妙命中单栏 ——
       表现是「侧栏又跑到页面最下面去了」，而模板和 CSS 都完全正确，
       从代码上怎么查都查不出来。
       720 的依据：侧栏最少 208 + 间距 18 + 表单可用宽度约 420
       + 页面左右内边距 40 ≈ 686，留一点余量取 720。
       低于这个宽度堆叠是对的（表单比侧栏更重要），
       但临界点绝不能落在「大多数人正在用的正常宽度」上。 */
  .detail-layout { grid-template-columns: 1fr; }
  .detail-side {
    position: static;
    max-height: none;
    display: block;
  }
  .detail-side .card { display: block; margin-bottom: 16px; }
  .detail-side .rule-list { overflow-y: visible; }
  .detail-side .rule-item { font-size: 13px; padding: 10px 12px; }
}

/* ---------- 收件箱（开发用） ---------- */

.mail-item {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px; margin-bottom: 10px; background: #fff;
}
.mail-item pre {
  white-space: pre-wrap; word-break: break-word;
  font-size: 12px; background: var(--line-soft);
  padding: 10px; border-radius: 6px; margin: 8px 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- 空状态 ---------- */

.empty {
  text-align: center; padding: 40px 20px; color: var(--text-mute);
}
.empty-icon { font-size: 32px; margin-bottom: 10px; opacity: .5; }

/* ---------- 错误页 ---------- */

.error-page { text-align: center; padding: 60px 20px; }
.error-code { font-size: 56px; font-weight: 750; color: var(--line); line-height: 1; }

/* ---------- 响应式 ---------- */

@media (max-width: 560px) {
  .site-main { padding: 20px 14px 48px; }
  .display-title { font-size: 24px; }
  h1 { font-size: 22px; }
  .card { padding: 18px 16px; }
  .site-nav { gap: 12px; font-size: 13px; }
  .countdown-cell { min-width: 54px; padding: 8px 10px; }
  .countdown-num { font-size: 19px; }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
