/* ============================================================
   糖尿病预治智能助手 — 移动端设计系统
   配色严格对齐项目原型 (图8)：主色 #4A90E2 / 文字 #333 / 次要 #666 / 说明 #999
   字体走系统中文字体栈，规避 Inter/Roboto 默认 AI 风
   ============================================================ */

:root {
    --primary: #2f7fe4;
    --primary-dark: #1f63bf;
    --primary-light: #eaf2fd;
    --primary-grad: linear-gradient(135deg, #4a90e2 0%, #2f6fd0 100%);
    --success: #21b673;
    --success-light: #e8f8f0;
    --warning: #f5a623;
    --danger: #e8543e;
    --danger-light: #fdecea;
    --text: #2b3038;
    --text-2: #646b76;
    --text-3: #9aa0a8;
    --line: #edf0f3;
    --bg: #f4f6f9;
    --card: #ffffff;
    --r-sm: 8px;
    --r: 14px;
    --r-lg: 20px;
    --shadow: 0 2px 12px rgba(31, 45, 71, .06);
    --shadow-lg: 0 8px 28px rgba(31, 45, 71, .12);
    --app-max: 480px;
    --header-h: 52px;
    --tabbar-h: 58px;
    --pad: 16px;
    --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
            "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
    font-family: var(--font); color: var(--text); background: #e9edf2;
    line-height: 1.55; font-size: 15px; -webkit-font-smoothing: antialiased;
}
.app {
    position: relative; max-width: var(--app-max); min-height: 100vh;
    margin: 0 auto; background: var(--bg); box-shadow: 0 0 40px rgba(0, 0, 0, .08); overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: 15px; outline: none; }
ul { list-style: none; }

/* ---------- 顶部导航 ---------- */
.appbar {
    position: sticky; top: 0; z-index: 40; height: var(--header-h);
    display: flex; align-items: center; justify-content: center;
    background: var(--card); border-bottom: 1px solid var(--line); padding: 0 var(--pad);
}
.appbar__title { font-size: 17px; font-weight: 600; color: var(--text); }
.appbar__left, .appbar__right { position: absolute; top: 0; height: var(--header-h); display: flex; align-items: center; gap: 10px; }
.appbar__left { left: var(--pad); }
.appbar__right { right: var(--pad); }
.appbar__btn { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--text-2); }
.appbar__btn:active { background: var(--bg); }
.appbar--brand { justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; color: var(--primary); }
.brand svg { width: 24px; height: 24px; }

/* ---------- 页面滚动区 ---------- */
.page { padding: var(--pad); padding-bottom: calc(var(--tabbar-h) + 24px); min-height: calc(100vh - var(--header-h)); }
.page--chat { padding: 0; padding-bottom: 0; display: flex; flex-direction: column; height: calc(100vh - var(--header-h)); }

/* ---------- 区块标题 ---------- */
.section { margin-bottom: 22px; }
.section__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section__title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; color: var(--text); }
.section__title::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--primary); }
.section__more { font-size: 13px; color: var(--text-3); display: flex; align-items: center; gap: 2px; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 12px; }

/* ---------- 轮播 / 横幅 ---------- */
.banner { position: relative; border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); }
.banner__track { display: flex; transition: transform .45s cubic-bezier(.4,0,.2,1); }
.banner__slide { min-width: 100%; height: 158px; display: flex; align-items: center; }
.banner__dots { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
.banner__dot { width: 6px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.55); transition: width .3s; }
.banner__dot.is-active { width: 16px; background: #fff; }

/* ---------- 医师卡片 ---------- */
.hscroll { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.hscroll::-webkit-scrollbar { display: none; }
.doctor-card { flex: 0 0 138px; scroll-snap-align: start; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px 12px; text-align: center; }
.doctor-card__avatar { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 8px; overflow: hidden; border: 2px solid var(--primary-light); }
.doctor-card__name { font-weight: 700; font-size: 15px; }
.doctor-card__dept { font-size: 12px; color: var(--text-3); margin: 2px 0 10px; }
.doctor-card__btn { display: inline-block; font-size: 12px; color: var(--primary); border: 1px solid var(--primary); border-radius: 14px; padding: 4px 14px; }
.doctor-card__btn:active { background: var(--primary-light); }

/* ---------- 资讯列表项 ---------- */
.article { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.article:last-child { border-bottom: none; }
.article__thumb { flex: 0 0 84px; height: 64px; border-radius: var(--r-sm); overflow: hidden; background: var(--primary-light); }
.article__body { flex: 1; min-width: 0; }
.article__title { font-size: 14px; font-weight: 600; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.article__excerpt { font-size: 12px; color: var(--text-3); margin: 4px 0 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.article__meta { font-size: 11px; color: var(--text-3); display: flex; align-items: center; gap: 4px; }

/* ---------- 糖尿病类型网格 ---------- */
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.type-card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; }
.type-card__icon { width: 38px; height: 38px; border-radius: 10px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.type-card__name { font-weight: 700; font-size: 14px; }
.type-card__desc { font-size: 12px; color: var(--text-3); margin-top: 4px; line-height: 1.5; }

/* ---------- 底部 Tab Bar ---------- */
.tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 50; width: 100%; max-width: var(--app-max); height: var(--tabbar-h); display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0); }
.tabbar__item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-3); font-size: 11px; }
.tabbar__item svg { width: 23px; height: 23px; }
.tabbar__item.is-active { color: var(--primary); }

/* ---------- 按钮 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 46px; padding: 0 20px; border-radius: var(--r-sm); font-size: 15px; font-weight: 600; transition: opacity .15s, transform .1s; }
.btn:active { transform: scale(.98); }
.btn--block { display: flex; width: 100%; }
.btn--primary { background: var(--primary-grad); color: #fff; box-shadow: 0 6px 16px rgba(47,127,228,.28); }
.btn--dark { background: #1c2128; color: #fff; }
.btn--ghost { background: var(--card); color: var(--primary); border: 1px solid var(--primary); }
.btn--lg { height: 50px; font-size: 16px; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ---------- 表单 ---------- */
.form-card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 4px 16px; margin-bottom: 16px; }
.form-card__h { font-size: 16px; font-weight: 700; padding: 14px 0 10px; border-bottom: 1px dashed var(--line); margin-bottom: 4px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: none; }
.field__label { font-size: 14px; color: var(--text); flex-shrink: 0; }
.field__label .req { color: var(--danger); margin-left: 2px; }
.field__control { flex: 1; text-align: right; }
.field__control input[type=text], .field__control input[type=number], .field__control input[type=password], .field__control input[type=tel] { width: 100%; text-align: right; border: none; background: transparent; color: var(--text); }
.field--col { flex-direction: column; align-items: stretch; text-align: left; }
.field--col .field__control { text-align: left; }
.input-line { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 12px; background: #fafbfc; }
.input-line:focus { border-color: var(--primary); background: #fff; }
.radio-row, .check-col { display: flex; gap: 18px; }
.check-col { flex-direction: column; gap: 12px; align-items: flex-start; }
.radio, .checkbox { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-2); }
.radio input, .checkbox input { width: 17px; height: 17px; accent-color: var(--primary); }

/* ---------- 徽章 / 标签 ---------- */
.badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 12px; }
.badge--done { background: var(--success); color: #fff; }
.badge--soft { background: var(--primary-light); color: var(--primary); }
.tag { display: inline-block; font-size: 12px; color: var(--primary); background: var(--primary-light); border-radius: 10px; padding: 3px 10px; margin: 0 6px 6px 0; }

/* ---------- 方案/打卡卡片 ---------- */
.plan-head { background: var(--primary-grad); color: #fff; border-radius: var(--r); padding: 16px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.plan-head__t { font-size: 16px; font-weight: 700; }
.plan-head__s { font-size: 12px; opacity: .9; }
.plan-item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.plan-item:last-child { border-bottom: none; }
.plan-item__row { display: flex; justify-content: space-between; align-items: baseline; }
.plan-item__name { font-weight: 600; font-size: 14px; }
.plan-item__time { font-size: 12px; color: var(--text-3); }
.plan-item__desc { font-size: 13px; color: var(--text-2); margin-top: 4px; }

/* ---------- 聊天 ---------- */
.chat-doctor-bar { display: flex; align-items: center; gap: 10px; padding: 12px var(--pad); background: var(--card); border-bottom: 1px solid var(--line); }
.chat-doctor-bar__avatar { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; }
.chat-doctor-bar__name { font-weight: 700; font-size: 14px; }
.chat-doctor-bar__dept { font-size: 12px; color: var(--text-3); }
.dot-online { width: 7px; height: 7px; border-radius: 50%; background: var(--success); display: inline-block; }
.chat-body { flex: 1; overflow-y: auto; padding: 16px var(--pad); display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; gap: 8px; max-width: 86%; }
.msg__avatar { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 12px; color: #fff; }
.msg__bubble { padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.6; word-break: break-word; }
.msg--bot { align-self: flex-start; }
.msg--bot .msg__avatar { background: var(--primary); }
.msg--bot .msg__bubble { background: var(--card); color: var(--text); border-top-left-radius: 4px; box-shadow: var(--shadow); }
.msg--me { align-self: flex-end; flex-direction: row-reverse; }
.msg--me .msg__avatar { background: #f06292; }
.msg--me .msg__bubble { background: var(--primary); color: #fff; border-top-right-radius: 4px; }
.md p { margin: 0 0 8px; } .md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 6px 0 8px 18px; } .md li { margin: 2px 0; }
.md strong { font-weight: 700; }
.md h1, .md h2, .md h3, .md h4 { font-size: 14px; font-weight: 700; margin: 10px 0 6px; }
.md code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.msg--me .md code { background: rgba(255,255,255,.2); }
.thinking { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; overflow: hidden; background: #fafbfc; }
.thinking__head { font-size: 12px; color: var(--text-3); padding: 6px 10px; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.thinking__body { font-size: 12px; color: var(--text-3); padding: 0 10px 8px; line-height: 1.6; white-space: pre-wrap; max-height: 180px; overflow-y: auto; }
.thinking.is-collapsed .thinking__body { display: none; }
.thinking__caret { transition: transform .2s; } .thinking.is-collapsed .thinking__caret { transform: rotate(-90deg); }
.chat-input { display: flex; align-items: flex-end; gap: 8px; padding: 10px var(--pad); background: var(--card); border-top: 1px solid var(--line); }
.chat-input textarea { flex: 1; max-height: 96px; min-height: 40px; border: 1px solid var(--line); border-radius: 20px; padding: 9px 14px; resize: none; background: #fafbfc; line-height: 1.4; }
.chat-input textarea:focus { border-color: var(--primary); }
.chat-input__send { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; }
.chat-input__send[disabled] { opacity: .5; }
.quick-row { display: flex; gap: 8px; overflow-x: auto; padding: 10px var(--pad); background: var(--card); border-bottom: 1px solid var(--line); }
.quick-row::-webkit-scrollbar { display: none; }
.quick-chip { flex: 0 0 auto; font-size: 13px; color: var(--text-2); background: var(--bg); border-radius: 16px; padding: 6px 14px; }
.quick-chip:active { background: var(--primary-light); color: var(--primary); }

/* ---------- 风险评估结果 ---------- */
.result-hero { text-align: center; padding: 26px 16px; }
.result-hero__icon { width: 58px; height: 58px; margin: 0 auto 12px; color: var(--primary); }
.result-hero__type { font-size: 20px; font-weight: 700; }
.result-hero__sub { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.risk-pill { display: inline-block; padding: 4px 14px; border-radius: 14px; font-size: 13px; font-weight: 600; margin-top: 10px; }
.risk--low { background: var(--success-light); color: var(--success); }
.risk--mid { background: #fff5e6; color: var(--warning); }
.risk--high { background: var(--danger-light); color: var(--danger); }

/* ---------- 进度圆环 ---------- */
.ring { position: relative; width: 120px; height: 120px; margin: 4px auto 12px; }
.ring svg { transform: rotate(-90deg); }
.ring__val { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; color: var(--success); }

/* ---------- 日期选择条 ---------- */
.date-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.date-row::-webkit-scrollbar { display: none; }
.date-pill { flex: 0 0 auto; width: 48px; text-align: center; padding: 8px 0; border-radius: 10px; color: var(--text-2); }
.date-pill__d { font-size: 12px; } .date-pill__n { font-size: 16px; font-weight: 700; }
.date-pill.is-active { background: var(--primary); color: #fff; }

/* ---------- 认证 / 个人中心 ---------- */
.auth-tabs { display: flex; background: var(--bg); border-radius: var(--r-sm); padding: 4px; margin-bottom: 18px; }
.auth-tabs button { flex: 1; height: 38px; border-radius: 6px; font-size: 14px; font-weight: 600; color: var(--text-3); }
.auth-tabs button.is-active { background: var(--card); color: var(--primary); box-shadow: var(--shadow); }
.profile-hero { background: var(--primary-grad); color: #fff; border-radius: var(--r); padding: 20px; display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.profile-hero__avatar { width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,.25); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; }
.profile-hero__name { font-size: 18px; font-weight: 700; }
.profile-hero__sub { font-size: 12px; opacity: .9; }
.menu-list { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.menu-item { display: flex; align-items: center; gap: 12px; padding: 15px 16px; border-bottom: 1px solid var(--line); }
.menu-item:last-child { border-bottom: none; }
.menu-item__icon { width: 22px; height: 22px; color: var(--primary); }
.menu-item__label { flex: 1; font-size: 15px; }
.menu-item__arrow { color: var(--text-3); }

/* ---------- 通用 ---------- */
.text-2 { color: var(--text-2); } .text-3 { color: var(--text-3); }
.muted { color: var(--text-3); font-size: 12px; }
.center { text-align: center; }
.empty { text-align: center; color: var(--text-3); padding: 50px 20px; font-size: 14px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mb12 { margin-bottom: 12px; }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner--dark { border-color: var(--line); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }
.typing-cursor::after { content: "▋"; color: var(--primary); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.toast { position: fixed; left: 50%; top: 80px; transform: translateX(-50%); z-index: 9999; max-width: 80%; background: rgba(30,34,40,.92); color: #fff; font-size: 14px; padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow-lg); transition: opacity .3s; }
.toast--error { background: rgba(200,60,40,.95); }
.toast--success { background: rgba(33,182,115,.95); }
.overlay { position: fixed; inset: 0; z-index: 9000; background: rgba(255,255,255,.7); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; max-width: var(--app-max); left: 50%; transform: translateX(-50%); }
.overlay__text { font-size: 13px; color: var(--text-2); }
.sheet-mask { position: fixed; inset: 0; z-index: 8000; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: var(--app-max); background: var(--card); border-radius: 18px 18px 0 0; padding: 20px; max-height: 80vh; overflow-y: auto; animation: sheetUp .3s; }
@keyframes sheetUp { from { transform: translateY(100%); } }
.sheet__title { font-size: 17px; font-weight: 700; margin-bottom: 12px; }

/* ---------- 图标容器尺寸（覆盖默认 1.1em） ---------- */
.appbar__btn svg { width: 22px; height: 22px; }
.type-card__icon svg { width: 20px; height: 20px; }
.menu-item__icon svg { width: 20px; height: 20px; }
.result-hero__icon svg { width: 48px; height: 48px; }
.article__thumb svg { width: 28px; height: 28px; }
.chat-input__send svg { width: 20px; height: 20px; }
.msg__avatar svg { width: 19px; height: 19px; }
.badge svg { width: 13px; height: 13px; margin-right: 3px; }
.btn svg { width: 18px; height: 18px; }
