/* formkit — 「师徒问诊」视觉
   学员填的内容是墨色，所有朱红都是老师的笔迹：题号、指引、按钮。 */

:root {
  color-scheme: light dark;   /* 让滚动条、原生控件跟着主题走 */

  --ink:      #1B2A33;
  --ink-2:    #3C505A;
  --muted:    #5F7178;
  --paper:    #F1F4F3;
  --card:     #FFFFFF;
  --rule:     #DCE3E2;
  --rule-2:   #EBEFEE;
  --zhu:      #BE4238;
  --zhu-wash: #FAEDEB;
  --focus:    #1F6F8B;

  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --num:  Georgia, "Times New Roman", "Songti SC", serif;

  --shell: 40rem;
  --r: 4px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink:      #E6EDEA;
    --ink-2:    #BFCDD2;
    --muted:    #93A3A9;
    --paper:    #12191C;
    --card:     #1A2327;
    --rule:     #2E3B41;
    --rule-2:   #232E33;
    --zhu:      #E0705F;
    --zhu-wash: #2C1E1C;
    --focus:    #7FC4DC;
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 4.5rem;   /* 别让 sticky 顶栏压住 scrollIntoView 的目标 */
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  /* 块切换时高度会变，浏览器的滚动锚定会把 scrollTo(0) 拽回去 */
  overflow-anchor: none;
  /* 手机上去掉双击缩放带来的点击延迟（捏合缩放仍然保留） */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* 键盘可见焦点 —— 全局兜底 */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ------------------------------------------------------- 顶栏与进度 */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);          /* 实色而非毛玻璃：老手机上滚动更稳，也少一层花哨 */
  border-bottom: 1px solid var(--rule);
  padding-top: env(safe-area-inset-top);
}

.topbar__inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0.625rem 1.25rem 0.5rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.topbar__title {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink-2);
  margin: 0;
  min-width: 0;              /* flex 子项默认不肯收缩，没这行截断不生效 */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__count {
  font-family: var(--num);
  font-size: 0.8125rem;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.progress {
  height: 2px;
  background: var(--rule-2);
  overflow: hidden;
}

/* 用 scaleX 而不是 width：动 width 每帧都要重排，老手机上会卡 */
.progress__bar {
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: var(--ink);
  transition: transform 320ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

@media (prefers-reduced-motion: reduce) {
  .progress__bar { transition: none; }
}

/* ------------------------------------------------------- 主体骨架 */

.shell {
  max-width: var(--shell);
  margin: 0 auto;
  /* 横屏时刘海会切进来，左右也要让开安全区 */
  padding: 1.75rem max(1.25rem, env(safe-area-inset-right))
           1.5rem max(1.25rem, env(safe-area-inset-left));
}

/* 开场白 */

.intro__kicker {
  font-family: var(--num);
  font-size: 0.875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--zhu);
  margin: 0 0 0.5rem;
}

.intro__title {
  font-size: 1.5rem;
  line-height: 1.4;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin: 0 0 1rem;
}

.intro__body {
  color: var(--ink-2);
  margin: 0 0 1rem;
}

.intro__body strong { color: var(--ink); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 1.5rem 0 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  background: var(--card);
  font-size: 0.875rem;
  color: var(--muted);
}

.legend__no {
  font-family: var(--num);
  font-weight: 700;
}

.legend__no--req { color: var(--zhu); }
.legend__no--opt { color: var(--muted); }

/* ------------------------------------------------------- 分块 */

.block { display: none; }
.block.is-active { display: block; }

@media (prefers-reduced-motion: no-preference) {
  .block.is-active { animation: blockin 200ms cubic-bezier(0.22, 0.61, 0.36, 1); }
  @keyframes blockin {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: none; }
  }
}

.block__head { margin: 0 0 1.5rem; }

.block__no {
  font-family: var(--num);
  font-size: 2rem;
  line-height: 1;
  color: var(--zhu);
  display: block;
  margin-bottom: 0.375rem;
  font-variant-numeric: lining-nums;
}

.block__title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.375rem;
}

/* 老师的一句话 —— 每块开头，把填表变成被问诊 */
.block__say {
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.65;
}

/* ------------------------------------------------------- 题 */

.q {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 1.125rem 1.125rem 1.25rem;
  margin-bottom: 0.875rem;
  scroll-margin-top: 4.5rem;
  transition: border-color 200ms ease;
}

/* 从提交处跳回来补答时，让人一眼看到是哪一题 */
.q--flag { border-color: var(--zhu); }

.q__head {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  margin-bottom: 0.75rem;
}

/* 题号本身编码必填状态（红=必填），legend 里有图例，下面还有文字兜底 */
.q__no {
  font-family: var(--num);
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--muted);
  flex: none;
  min-width: 1.25rem;
  font-variant-numeric: tabular-nums lining-nums;
}

.q--req .q__no { color: var(--zhu); }

.q__label {
  margin: 0;
  font-weight: 600;
  line-height: 1.6;
  text-wrap: pretty;
  color: var(--ink);
}

.q__req {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--zhu);
  background: var(--zhu-wash);
  border-radius: 2px;
  padding: 0.0625rem 0.3125rem;
  margin-left: 0.375rem;
  white-space: nowrap;
  vertical-align: 0.08em;
}

.q__hint {
  margin: -0.25rem 0 0.75rem;
  padding-left: 2rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--muted);
}

/* 没有题号的引导题：正文和选项一起靠左，别空着题号位 */
.q__hint--flush { padding-left: 0; }

/* 输入 */

.q input[type="text"],
.q input[type="number"],
.q textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;                /* ≥16px，否则 iOS 聚焦时会放大整页 */
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 0.625rem 0.75rem;
  transition: border-color 140ms ease, background 140ms ease;
}

.q textarea {
  min-height: 5.5rem;
  resize: vertical;
  line-height: 1.7;
}

.q textarea.is-tall { min-height: 9rem; }

.q input:focus,
.q textarea:focus {
  outline: none;
  border-color: var(--focus);
  background: var(--card);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent);
}

/* 选项 */

.opts {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.opt {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.5rem;
  margin-left: -0.5rem;
  border-radius: var(--r);
  min-height: 2.75rem;            /* 触摸目标 ≥44px */
  cursor: pointer;
  line-height: 1.6;
  transition: background 120ms ease;
}

.opt:hover,
.opt:active { background: var(--rule-2); }

.opt input {
  margin: 0.4375rem 0 0;
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--zhu);
  flex: none;
}

/* 截图上传 */

.up__drop {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 3.25rem;
  padding: 0.75rem 1rem;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px dashed var(--rule);
  border-radius: var(--r);
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease;
}

.up__drop:hover { border-color: var(--zhu); color: var(--zhu); }

.up__list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5rem, 1fr));
  gap: 0.5rem;
}

.up__item {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--paper);
}

.up__item img { width: 100%; height: 100%; object-fit: cover; display: block; }

.up__kill {
  position: absolute;
  top: 0.1875rem;
  right: 0.1875rem;
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  border-radius: 50%;
  background: rgba(20, 28, 32, 0.72);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.up__note { margin: 0.5rem 0 0; font-size: 0.8125rem; color: var(--muted); }
.up__note--bad { color: var(--zhu); }

/* ------------------------------------------------------- 底部操作条 */

.actions {
  position: sticky;
  bottom: 0;
  z-index: 20;
  background: var(--paper);
  border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom);   /* iPhone 底部横条 */
}

.actions__inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0.625rem 1.25rem 0.75rem;
}

.saved {
  font-size: 0.75rem;
  color: var(--muted);
  min-height: 1.125rem;
  margin: 0 0 0.375rem;
  opacity: 0;
  transition: opacity 220ms ease;
  font-variant-numeric: tabular-nums;
}

.saved.is-on { opacity: 1; }

.actions__row { display: flex; gap: 0.625rem; }

.btn {
  flex: 1;
  min-height: 2.875rem;           /* 46px */
  padding: 0.625rem 1rem;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: var(--r);
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 90ms ease;
}

.btn:active { transform: scale(0.985); }

@media (prefers-reduced-motion: reduce) {
  .btn:active { transform: none; }
}

.btn--ghost {
  flex: 0 0 auto;
  min-width: 5.5rem;
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--rule);
}

.btn--ghost:hover { border-color: var(--ink-2); }

.btn--main {
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
}

.btn--main:hover { background: var(--ink-2); border-color: var(--ink-2); }

/* 提交键是老师的笔 —— 全场唯一的朱红实底 */
.btn--send {
  background: var(--zhu);
  border-color: var(--zhu);
  color: #fff;
}

.btn--send:hover {
  background: color-mix(in srgb, var(--zhu) 86%, #000);
  border-color: color-mix(in srgb, var(--zhu) 86%, #000);
}

/* 必填没填完时，提交退成次要键 —— 主键让给「回去补」 */
.btn--send.btn--quiet {
  background: transparent;
  color: var(--zhu);
  border-color: var(--zhu);
}

.btn--send.btn--quiet:hover { background: var(--zhu-wash); }

.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn[disabled]:active { transform: none; }

.formnote {
  margin: 0.625rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
  text-align: center;
}

.formnote--bad { color: var(--zhu); font-weight: 600; }

/* ------------------------------------------------------- 收尾页 */

.done { padding: 3.5rem 1.25rem 4rem; max-width: var(--shell); margin: 0 auto; }

.done__mark {
  font-family: var(--num);
  font-size: 2.5rem;
  line-height: 1;
  color: var(--zhu);
  margin: 0 0 1rem;
}

.done__title { font-size: 1.375rem; font-weight: 700; margin: 0 0 0.875rem; }
.done__body { color: var(--ink-2); margin: 0 0 0.875rem; }

/* ------------------------------------------------------- 管理端 */

.adm { max-width: 62rem; margin: 0 auto; padding: 2rem 1.25rem 4rem; }

.adm__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
  padding-bottom: 0.875rem;
  border-bottom: 1px solid var(--rule);
}

.adm__title { font-size: 1.375rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.adm__sub { color: var(--muted); font-size: 0.875rem; margin: 0.25rem 0 0; }

.adm__link {
  color: var(--muted);
  font-size: 0.875rem;
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}

.adm__link:hover { color: var(--zhu); border-color: var(--zhu); }

.cards { display: grid; gap: 0.75rem; }

.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 1rem 1.125rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 140ms ease;
}

.card:hover { border-color: var(--ink-2); }

.card__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.card__name { font-weight: 600; margin: 0; }

.card__meta {
  font-family: var(--num);
  font-size: 0.875rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.card__warn {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--zhu);
  font-weight: 600;
}

.card__url {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
  word-break: break-all;
}

.empty {
  border: 1px dashed var(--rule);
  border-radius: var(--r);
  padding: 2.5rem 1.25rem;
  text-align: center;
  color: var(--muted);
}

/* 单份回执 */

.ans { margin: 0 0 1.75rem; }

.ans__sec {
  font-size: 1.0625rem;
  font-weight: 700;
  margin: 2rem 0 0.875rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}

.ans__q { margin: 0 0 1rem; }

.ans__label {
  display: flex;
  gap: 0.625rem;
  align-items: baseline;
  margin: 0 0 0.25rem;
  font-weight: 600;
  font-size: 0.9375rem;
}

.ans__no {
  font-family: var(--num);
  color: var(--muted);
  flex: none;
  font-variant-numeric: tabular-nums;
}

.ans__q--req .ans__no { color: var(--zhu); }

/* 学员的回答可能是整段聊天记录，行太长读不动 —— 卡在舒服的中文行宽 */
.ans__val {
  margin: 0;
  padding-left: 1.875rem;
  max-width: 48rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;      /* 学员可能贴一长串没空格的链接 */
  color: var(--ink-2);
  line-height: 1.7;
}

.ans__val--none { color: var(--muted); font-style: italic; }
.ans__val--miss { color: var(--zhu); font-weight: 600; font-style: normal; }

.ans__shots {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0 0 0 1.875rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: 0.625rem;
}

.ans__shots img {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  display: block;
}

.bar {
  display: flex;
  gap: 0.625rem;
  flex-wrap: wrap;
  align-items: center;
  padding: 1rem 0 0;
  border-top: 1px solid var(--rule);
  margin-top: 2rem;
}

/* 回执页很长（快 30 题），导出键放顶部，别逼人滚到底 */
.bar--top {
  border-top: none;
  border-bottom: 1px solid var(--rule);
  margin: 0 0 1.75rem;
  padding: 0 0 1.125rem;
}

.bar .btn { flex: 0 0 auto; min-width: 8rem; }

.bar__note {
  flex: 1 1 16rem;
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--muted);
}

.btn--burn {
  background: transparent;
  color: var(--zhu);
  border: 1px solid var(--zhu);
}

.btn--burn:hover { background: var(--zhu); color: #fff; }

/* 登录 */

.login { max-width: 22rem; margin: 0 auto; padding: 5rem 1.25rem; }
.login__title { font-size: 1.25rem; font-weight: 700; margin: 0 0 1.25rem; }

.login input {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 0.625rem 0.75rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  margin-bottom: 0.75rem;
}

.login input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent);
}

.login .btn { width: 100%; }

.alert {
  margin: 0 0 1rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--r);
  background: var(--zhu-wash);
  color: var(--zhu);
  font-size: 0.875rem;
  font-weight: 600;
}

/* 桌面上把题卡拉开一点，别贴着 */
@media (min-width: 40rem) {
  .shell { padding: 2.5rem 2rem 2rem; }
  .intro__title { font-size: 1.75rem; }
  .q { padding: 1.25rem 1.375rem 1.375rem; }
}
