/* 爸爸有话说 · 设计系统（对齐设计草图：暖米纸底＋棕墨＋橙强调） */
:root {
  --paper: #FAF5EC;
  --card: #FFFDF8;
  --ink: #4E342E;
  --ink-soft: #8D6E63;
  --ink-faint: #B9A795;
  --accent: #E8944A;
  --accent-deep: #D97B2F;
  --accent-soft: #F7E3C8;
  --accent-glow: #FBEEDC;
  --line: #E5D9C9;
  --ok: #7A9B6D;
  --ok-soft: #EAF0E4;
  --warn: #C25E4C;
  --warn-soft: #F8E7E1;
  --r-card: 20px;
  --r-btn: 16px;
  --shadow: 0 2px 12px rgba(78, 52, 46, .07);
  --shadow-lift: 0 6px 24px rgba(78, 52, 46, .13);
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", sans-serif;
  --tab-h: 64px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: var(--font); background: var(--paper); color: var(--ink);
  background-image: radial-gradient(rgba(141, 110, 99, .045) 1px, transparent 1px);
  background-size: 22px 22px;
  min-height: 100vh; line-height: 1.65;
}
#app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: 1rem; color: var(--ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ===== 顶栏 ===== */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 14px 18px 10px; background: linear-gradient(var(--paper) 82%, transparent);
}
.topbar h1 { font-size: 1.45rem; font-weight: 800; letter-spacing: .04em; flex: 1; }
.topbar .sub { font-size: .8rem; color: var(--ink-soft); font-weight: 400; display: block; letter-spacing: .02em; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; background: var(--card); border: 1.5px solid var(--line);
  display: grid; place-items: center; font-size: 1.15rem; box-shadow: var(--shadow); position: relative;
  transition: transform .15s;
}
.icon-btn:active { transform: scale(.92); }
.badge-dot {
  position: absolute; top: -3px; right: -3px; min-width: 19px; height: 19px; padding: 0 5px;
  background: var(--warn); color: #fff; border-radius: 10px; font-size: .68rem; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--paper);
}

/* ===== 底部标签栏 ===== */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1.5px solid var(--line); display: flex; z-index: 30;
  box-shadow: 0 -4px 18px rgba(78, 52, 46, .06);
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .74rem; color: var(--ink-faint); font-weight: 600; position: relative; transition: color .2s;
}
.tabbar button .t-ico { font-size: 1.3rem; line-height: 1; }
.tabbar button.on { color: var(--accent-deep); }
.tabbar button.on::before {
  content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px;
  background: var(--accent); border-radius: 0 0 4px 4px;
}
.tabbar .badge-dot { top: 4px; right: calc(50% - 22px); }

/* ===== 通用组件 ===== */
.page { padding: 4px 16px 20px; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.card {
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r-card);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.card.dashed { border-style: dashed; border-color: var(--accent); background: var(--accent-glow); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 48px; padding: 10px 22px; border-radius: 999px; font-size: 1rem; font-weight: 700;
  background: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-deep);
  transition: transform .12s, box-shadow .12s; letter-spacing: .03em;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--accent-deep); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.ghost { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; }
.btn.ghost:active { background: var(--accent-glow); }
.btn.small { min-height: 38px; padding: 6px 16px; font-size: .88rem; }
.btn.block { width: 100%; }
.btn.danger { background: var(--warn); box-shadow: 0 3px 0 #A34534; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 13px; border-radius: 999px;
  font-size: .8rem; font-weight: 600; background: var(--accent-soft); color: var(--accent-deep);
  border: 1px solid transparent;
}
.chip.plain { background: var(--card); border-color: var(--line); color: var(--ink-soft); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.sel { background: var(--accent); color: #fff; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.ai-tag {
  display: inline-block; font-size: .7rem; color: var(--accent-deep); background: var(--accent-soft);
  padding: 2px 10px; border-radius: 8px; font-weight: 600; letter-spacing: .05em;
}
.muted { color: var(--ink-soft); font-size: .86rem; }
.tiny { font-size: .76rem; color: var(--ink-faint); }
.empty { text-align: center; padding: 44px 20px; color: var(--ink-soft); }
.empty .e-ico { font-size: 2.6rem; display: block; margin-bottom: 10px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .88rem; font-weight: 700; margin-bottom: 6px; color: var(--ink); }
.field input, .field textarea, .field select {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--r-btn);
  background: var(--card); transition: border-color .2s;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); outline: none; }
.field textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
.divider { height: 1.5px; background: var(--line); margin: 14px 0; border-radius: 2px; }

/* 缎带（爸爸用N件事证明过） */
.ribbon {
  position: relative; display: inline-block; background: var(--ink); color: #F7E3C8;
  font-size: .82rem; font-weight: 700; padding: 5px 18px; margin: 6px 0 10px;
  border-radius: 4px; letter-spacing: .06em;
}
.ribbon::before, .ribbon::after {
  content: ""; position: absolute; top: 0; border: 14px solid var(--ink);
}
.ribbon::before { left: -14px; border-left-color: transparent; }
.ribbon::after { right: -14px; border-right-color: transparent; }

/* ===== 录音大按钮 ===== */
.mic-zone { text-align: center; padding: 8px 0 4px; }
.greet-bubble {
  display: inline-flex; align-items: center; gap: 8px; background: var(--accent-soft);
  border: 1.5px solid var(--accent); color: var(--ink); font-weight: 700; font-size: .92rem;
  padding: 7px 18px; border-radius: 999px; margin-bottom: 12px;
}
.mic-btn {
  width: 128px; height: 128px; border-radius: 50%; background: radial-gradient(circle at 34% 28%, #F5B071, var(--accent) 62%);
  border: 6px solid var(--card); outline: 2.5px solid var(--line);
  color: #fff; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: .95rem; font-weight: 800; letter-spacing: .1em;
  box-shadow: var(--shadow-lift), inset 0 -6px 14px rgba(160, 80, 20, .28);
  transition: transform .15s; touch-action: none; user-select: none; -webkit-user-select: none;
}
.mic-btn .m-ico { font-size: 1.9rem; }
.mic-btn.rec { transform: scale(1.07); background: radial-gradient(circle at 34% 28%, #E98A6B, var(--warn) 65%); animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(194,94,76,.35), var(--shadow-lift); } 50% { box-shadow: 0 0 0 20px rgba(194,94,76,0), var(--shadow-lift); } }
.rec-timer { font-size: .9rem; color: var(--warn); font-weight: 700; min-height: 1.5em; margin-top: 10px; }
.mat-row { display: flex; justify-content: space-around; margin: 10px 0 8px; }
.mat-entry { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.mat-entry .m-circle {
  width: 52px; height: 52px; border-radius: 50%; background: var(--card); border: 1.5px solid var(--line);
  display: grid; place-items: center; font-size: 1.35rem; box-shadow: var(--shadow); transition: transform .15s;
}
.mat-entry:active .m-circle { transform: scale(.9); background: var(--accent-glow); }
.mat-entry.soon { opacity: .45; }

/* ===== 素材与经验卡片 ===== */
.mat-item { display: flex; gap: 10px; align-items: flex-start; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.mat-item:last-child { border-bottom: none; }
.mat-item .m-type { font-size: 1.25rem; width: 34px; height: 34px; flex: none; display: grid; place-items: center; background: var(--accent-glow); border-radius: 10px; }
.mat-item .m-body { flex: 1; min-width: 0; }
.mat-item .m-text { font-size: .9rem; word-break: break-all; }
.mat-item input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); margin-top: 6px; flex: none; }
.entry-card { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.entry-card:active { transform: scale(.985); }
.entry-card h3 { font-size: 1.12rem; font-weight: 800; margin-bottom: 2px; }
.entry-card .e-body { font-size: .9rem; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.entry-card .e-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; align-items: center; }
.status-dot { font-size: .74rem; font-weight: 700; }
.status-dot.draft { color: var(--ink-faint); }
.status-dot.confirmed { color: var(--ok); }
.status-dot.delivered { color: var(--accent-deep); }

/* ===== 收件箱（孩子端） ===== */
.letter-card { border-left: 5px solid var(--accent); }
.letter-card .l-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); border: 1.5px solid var(--accent);
  display: grid; place-items: center; font-size: 1.3rem; flex: none;
}
.letter-card .l-body { font-size: 1.08rem; font-weight: 600; line-height: 1.8; margin: 8px 0; }
.audio-bubble {
  display: inline-flex; align-items: center; gap: 8px; background: var(--accent-soft);
  border-radius: 999px; padding: 8px 16px; font-size: .86rem; font-weight: 700; color: var(--accent-deep);
  border: 1px solid var(--accent); margin: 4px 0;
}
.audio-bubble:active { background: var(--accent); color: #fff; }

/* ===== PIN 键盘 ===== */
.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 22px 0; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--accent); transition: background .15s; }
.pin-dots span.fill { background: var(--accent); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 300px; margin: 0 auto; }
.pin-pad button {
  height: 62px; border-radius: var(--r-btn); background: var(--card); border: 1.5px solid var(--line);
  font-size: 1.5rem; font-weight: 700; box-shadow: var(--shadow); transition: transform .1s;
}
.pin-pad button:active { transform: scale(.93); background: var(--accent-glow); }
.pin-pad button.fn { font-size: 1rem; color: var(--ink-soft); }

/* ===== 选择题 ===== */
.quiz-opt {
  display: block; width: 100%; text-align: left; padding: 13px 16px; margin-bottom: 10px;
  border: 1.5px solid var(--line); border-radius: var(--r-btn); background: var(--card);
  font-size: .98rem; font-weight: 600; transition: all .15s;
}
.quiz-opt.sel { border-color: var(--accent); background: var(--accent-glow); box-shadow: 0 0 0 1.5px var(--accent); }
.quiz-opt .opt-key {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-deep); font-size: .8rem; margin-right: 9px; font-weight: 800;
}
.quiz-opt.sel .opt-key { background: var(--accent); color: #fff; }

/* ===== 弹层与提示 ===== */
#modal-root .mask {
  position: fixed; inset: 0; background: rgba(62, 42, 35, .45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center; animation: fadein .2s;
}
#modal-root .sheet {
  background: var(--paper); width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  border-radius: 24px 24px 0 0; padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  animation: slideup .25s ease;
}
@keyframes slideup { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet h2 { font-size: 1.2rem; font-weight: 800; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.sheet .close-x { margin-left: auto; width: 34px; height: 34px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); font-size: 1rem; }
#toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 99; width: max-content; max-width: 88vw; }
.toast {
  background: var(--ink); color: #FFF8EE; padding: 11px 22px; border-radius: 999px; font-size: .92rem;
  font-weight: 600; box-shadow: var(--shadow-lift); margin-bottom: 8px; animation: fadein .2s; text-align: center;
}
.toast.err { background: var(--warn); }
.toast.ok { background: var(--ok); }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; }
.spinner.dark { border-color: var(--line); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-box { text-align: center; padding: 40px; color: var(--ink-soft); }

/* ===== 设置与家庭 ===== */
.code-big { font-size: 2.3rem; font-weight: 800; letter-spacing: .35em; text-align: center; color: var(--accent-deep); padding: 8px 0; font-variant-numeric: tabular-nums; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.member-row:last-child { border-bottom: none; }
.member-row .m-name { flex: 1; font-weight: 700; }
.tagline { text-align: center; color: var(--ink-soft); font-size: .9rem; padding: 10px 0 4px; letter-spacing: .08em; }
.seg { display: flex; background: var(--card); border: 1.5px solid var(--line); border-radius: 999px; padding: 3px; margin-bottom: 14px; }
.seg button { flex: 1; min-height: 38px; border-radius: 999px; font-size: .88rem; font-weight: 700; color: var(--ink-soft); }
.seg button.on { background: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(217,123,47,.3); }
.care-box { background: var(--warn-soft); border: 1.5px solid var(--warn); border-radius: var(--r-card); padding: 14px 16px; margin: 12px 0; font-size: .9rem; }
.care-box b { color: var(--warn); }
.version-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: .85rem; }
.hero-icon { width: 92px; height: 92px; border-radius: 24px; box-shadow: var(--shadow-lift); }
.setup-role { display: flex; gap: 12px; margin: 16px 0; }
.setup-role button {
  flex: 1; background: var(--card); border: 2px solid var(--line); border-radius: var(--r-card);
  padding: 18px 8px; text-align: center; font-weight: 800; font-size: 1rem; transition: all .15s;
}
.setup-role button .r-ico { font-size: 2.2rem; display: block; margin-bottom: 6px; }
.setup-role button.sel { border-color: var(--accent); background: var(--accent-glow); box-shadow: 0 0 0 1.5px var(--accent); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (min-width: 520px) { #app { border-left: 1.5px solid var(--line); border-right: 1.5px solid var(--line); } }/* ===== 日常页折叠分组（一屏完整呈现） ===== */
.page-daily { padding-top: 0; }
.day-card { padding: 10px 14px; margin-bottom: 10px; }
.day-head { display: flex; align-items: center; gap: 8px; cursor: pointer; min-height: 34px; }
.day-head b { font-size: .98rem; }
.day-head .tiny { flex: 1; }
.day-head .chev { color: var(--accent-deep); font-size: 1.2rem; font-weight: 800; width: 22px; text-align: center; transition: transform .2s; }
.day-card.open .day-head .chev { transform: rotate(90deg); }
.day-preview { font-size: .82rem; color: var(--ink-faint); padding: 2px 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-body { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 4px; }
.day-group { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 14px; margin-bottom: 10px; cursor: pointer; box-shadow: var(--shadow); }
.day-group .chev { margin-left: auto; color: var(--accent-deep); font-size: 1.2rem; font-weight: 800; }
.day-group.letter-nudge { border-color: var(--accent); background: var(--accent-glow); }
.video-thumb { width: 96px; height: 60px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); margin-top: 6px; display: block; background: var(--accent-glow); color: transparent; font-size: 0; }
.wx-banner { background: var(--ok-soft); border: 1.5px solid var(--ok); border-radius: 14px; padding: 10px 12px; font-size: .82rem; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wx-banner .btn { min-height: 32px; padding: 4px 12px; font-size: .78rem; }

/* ===== 响应式：多分辨率适配 ===== */
/* 小屏手机 */
@media (max-width: 360px) {
  html { font-size: 15px; }
  .mic-btn { width: 112px; height: 112px; }
  .mat-entry .m-circle { width: 46px; height: 46px; font-size: 1.2rem; }
  .topbar h1 { font-size: 1.25rem; }
}
/* 矮屏（iPhone SE 等 ≤700px 高）：保持一屏 */
@media (max-height: 700px) {
  .mic-btn { width: 104px; height: 104px; }
  .mic-btn .m-ico { font-size: 1.6rem; }
  .greet-bubble { margin-bottom: 8px; padding: 5px 14px; font-size: .85rem; }
  .mat-row { margin: 6px 0; }
  .tagline { display: none; }
  .day-card { padding: 8px 12px; margin-bottom: 8px; }
  .rec-timer { margin-top: 4px; min-height: 1.2em; }
}
/* 横屏/超矮屏 */
@media (max-height: 560px) {
  .mic-btn { width: 84px; height: 84px; font-size: .8rem; }
  .mic-btn .m-ico { font-size: 1.3rem; }
  .greet-bubble { display: none; }
  .topbar { padding: 8px 14px 6px; }
  .topbar h1 { font-size: 1.1rem; }
  .mat-entry .m-circle { width: 42px; height: 42px; }
  .page { padding: 2px 12px 12px; }
}
/* 平板 */
@media (min-width: 768px) {
  #app { max-width: 560px; box-shadow: 0 0 40px rgba(78, 52, 46, .08); }
  .mic-btn { width: 150px; height: 150px; }
  .mic-btn .m-ico { font-size: 2.2rem; }
}
/* 桌面：居中手机列 + 两侧留白 */
@media (min-width: 1200px) {
  body { background-size: 26px 26px; }
  #app { max-width: 520px; border-left: 1.5px solid var(--line); border-right: 1.5px solid var(--line); min-height: 100vh; }
  .tabbar { border-radius: 0; }
}