/* ====================================================
   婧安小记 - 完整 UI 样式表
   含状态栏适配、刘海屏适配、响应式、深色模式

   设计令牌分层：
     ① 原始令牌 primitive  —— 完整色阶（粉/蓝/绿/紫/琥珀/中性灰）
     ② 语义令牌 semantic   —— 组件唯一可引用的层，换肤只改这层
     ③ 兼容别名 compat     —— 保留旧变量名，避免既有引用失效
   ==================================================== */

/* ========== ① 原始令牌：色板 ========== */
:root {
    /* 品牌粉 */
    --pink-50:  #fff5f8;
    --pink-100: #ffe8ef;
    --pink-200: #fdd3e0;
    --pink-300: #f8b4c4;
    --pink-400: #f292aa;
    --pink-500: #e88a9e;
    --pink-600: #d96b83;

    /* 喂奶蓝 */
    --blue-50:  #eff6ff;
    --blue-100: #dbeafe;
    --blue-300: #93c5fd;
    --blue-500: #60a5fa;
    --blue-600: #3b82f6;
    --blue-700: #1d4ed8;

    /* 尿布绿 */
    --green-50:  #f0fdf4;
    --green-100: #dcfce7;
    --green-300: #86efac;
    --green-500: #4ade80;
    --green-600: #16a34a;
    --green-700: #15803d;

    /* 经期紫 */
    --violet-50:  #faf5ff;
    --violet-100: #f3e8ff;
    --violet-300: #d8b4fe;
    --violet-500: #c084fc;
    --violet-600: #9333ea;
    --violet-700: #7e22ce;

    /* 疫苗琥珀 */
    --amber-50:  #fffbeb;
    --amber-100: #fef3c7;
    --amber-300: #fcd34d;
    --amber-500: #f59e0b;
    --amber-600: #d97706;
    --amber-700: #b45309;

    /* 成长青绿（新增，用于区分身高体重与喂奶） */
    --teal-50:  #f0fdfa;
    --teal-600: #0d9488;
    --teal-700: #0f766e;

    --red-50:  #fef2f2;
    --red-500: #ef4444;
    --red-600: #dc2626;

    /* 中性灰 11 阶 */
    --g-25:  #fcfcfd;
    --g-50:  #f8fafc;
    --g-100: #f1f5f9;
    --g-200: #e2e8f0;
    --g-300: #cbd5e1;
    --g-400: #94a3b8;
    --g-500: #64748b;
    --g-600: #475569;
    --g-700: #334155;
    --g-800: #1e293b;
    --g-900: #0f172a;

    /* 圆角刻度（统一 4 档 + 全圆） */
    --r-xs:   6px;
    --r-sm:   10px;
    --r-md:   14px;
    --r-lg:   20px;
    --r-full: 999px;

    /* 间距：8pt 栅格 */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;

    /* 字号：以 15px 为正文基准（抱娃/夜间场景可读性优先） */
    --fs-xs:  11px;
    --fs-sm:  13px;
    --fs-md:  15px;
    --fs-lg:  17px;
    --fs-xl:  20px;
    --fs-2xl: 26px;

    /* 阴影 4 档 */
    --sh-xs: 0 1px 2px rgba(15, 23, 42, .04);
    --sh-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --sh-md: 0 4px 16px rgba(15, 23, 42, .07), 0 1px 3px rgba(15, 23, 42, .04);
    --sh-lg: 0 12px 32px rgba(15, 23, 42, .12), 0 2px 8px rgba(15, 23, 42, .05);
    --sh-accent: 0 6px 18px rgba(232, 138, 158, .32);

    /* 动效 */
    --ease: cubic-bezier(.32, .72, .28, 1);
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    --dur-fast: .14s;
    --dur-base: .24s;
    --dur-slow: .38s;

    /* 层级 */
    --z-nav: 30;
    --z-fab: 40;
    --z-sheet: 60;
    --z-modal: 70;
    --z-toast: 90;

    /* 布局 */
    --h-header: 56px;
    --hit: 44px;                    /* 最小可点区域 */

    /* 状态栏高度（由 JS 动态设置） */
    --status-bar-height: 0px;

    /* 底部安全区域 */
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ========== ② 语义令牌：浅色主题（默认） ========== */
:root {
    color-scheme: light;

    --bg-app:         var(--g-50);
    --bg-app-alt:     var(--pink-50);
    --surface:        #ffffff;
    --surface-sunken: var(--g-100);
    --surface-hover:  var(--g-50);
    --surface-glass:  rgba(255, 255, 255, .82);

    --text-primary:   var(--g-800);
    --text-secondary: var(--g-500);
    --text-muted:     var(--g-400);
    --text-inverse:   #ffffff;

    --border:        var(--g-200);
    --border-light:  var(--g-100);
    --border-strong: var(--g-300);

    --accent:        var(--pink-500);
    --accent-hover:  var(--pink-600);
    --accent-soft:   var(--pink-100);
    --accent-softer: var(--pink-50);
    --accent-text:   var(--pink-600);

    /* 记录类型语义色 */
    --c-feed:       var(--blue-600);
    --c-feed-bg:    var(--blue-50);
    --c-diaper:     var(--green-600);
    --c-diaper-bg:  var(--green-50);
    --c-period:     var(--violet-600);
    --c-period-bg:  var(--violet-50);
    --c-vaccine:    var(--amber-600);
    --c-vaccine-bg: var(--amber-50);
    --c-growth:     var(--teal-600);
    --c-growth-bg:  var(--teal-50);
    --c-danger:     var(--red-600);
    --c-danger-bg:  var(--red-50);
}

/* ========== ③ 语义令牌：深色主题 ========== */
/* 由 js/ui.js 的 applyTheme() 在 <html> 上设置 data-theme="dark" */
:root[data-theme="dark"] {
    color-scheme: dark;

    --bg-app:         #14161c;
    --bg-app-alt:     #191b23;
    --surface:        #1e2129;
    --surface-sunken: #252833;
    --surface-hover:  #2a2e3a;
    --surface-glass:  rgba(30, 33, 41, .86);

    --text-primary:   #eef1f6;
    --text-secondary: #a3adbd;
    --text-muted:     #6f7889;
    --text-inverse:   var(--g-900);

    --border:        #2c303b;
    --border-light:  #262a34;
    --border-strong: #3a3f4d;

    --accent:        var(--pink-400);
    --accent-hover:  var(--pink-300);
    --accent-soft:   rgba(248, 180, 196, .16);
    --accent-softer: rgba(248, 180, 196, .08);
    --accent-text:   var(--pink-300);

    --c-feed:       var(--blue-300);
    --c-feed-bg:    rgba(96, 165, 250, .14);
    --c-diaper:     var(--green-300);
    --c-diaper-bg:  rgba(74, 222, 128, .14);
    --c-period:     var(--violet-300);
    --c-period-bg:  rgba(192, 132, 252, .14);
    --c-vaccine:    var(--amber-300);
    --c-vaccine-bg: rgba(245, 158, 11, .14);
    --c-growth:     #5eead4;
    --c-growth-bg:  rgba(45, 212, 191, .14);
    --c-danger:     #f87171;
    --c-danger-bg:  rgba(239, 68, 68, .14);

    /* 深色下徽标需浅底深字改为深底浅字，单独覆写 */
    --badge-amber-bg: rgba(245, 158, 11, .18);
    --badge-amber-fg: var(--amber-300);
    --badge-violet-bg: rgba(192, 132, 252, .18);
    --badge-violet-fg: var(--violet-300);

    --sh-xs: 0 1px 2px rgba(0, 0, 0, .3);
    --sh-sm: 0 1px 3px rgba(0, 0, 0, .35);
    --sh-md: 0 4px 16px rgba(0, 0, 0, .42);
    --sh-lg: 0 12px 32px rgba(0, 0, 0, .55);
    --sh-accent: 0 6px 18px rgba(232, 138, 158, .22);
}

/* ========== ③ 兼容别名：旧变量名映射到新令牌 ========== */
/* 目的：既有 CSS/JS 中对 --color-* / --shadow-card / --radius-* 的引用继续生效 */
:root {
    --color-primary:        var(--accent);
    --color-primary-dark:   var(--accent-hover);
    --color-primary-light:  var(--accent-softer);

    --color-feed:   var(--c-feed);
    --color-diaper: var(--c-diaper);
    --color-period: var(--c-period);
    --color-vaccine: var(--c-vaccine);

    --color-bg:             var(--bg-app);
    --color-card:           var(--surface);
    --color-text:           var(--text-primary);
    --color-text-secondary: var(--text-secondary);
    --color-text-muted:     var(--text-muted);
    --color-border:         var(--border);
    --color-border-light:   var(--border-light);

    --shadow-card: var(--sh-sm);
    --shadow-btn:  var(--sh-accent);
    --radius-card: var(--r-lg);
    --radius-btn:  var(--r-sm);
    --radius-input: var(--r-sm);
}

/* ========== 全局重置 ========== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
                 "Segoe UI", Roboto, "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-app);
    color: var(--text-primary);
    font-size: var(--fs-md);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
    transition: background var(--dur-base) var(--ease), color var(--dur-base) var(--ease);
}

/* 数字等宽，避免计数跳动 */
.num,
.tabular {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

/* 键盘可见焦点（仅键盘导航时出现，触摸不显示） */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* 尊重系统「减弱动效」设置 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* 补齐项目里在用、但 dist/output.css 未生成的原子类 */
.items-start { align-items: flex-start; }

/* 屏幕阅读器专用文本 */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

html { overflow: hidden; }
body {
    overflow: auto;
    display: flex;
    flex-direction: column;
}

/* ========== 顶部导航栏（含状态栏适配） ========== */
.header {
    flex-shrink: 0;
    position: relative;
    background: var(--surface-glass);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--border-light);
    z-index: var(--z-nav);
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    min-height: var(--h-header);
    transition: background var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease);
}

/* 顶部标题分组：标题随子页签变化 */
.header-title-group {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 6px;
    overflow: hidden;
}
.header h1 {
    font-size: var(--fs-lg);
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--text-primary);
    white-space: nowrap;
}
/* 子页签名（次要层级） */
.header h1 .header-sub {
    margin-left: 6px;
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-muted);
}

#menuToggle {
    width: var(--hit);
    height: var(--hit);
    margin-left: -8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--r-sm);
    transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
    touch-action: manipulation;
}
#menuToggle:active {
    background: var(--surface-sunken);
    transform: scale(.92);
}

/* ========== 日期胶囊 ========== */
/* 外观完全自绘，透明原生 date input 覆盖其上以保留系统日期选择器 */
.date-chip {
    position: relative;
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 34px;
    padding: 0 var(--sp-3);
    border-radius: var(--r-full);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: var(--fs-sm);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    box-shadow: var(--sh-xs);
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.date-chip:active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.date-chip__icon { font-size: 12px; line-height: 1; }
.date-chip input[type="date"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    border: 0;
    padding: 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
/* 兼容旧写法：若 #selectDay 未包在 .date-chip 内，退化为普通输入框样式 */
#selectDay:not(.date-chip input) {
    width: 140px;
    height: 38px;
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
    touch-action: manipulation;
}

/* ========== 主滚动区域 ========== */
.main-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(1.5rem + var(--safe-bottom));
}

/* ========== 卡片组件 ========== */
.card-shadow {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--r-lg);
    padding: 1.25rem;
    margin-bottom: var(--sp-4);
    box-shadow: var(--sh-sm);
    transition: box-shadow var(--dur-base) var(--ease),
                background var(--dur-base) var(--ease),
                border-color var(--dur-base) var(--ease);
}
.card-shadow:hover {
    box-shadow: var(--sh-md);
}
/* 深色下 hover 无意义（触摸设备），取消上浮避免闪烁 */
:root[data-theme="dark"] .card-shadow:hover {
    box-shadow: var(--sh-sm);
}

/* 左侧色条用 ::before 绘制，圆角不会被切断 */
/* 目前只有疫苗卡在用（汇总页），其余三色的卡类已随界面重构移除 */
.card-vaccine {
    position: relative;
    overflow: hidden;
}
.card-vaccine::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
}
.card-vaccine::before { background: var(--c-vaccine); }

.card-title {
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}
/* 卡片标题前的图标块 */
.card-title-icon {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: var(--r-xs);
    background: var(--icon-bg, var(--accent-soft));
    font-size: 13px;
    line-height: 1;
}
/* 分组小标题改用 .group-head，.section-label / .card-value / .stat-label 已移除 */

/* ========== 按钮 ========== */
.btn-main {
    background: linear-gradient(135deg, var(--pink-400), var(--accent));
    color: #ffffff;
    border: none;
    border-radius: var(--r-sm);
    padding: 0.7rem 1.25rem;
    font-weight: 600;
    font-size: var(--fs-md);
    width: 100%;
    transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-base) var(--ease);
    box-shadow: var(--sh-accent);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    min-height: var(--hit);
}
.btn-main:active {
    transform: scale(0.97);
    box-shadow: 0 2px 8px rgba(232, 138, 158, .28);
}
/* 主题色变体：删除已随重构移除的 btn-diaper / btn-period / btn-growth */

.btn-gray {
    background: var(--surface-sunken);
    color: var(--text-primary);
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    padding: 0.65rem 1rem;
    font-weight: 500;
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
    touch-action: manipulation;
    min-height: var(--hit);
}
.btn-gray:active {
    background: var(--border-light);
}

/* 软色按钮（次要操作，如「导入疫苗模板」） */
.btn-soft {
    background: var(--accent-soft);
    color: var(--accent-text);
    border: none;
    border-radius: var(--r-sm);
    padding: 0.65rem 1rem;
    font-weight: 600;
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
    touch-action: manipulation;
    min-height: var(--hit);
}
.btn-soft:active { transform: scale(.97); }

/* 危险操作按钮 */
.btn-danger {
    background: var(--c-danger-bg);
    color: var(--c-danger);
    border: none;
    border-radius: var(--r-sm);
    padding: 0.65rem 1rem;
    font-weight: 600;
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: transform var(--dur-fast) var(--ease);
    touch-action: manipulation;
    min-height: var(--hit);
}
.btn-danger:active { transform: scale(.97); }

/* ========== 输入框 ========== */
.input-field {
    border: 1.5px solid transparent;
    border-radius: var(--r-sm);
    padding: 0.6rem 0.9rem;
    width: 100%;
    font-size: var(--fs-md);
    background: var(--surface-sunken);
    color: var(--text-primary);
    transition: background var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease);
    outline: none;
    min-height: 42px;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
}
.input-field:focus {
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}
.input-field::placeholder {
    color: var(--text-muted);
}

/* 下拉框自绘箭头（原生箭头在深色下不跟随主题） */
select.input-field {
    padding-right: 2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%2394a3b8' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}
/* 深色下箭头改为浅灰，保证可见 */
:root[data-theme="dark"] select.input-field {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%23a3adbd' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* 日期/时间输入框加大点击区域 */
input[type="date"].input-field,
input[type="datetime-local"].input-field,
input[type="month"].input-field {
    min-height: 46px;
    cursor: pointer;
    padding: 0.55rem 0.8rem;
    font-variant-numeric: tabular-nums;
}
/* 深色下原生日期控件图标反色，否则看不见 */
:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
:root[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator,
:root[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator,
:root[data-theme="dark"] input[type="month"]::-webkit-calendar-picker-indicator {
    filter: invert(1) opacity(.72);
}

/* 带单位的输入框 */
.unit-input { position: relative; }
.unit-input .input-field { padding-right: 42px; }
.unit-input__unit {
    position: absolute;
    right: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-muted);
    pointer-events: none;
}

/* 表单字段间距 */
.field-gap { margin-top: var(--sp-3); }

/* 喂奶「开始 / 结束」并排两列。
   此前 index.html 用了 time-row 但样式表里没有这条规则，
   两个 datetime-local 输入框只能上下堆叠、占满整行。
   窄屏（<360px）自动回落为单列，避免输入框被压得过窄。 */
.time-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
}
@media (max-width: 360px) {
    .time-row { grid-template-columns: 1fr; }
}
.field-label {
    display: block;
    margin-bottom: 5px;
    font-size: var(--fs-xs);
    font-weight: 500;
    color: var(--text-secondary);
}
.field-hint {
    margin-top: 6px;
    font-size: var(--fs-xs);
    line-height: 1.55;
    color: var(--text-muted);
}

/* ========== 记录列表（时间轴式） ========== */
/* 结构：左时间锚点（含时间轴竖线） | 中内容 | 右操作按钮 */
.list-item {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    background: var(--surface-sunken);
    border: 1px solid transparent;
    border-radius: var(--r-md);
    padding: 0.65rem 0.9rem;
    margin-bottom: var(--sp-2);
    gap: var(--sp-3);
    min-width: 0;
    overflow: hidden;
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.list-item:active {
    background: var(--surface);
    border-color: var(--border);
}

/* 左侧时间锚点 */
.rec-time {
    flex: none;
    position: relative;
    width: 52px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.rec-time__main {
    display: block;
    font-size: var(--fs-md);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -.02em;
    line-height: 1.3;
}
.rec-time__sub {
    display: block;
    font-size: var(--fs-xs);
    color: var(--text-muted);
    line-height: 1.3;
}
/* 时间轴竖线：用伪元素画，不占 DOM */
.rec-time::after {
    content: "";
    position: absolute;
    right: -7px;
    top: 50%;
    width: 1px;
    height: 26px;
    transform: translateY(-50%);
    background: var(--border);
}

/* 中间内容区 */
.rec-body { flex: 1 1 0; min-width: 0; }
.rec-title {
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
}
.rec-meta {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    margin-top: 3px;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    overflow: hidden;
    min-width: 0;
}
.rec-meta__note {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* 右侧操作按钮 */
.record-actions {
    flex-shrink: 0;
    display: flex !important;
    align-items: center;
    gap: 2px;
}
.record-actions button {
    width: 38px;
    height: 38px;
    border-radius: var(--r-sm);
    background: var(--surface);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: transform var(--dur-fast) var(--ease),
                background var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease);
    touch-action: manipulation;
}
.record-actions button:active { transform: scale(.9); }
.record-actions button.btn-edit:active {
    background: var(--c-feed-bg);
    color: var(--c-feed);
    border-color: transparent;
}
.record-actions button.btn-del:active {
    background: var(--c-danger-bg);
    color: var(--c-danger);
    border-color: transparent;
}

/* ========== 徽标 ========== */
/* 喂奶间隔：琥珀色（核心信息，需高对比） */
.interval-badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 20px;
    padding: 0 7px;
    border-radius: var(--r-full);
    background: var(--amber-100);
    color: var(--amber-700);
    font-size: var(--fs-xs);
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
/* 经期相对天数：紫色 */
.period-badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 7px;
    border-radius: var(--r-full);
    background: var(--violet-100);
    color: var(--violet-700);
    font-size: var(--fs-xs);
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}
/* 喂奶/尿布/中性/体重徽标 */
.badge-feed {
    background: var(--blue-100);
    color: var(--blue-700);
}
.badge-diaper {
    background: var(--green-100);
    color: var(--green-700);
}
.badge-muted {
    background: var(--g-100);
    color: var(--text-secondary);
}
/* 体重徽标：growth.js 一直在用 badge-violet，但此前漏了这条基础规则，
   导致「体重」徽标只剩裸文字、没有药丸底色（深色令牌反而早就备好了） */
.badge-violet {
    background: var(--violet-100);
    color: var(--violet-700);
}
.badge-feed,
.badge-diaper,
.badge-muted,
.badge-violet {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 7px;
    border-radius: var(--r-full);
    font-size: var(--fs-xs);
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

/* 深色模式下徽标需换底换字，否则浅底白字看不清 */
:root[data-theme="dark"] .interval-badge {
    background: var(--badge-amber-bg, rgba(245, 158, 11, .18));
    color: var(--badge-amber-fg, var(--amber-300));
}
:root[data-theme="dark"] .period-badge {
    background: var(--badge-violet-bg, rgba(192, 132, 252, .18));
    color: var(--badge-violet-fg, var(--violet-300));
}
:root[data-theme="dark"] .badge-feed { background: var(--c-feed-bg); color: var(--c-feed); }
:root[data-theme="dark"] .badge-diaper { background: var(--c-diaper-bg); color: var(--c-diaper); }
:root[data-theme="dark"] .badge-muted { background: var(--surface-sunken); color: var(--text-secondary); }
:root[data-theme="dark"] .badge-violet {
    background: var(--badge-violet-bg, rgba(192, 132, 252, .18));
    color: var(--badge-violet-fg, var(--violet-300));
}

.feed-list-item { justify-content: flex-start; }
.feed-list-item .rec-body { flex: 1; }
.feed-list-item .record-actions { flex: 0 0 auto; }

/* ========== 侧边栏（含状态栏适配） ========== */
#sidebar {
    width: 282px;
    max-width: 82vw;
    background: var(--surface);
    box-shadow: var(--sh-lg);
    z-index: 50;
    transition: transform var(--dur-slow) var(--ease-out), background var(--dur-base) var(--ease);
    overflow-y: auto;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    padding-top: var(--status-bar-height);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateX(-100%);
}
#sidebar.open {
    transform: translateX(0);
}
#sidebarOverlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 40;
    opacity: 0;
    transition: opacity var(--dur-base) var(--ease);
    pointer-events: none;
}
#sidebarOverlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}
#sidebarOverlay.hidden { display: none; }

#sidebar .p-4 {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
}
#closeSidebarBtn {
    width: var(--hit);
    height: var(--hit);
    border: none;
    background: transparent;
    font-size: 1.4rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
#closeSidebarBtn:active {
    background: var(--surface-sunken);
    transform: scale(.92);
}

.sidebar-group {
    border-bottom: 1px solid var(--border-light);
    padding: 0.25rem 0;
}
.sidebar-group:last-child { border-bottom: none; }

.sidebar-item {
    display: block;
    padding: 0.7rem 1.25rem;
    border-radius: var(--r-sm);
    cursor: pointer;
    color: var(--text-primary);
    font-size: var(--fs-md);
    transition: background var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease);
    border-left: 4px solid transparent;
    margin: 0.1rem 0.5rem;
    touch-action: manipulation;
    min-height: 42px;
}
.sidebar-item.active {
    background: var(--accent-softer);
    color: var(--accent-text);
    font-weight: 600;
    border-left-color: var(--accent);
}
.sidebar-sub .sidebar-item {
    font-size: var(--fs-sm);
    padding: 0.5rem 1.25rem 0.5rem 2rem;
}
.sidebar-sub {
    display: none;
    padding-left: 0.25rem;
}

/* ========== 维生素卡片（完整状态卡） ========== */
.vitamin-card {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--violet-600) 0%, #6d28d9 100%);
    color: #ffffff;
    border: none;
    border-radius: var(--r-lg);
    padding: var(--sp-4);
    margin-bottom: var(--sp-4);
    box-shadow: 0 8px 24px rgba(147, 51, 234, .26);
}
/* 装饰光斑 */
.vitamin-card::after {
    content: "";
    position: absolute;
    right: -28px;
    top: -34px;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, .22), transparent 68%);
    pointer-events: none;
}
.vitamin-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
}
.vitamin-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 24px;
    padding: 0 var(--sp-2);
    border-radius: var(--r-full);
    background: rgba(255, 255, 255, .20);
    font-size: var(--fs-xs);
    font-weight: 600;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.vitamin-date {
    font-size: var(--fs-xs);
    color: rgba(255, 255, 255, .82);
    font-variant-numeric: tabular-nums;
}
.vitamin-main {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}
.vitamin-drug {
    font-size: var(--fs-2xl);
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.15;
}
.vitamin-switch {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 7px;
    border-radius: var(--r-full);
    background: rgba(255, 255, 255, .18);
    font-size: var(--fs-xs);
    font-weight: 500;
}
.vitamin-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    margin-top: var(--sp-3);
    padding-top: var(--sp-3);
    border-top: 1px solid rgba(255, 255, 255, .18);
    font-size: var(--fs-xs);
}
.vitamin-next {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: rgba(255, 255, 255, .92);
}
.vitamin-next b {
    font-weight: 700;
    color: #ffffff;
}
/* 「已服用」开关 */
.vitamin-check {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 30px;
    padding: 0 var(--sp-3);
    border-radius: var(--r-full);
    border: 1px solid transparent;
    background: rgba(255, 255, 255, .94);
    color: var(--violet-700);
    font-size: var(--fs-xs);
    font-weight: 700;
    cursor: pointer;
    transition: transform var(--dur-fast) var(--ease),
                background var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease);
    touch-action: manipulation;
}
.vitamin-check:active { transform: scale(.94); }
.vitamin-check.is-done {
    background: transparent;
    color: #ffffff;
    border-color: rgba(255, 255, 255, .5);
}

/* ========== 疫苗本 ========== */
.vaccine-item {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    background: var(--surface-sunken);
    border: 1px solid transparent;
    border-radius: var(--r-md);
    padding: var(--sp-3);
    margin-bottom: var(--sp-2);
    transition: background var(--dur-fast) var(--ease), opacity var(--dur-base) var(--ease);
}
/* 已完成整行降透明度，形成强弱对比 */
.vaccine-item.completed {
    opacity: .56;
}
.vaccine-info { flex: 1; min-width: 0; }
.vaccine-name {
    font-weight: 600;
    font-size: var(--fs-md);
    color: var(--text-primary);
}
.vaccine-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    margin-top: 4px;
}

/* 自绘复选框：原生 checkbox 在深色下无法控色 */
.vaccine-check {
    flex-shrink: 0;
    position: relative;
    width: 24px;
    height: 24px;
    margin-top: 1px;
    border-radius: var(--r-xs);
    border: 2px solid var(--border-strong);
    background: var(--surface);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: background var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease),
                transform var(--dur-fast) var(--ease);
    touch-action: manipulation;
}
.vaccine-check:active { transform: scale(.9); }
.vaccine-check:checked {
    background: var(--c-vaccine);
    border-color: var(--c-vaccine);
}
/* 勾选标记（SVG data-uri，跟随主题无需改色） */
.vaccine-check:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 7px;
    height: 12px;
    border: solid #ffffff;
    border-width: 0 2.2px 2.2px 0;
    transform: rotate(45deg);
}
.vaccine-name.line-through {
    text-decoration: line-through;
    color: var(--text-muted);
}
.vaccine-del {
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border-light);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
    touch-action: manipulation;
}
.vaccine-del:active {
    background: var(--c-danger-bg);
    color: var(--c-danger);
    border-color: transparent;
    transform: scale(.9);
}

/* 疫苗提醒条 */
.reminder-bar {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3);
    border-radius: var(--r-md);
    background: var(--c-vaccine-bg);
    border: 1px solid rgba(245, 158, 11, .22);
    margin-bottom: var(--sp-4);
}
.reminder-bar__icon {
    flex: none;
    font-size: 20px;
    line-height: 1.2;
}
.reminder-bar__title {
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--c-vaccine);
}
.reminder-bar__text {
    margin-top: 2px;
    font-size: var(--fs-sm);
    line-height: 1.55;
    color: var(--text-secondary);
}

/* 疫苗分组标题（替代原生 <details>/<summary>，深色下可控样式） */
.group-head {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin: var(--sp-4) 0 var(--sp-2);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-secondary);
}
.group-head__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--r-full);
    background: var(--surface-sunken);
    font-size: var(--fs-xs);
    font-variant-numeric: tabular-nums;
}

/* ========== AI 聊天（含底部安全区域适配） ========== */
.ai-float-btn {
    position: fixed;
    z-index: var(--z-fab);
    bottom: calc(20px + var(--safe-bottom));
    right: 16px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--pink-400), var(--accent));
    border-radius: 50%;
    box-shadow: var(--sh-accent), var(--sh-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    cursor: pointer;
    border: none;
    transition: transform var(--dur-base) var(--ease-out);
    touch-action: manipulation;
}
.ai-float-btn:active {
    transform: scale(0.9);
}
.ai-message {
    max-width: 85%;
    padding: 0.6rem 1rem;
    border-radius: var(--r-md);
    line-height: 1.5;
    font-size: var(--fs-md);
    white-space: pre-wrap;
    word-break: break-word;
}
.ai-message.user {
    background: linear-gradient(135deg, var(--pink-400), var(--accent));
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: var(--r-xs);
    margin-left: auto;
    box-shadow: var(--sh-accent);
}
.ai-message.assistant {
    background: var(--surface-sunken);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: var(--r-xs);
}
.ai-message.system {
    background: var(--c-danger-bg);
    color: var(--c-danger);
    align-self: center;
    font-size: var(--fs-sm);
    text-align: center;
}

#aiLogContent .log-entry {
    background: var(--surface-sunken);
    border-radius: var(--r-sm);
    padding: 0.5rem;
    margin-bottom: var(--sp-2);
    font-size: var(--fs-xs);
    line-height: 1.6;
    color: var(--text-secondary);
}
.log-entry .label { font-weight: 600; color: var(--text-secondary); }
.log-entry .content {
    white-space: pre-wrap;
    word-break: break-all;
    margin-top: 0.25rem;
}
.log-entry.success {
    border-left: 3px solid var(--c-diaper);
    background: var(--c-diaper-bg);
    color: var(--green-700);
}
.log-entry.error {
    border-left: 3px solid var(--c-danger);
    background: var(--c-danger-bg);
    color: var(--c-danger);
}
:root[data-theme="dark"] .log-entry.success { color: var(--green-300); }
:root[data-theme="dark"] .log-entry.error { color: #fca5a5; }

/* ========== 统计格 ========== */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
}
.stat {
    padding: var(--sp-3);
    border-radius: var(--r-md);
    background: var(--surface-sunken);
    border: 1px solid var(--border-light);
}
.stat__key {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}
.stat__val {
    margin-top: 4px;
    font-size: var(--fs-lg);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    letter-spacing: -.02em;
    line-height: 1.3;
}
/* 今日汇总顶部高亮条 */
.summary-hero {
    display: flex;
    align-items: stretch;
    gap: var(--sp-2);
    padding: var(--sp-4);
    border-radius: var(--r-lg);
    background: linear-gradient(135deg, var(--pink-400) 0%, var(--violet-500) 100%);
    color: #ffffff;
    box-shadow: var(--sh-md);
    margin-bottom: var(--sp-4);
}
.summary-hero__cell { flex: 1; text-align: center; }
.summary-hero__cell + .summary-hero__cell {
    border-left: 1px solid rgba(255, 255, 255, .28);
}
.summary-hero__num {
    display: block;
    font-size: var(--fs-2xl);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.03em;
    line-height: 1.15;
}
.summary-hero__lab {
    display: block;
    margin-top: 2px;
    font-size: var(--fs-xs);
    opacity: .88;
}

/* ========== 空状态 ========== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-6) var(--sp-4);
    text-align: center;
}
.empty-state__icon {
    font-size: 32px;
    line-height: 1;
    opacity: .42;
}
.empty-state__text {
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

/* 图表容器的引导空态（未设置出生日期等场景） */
.h-64 {
    position: relative;
}
.chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: var(--r-md);
    z-index: 1;
}

/* ========== Toast 反馈 ========== */
.toast-host {
    position: fixed;
    left: 50%;
    bottom: calc(88px + var(--safe-bottom));
    transform: translateX(-50%);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-2);
    pointer-events: none;
    width: max-content;
    max-width: 92vw;
}
.toast {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 92vw;
    padding: 10px var(--sp-4);
    border-radius: var(--r-full);
    background: var(--g-800);
    color: #ffffff;
    font-size: var(--fs-sm);
    font-weight: 500;
    box-shadow: var(--sh-lg);
    animation: toastIn var(--dur-base) var(--ease-out);
}
:root[data-theme="dark"] .toast {
    background: var(--g-700);
    border: 1px solid var(--border-strong);
}
.toast--ok  { background: var(--green-600); }
.toast--err { background: var(--red-600); }
:root[data-theme="dark"] .toast--ok  { background: #166534; }
:root[data-theme="dark"] .toast--err { background: #991b1b; }
.toast.is-out { animation: toastOut var(--dur-base) var(--ease) forwards; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px) scale(.96); }
    to   { opacity: 1; transform: none; }
}
@keyframes toastOut {
    to { opacity: 0; transform: translateY(-6px) scale(.97); }
}

/* ========== 底部弹层（编辑器） ========== */
.sheet-mask {
    position: fixed;
    inset: 0;
    z-index: var(--z-sheet);
    background: rgba(15, 23, 42, .42);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur-base) var(--ease), visibility var(--dur-base);
}
.sheet-mask.open { opacity: 1; visibility: visible; }

.sheet {
    position: fixed;
    left: 50%;
    bottom: 0;
    z-index: var(--z-sheet);
    width: 100%;
    max-width: 640px;
    transform: translate(-50%, 102%);
    display: flex;
    flex-direction: column;
    max-height: 88vh;
    padding-bottom: var(--safe-bottom);
    background: var(--surface);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    box-shadow: var(--sh-lg);
    transition: transform var(--dur-slow) var(--ease-out);
}
.sheet.open { transform: translate(-50%, 0); }
.sheet__grab {
    flex: none;
    width: 36px;
    height: 4px;
    margin: var(--sp-2) auto var(--sp-1);
    border-radius: var(--r-full);
    background: var(--border-strong);
    opacity: .5;
}
.sheet__head {
    flex: none;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-light);
}
.sheet__title {
    flex: 1;
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--text-primary);
}
.sheet__close {
    flex: none;
    width: var(--hit);
    height: var(--hit);
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.3rem;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease);
}
.sheet__close:active { background: var(--surface-sunken); }
.sheet__body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-4);
    -webkit-overflow-scrolling: touch;
}
.sheet__foot {
    flex: none;
    display: flex;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4) var(--sp-4);
    border-top: 1px solid var(--border-light);
}
.sheet__foot .btn-main,
.sheet__foot .btn-gray { flex: 1; }

/* ========== 设置行 ========== */

/* 主题切换段控 */
.theme-toggle {
    display: flex;
    gap: 2px;
    padding: 3px;
    border-radius: var(--r-full);
    background: var(--surface-sunken);
    border: 1px solid var(--border-light);
    margin-top: var(--sp-2);
}
.theme-toggle button {
    flex: 1;
    min-height: 34px;
    border-radius: var(--r-full);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
    transition: background var(--dur-base) var(--ease), color var(--dur-base) var(--ease);
}
.theme-toggle button.is-active {
    background: var(--surface);
    color: var(--accent-text);
    font-weight: 600;
    box-shadow: var(--sh-xs);
}

/* 用户身份徽标 */
.identity {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-4);
    border-radius: var(--r-lg);
    background: linear-gradient(135deg, var(--pink-400) 0%, var(--pink-600) 100%);
    color: #ffffff;
    box-shadow: var(--sh-accent);
    margin-bottom: var(--sp-4);
}
.identity__avatar {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: var(--r-md);
    background: rgba(255, 255, 255, .22);
    font-size: 22px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.identity__body { flex: 1; min-width: 0; }
.identity__name {
    font-size: var(--fs-lg);
    font-weight: 700;
}
.identity__code {
    font-size: var(--fs-sm);
    opacity: .88;
    font-variant-numeric: tabular-nums;
}

/* ========== 动画 ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.page-content {
    animation: fadeIn var(--dur-slow) var(--ease-out);
}

.sub-content {
    animation: slideIn var(--dur-base) var(--ease-out);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ========== 响应式 ========== */
@media (max-width: 400px) {
    .header {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        min-height: calc(52px + var(--status-bar-height));
    }
    #menuToggle {
        width: 42px;
        height: 42px;
    }
    .card-shadow {
        padding: 1rem;
        border-radius: var(--r-md);
    }
    .stat-grid { gap: var(--sp-2); }
    .rec-time { width: 46px; }
    /* 小屏下日期胶囊只留日期，去掉星期 */
    .date-chip { padding: 0 10px; font-size: var(--fs-xs); }
}

/* ========== 横屏 / 小高度设备 ========== */
@media (max-height: 500px) {
    .header {
        min-height: calc(48px + var(--status-bar-height));
    }
    .card-shadow {
        padding: 1rem;
        margin-bottom: 0.75rem;
    }
    .sheet { max-height: 94vh; }
}

/* ========== AI 聊天底部输入栏 ========== */
.ai-chat-footer {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 0.75rem;
    border-top: 1px solid var(--border-light);
    background: var(--surface);
}
.ai-chat-footer input#aiChatInput {
    flex: 1 1 auto;
    min-width: 0;
    border: 1.5px solid transparent;
    border-radius: var(--r-sm);
    padding: 0.6rem 0.9rem;
    font-size: var(--fs-md);
    outline: none;
    background: var(--surface-sunken);
    color: var(--text-primary);
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
    height: var(--hit);
}
.ai-chat-footer input#aiChatInput:focus {
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}
.ai-chat-footer button {
    flex-shrink: 0;
    width: auto;
    height: var(--hit);
    padding: 0 1.25rem;
    border-radius: var(--r-sm);
    font-weight: 600;
    font-size: var(--fs-md);
    border: none;
    cursor: pointer;
    white-space: nowrap;
    touch-action: manipulation;
}
.ai-chat-footer button.btn-send {
    background: linear-gradient(135deg, var(--pink-400), var(--accent));
    color: white;
    box-shadow: var(--sh-accent);
}
.ai-chat-footer button.btn-send:active { transform: scale(0.97); }
.ai-chat-footer button.btn-log {
    background: var(--surface-sunken);
    color: var(--text-secondary);
    padding: 0 0.9rem;
    font-size: 1rem;
}
.ai-chat-footer button.btn-log:active { background: var(--border-light); }

/* ========== 模态弹窗（AI 聊天 / 日志 / 编辑）深色适配 ========== */
/* 这些容器在 HTML 中用 Tailwind 的 bg-white，深色下需覆写 */
:root[data-theme="dark"] .bg-white {
    background-color: var(--surface) !important;
}
:root[data-theme="dark"] .bg-gray-50,
:root[data-theme="dark"] .bg-gray-100 {
    background-color: var(--surface-sunken) !important;
}
:root[data-theme="dark"] .text-gray-400 { color: var(--text-muted) !important; }
:root[data-theme="dark"] .text-gray-500,
:root[data-theme="dark"] .text-gray-600 { color: var(--text-secondary) !important; }
:root[data-theme="dark"] .text-gray-700,
:root[data-theme="dark"] .text-gray-800 { color: var(--text-primary) !important; }
:root[data-theme="dark"] .border-b,
:root[data-theme="dark"] .border-t { border-color: var(--border-light) !important; }
/* 深色下 Tailwind 的粉底按钮改深色调，避免刺眼 */
:root[data-theme="dark"] .bg-milk { background-color: var(--accent) !important; }
:root[data-theme="dark"] .bg-gray-200 { background-color: var(--surface-sunken) !important; }
/* ========== 工具类 ==========
   收口原先散落在 index.html 内联 style 里的硬编码尺寸，
   统一走 8pt 栅格令牌，改版时只需改令牌。
   （mb-3 / mt-4 / w-full 与 Tailwind 同名同值，此处显式定义
     是为了在 output.css 重新生成后依然稳定。） */
.m-0    { margin: 0; }
.mb-1   { margin-bottom: var(--sp-1); }   /* 4px */
.mb-3   { margin-bottom: var(--sp-3); }   /* 12px */
.mt-4   { margin-top: var(--sp-4); }      /* 16px */
.w-full { width: 100%; }

/* 卡片标题旁的次要操作按钮：视觉更紧凑（34px），
   但用 ::after 把热区补足到 44px，不牺牲可点性 */
.btn-xs {
    min-height: 34px;
    padding: 0 var(--sp-3);
    position: relative;
}
.btn-xs::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: var(--hit);
    transform: translateY(-50%);
}

/* 卡片标题行：左标题 + 右次要操作（如刷新） */
.list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
}

/* 紧凑图标按钮：视觉 32px，热区补足到 44px */
.btn-icon-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    flex: none;
    border: none;
    border-radius: var(--r-full);
    background: var(--surface-sunken);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    cursor: pointer;
    position: relative;
    transition: background-color .15s, color .15s;
}
.btn-icon-sm:hover { background: var(--border); color: var(--text-primary); }
.btn-icon-sm:active { transform: scale(.94); }
.btn-icon-sm::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: var(--hit);
    height: var(--hit);
    transform: translate(-50%, -50%);
}
.btn-icon-sm.is-loading i { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
