:root {
  --bg: #f4f6f9;
  --card-bg: #ffffff;
  --primary: #00b894;
  --primary-dim: rgba(0,184,148,0.12);
  --text: #1a2332;
  --text-dim: #5a6488;
  --text-muted: #8a94a8;
  --border: rgba(0,0,0,0.08);
  --radius: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.app-wrapper {
  max-width: 480px; margin: 0 auto;
  display: flex; flex-direction: column; min-height: 100vh;
}
.main-content { flex: 1; overflow-y: auto; padding: 0 16px 80px; }
.main-content::-webkit-scrollbar { display: none; }

.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: flex; background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px); border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 100;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  text-decoration: none; color: var(--text-muted); font-size: 11px;
  padding: 4px 0; transition: color .2s;
}
.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 22px; margin-bottom: 2px; }

.container { padding: 0 16px 80px; }
.card {
  background: var(--card-bg); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 16px; margin-bottom: 12px;
}
.btn-primary {
  display: inline-block; padding: 10px 24px; border-radius: 10px;
  border: none; font-size: 15px; font-weight: bold; cursor: pointer;
  background: linear-gradient(135deg, #00d4aa, #00b894); color: #fff;
  text-align: center;
}
.btn-secondary {
  display: inline-block; padding: 10px 24px; border-radius: 10px;
  border: 1px solid var(--border); font-size: 15px; cursor: pointer;
  background: transparent; color: var(--text-dim); text-align: center;
}
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.tag {
  display: inline-block; padding: 6px 14px; border-radius: 16px;
  background: rgba(0,0,0,0.05); color: var(--text-dim);
  font-size: 13px; cursor: pointer; transition: all .2s;
}
.tag.active { background: var(--primary-dim); color: var(--primary); }

.empty-state { text-align: center; padding: 40px 0; color: var(--text-dim); font-size: 14px; }
input, textarea {
  outline: none;
}
input:focus, textarea:focus { border-color: var(--primary) !important; }

.spinner {
  width: 20px; height: 20px; border: 2px solid var(--primary-dim);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.fade-in { animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── 聊天页面 ── */
.chat-container {
  display: flex; flex-direction: column;
  height: calc(100vh - 66px);
}
.msg-list { padding: 0; }
.msg-row { display: flex; margin-bottom: 14px; }
.msg-right { justify-content: flex-end; }
.msg-left { justify-content: flex-start; }
.msg-bubble {
  max-width: 85%; padding: 10px 14px;
  border-radius: 16px; font-size: 14px; line-height: 1.6;
  word-break: break-word;
}
.msg-right .msg-bubble {
  background: var(--primary-dim); color: var(--text);
  border-bottom-right-radius: 4px;
}
.msg-left .msg-bubble {
  background: rgba(0,0,0,0.05); color: var(--text);
  border-bottom-left-radius: 4px;
}
.bubble-pending { opacity: 0.7; }

/* ── 选择框 / 下拉菜单 ── */
select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px; cursor: pointer;
}
select:focus { border-color: var(--primary) !important; }

/* ── 按钮状态增强 ── */
.btn-primary:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.btn-secondary:hover:not(:disabled) { background: rgba(0,0,0,0.04); }
.btn-small {
  display: inline-block; padding: 6px 14px; border-radius: 8px;
  border: none; font-size: 13px; cursor: pointer;
  background: var(--primary-dim); color: var(--primary);
  text-align: center;
}

/* ── 滚动条美化 ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 2px; }

/* ── 诊断页面特殊 ── */
.ans-step { margin: 18px 0 10px; }

/* ── 输入框底部安全区 ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav { padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
}

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal-content {
  background: #ffffff; border-radius: 16px; padding: 24px;
  width: 85%; max-width: 360px;
}
