:root {
  --bg: #fdf7f1;
  --bg-soft: #fff;
  --ink: #2f2a26;
  --ink-soft: #6f665e;
  --line: #ece2d8;
  --brand: #e86a33;
  --brand-dark: #cf5827;
  --brand-soft: #ffe9de;
  --green: #2f9e6e;
  --green-soft: #e6f6ee;
  --warn: #c2410c;
  --warn-soft: #fff1e6;
  --danger: #b91c1c;
  --radius: 18px;
  --shadow: 0 8px 24px rgba(80, 50, 30, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(84px + var(--safe-bottom));
}

/* ------------------------------------------------------------------ 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px 10px;
  background: rgba(253, 247, 241, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; letter-spacing: 0.2px; }
.topbar .sub { font-size: 12px; color: var(--ink-soft); }
.topbar .spacer { flex: 1; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg-soft); border: 1px solid var(--line);
  font-size: 18px;
}
.icon-btn:active { transform: scale(0.95); }

/* ------------------------------------------------------------------ 成员 */
.members {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 14px 18px 6px;
  scrollbar-width: none;
}
.members::-webkit-scrollbar { display: none; }
.member {
  flex: 0 0 auto;
  width: 76px;
  text-align: center;
  padding: 6px 0;
  border-radius: var(--radius);
}
.member .avatar {
  width: 58px; height: 58px; border-radius: 50%;
  margin: 0 auto 4px;
  display: grid; place-items: center;
  color: #fff; font-size: 22px; font-weight: 700;
  border: 3px solid transparent;
  transition: border-color 0.15s;
  position: relative;
}
.member .name { font-size: 13px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member.active .avatar { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.member.active .name { color: var(--brand); font-weight: 700; }
.member .allergy-dot {
  position: absolute; right: -2px; top: -2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--danger); color: #fff; font-size: 10px;
  display: grid; place-items: center; border: 2px solid var(--bg);
}
.member.add .avatar { background: #fff; border: 2px dashed var(--line); color: var(--brand); font-weight: 400; font-size: 26px; }

/* ------------------------------------------------------------------ 主区 */
main { flex: 1; padding: 0 18px; }
.section { margin: 14px 0; }
.section-title { display: flex; align-items: center; gap: 8px; margin: 18px 0 10px; }
.section-title h2 { font-size: 15px; margin: 0; color: var(--ink-soft); font-weight: 600; letter-spacing: 0.3px; }
.section-title .spacer { flex: 1; }
.link-btn { font-size: 13px; color: var(--brand); }

/* ------------------------------------------------------------------ 录音主按钮 */
.record {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0 6px;
}
.mic {
  width: 152px; height: 152px; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #ff9261, var(--brand) 62%, var(--brand-dark));
  color: #fff;
  box-shadow: 0 14px 30px rgba(232, 106, 51, 0.34);
  display: grid; place-items: center;
  transition: transform 0.12s ease, box-shadow 0.12s;
  user-select: none;
  touch-action: none;
}
.mic svg { width: 62px; height: 62px; }
.mic.recording {
  transform: scale(1.05);
  animation: pulse 1.4s infinite;
  box-shadow: 0 0 0 12px rgba(232, 106, 51, 0.14), 0 14px 30px rgba(232, 106, 51, 0.4);
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(232, 106, 51, 0.34), 0 14px 30px rgba(232, 106, 51, 0.4); }
  70% { box-shadow: 0 0 0 26px rgba(232, 106, 51, 0), 0 14px 30px rgba(232, 106, 51, 0.4); }
  100% { box-shadow: 0 0 0 0 rgba(232, 106, 51, 0), 0 14px 30px rgba(232, 106, 51, 0.4); }
}
.mic-hint { margin-top: 12px; font-size: 15px; color: var(--ink-soft); }
.mic-hint strong { color: var(--brand); }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--brand); }

.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.quick {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 8px; display: grid; gap: 4px; place-items: center;
  font-size: 13px; color: var(--ink-soft); box-shadow: var(--shadow);
}
.quick span.emoji { font-size: 20px; }
.quick:active { transform: scale(0.97); }

/* ------------------------------------------------------------------ 时间线 */
.event-card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.event-card .row1 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.event-card .date { font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.event-card .tag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-dark);
}
.event-card .tag.visit { background: #e8f1ff; color: #1d4ed8; }
.event-card .tag.manual { background: #f1f1ef; color: var(--ink-soft); }
.event-card .tag.attention { background: var(--danger); color: #fff; }
.event-card .summary { font-size: 15px; }
.event-card .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: #f7f1ea; color: var(--ink-soft); border: 1px solid var(--line);
}
.chip.attention { background: var(--warn-soft); color: var(--warn); border-color: #f7d3b8; }
.event-card .foot { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--ink-soft); }
.empty {
  text-align: center; color: var(--ink-soft); font-size: 14px;
  padding: 26px 18px; border: 1px dashed var(--line); border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.6);
}

/* ------------------------------------------------------------------ 底部导航 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar .inner { display: flex; width: 100%; max-width: 560px; }
.tab {
  flex: 1; display: grid; place-items: center; gap: 2px;
  padding: 6px 0; border-radius: 12px; font-size: 11px; color: var(--ink-soft);
}
.tab .emoji { font-size: 20px; }
.tab.active { color: var(--brand); font-weight: 700; background: var(--brand-soft); }

/* ------------------------------------------------------------------ 弹层/卡片 */
.sheet-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(40, 28, 20, 0.42);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(20px + var(--safe-bottom));
  animation: rise 0.2s ease;
}
@keyframes rise { from { transform: translateY(18px); } to { transform: translateY(0); } }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.sheet-head h2 { font-size: 18px; margin: 0; flex: 1; }
.sheet-sub { font-size: 13px; color: var(--ink-soft); margin: 0 0 14px; }

.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 5px; }
.field input[type="text"], .field input[type="number"], .field input[type="date"],
.field input[type="datetime-local"], .field input[type="password"], .field textarea, .field select {
  width: 100%; padding: 12px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg-soft);
  font-size: 16px;
}
.field textarea { min-height: 84px; resize: vertical; }
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; }
.med-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.med-row input[type="text"] {
  flex: 1 1 0; min-width: 0; width: auto !important;
  padding: 11px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg-soft); font-size: 16px;
}
.med-row input[type="text"]:first-child { flex: 2 1 0; }
.med-row .icon-btn { flex: 0 0 auto; }

.btn {
  display: block; width: 100%; padding: 15px; border-radius: 14px;
  font-size: 17px; font-weight: 700; text-align: center;
  background: var(--brand); color: #fff;
  box-shadow: 0 8px 18px rgba(232, 106, 51, 0.25);
}
.btn:active { transform: scale(0.99); }
.btn.ghost { background: var(--bg-soft); color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn.subtle { background: var(--brand-soft); color: var(--brand-dark); box-shadow: none; }
.btn.small { padding: 10px 14px; font-size: 14px; width: auto; display: inline-block; }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #f3d0d0; box-shadow: none; }
.btn-row { display: flex; gap: 10px; margin-top: 10px; }
/* 弹层里主操作按钮吸底，避免要滚到最底部才能确认 */
.sheet > .btn-row {
  position: sticky;
  bottom: calc(-20px - var(--safe-bottom));
  margin: 6px -18px 0;
  padding: 10px 18px calc(14px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 72%, rgba(253, 247, 241, 0.86));
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
}
.btn-row .btn { flex: 1; }
.btn[disabled] { opacity: 0.55; }

.notice {
  border-radius: 14px; padding: 12px 14px; font-size: 14px;
  margin-bottom: 12px; border: 1px solid transparent;
}
.notice.info { background: #eef5ff; color: #1d4ed8; border-color: #d6e4ff; }
.notice.warn { background: var(--warn-soft); color: var(--warn); border-color: #f7d3b8; }
.notice.danger { background: #fdecec; color: var(--danger); border-color: #f6c9c9; }
.notice.ok { background: var(--green-soft); color: var(--green); border-color: #c7ecda; }

.pill-tabs { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; }
.pill {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px; font-size: 13px;
  background: var(--bg-soft); border: 1px solid var(--line); color: var(--ink-soft);
}
.pill.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(47, 42, 38, 0.94); color: #fff;
  padding: 11px 18px; border-radius: 999px; font-size: 14px;
  z-index: 100; max-width: 88vw; text-align: center;
  animation: fade 0.15s ease;
}
.toast.error { background: var(--danger); }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.45); border-top-color: #fff;
  animation: spin 0.8s linear infinite; display: inline-block; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ OCR 对照 */
.compare { display: grid; grid-template-columns: 1fr; gap: 12px; }
.compare img {
  width: 100%; border-radius: 14px; border: 1px solid var(--line); background: #fff;
  max-height: 260px; object-fit: contain;
}
.ocr-text {
  font-size: 13px; white-space: pre-wrap; background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px;
  max-height: 220px; overflow: auto; color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ------------------------------------------------------------------ 问答 */
.answer-card { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.answer-card h3 { margin: 0 0 8px; font-size: 16px; }
.answer-body { font-size: 15.5px; white-space: pre-wrap; }
.citation {
  display: block; width: 100%; text-align: left;
  border: 1px solid var(--line); border-radius: 12px; background: #fffaf6;
  padding: 10px 12px; margin-top: 8px; font-size: 13.5px; color: var(--ink-soft);
}
.citation strong { color: var(--ink); font-weight: 600; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.example { font-size: 13px; padding: 7px 12px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); }

.muted { color: var(--ink-soft); font-size: 13px; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------------ 登录页 */
.login-wrap {
  max-width: 420px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: center; padding: 28px 22px;
}
.login-logo {
  width: 84px; height: 84px; border-radius: 26px; margin: 0 auto 16px;
  background: radial-gradient(circle at 30% 25%, #ff9261, var(--brand) 65%);
  display: grid; place-items: center; color: #fff; font-size: 40px;
  box-shadow: 0 12px 24px rgba(232, 106, 51, 0.3);
}
.login-wrap h1 { text-align: center; font-size: 23px; margin: 0 0 4px; }
.login-wrap .slogan { text-align: center; color: var(--ink-soft); font-size: 14px; margin: 0 0 26px; }
.login-card { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 20px; padding: 20px; box-shadow: var(--shadow); }
