:root {
  --teal-900: #063f3d;
  --teal-700: #0b6f6b;
  --teal-600: #0e9f9a;
  --teal-500: #14b8a6;
  --teal-100: #d8f3ef;
  --teal-050: #f0fbf9;
  --blue-600: #1d6fd8;
  --blue-100: #e3eefc;
  --text: #14302f;
  --text-2: #587573;
  --line: #d5eae7;
  --bg: #f4fbfa;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --header-h: 88px;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: linear-gradient(180deg, var(--teal-050) 0%, var(--bg) 40%, #eef7fb 100%);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

button, input { font-family: inherit; font-size: inherit; }

/* hidden 属性优先级最高，防止被 display:flex 覆盖 */
[hidden] { display: none !important; }

/* ---------- 顶部合规声明（固定、不可关闭） ---------- */
.app-header {
  flex: 0 0 auto;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
  background: linear-gradient(135deg, var(--teal-600) 0%, var(--blue-600) 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(11, 111, 107, 0.18);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  margin-bottom: 6px;
}

.brand-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #7ef2e0;
  box-shadow: 0 0 0 3px rgba(126, 242, 224, 0.25);
}

.compliance-banner {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
}

.warn-ico { width: 15px; height: 15px; flex: 0 0 auto; fill: #ffe27a; }

/* ---------- 固定回答框架提示条 ---------- */
.frame-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 12px;
  background: rgba(216, 243, 239, 0.75);
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--teal-700);
  z-index: 15;
}

.frame-title { font-weight: 600; opacity: 0.85; flex: 0 0 auto; }

.frame-tags { display: flex; gap: 5px; flex-wrap: wrap; }

.frame-tag {
  padding: 1px 7px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #bfe5df;
  color: var(--teal-700);
  white-space: nowrap;
}

/* ---------- 聊天区 ---------- */
.chat {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px 8px;
  scroll-behavior: smooth;
}

.msg { display: flex; margin-bottom: 12px; }
.msg-user { justify-content: flex-end; }
.msg-ai { justify-content: flex-start; }

.bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 14px;
  word-break: break-word;
  white-space: pre-wrap;
  font-size: 15px;
  animation: pop 0.18s ease-out;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.msg-user .bubble {
  background: linear-gradient(135deg, var(--teal-500), var(--blue-600));
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* 结构化长回答给更宽的阅读区，短句仍按 82% 收敛 */
.msg-ai .bubble {
  max-width: 90%;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(20, 184, 166, 0.06);
}

.msg-ai .bubble.is-error {
  background: #fff5f5;
  border-color: #ffd6d4;
  color: #a3302c;
}

.msg-ai .bubble.is-notice {
  background: var(--teal-100);
  border-color: #b7e6de;
  color: var(--teal-900);
  font-weight: 500;
}

.disclaimer {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-2);
}

.msg-ai .bubble.is-error .disclaimer { border-top-color: rgba(0, 0, 0, 0.08); }

/* 四维度小标题：由 app.js 在渲染时把【xxx】包成 .sec-title */
.sec-title {
  display: block;
  margin: 9px 0 3px;
  font-weight: 700;
  color: var(--teal-700);
  font-size: 14px;
}

.sec-title:first-child { margin-top: 0; }

.sec-title::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 12px;
  margin-right: 6px;
  border-radius: 2px;
  vertical-align: -1px;
  background: linear-gradient(180deg, var(--teal-500), var(--blue-600));
}

/* 打字光标 */
.caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--teal-600);
  animation: blink 0.9s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.thinking { display: inline-flex; gap: 4px; align-items: center; height: 1em; }
.thinking i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--teal-500);
  animation: bounce 1s infinite ease-in-out;
}
.thinking i:nth-child(2) { animation-delay: 0.15s; }
.thinking i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; } 40% { transform: scale(1); opacity: 1; } }

/* ---------- 底部小字 ---------- */
.ai-footnote {
  flex: 0 0 auto;
  text-align: center;
  font-size: 11.5px;
  color: #8aa5a3;
  padding: 2px 0 4px;
  letter-spacing: 0.2px;
}

/* ---------- 输入区 ---------- */
.composer {
  flex: 0 0 auto;
  padding: 6px 12px calc(8px + var(--safe-b));
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.text-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }

.text-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--teal-050);
  color: var(--text);
  font-size: 15px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.text-input:focus { border-color: var(--teal-500); background: #fff; }
.text-input::placeholder { color: #9ab7b5; }

.send-btn {
  flex: 0 0 auto;
  height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 20px;
  color: #fff;
  font-weight: 600;
  background: linear-gradient(135deg, var(--teal-500), var(--blue-600));
  opacity: 0.45;
  transition: opacity 0.15s;
}
.send-btn:disabled { opacity: 0.35; }
.send-btn:not(:disabled):active { transform: scale(0.97); }

/* ---------- 麦克风按钮 ---------- */
.mic-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 50px;
  border: none;
  border-radius: 25px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--teal-500) 0%, var(--blue-600) 100%);
  box-shadow: 0 6px 16px rgba(20, 184, 166, 0.28);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}

.mic-btn svg { width: 22px; height: 22px; fill: #fff; pointer-events: none; }
.mic-btn .mic-label { pointer-events: none; }

/* 按下录音态：变色 */
.mic-btn.is-active {
  background: linear-gradient(135deg, #0f8f8a 0%, #155fb8 100%);
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(14, 159, 154, 0.35) inset, 0 0 0 3px rgba(20, 184, 166, 0.18);
}
.mic-btn.is-cancel {
  background: linear-gradient(135deg, #d9433f, #b5322f);
  box-shadow: 0 0 0 3px rgba(226, 65, 61, 0.18);
}
.mic-btn:disabled { opacity: 0.5; box-shadow: none; }

/* ---------- 录音浮层 ---------- */
.record-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 63, 61, 0.22);
  pointer-events: none;
}

.record-panel {
  width: 200px;
  padding: 20px 16px 18px;
  border-radius: 18px;
  background: rgba(9, 60, 58, 0.94);
  color: #fff;
  text-align: center;
  box-shadow: 0 12px 32px rgba(6, 63, 61, 0.35);
  transition: background 0.15s, transform 0.15s;
}

.record-panel.is-cancel { background: rgba(180, 46, 42, 0.95); }

.wave { display: flex; justify-content: center; align-items: flex-end; gap: 4px; height: 34px; margin-bottom: 10px; }
.wave i {
  display: block;
  width: 5px;
  height: 10px;
  border-radius: 3px;
  background: #7ef2e0;
  animation: wave 0.9s infinite ease-in-out;
}
.wave i:nth-child(2) { animation-delay: 0.1s; }
.wave i:nth-child(3) { animation-delay: 0.2s; }
.wave i:nth-child(4) { animation-delay: 0.3s; }
.wave i:nth-child(5) { animation-delay: 0.4s; }
@keyframes wave { 0%, 100% { height: 8px; opacity: 0.6; } 50% { height: 30px; opacity: 1; } }

.record-timer { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.record-tip { margin-top: 4px; font-size: 12.5px; opacity: 0.85; }
.record-tip.is-warn { color: #ffe27a; }
.cancel-hint { display: none; margin-top: 4px; font-size: 12.5px; font-weight: 600; color: #ffd9d7; }
.record-panel.is-cancel .record-tip { display: none; }
.record-panel.is-cancel .cancel-hint { display: block; }


/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(120px + var(--safe-b));
  transform: translateX(-50%);
  max-width: 80vw;
  padding: 9px 16px;
  border-radius: 10px;
  background: rgba(9, 60, 58, 0.9);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.45;
  text-align: center;
  z-index: 80;
  pointer-events: none;
  animation: pop 0.18s ease-out;
}
.toast[hidden] { display: none; }

/* 小屏适配 */
@media (max-height: 600px) {
  .mic-btn { height: 44px; border-radius: 22px; font-size: 15px; }
  .record-panel { padding: 14px 14px 12px; }
  .wave { height: 26px; }
}
