/* 家康记录 · 样式 */
:root {
  --bg: #eef4f2;
  --card: #ffffff;
  --ink: #0f2723;
  --muted: #5f7480;
  --line: #e3ebe9;
  --brand: #0f766e;
  --brand-dark: #0b5b55;
  --brand-soft: #e6f4f1;
  --warn: #a8540a;
  --warn-bg: #fdf1d8;
  --bad: #b3261e;
  --bad-bg: #fde8e6;
  --good: #14742f;
  --good-bg: #ddf5e3;
  --radius: 18px;
  --shadow: 0 2px 10px rgba(15, 39, 35, .06), 0 1px 2px rgba(15, 39, 35, .05);
}

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

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  background-image: radial-gradient(1200px 600px at 50% -10%, #dcefe9 0%, rgba(238, 244, 242, 0) 60%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

.app { max-width: 680px; margin: 0 auto; padding: 0 14px calc(28px + env(safe-area-inset-bottom)); }
.boot { padding: 80px 0; text-align: center; color: var(--muted); }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: .2px; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  margin: 0 -14px 14px; padding: 12px 14px calc(10px + env(safe-area-inset-top));
  background: rgba(238, 244, 242, .92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid rgba(15, 118, 110, .08);
}
.topbar .tb-left { flex: 1; min-width: 0; }
.topbar .tb-title { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .tb-sub { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #b6c4c1; display: inline-block; flex: none; }
.dot.on { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }
.dot.off { background: #cbd5cf; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; font-size: 19px; line-height: 1; display: grid; place-items: center;
  color: var(--ink); box-shadow: var(--shadow);
}
.icon-btn:active { transform: scale(.96); }

/* ---------------- 通用 ---------------- */
.screen { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.greet { font-size: 23px; font-weight: 700; margin: 4px 2px 2px; }
.date { color: var(--muted); font-size: 14px; margin: 0 2px 16px; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px; border: 1px solid rgba(15, 118, 110, .05);
}
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.sec-head h3 { font-size: 16.5px; }
.muted { color: var(--muted); font-size: 13.5px; }
.small { font-size: 13px; }
.spacer { flex: 1; }
hr.sep { border: 0; border-top: 1px dashed var(--line); margin: 14px 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 14px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 16px; font-weight: 600;
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(15, 118, 110, .22); }
.btn.primary:active { background: var(--brand-dark); }
.btn.big { min-height: 60px; font-size: 19px; border-radius: 16px; width: 100%; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--brand-soft); border-color: transparent; color: var(--brand-dark); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .55; pointer-events: none; }
.text-btn { background: none; border: 0; color: var(--brand); font-weight: 600; padding: 6px 4px; font-size: 14px; }

/* ---------------- 表单 ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13.5px; color: var(--muted); font-weight: 600; padding-left: 2px; }
.field .unit { color: var(--muted); font-size: 12px; font-weight: 400; }
input[type="number"], input[type="text"], input[type="password"], textarea {
  width: 100%; border: 1.5px solid var(--line); background: #fbfdfc;
  border-radius: 13px; padding: 13px 14px; font-size: 19px; font-weight: 600;
  outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
  color: var(--ink);
}
textarea { font-size: 17px; font-weight: 400; line-height: 1.6; min-height: 96px; resize: vertical; }
input:focus, textarea:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(15, 118, 110, .1); }
input::placeholder, textarea::placeholder { color: #a9b8b5; font-weight: 400; }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.field-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.field-row .grow { flex: 1; }
.field-row input[type="text"] { font-size: 16px; padding: 11px 12px; }

.form-group { margin-bottom: 18px; }
.form-group > .gt { font-size: 15px; font-weight: 700; margin-bottom: 9px; display: flex; align-items: center; gap: 6px; }
.form-group > .gt .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }

/* ---------------- 卡片/指标 ---------------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { background: #f7fbfa; border: 1px solid var(--line); border-radius: 14px; padding: 11px 13px; }
.tile .k { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.tile .v { font-size: 21px; font-weight: 700; letter-spacing: .2px; }
.tile .v small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.tile.tone-warn { background: var(--warn-bg); border-color: #f0d9a8; }
.tile.tone-warn .v { color: var(--warn); }
.tile.tone-bad { background: var(--bad-bg); border-color: #f3c9c4; }
.tile.tone-bad .v { color: var(--bad); }
.tile.tone-good { background: var(--good-bg); border-color: #c2e8cc; }
.tile.tone-good .v { color: var(--good); }

.bp-big { display: flex; align-items: baseline; gap: 6px; }
.bp-big .num { font-size: 34px; font-weight: 800; letter-spacing: -.5px; }
.bp-big .slash { font-size: 24px; color: #9fb2ad; }
.bp-big .unit { font-size: 13px; color: var(--muted); margin-left: 4px; }

.banner { border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; font-size: 14.5px; display: flex; gap: 9px; align-items: flex-start; }
.banner .bi { font-size: 18px; line-height: 1.2; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.good { background: var(--good-bg); color: var(--good); }
.banner strong { font-weight: 700; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--brand-soft); color: var(--brand-dark); }
.badge.red { background: var(--bad-bg); color: var(--bad); }

/* ---------------- 列表 ---------------- */
.list-item { padding: 11px 0; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; padding-top: 2px; }
.li-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.li-head .who { font-weight: 700; color: var(--brand-dark); font-size: 13px; }
.li-body { margin-top: 3px; font-size: 15px; }
.li-sub { margin-top: 4px; font-size: 13.5px; color: var(--muted); white-space: pre-wrap; }
.li-note { margin-top: 5px; padding: 8px 10px; background: #f7fbfa; border-radius: 10px; font-size: 14px; white-space: pre-wrap; color: #33463f; }
.del-btn { border: 0; background: none; color: #b0bfbb; font-size: 15px; padding: 4px 2px; }

.advice { border-radius: 14px; padding: 12px 14px; margin-bottom: 9px; background: var(--brand-soft); border-left: 4px solid var(--brand); }
.advice.unread { background: #fff8e6; border-left-color: #e0a008; }
.advice .a-head { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
.advice .a-text { font-size: 16.5px; line-height: 1.6; white-space: pre-wrap; }
.advice .a-head .from { font-weight: 700; color: var(--brand-dark); }

.empty { text-align: center; color: #94a8a3; font-size: 14px; padding: 16px 6px; }

/* ---------------- 今日状态 ---------------- */
.today { border-left: 5px solid var(--brand); padding-left: 9px; }
.today .t-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.today .t-time { color: var(--muted); font-size: 12.5px; }
.today .t-sum { font-size: 15px; color: #33463f; line-height: 1.7; }

/* ---------------- 图表 ---------------- */
.chart-wrap { position: relative; width: 100%; height: 170px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; font-size: 13.5px; color: var(--muted); font-weight: 600; white-space: nowrap;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------------- 语音 ---------------- */
.voice-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 9px 13px; font-size: 14px; font-weight: 600; color: var(--brand-dark); }
.voice-btn.rec { background: var(--bad); color: #fff; border-color: var(--bad); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(179, 38, 30, .35); } 50% { box-shadow: 0 0 0 8px rgba(179, 38, 30, 0); } }
.composer-actions { display: flex; gap: 8px; align-items: center; margin-top: 9px; }

/* ---------------- 欢迎页 ---------------- */
.setup { padding: calc(38px + env(safe-area-inset-top)) 4px 30px; }
.logo { width: 64px; height: 64px; border-radius: 20px; display: block; object-fit: cover; box-shadow: 0 10px 24px rgba(15, 118, 110, .28); margin-bottom: 16px; }
.setup h1 { font-size: 27px; line-height: 1.25; margin-bottom: 8px; }
.setup .lead { color: var(--muted); font-size: 15px; margin-bottom: 22px; }
.role-card {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.role-card .ic { width: 48px; height: 48px; border-radius: 14px; background: var(--brand-soft); display: grid; place-items: center; font-size: 24px; flex: none; }
.role-card .rc-t { font-weight: 700; font-size: 17px; }
.role-card .rc-d { font-size: 13px; color: var(--muted); margin-top: 2px; line-height: 1.45; }
.role-card .arrow { color: #b9c8c4; font-size: 20px; }
.setup .foot { margin-top: 22px; font-size: 12.5px; color: #8ea29d; text-align: center; line-height: 1.7; }

.auth-tabs { display: flex; gap: 6px; background: #e4eeeb; padding: 4px; border-radius: 14px; margin-bottom: 14px; }
.auth-tab { flex: 1; border: 0; background: none; padding: 11px 8px; border-radius: 11px; font-weight: 600; color: var(--muted); font-size: 15px; }
.auth-tab.active { background: #fff; color: var(--brand-dark); box-shadow: 0 1px 4px rgba(15, 39, 35, .1); }

.member-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 2px; border-top: 1px solid var(--line); font-size: 15px; }
.member-row:first-of-type { border-top: 0; }
.member-row .badge { flex: none; }

/* ---------------- 弹层 ---------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(15, 39, 35, .93); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14.5px; z-index: 90; max-width: 88vw; text-align: center; box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
  animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.sheet { position: fixed; inset: 0; z-index: 80; }
.sheet-mask { position: absolute; inset: 0; background: rgba(15, 39, 35, .38); animation: fade .18s; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; background: #fff;
  border-radius: 22px 22px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  max-width: 680px; margin: 0 auto; animation: sheet-up .22s ease-out;
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-panel h3 { font-size: 17px; margin-bottom: 12px; }
.sheet-close { position: absolute; right: 14px; top: 12px; }
.sheet-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 2px; border-top: 1px solid var(--line); font-size: 15px; }
.sheet-row:first-of-type { border-top: 0; }
.room-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 26px; letter-spacing: 5px; font-weight: 700; color: var(--brand-dark); }

@media (max-width: 360px) {
  body { font-size: 16px; }
  .grid3 { gap: 7px; }
  input[type="number"], input[type="text"] { padding: 11px 10px; font-size: 17px; }
  .bp-big .num { font-size: 30px; }
}
@media (prefers-color-scheme: dark) {
  /* 老人使用以浅色为主，这里保持浅色，避免误判 */
}
