:root {
  --sage: #4a9d8e;
  --sage-d: #3c8276;
  --sage-l: #e7f2ef;
  --ink: #2c3a39;
  --ink-soft: #5c6b6a;
  --bg1: #eaf4f1;
  --bg2: #f6f3ee;
  --sys-bubble: #ffffff;
  --warn: #d98a4a;
  --radius: 20px;
  --shadow: 0 8px 30px rgba(60, 90, 85, 0.10);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
          "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1) 0%, var(--bg2) 100%);
  background-attachment: fixed;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}
@media (min-width: 540px) {
  .app {
    height: min(860px, 96dvh);
    margin-top: 2dvh;
    border-radius: 28px;
    overflow: hidden;
    box-shadow: var(--shadow);
    background: rgba(255,255,255,0.35);
    backdrop-filter: blur(2px);
  }
}

.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.screen[hidden] { display: none; }

/* ---------- 开始页 ---------- */
.screen-start { justify-content: center; padding: 28px 24px; overflow-y: auto; }
.start-card { animation: rise .5s ease both; }
.brand { text-align: center; margin-bottom: 22px; }
.brand-leaf { font-size: 40px; line-height: 1; }
.brand h1 { margin: 8px 0 2px; font-size: 26px; letter-spacing: 2px; color: var(--sage-d); }
.brand-sub { margin: 0; color: var(--ink-soft); font-size: 14px; }
.start-intro {
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(74,157,142,0.15);
  border-radius: var(--radius);
  padding: 18px 18px;
  margin-bottom: 20px;
  line-height: 1.85;
  font-size: 15px;
  color: var(--ink);
}
.start-intro p { margin: 0 0 6px; }
.start-intro p:last-child { margin-bottom: 0; }
.start-intro strong { color: var(--sage-d); }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; padding-left: 4px; }
.field input, .field select {
  width: 100%; font-family: var(--font); font-size: 16px; color: var(--ink);
  padding: 13px 16px; border: 1.5px solid rgba(74,157,142,0.25);
  border-radius: 14px; background: #fff; outline: none; transition: border-color .15s;
}
.field input:focus, .field select:focus { border-color: var(--sage); }

.btn-primary {
  display: block; width: 100%; text-align: center; text-decoration: none;
  font-family: var(--font); font-size: 17px; font-weight: 600; color: #fff;
  padding: 15px; border: none; border-radius: 16px; cursor: pointer;
  background: linear-gradient(135deg, var(--sage) 0%, var(--sage-d) 100%);
  box-shadow: 0 6px 18px rgba(60,130,118,0.30);
  transition: transform .08s, box-shadow .2s, opacity .2s; margin-top: 6px;
}
.btn-primary:active { transform: translateY(1px) scale(.995); }
.btn-primary:disabled { opacity: .55; cursor: default; }

.disclaimer { margin-top: 18px; font-size: 12px; line-height: 1.7; color: var(--ink-soft); text-align: center; }
.disclaimer b { color: var(--warn); }

/* ---------- 对话页 ---------- */
.chat-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid rgba(74,157,142,0.12);
  background: rgba(255,255,255,0.65); backdrop-filter: blur(6px);
}
.chat-title { font-weight: 600; color: var(--sage-d); letter-spacing: 1px; }
.chat-badge { font-size: 11px; color: var(--sage-d); background: var(--sage-l);
  padding: 3px 9px; border-radius: 999px; margin-left: auto; }

.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 16px 8px; scroll-behavior: smooth; }
.row { display: flex; margin-bottom: 14px; animation: rise .35s ease both; }
.row.sys { justify-content: flex-start; }
.row.me { justify-content: flex-end; }
.bubble {
  max-width: 80%; padding: 11px 15px; font-size: 15.5px; line-height: 1.7;
  border-radius: 18px; white-space: pre-wrap; word-break: break-word;
}
.row.sys .bubble {
  background: var(--sys-bubble); color: var(--ink);
  border: 1px solid rgba(74,157,142,0.12); border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(60,90,85,0.05);
}
.row.me .bubble {
  background: linear-gradient(135deg, var(--sage) 0%, var(--sage-d) 100%);
  color: #fff; border-bottom-right-radius: 6px;
  box-shadow: 0 4px 12px rgba(60,130,118,0.22);
}
.row.crisis .bubble {
  background: #fff6ef; border: 1px solid rgba(217,138,74,0.4); color: #8a4a1d;
  border-bottom-left-radius: 6px;
}

/* 正在输入 */
.typing .bubble { padding: 14px 16px; }
.dots { display: inline-flex; gap: 5px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--sage);
  opacity: .5; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }

/* 输入区 */
.composer {
  display: flex; align-items: flex-end; gap: 10px; padding: 12px 14px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(74,157,142,0.12);
  background: rgba(255,255,255,0.75); backdrop-filter: blur(6px);
}
.composer textarea {
  flex: 1; resize: none; font-family: var(--font); font-size: 16px; line-height: 1.6;
  min-height: 112px; max-height: 200px; padding: 11px 16px; border: 1.5px solid rgba(74,157,142,0.22);
  border-radius: 16px; outline: none; background: #fff; color: var(--ink);
  transition: border-color .15s;
}
.composer textarea:focus { border-color: var(--sage); }
.btn-send {
  flex: none; width: 44px; height: 44px; border: none; border-radius: 50%; cursor: pointer;
  color: #fff; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--sage) 0%, var(--sage-d) 100%);
  box-shadow: 0 4px 12px rgba(60,130,118,0.30); transition: transform .08s, opacity .2s;
}
.btn-send:active { transform: scale(.93); }
.btn-send:disabled { opacity: .45; cursor: default; }

/* ---------- 结束页 ---------- */
.screen-end { justify-content: center; align-items: center; padding: 32px 26px; text-align: center; }
.end-card { animation: rise .5s ease both; max-width: 360px; }
.end-emoji { font-size: 48px; }
.end-card h2 { margin: 14px 0 8px; font-size: 22px; color: var(--sage-d); }
.end-card p { margin: 0 0 16px; color: var(--ink-soft); line-height: 1.85; font-size: 15px; }
.end-closing { color: var(--ink); }
.end-guide {
  background: var(--sage-l); color: var(--sage-d); font-weight: 500;
  border-radius: 14px; padding: 13px 16px; margin: 0 0 24px !important; line-height: 1.7;
}
.end-card .btn-primary { max-width: 240px; margin: 0 auto; }
.dev-result { margin-top: 26px; }
.btn-ghost { background: none; border: 1px dashed rgba(74,157,142,0.5); color: var(--sage-d);
  font-family: var(--font); font-size: 13px; padding: 8px 14px; border-radius: 10px; cursor: pointer; }
.dev-result pre {
  text-align: left; margin-top: 12px; background: #0f1f1d; color: #cfe9e2;
  padding: 14px; border-radius: 12px; font-size: 12px; line-height: 1.6; overflow-x: auto;
}

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ==========================================================================
   对话后主观体验评价（7 题 · 滚动长屏）
   横向 5 点 Likert，参考问卷星的移动端排版：每个选项 = 圆圈(数字) + 下方文字标签。
   ========================================================================== */
.screen-survey { padding: 0; }

.survey-scroll {
  /* .screen 是 flex column 容器；用 flex:1+min-height:0 而不是 height:100%，
     后者在部分浏览器的 flex 子项里会塌成内容高度、导致整页不滚动。 */
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 22px 16px 40px;
  scroll-behavior: smooth;
}

/* ---- 顶部说明 ---- */
.survey-intro {
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--radius);
  padding: 20px 20px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.survey-intro p {
  margin: 0 0 10px;
  font-size: 14.5px;
  line-height: 1.8;
  color: var(--ink);
}
.survey-intro p:last-child { margin-bottom: 0; }

/* ---- 单题卡片 ---- */
.q-card {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 18px;
  padding: 18px 16px 12px;
  margin-bottom: 14px;
  box-shadow: 0 4px 18px rgba(60, 90, 85, 0.07);
  border: 1.5px solid transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.q-card.answered { border-color: rgba(74, 157, 142, 0.35); }
.q-card.missing {
  border-color: var(--warn);
  box-shadow: 0 4px 18px rgba(217, 138, 74, 0.22);
}

.q-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.q-num {
  flex: none;
  min-width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--sage);
  color: #fff;
  font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.q-text { font-size: 15px; line-height: 1.65; color: var(--ink); }

/* ---- 横向 5 点量表 ---- */
.likert { display: flex; gap: 2px; }
.likert-opt {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 1px 10px;
  border: none;
  background: none;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.likert-opt:active { background: var(--sage-l); }
.likert-dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid #cfdedb;
  background: #fff;
  color: var(--ink-soft);
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.likert-lab {
  font-size: 11px;
  line-height: 1.3;
  color: var(--ink-soft);
  text-align: center;
  word-break: keep-all;
}
.likert-opt.on .likert-dot {
  background: var(--sage);
  border-color: var(--sage);
  color: #fff;
  transform: scale(1.08);
  box-shadow: 0 3px 10px rgba(74, 157, 142, 0.35);
}
.likert-opt.on .likert-lab { color: var(--sage-d); font-weight: 600; }

/* ---- 底部提交 ---- */
.survey-foot { margin-top: 22px; text-align: center; }
.survey-foot .btn-primary { width: 100%; }
.survey-err {
  margin: 0 0 10px;
  color: var(--warn);
  font-size: 13px;
  line-height: 1.6;
}
.survey-progress {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
}

/* 开发模式：跳到体验评价的浮标 */
.dev-jump {
  position: absolute;
  right: 10px; bottom: 96px;
  z-index: 20;
  padding: 7px 11px;
  font-size: 12px;
  font-family: inherit;
  color: var(--sage-d);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(74, 157, 142, 0.4);
  border-radius: 999px;
  box-shadow: 0 3px 12px rgba(60, 90, 85, 0.16);
  cursor: pointer;
}

/* 窄屏把标签再缩一点，保证 5 个并排不挤 */
@media (max-width: 380px) {
  .likert-dot { width: 27px; height: 27px; font-size: 12px; }
  .likert-lab { font-size: 10px; }
  .survey-scroll { padding-left: 12px; padding-right: 12px; }
}
