/* ADRAM 皮宝康复助手 - 共享样式 (移动优先, 桌面自适应) */
:root {
  --primary: #2a9d8f;
  --primary-dark: #21867a;
  --primary-light: #e6f4f2;
  --accent: #e76f51;
  --warn: #e9c46a;
  --bg: #f4f7f6;
  --card: #ffffff;
  --text: #26302e;
  --muted: #7d8a87;
  --line: #e3eae8;
  --danger: #d95555;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(38, 78, 72, .08);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 15px; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; border: none; }
input, select, textarea { font-family: inherit; font-size: 1rem; }
img { max-width: 100%; }

/* 应用外壳: 手机全屏, 桌面居中成手机样式卡片 */
.shell { max-width: 560px; margin: 0 auto; min-height: 100vh; background: var(--bg); position: relative; }
@media (min-width: 700px) {
  body.patient-body { background: linear-gradient(135deg, #d8ece9, #eef3f2); }
  .shell { box-shadow: 0 0 40px rgba(0,0,0,.12); min-height: 100vh; }
}
/* 医生/管理员宽布局 */
.wide { max-width: 1100px; margin: 0 auto; padding: 16px; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--primary); color: #fff;
  padding: 14px 18px; display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow);
}
.topbar h1 { font-size: 1.1rem; font-weight: 600; flex: 1; }
.topbar .sub { font-size: .78rem; opacity: .85; }

.page { padding: 14px 14px 90px; }
.wide .page { padding-bottom: 20px; }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.card h3 { font-size: 1rem; margin-bottom: 10px; color: var(--primary-dark); }
.card .hint { color: var(--muted); font-size: .85rem; }

.btn {
  display: inline-block; background: var(--primary); color: #fff;
  border-radius: 10px; padding: 12px 18px; font-size: 1rem;
  transition: opacity .15s; text-align: center;
}
.btn:active { opacity: .8; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--primary-light); color: var(--primary-dark); }
.btn.warn { background: var(--accent); }
.btn.small { padding: 7px 12px; font-size: .85rem; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: .88rem; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field textarea { min-height: 80px; resize: vertical; }

.seg { display: flex; background: var(--primary-light); border-radius: 10px; padding: 4px; margin-bottom: 16px; }
.seg button { flex: 1; padding: 10px; border-radius: 8px; background: transparent; color: var(--primary-dark); font-size: .95rem; }
.seg button.on { background: var(--primary); color: #fff; }

/* 底部导航 */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  max-width: 560px; margin: 0 auto;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.tabbar button { flex: 1; background: none; color: var(--muted); font-size: .72rem; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tabbar button .ico { font-size: 1.35rem; line-height: 1; }
.tabbar button.on { color: var(--primary); font-weight: 600; }

/* 弹窗 */
.mask {
  position: fixed; inset: 0; background: rgba(20, 40, 37, .5); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 480px;
  max-height: 82vh; display: flex; flex-direction: column; overflow: hidden;
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
.modal .m-head { padding: 14px 16px; background: var(--primary-light); display: flex; align-items: center; }
.modal .m-head b { flex: 1; color: var(--primary-dark); }
.modal .m-close { background: none; font-size: 1.3rem; color: var(--muted); padding: 0 4px; }
.modal .m-body { padding: 16px; overflow-y: auto; white-space: pre-wrap; line-height: 1.65; font-size: .95rem; }

/* 首页功能宫格 */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 14px; text-align: center; cursor: pointer; transition: transform .12s;
}
.tile:active { transform: scale(.96); }
.tile .ico { font-size: 1.9rem; }
.tile .t { font-weight: 600; margin-top: 6px; font-size: .95rem; }
.tile .d { color: var(--muted); font-size: .75rem; margin-top: 3px; }

.hero {
  background: linear-gradient(135deg, var(--primary), #48b8a9);
  color: #fff; border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}
.hero b { font-size: 1.15rem; }
.hero p { font-size: .85rem; opacity: .92; margin-top: 6px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .75rem; }
.badge.mild { background: #dcf1e3; color: #1d7a43; }
.badge.moderate { background: #fdf0d5; color: #a26b00; }
.badge.severe { background: #fbdcdc; color: #b02a2a; }

/* 量表 */
.level-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.level-opt {
  border: 2px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer;
  text-align: center; background: #fff;
}
.level-opt img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.level-opt .lv { font-size: .72rem; padding: 5px 2px; color: var(--muted); }
.level-opt.on { border-color: var(--primary); }
.level-opt.on .lv { background: var(--primary); color: #fff; }
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input[type=range] { flex: 1; accent-color: var(--primary); }
.slider-val { min-width: 40px; text-align: center; font-weight: 700; color: var(--primary-dark); font-size: 1.2rem; }

.bodymap-wrap { display: flex; gap: 10px; justify-content: center; }
.bodymap-wrap svg { width: 46%; max-width: 170px; height: auto; }
.bm-region { fill: #dfe9e7; stroke: #b7c8c5; stroke-width: 1.5; cursor: pointer; transition: fill .15s; }
.bm-region.half { fill: #7fd0c5; }
.bm-region.full { fill: var(--primary); }
.bm-label { font-size: 9px; fill: #6a7a77; pointer-events: none; text-anchor: middle; }

.score-big { text-align: center; padding: 10px 0; }
.score-big .n { font-size: 3rem; font-weight: 800; color: var(--primary-dark); }
.score-big .g { margin-top: 4px; }

.steps { display: flex; gap: 6px; margin-bottom: 14px; }
.steps .st { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.steps .st.on { background: var(--primary); }

/* 聊天 */
.chat-box { display: flex; flex-direction: column; gap: 10px; max-height: 46vh; overflow-y: auto; padding: 4px 0; }
.chat-msg { max-width: 82%; padding: 10px 13px; border-radius: 14px; font-size: .92rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.chat-msg.me { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.other { align-self: flex-start; background: #fff; box-shadow: var(--shadow); border-bottom-left-radius: 4px; }
.chat-msg .tm { display: block; font-size: .68rem; opacity: .6; margin-top: 4px; }
.chat-input { display: flex; gap: 8px; margin-top: 10px; }
.chat-input input, .chat-input textarea { flex: 1; padding: 11px; border: 1px solid var(--line); border-radius: 10px; outline: none; }

/* 列表 */
.list-item { padding: 12px 2px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; cursor: pointer; }
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .t { font-weight: 600; font-size: .95rem; }
.list-item .d { color: var(--muted); font-size: .8rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; }

/* 表格 (医生/管理员) */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; padding: 10px 8px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 8px; border-bottom: 1px solid var(--line); }
.tbl tr:hover td { background: var(--primary-light); }

.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: rgba(30, 45, 42, .92); color: #fff; padding: 10px 20px; border-radius: 10px;
  font-size: .9rem; max-width: 86vw; text-align: center;
}
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -3px; }
.spin.dark { border-color: rgba(42,157,143,.3); border-top-color: var(--primary); }
@keyframes sp { to { transform: rotate(360deg); } }

.disclaimer { color: var(--muted); font-size: .75rem; text-align: center; padding: 14px 20px 6px; line-height: 1.5; }

/* 网站底部备案信息 (工信部要求: 首页底部展示且可点击跳转) */
.beian { color: var(--muted); font-size: .72rem; text-align: center; padding: 8px 20px 16px; line-height: 1.8; }
.beian a { color: var(--muted); text-decoration: none; }
.beian a:hover { text-decoration: underline; }
.beian .sep { margin: 0 8px; opacity: .5; }
.beian img { height: 14px; vertical-align: -2px; margin-right: 3px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mb8 { margin-bottom: 8px; }
.row { display: flex; gap: 10px; align-items: center; }
.row .grow { flex: 1; }
.hidden { display: none !important; }

/* 登录页 */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 26px; max-width: 460px; margin: 0 auto; }
.login-logo { text-align: center; margin-bottom: 26px; }
.login-logo .ico { font-size: 3.2rem; }
.login-logo h1 { font-size: 1.5rem; color: var(--primary-dark); margin-top: 8px; }
.login-logo p { color: var(--muted); font-size: .85rem; margin-top: 4px; }

/* 趋势图 */
.chart-svg { width: 100%; height: auto; }

/* ============ 长者模式: 整体放大 + 简化布局 ============ */
body.elder .shell { zoom: 1.22; }
body.elder .grid2 { grid-template-columns: 1fr; }
body.elder .tile { display: flex; align-items: center; gap: 16px; text-align: left; padding: 18px 16px; }
body.elder .tile .ico { font-size: 2.3rem; }
body.elder .tile .t { font-size: 1.2rem; margin-top: 0; }
body.elder .tile .d { font-size: .95rem; }
body.elder .tabbar button { font-size: .95rem; font-weight: 600; }
body.elder .tabbar button .ico { font-size: 1.75rem; }
body.elder .btn { padding: 15px 20px; font-size: 1.12rem; }
body.elder .btn.small { padding: 10px 15px; font-size: 1rem; }
body.elder .field input, body.elder .field select, body.elder .field textarea { padding: 15px; font-size: 1.1rem; }
body.elder .field label { font-size: 1rem; }
body.elder .modal .m-body { font-size: 1.12rem; line-height: 1.85; }
body.elder .list-item .t { font-size: 1.12rem; }
body.elder .list-item .d { font-size: .95rem; }
body.elder .chat-msg { font-size: 1.08rem; max-width: 88%; }
body.elder .hint, body.elder .card .hint { font-size: 1rem; }
body.elder .level-opt .lv { font-size: .85rem; padding: 7px 2px; }
body.elder .slider-val { font-size: 1.5rem; min-width: 50px; }
body.elder .hero b { font-size: 1.35rem; }
body.elder .hero p { font-size: 1rem; }
body.elder h3 { font-size: 1.15rem; }

/* 长者模式选择弹窗的大按钮 */
.elder-choice-btn { display: block; width: 100%; padding: 20px; border-radius: 14px; font-size: 1.2rem; font-weight: 600; margin-bottom: 12px; text-align: center; }

/* 照片九宫格 */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-grid .ph { position: relative; border-radius: 10px; overflow: hidden; aspect-ratio: 1; cursor: pointer; }
.photo-grid .ph img { width: 100%; height: 100%; object-fit: cover; }
.photo-grid .ph .cap { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,.45); color: #fff; font-size: .68rem; padding: 3px 6px; }
