/* 筑Studio 问卷样式 —— 米白底、墨色字、中式极简，对齐官网风格 */
:root {
  --bg: #f5f1ea;
  --card: #fffdf9;
  --ink: #26221c;
  --ink-soft: #6b6255;
  --line: #e3dccf;
  --accent: #8f2f27;
  --accent-dark: #74241e;
  --radius: 10px;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

/* 头部 */
.site-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 28px 24px 20px;
  max-width: 860px;
  margin: 0 auto;
}
.site-header .logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
}
.site-header .brand h1 {
  font-size: 26px;
  letter-spacing: 6px;
  font-weight: 600;
}
.site-header .brand p {
  font-size: 13px;
  letter-spacing: 4px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px 140px; /* 底部留出固定按钮栏的高度 */
}

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 26px;
  margin-bottom: 18px;
  box-shadow: 0 1px 4px rgba(60, 50, 30, 0.05);
}

.intro h2 {
  font-size: 21px;
  letter-spacing: 2px;
  margin-bottom: 12px;
}
.intro p { margin-bottom: 8px; }
.muted { color: var(--ink-soft); font-size: 14px; }

/* 题目 */
.question { scroll-margin-top: 20px; }
.question.invalid { border-color: var(--accent); }
.q-title {
  font-size: 16.5px;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.7;
}
.q-title .q-num { color: var(--accent); margin-right: 6px; }
.q-title .req { color: var(--accent); margin-left: 4px; }
.q-note {
  font-size: 13.5px;
  color: var(--ink-soft);
  background: #f7f3ea;
  border-left: 3px solid var(--line);
  padding: 8px 12px;
  border-radius: 4px;
  margin: 8px 0 4px;
}
.q-error { color: var(--accent); font-size: 13.5px; margin-top: 10px; }

/* 长文本（风险告知） */
.q-longtext {
  max-height: min(420px, 42vh); /* 限制在视口高度内，保证下方选项无需翻页即可见 */
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #faf7f0;
  padding: 16px 18px;
  margin: 10px 0;
  font-size: 14px;
  line-height: 1.9;
}
.q-longtext h4 {
  font-size: 15px;
  color: var(--accent);
  letter-spacing: 1px;
  margin: 14px 0 4px;
}
.q-longtext h4:first-child { margin-top: 0; }
.q-longtext p { margin-bottom: 8px; color: #4a443a; }

/* 汇总页 */
.review-group { margin-bottom: 22px; }
.review-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin-bottom: 10px;
}
.review-group-head h4 { font-size: 16px; letter-spacing: 1px; }
.review-group-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.review-status { font-size: 13px; }
.review-status.ok { color: #4a7c59; }
.review-status.bad { color: var(--accent); }
.review-final {
  text-align: center;
  font-size: 15.5px;
  letter-spacing: 1px;
  padding: 12px;
  border-radius: 6px;
  margin-top: 6px;
}
.review-final.ok { color: #4a7c59; background: #eef4ee; }
.review-final.bad { color: var(--accent); background: #f9eeec; }

/* 选项 */
.options { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
/* 短选项多列布局：按宽度自动分列，手机 2 列、桌面 3~4 列 */
.options.compact {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 2px 10px;
}
/* 带补充输入框的选项独占一行，方便填写 */
.options.compact .option:has(.opt-text-input) { grid-column: 1 / -1; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.option:hover { background: #f5f0e6; }
.option input[type="radio"], .option input[type="checkbox"] {
  margin-top: 7px;
  accent-color: var(--accent);
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}
.option .opt-label { flex: 1; font-size: 15px; }
.option.checked { background: #f3ede0; }
.option .opt-text-input {
  margin-top: 6px;
  width: 100%;
}

/* 文本输入 */
.text-input, .opt-text-input {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-family: var(--serif);
  font-size: 15px;
  color: var(--ink);
}
.text-input:focus, .opt-text-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* 进度条 */
.progress-wrap { margin-bottom: 18px; }
.progress-info {
  text-align: center;
  font-size: 14px;
  color: var(--ink-soft);
  letter-spacing: 2px;
  margin-bottom: 8px;
}
.progress-track {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* 分步导航按钮（固定在屏幕底部） */
.nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(245, 241, 234, 0.96);
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 10px rgba(60, 50, 30, 0.06);
}
.nav-btns {
  display: flex;
  gap: 14px;
  justify-content: center;
  max-width: 860px;
  margin: 0 auto;
}
.nav-btns .btn { min-width: 160px; }
.nav-btns .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.nav-bar .form-error { text-align: center; margin-bottom: 8px; }
.intro .btn { margin-top: 18px; }

/* 草稿恢复确认（介绍页） */
.draft-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.draft-actions .btn { margin-top: 10px; }

/* 提交区 */
.submit-bar { text-align: center; margin: 26px 0 10px; }
.form-error {
  color: var(--accent);
  margin-bottom: 12px;
  font-size: 15px;
}
.form-error a { color: var(--accent); text-decoration: underline; }

.btn {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 3px;
  padding: 13px 42px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--ink-soft); }

/* 结果页 */
.result-success { text-align: center; margin-bottom: 20px; }
.result-success img { width: 64px; height: 64px; object-fit: contain; margin-bottom: 8px; }
.result-success h2 { font-size: 22px; letter-spacing: 3px; }
.result-no { margin-top: 14px; font-size: 15px; letter-spacing: 2px; color: var(--ink-soft); }
.result-no strong {
  display: inline-block;
  font-size: 24px;
  letter-spacing: 3px;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 2px 18px;
  margin-left: 10px;
  background: #faf3f1;
}
.result-success .muted { margin-top: 10px; }
.result-tip { color: var(--ink-soft); font-size: 14px; margin-top: 14px; }
.result-actions { display: flex; flex-direction: column; gap: 12px; }
.result-actions .btn { width: 100%; }
.result-summary {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #faf7f0;
  padding: 18px;
  margin-top: 18px;
  font-size: 14px;
}
.result-summary .rs-item { margin-bottom: 12px; }
.result-summary .rs-q { font-weight: 600; margin-bottom: 2px; }
.result-summary .rs-a { color: var(--ink-soft); white-space: pre-wrap; }

/* 页脚 */
.site-footer {
  text-align: center;
  padding: 24px;
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: 2px;
}

@media (max-width: 600px) {
  .site-header .logo { width: 56px; height: 56px; }
  .site-header .brand h1 { font-size: 21px; }
  .card { padding: 20px 16px; }
  .btn { width: 100%; letter-spacing: 2px; }
  /* 固定底栏中的两个按钮并排等宽 */
  .nav-btns .btn { width: auto; flex: 1; min-width: 0; letter-spacing: 1px; padding: 13px 10px; }
}

/* ============ 后台 ============ */
.admin-wrap { max-width: 1000px; margin: 0 auto; padding: 24px 16px 60px; }
.admin-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 18px;
}
.admin-top h2 { font-size: 20px; letter-spacing: 2px; }
.admin-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-sm {
  font-size: 14px; letter-spacing: 1px; padding: 8px 18px;
  font-family: var(--serif); border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
.btn-sm:hover { border-color: var(--ink-soft); }
.btn-sm.danger { color: var(--accent); border-color: var(--accent); background: transparent; }
.btn-sm.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

.login-box { max-width: 380px; margin: 80px auto; text-align: center; }
.login-box .logo { width: 64px; height: 64px; object-fit: contain; margin-bottom: 12px; }
.login-box h2 { letter-spacing: 3px; margin-bottom: 20px; font-size: 19px; }
.login-box .btn { width: 100%; margin-top: 14px; }

.table-scroll { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.admin-table th, .admin-table td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.admin-table th { color: var(--ink-soft); font-weight: 600; white-space: nowrap; }
.admin-table tr:hover td { background: #f7f3ea; }
.admin-table a { color: var(--accent); cursor: pointer; text-decoration: none; }
.admin-table a:hover { text-decoration: underline; }

.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 18px; font-size: 14px; }
.search-input { padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; font-family: var(--serif); font-size: 14px; background: #fff; }

.detail-item { margin-bottom: 14px; }
.detail-item .d-q { font-weight: 600; margin-bottom: 2px; }
.detail-item .d-a { color: var(--ink-soft); white-space: pre-wrap; }
.detail-meta { color: var(--ink-soft); font-size: 13.5px; margin-bottom: 16px; }

/* ============ 统计分析 ============ */
.tabs { display: flex; gap: 10px; margin-bottom: 16px; }
.tab-btn {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 2px;
  padding: 9px 26px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
}
.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.stats-overview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stat-num-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 10px;
  text-align: center;
}
.stat-num { font-size: 26px; font-weight: 600; color: var(--accent); letter-spacing: 1px; }
.stat-num-label { font-size: 13px; color: var(--ink-soft); margin-top: 4px; letter-spacing: 1px; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-card.wide { grid-column: 1 / -1; }
.stat-card h3 {
  font-size: 15.5px;
  letter-spacing: 1px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13.5px;
}
.bar-label {
  width: 110px;
  flex-shrink: 0;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-track {
  flex: 1;
  height: 14px;
  background: #efe9dc;
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%;
  background: #8a7a5f;
  border-radius: 4px;
  min-width: 2px;
}
.bar-fill.danger { background: var(--accent); }
.bar-num { width: 28px; text-align: right; color: var(--ink-soft); flex-shrink: 0; }

.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
}
.trend-bar {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
}
.trend-bar span {
  display: block;
  width: 100%;
  background: #8a7a5f;
  border-radius: 2px 2px 0 0;
  min-height: 1px;
}
.trend-bar:hover span { background: var(--accent); }
.trend-axis {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 6px;
}

@media (max-width: 700px) {
  .stats-overview { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: 1fr; }
  .bar-label { width: 88px; }
}
