/* =========================================
   1. 全局定义 (Variables & Reset)
   ========================================= */
:root {
    /* 核心配色 (Light Mode) */
    --bg-color: #fafafa;
    --card-bg: #ffffff;
    --text-color: #1c1c1e;
    --accent-brown: #1c1c1e;
    
    /* 辅助色 & 边框 */
    --border-color: rgba(0, 0, 0, 0.08);
    --border-light: rgba(0, 0, 0, 0.05);
    --link-text-color: #8e8e93; 
    
    /* 功能色 */
    --btn-danger: #FF3B30;
    --btn-warn: #FF9500;
    --btn-pin: #FF9500;
    
    /* 字体与布局 */
    --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, sans-serif;
    --link-font-size: 0.9rem;
    --link-font-weight: 600; 
    
    /* 动态计算变量 (由 JS 控制) */
    --header-h: 0px;
    --freeze-h: 0px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    font-family: var(--font-stack);
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0; padding: 20px;
    display: flex; flex-direction: column; align-items: center;
    min-height: 100vh;
    overscroll-behavior-y: contain; overflow-x: hidden; touch-action: pan-y;
}

/* =========================================
   2. 核心布局 (Header, Footer & Main)
   ========================================= */
/* 2.1 顶部标题区 */
header { 
    position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 900; 
    width: calc(100% - 40px); max-width: 900px; 
    background: var(--bg-color); 
    text-align: center; padding: 10px 0 1px; /* 增加一点内边距让比例更协调 */
}

header::after {
    content: '';
    position: absolute;
    left: 0; 
    bottom: -2px; /* 向下延伸 2px，盖住缝隙 */
    width: 100%; 
    height: 4px;  /* 高度给足一点 */
    background: var(--bg-color); /* 颜色和 header 一样 */
    z-index: -1;  /* 放在文字层级后面 */
    pointer-events: none; /* 不影响点击 */
}

/* --- 统一视觉版 --- */
.logo-row {
    display: flex;
    justify-content: center;
    align-items: baseline;   /* 基线对齐 */
    gap: 10px;                /* 间距拉近，显得更像一个整体 */
    
    padding-top: 8px;
    margin-bottom: 2px;
}
/* --- 中文：有料 --- */
.brand-zh {
    margin: 0;
    font-size: 1.3rem;       /* 约 24px */
    font-weight: 600;        /* 特粗 */
    color: var(--text-color);
    letter-spacing: 3px;     
}
/* --- 英文：ULOG --- */
.brand-en {
    /* 【视觉修正】英文调大一点，为了跟中文高度看起来一致 */
    font-size: 1.3rem;      
    /* 【字重统一】也设为 800，甚至可以用 900 */
    font-weight: 600;        
    /* 【颜色统一】不再用灰色，而是用跟中文一样的主题色 */
    color: var(--text-color); 
    letter-spacing: 3px;
    /* 选用无衬线字体，更硬朗 */
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "SF Pro Text", sans-serif;
}

/* =========================================
   新增：搜索框样式 (优化版：胶囊状、带图标、浅色)
   ========================================= */
.search-input {
    /* 1. 布局与尺寸 */
    width: 100%; 
    height: 36px;
    margin-top: 5px; 
    
    /* 2. 视觉风格：胶囊状，定制色彩 */
    border-radius: 999px; 
    /* 采用更具质感的中性浅灰色，参考主流设计 
       (如果觉得颜色不对，可以调整这里的 rgba 值)
    */
    background-color: rgba(118, 118, 128, 0.12);
    border: none;

    /* 3. 加入放大镜图标 (位置不变) */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23999999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 10px center; /* 稍微靠左一点点，让出空间 */
    background-size: 16px;
    
    /* 4. 文字样式与关键的对齐设置 */
    font-family: var(--font-stack);
    font-size: 0.85rem;
    color: var(--text-color);
    
    /* 【核心改动】文字居中 */
    text-align: center; 
    
    /* 【关键技巧】
       为了让文字在视觉上绝对居中，左右 padding 必须一致。
       左侧为了放图标需要约 32px 的空间，所以右侧也要给 32px。
    */
    padding: 0 32px; 
    
    /* 5. 交互 */
    outline: none;
    transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    -webkit-appearance: none;
}

/* 占位符颜色 */
.search-input::placeholder {
    color: var(--link-text-color);
    opacity: 0.7; /* 稍微提升一点不透明度，让它在新的背景色上更清晰 */
    letter-spacing: 1px;
}

/* 聚焦时的交互 */
.search-input:focus {
    /* 聚焦时背景变亮成卡片色 */
    background-color: var(--card-bg);
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    /* 聚焦时，文字颜色加深，保持居中 */
    color: var(--text-color);
}

/* 暗黑模式适配 */
@media (prefers-color-scheme: dark) {
    .search-input {
        /* 深色模式下的背景色调整 */
        background-color: rgba(255, 255, 255, 0.1);
    }
    .search-input:focus {
        background-color: #1c1c1e;
    }
}

/* =========================================
   🔍 全屏搜索覆盖层 (沉浸式精简版)
   ========================================= */
/* 1. 全屏容器 */
.search-overlay {
    position: fixed;
    top: var(--freeze-h, 0px); 
    left: 50%;                 /* ✨ 修改点：配合 transform 实现居中 */
    transform: translateX(-50%); /* ✨ 修改点：居中对齐 */
    width: calc(100% - 40px);  /* ✨ 修改点：与导航栏宽度逻辑一致 */
    max-width: 900px;          /* ✨ 修改点：限制 PC 端最大宽度 */
    height: calc(100% - var(--freeze-h));
    background-color: var(--bg-color); 
    z-index: 1500; 
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 5px 0;
    display: none;
    /* 建议添加一个微弱的侧边阴影或边框，增加 PC 端的边界感 */
    border-left: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
}

/* 2. 列表项：参考小红书，增加水平内边距，减小垂直间距 */
.search-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px; /* 稍微收紧垂直高度 */
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background-color 0.2s;
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:active {
    background-color: rgba(0, 0, 0, 0.05);
}

/* 左侧：名称与图标 */
.s-name {
    /* ✨ 字体缩小：参考小红书 14px-15px 左右 */
    font-size: 0.92rem; 
    font-weight: 400; /* 抖音风格通常不使用粗体 */
    color: var(--text-color);
    display: flex;
    align-items: center;
    letter-spacing: 0.2px; /* 增加微小字间距提高精致感 */
}

/* 搜索建议前的小图标 */
.s-name::before {
    content: '';
    display: block;
    width: 14px; /* 图标随字体一起缩小 */
    height: 14px;
    margin-right: 12px;
    opacity: 0.35;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

/* 右侧标签：参考抖音，使用更小的辅助字号 */
.s-tag {
    font-size: 0.72rem; /* 显著缩小标签字体 */
    color: var(--link-text-color);
    font-weight: 300;
    opacity: 0.8;
}

/* --- 🎯 修正放大镜图标对齐 --- */
.search-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    height: 100%;
    cursor: pointer;
    margin-top: 1px; 
}

/* =========================================
   🌙 暗黑模式适配
   ========================================= */
@media (prefers-color-scheme: dark) {
    .search-overlay {
        background-color: var(--bg-color) !important;
        border-top: 1px solid var(--border-light);
    }
    
    .search-item:active {
        background-color: rgba(255, 255, 255, 0.05);
    }

    .s-tag {
        color: var(--link-text-color);
    }
}

/* =========================================
   2.2 分类导航栏 (Sticky) - 包含搜索增强版
   ========================================= */
.section-title {
    position: fixed; 
    top: var(--header-h, 0px); 
    left: 50%; 
    transform: translateX(-50%); 
    z-index: 800;
    width: calc(100% - 40px); 
    max-width: 900px;
    display: flex; 
    justify-content: space-between; 
    /* ✨ 修改点：使用 center 确保导航文字和右侧图标在一条水平线上 */
    align-items: center; 
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    /* ✨ 修改点：将 padding 改为上下对称，防止视觉偏移 */
    padding: 8px 0; 
    margin: 0 auto 15px; 
}

.section-left { 
    position: relative; display: flex; align-items: center;
    width: 100%; gap: 5px; padding: 0; background: transparent; 
}

/* 导航项基础样式 */
.section-item, #addCustomBtn, #timeBtn { 
    flex: 1; text-align: center;
    font-family: 'PingFang SC', 'SF Pro Text', sans-serif;
    font-size: 0.85rem; font-weight: 500; color: var(--link-text-color);
    padding: 8px 0; border-radius: 8px; cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}

#addCustomBtn, #timeBtn { margin-left: 0 !important; background: transparent; }

/* --- 新增：搜索触发图标 (放大镜) --- */
.search-trigger {
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--link-text-color);
    cursor: pointer;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

/* --- 新增：全宽搜索容器 (覆盖层) --- */
.nav-search-container {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-color);
    display: none; /* 由 JS 控制显示/隐藏 */
    align-items: center;
    padding: 0 2px 10px 2px; /* 与 section-title 的 padding 保持一致感 */
    z-index: 850;
}

.nav-search-input {
    flex: 1;
    height: 36px;
    border-radius: 18px;
    border: none;
    background-color: rgba(118, 118, 128, 0.12); /* 浅灰色背景 */
    padding: 0 15px;
    font-size: 0.9rem;
    outline: none;
    color: var(--text-color);
    -webkit-appearance: none;
}

.close-search-btn {
    padding: 0 12px;
    font-size: 0.85rem;
    color: var(--link-text-color);
    cursor: pointer;
    white-space: nowrap;
    font-weight: 500;
}

/* 导航激活状态 */
.section-item.active-nav, #timeBtn.active-nav, #addCustomBtn.active-nav {
    background-color: var(--card-bg) !important;
    color: var(--accent-brown) !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 10px var(--border-color);
    transform: none; opacity: 1;
}

/* 暗黑模式下搜索框背景微调 */
@media (prefers-color-scheme: dark) {
    .nav-search-input {
        background-color: rgba(255, 255, 255, 0.1);
    }
}

/* 2.3 底部合规栏 (Footer) - 修复层级问题 */
.app-footer {
    position: fixed; bottom: 0; left: 0; width: 100%; 
    /* 👇 【核心修复】降级到 500 */
    /* 这样它高于普通内容(0)，但远低于弹窗(20000) */
    z-index: 500; 
    padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    background-color: var(--bg-color) !important;
    border-top: 1px solid var(--border-light);
    font-size: 0.7rem; text-align: center;
    display: flex; justify-content: center; align-items: center;
    backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
}

.app-footer a {
    color: #999; text-decoration: none; margin: 0 8px; transition: color 0.2s;
    position: relative; z-index: 501; padding: 5px;
}
.app-footer a:hover { color: var(--text-color); }
.app-footer .divider { color: #ddd; font-size: 0.6rem; }

/* 2.4 主容器与侧边栏 */
.main-container {
    display: flex; width: 100%; max-width: 900px; gap: 15px;
    margin-bottom: 50px; padding-top: var(--freeze-h, 0px);
    padding-bottom: 80vh !important; /* 无限滑动视觉核心 */
    min-height: 100vh;
}

.sidebar {
    width: 86px; flex-shrink: 0; height: fit-content;
    display: flex; flex-direction: column; gap: 12px; 
    position: sticky; top: calc(var(--freeze-h, 0px) + 20px); 
}

.sidebar-item {
    padding: 12px 4px; border-radius: 12px; 
    background: transparent; border: none; 
    font-size: var(--link-font-size) !important; font-weight: 500 !important;
    color: #9e9e9e; text-align: center; word-wrap: break-word; cursor: pointer;
    transition: all 0.3s ease;
}
.sidebar-item.active {
    background-color: var(--card-bg); color: var(--accent-brown);
    font-weight: 600 !important; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06); 
}

/* 2.5 列表网格 */
.menu-grid {
    display: flex; flex-direction: column; width: 100%;
    padding-bottom: 80vh !important;
}

.menu-section-title {
    font-size: var(--link-font-size) !important;
    font-weight: var(--link-font-weight) !important;
    color: var(--link-text-color) !important;
    padding: 30px 0 10px 0; margin-bottom: 10px;
    border-bottom: none !important;
}
#section-coffee .menu-section-title, #section-custom .menu-section-title { padding-top: 20px !important; }

.menu-item {
    display: flex; align-items: center; position: relative;
    padding: 15px 0; border-bottom: none;
    background: transparent; border-radius: 0; 
    text-align: left; cursor: pointer; overflow: hidden;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: rgba(0,0,0,0.02); }

.menu-icon {
    width: 36px; height: 36px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-color); border-radius: 50%; 
    margin: 0 16px 0 0; font-size: 26px;
}
.menu-icon img.menu-thumb { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

.menu-name {
    flex: 1; min-width: 0; padding-right: 15px;
    font-size: 0.9rem; font-weight: 500; line-height: 1.2; color: var(--text-color);
    word-wrap: break-word;
}

/* =========================================
   3. 通用组件 (Buttons, Inputs & Swipes)
   ========================================= */
/* 3.1 毛玻璃按钮通用类 */
.save-btn, .small-btn, .add-step-bottom, .step-row-delete {
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    background-color: rgba(255, 255, 255, 0.65) !important;
    border: 1px solid var(--border-light) !important;
    color: var(--text-color) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
    font-weight: 500 !important;
    transition: transform 0.1s, background-color 0.2s !important;
    cursor: pointer;
}
.save-btn:active, .small-btn:active, .add-step-bottom:active, .step-row-delete:active {
    transform: scale(0.94) !important;
    background-color: rgba(255, 255, 255, 0.85) !important;
}

/* 保存按钮 (配方页) */
.save-btn {
    pointer-events: none; width: auto !important; min-width: 110px; 
    padding: 8px 20px; margin-top: 0 !important; border-radius: 50px !important; 
    font-size: 14px; background-color: rgba(255, 255, 255, 0.75) !important; 
    display: none; /* JS 控制显示 */
    align-items: center; justify-content: center; gap: 5px;
}

/* 小按钮 (确认框/存储框) */
.small-btn {
    font-size: 0.85rem !important; padding: 6px 12px; border-radius: 14px; white-space: nowrap;
    background-color: rgba(120, 120, 128, 0.08) !important;
    backdrop-filter: none !important; box-shadow: none !important;
    flex: 1; display: flex; align-items: center; justify-content: center;
}
.small-btn:active { opacity: 0.7; transform: scale(0.98); }

/* 特殊功能色按钮 */
#updateNowBtn { background-color: var(--text-color) !important; color: var(--bg-color) !important; }
.btn-danger-text { color: var(--btn-danger) !important; background-color: rgba(255, 59, 48, 0.08) !important; }

/* 3.2 圆形功能按钮 (添加/删除步骤) */
.step-row-delete, .add-step-bottom {
    width: 20px !important; height: 20px !important; flex-shrink: 0;
    display: flex !important; align-items: center; justify-content: center;
    border-radius: 50% !important; padding: 0 !important;
    background-color: transparent !important;
    color: var(--accent-brown) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
}

.add-step-bottom {
    margin: 10px 0 30px auto !important;
    font-size: 20px !important; font-weight: 400 !important; line-height: 1 !important;
}
#addStepBtn:not(.add-step-bottom) { display: none !important; }

.step-row-delete {
    margin-left: 8px; color: transparent !important; font-size: 0; position: relative;
}
.step-row-delete svg { display: none !important; }
.step-row-delete::after {
    content: '×'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -54%);
    color: var(--text-color) !important; font-size: 18px; font-weight: 400; line-height: 1;
}

/* 3.3 输入框组件 */
.step-row-wrapper {
    display: flex; align-items: center; 
    margin-bottom: 3px; padding: 0; position: relative; overflow: hidden; 
    transition: all 0.3s cubic-bezier(0.33, 1, 0.68, 1);
}

.step-input {
    flex: 1; background-color: transparent; 
    border: 1px solid rgba(0, 0, 0, 0.06); border-radius: 12px; padding: 12px 16px;
    font-size: 16px; color: var(--text-color); line-height: 1.6;
    outline: none; resize: none; transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.step-input:focus { 
    background-color: var(--card-bg); border-color: transparent; 
    box-shadow: 0 4px 15px var(--border-color); transform: scale(1.01); z-index: 5;
}

#customInputs { 
    width: 100%; display: flex; flex-direction: column; gap: 8px; 
    margin: -5px 0 0 18px !important; 
}
/* ✅ 粘贴这段新代码 */
#inputTitle {
    font-size: 1.2rem; 
    font-weight: 600; 
    color: var(--text-color);
    /* 统一视觉风格：圆角气泡框 */
    background-color: transparent; 
    border: 1px solid rgba(0, 0, 0, 0.06); 
    border-radius: 12px; 
    padding: 10px 16px; 
    width: 100%;
    outline: none; 
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
#inputTitle:focus { 
    /* 聚焦时的动效 */
    background-color: var(--card-bg); 
    border-color: transparent; 
    box-shadow: 0 4px 15px var(--border-color); 
    transform: scale(1.01); 
    z-index: 5;
}

/* 3.4 滑动操作 (Swipe Actions) */
.swipe-item { position: relative; overflow: hidden; display: flex; align-items: center; padding: 0; }

.swipe-content {
    width: 100%; padding: 15px 0; display: flex; align-items: center;
    background-color: var(--bg-color); position: relative; z-index: 2;
    transition: transform 0.2s ease-out; touch-action: pan-x;
}
.swipe-content::after {
    content: ''; position: absolute; top: 0; right: 0;
    width: 2px; height: 100%; background-color: var(--bg-color);
    z-index: 3; pointer-events: none;
}
.swipe-content.pinned-item {
    /* 1. 改为纯白色：比背景(#fafafa)更亮，形成自然的“凸起感” */
    background-color: #ffffff !important; 
    /* 2. 必须全宽：遮挡底部按钮 */
    width: 100% !important;
    margin: 0 !important;
    font-weight: 500;
}

/* 隐藏原有底部分割线 */
.swipe-content.pinned-item::after { display: none; }

.swipe-actions { 
    position: absolute; top: 0; right: 0; bottom: 0; z-index: 1; 
    display: flex; align-items: center; justify-content: center; gap: 12px; 
    padding: 0 16px; background: transparent; 
}

.swipe-btn, .hover-btn {
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; cursor: pointer; flex-shrink: 0;
}

.swipe-btn {
    width: 44px; height: 44px; border: none; color: white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1); padding: 0;
}
.swipe-btn svg { width: 20px; height: 20px; fill: currentColor; display: block; }
.btn-pin { background-color: var(--btn-pin); }
.btn-delete { background-color: var(--btn-danger); }

/* PC端悬浮 */
.card-hover-actions {
    position: absolute; top: 50%; transform: translateY(-50%); right: 15px;
    display: none; gap: 8px; z-index: 10;
}
@media (hover: hover) { .menu-item:hover .card-hover-actions { display: flex; } }

.hover-btn {
    width: 34px; height: 34px; background: rgba(255,255,255,0.95);
    border: 1px solid var(--border-color); transition: transform 0.2s;
}
.hover-btn:hover { transform: scale(1.1); background-color: #fff; }
.hover-btn-pin { color: #FFC107; }
.hover-btn-del { color: var(--btn-danger); }

/* =========================================
   4. 统一弹窗系统 (Modal System)
   ========================================= */
/* 4.1 遮罩层 */
.modal-overlay, .storage-overlay, .image-preview-overlay {
    position: fixed; inset: 0; 
    z-index: 20000; /* 弹窗层级：20000 */
    background-color: rgba(0, 0, 0, 0.4); 
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    display: flex; justify-content: center; align-items: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
    padding: 0;
}
.modal-overlay.active, .storage-overlay.active, .image-preview-overlay.active { 
    opacity: 1; pointer-events: auto; 
}

/* 当遮罩激活时，内部的保存按钮恢复点击 */
.modal-overlay.active .save-btn { pointer-events: auto; }

/* 4.2 确认卡片 & 存储卡片 */
.confirm-card, .storage-card {
    width: 85%; max-width: 320px; height: auto;
    display: flex; flex-direction: column; 
    position: relative; margin: auto;
    background: var(--card-bg); border-radius: 24px; padding: 24px 20px;
    border: none; box-shadow: 0 20px 40px rgba(0,0,0,0.2), 0 0 0 1px var(--border-light);
    transform: scale(0.92) translateY(10px); opacity: 0;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-overlay.active .confirm-card, 
.storage-overlay.active .storage-card {
    transform: scale(1) translateY(0); opacity: 1;
}

.confirm-title, .storage-header h3 {
    text-align: center; font-size: 1.1rem; font-weight: 700;
    margin: 0 0 12px 0; color: var(--text-color);
}
.confirm-card div, .storage-tip {
    text-align: center; font-size: 0.9rem; color: var(--text-color); opacity: 0.8; line-height: 1.5;
}
.confirm-actions, .storage-actions {
    display: flex; gap: 12px; margin-top: 24px; justify-content: center;
}
.storage-actions { flex-direction: column; gap: 10px; }

/* 4.3 存储空间专属 */
.storage-header { justify-content: center; position: relative; }
.storage-close-btn { 
    position: absolute; right: 0; top: -2px;
    background: transparent; border: none; font-size: 24px; color: #999; padding: 5px; 
}
.storage-progress-section { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.storage-info-row { display: flex; justify-content: space-between; font-size: 0.85rem; padding: 0 5px; }
.storage-track { height: 8px; width: 100%; background: rgba(0,0,0,0.05); border-radius: 10px; overflow: hidden; }
.storage-bar { height: 100%; background: linear-gradient(90deg, #32ade6 0%, #007aff 100%); border-radius: 10px; transition: width 0.5s ease; }

/* 4.4 图片预览专属 */
.image-preview-overlay {
    background-color: #000; /* 纯黑背景，不再透明 */
    backdrop-filter: none;  /* 既然纯黑不透明了，把毛玻璃关掉还能省电 */
}
.image-preview-overlay img { 
    /* 1. 强制宽高占满屏幕，给 object-fit 留出空间 */
    width: 100vw; 
    height: 100vh; 
    /* 2. 【核心】contain 保证图片按比例完整显示，绝不裁剪，不足的地方留黑边 */
    object-fit: contain; 
    /* 3. 去掉圆角和阴影，还原最真实的图片展示 */
    border-radius: 0; 
    box-shadow: none; 
}

/* 4.5 Toast 提示 */
#toast {
    position: fixed; left: 50%; top: 10%; z-index: 2147483647; 
    background: rgba(28, 28, 30, 0.95); backdrop-filter: blur(10px);
    color: #fff; padding: 12px 24px; border-radius: 50px;
    opacity: 0; pointer-events: none; transform: translate(-50%, 0) scale(0.9);
    transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2); font-weight: 600; font-size: 14px;
}
#toast.show { top: 12%; opacity: 1; transform: translate(-50%, 0) scale(1); }

/* =========================================
   4.6 iOS 风格底部菜单 (Action Sheet) - 补回缺失样式
   ========================================= */
.ios-sheet-overlay {
    position: fixed; inset: 0; 
    z-index: 21000; /* 这里的层级非常重要，必须比弹窗(20000)高 */
    background-color: rgba(0, 0, 0, 0.4);
    display: flex; flex-direction: column; justify-content: flex-end; 
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.ios-sheet-overlay.active { opacity: 1; pointer-events: auto; }

.ios-sheet-container {
    width: 100%; max-width: 500px; margin: 0 auto 10px; 
    padding: 0 8px;
    transform: translateY(100%); 
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.ios-sheet-overlay.active .ios-sheet-container { transform: translateY(0); }

.ios-sheet-group {
    background-color: rgba(250, 250, 250, 0.9);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-radius: 14px; overflow: hidden; margin-bottom: 8px;
}

.ios-sheet-btn {
    width: 100%; padding: 16px 0;
    background: transparent; border: none; border-bottom: 1px solid rgba(0,0,0,0.1);
    font-size: 1.1rem; color:var(--text-color); cursor: pointer;
    font-family: var(--font-stack);
}
.ios-sheet-btn:last-child { border-bottom: none; }
.ios-sheet-btn:active { background-color: rgba(0,0,0,0.05); }

.ios-sheet-btn.destructive { color: var(--btn-danger); }
.ios-sheet-btn.bold { font-weight: 600; }

/* =========================================
   5. 配方详情卡片 (Recipe Card)
   ========================================= */
.recipe-card {
    background: var(--bg-color); width: 100%; height: 100%; border: none;
    display: flex; flex-direction: column; 
    transform: translateY(20px); transition: transform 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.modal-overlay.active .recipe-card { transform: translateY(0); }

.recipe-header { 
    position: sticky; top: 0; z-index: 2; min-height: 50px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 20px; background-color: var(--bg-color); 
    border-bottom: 1px solid var(--border-light); 
}
.recipe-title { 
    flex: 1; margin: 0 0 0 18px; padding-right: 15px; position: relative;
    font-size: 1.2rem; line-height: 1.2; min-width: 0; 
}
.back-btn, .custom-back-btn { 
    position: absolute; top: 50%; transform: translateY(-50%); 
    display: inline-flex; align-items: center; justify-content: center; 
    width: 40px; height: 40px; cursor: pointer; color: var(--accent-brown); 
}
.back-btn { left: -36px; }
.custom-back-btn { left: 2px; z-index: 10; }
.ellipsis-btn {
    width: 36px; height: 36px; margin-right: -8px; 
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: none; cursor: pointer; color: var(--accent-brown); 
}

.recipe-content-scroll { 
    flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; 
    padding-bottom: 120px !important; 
}
.recipe-body { padding: 25px 0px 20px; }

/* 详情页图片容器 */
.image-container {
    margin: -25px 0 18px; width: 100%; aspect-ratio: 3 / 4; 
    position: relative; overflow: hidden; background-color: var(--border-light);
}
.recipe-image { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; }
.image-container:active .recipe-image { transform: scale(1.02); opacity: 0.95; }

/* 编辑模式图片 */
.image-container.edit-mode {
    width: auto !important; height: auto !important; aspect-ratio: unset !important;
    margin: 10px 0 20px 30px !important; display: flex; gap: 15px; overflow: visible !important;background-color: transparent !important;
}
.image-container.edit-mode .image-add-overlay {
    position: static !important; width: auto !important; height: auto !important;
    background: transparent !important; inset: auto !important; flex-shrink: 0; 
}
.image-container.edit-mode .recipe-image, 
.image-container.edit-mode .upload-tile {
    width: 80px !important; height: 80px !important; border-radius: 12px !important; margin: 0 !important;
}
.image-container.edit-mode .recipe-image { border: 1px solid var(--border-light); object-fit: cover; display: block; }
.upload-tile {
    display: flex; align-items: center; justify-content: center; 
    background: #fafafa; border: 1px dashed rgba(0,0,0,0.2); border-radius: 12px; cursor: pointer;
}
.upload-tile .plus { font-size: 32px; color: var(--accent-brown); }

/* 步骤与备注区域 */
.steps-block { margin-top: 10px; padding: 0 20px; }
.steps-bar { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 12px; }
.ratio-label { 
    font-size: 1rem !important; font-weight: 700 !important; 
    letter-spacing: -0.5px; color: var(--text-color) !important; 
}
#rSteps { 
    counter-reset: step-counter; list-style: none; padding-left: 0 !important; margin: 0 !important; 
}
#rSteps li:not(.step-row-wrapper) {
    position: relative; padding: 3px 0; border-bottom: none !important; 
    font-size: 0.95rem; line-height: 1.6; color: var(--text-color) !important;
    display: flex; align-items: baseline; 
}
#rSteps li:not(.step-row-wrapper)::before {
    counter-increment: step-counter; content: counter(step-counter);
    color: var(--accent-brown); font-weight: 450; font-size: 0.95rem;
    position: static; margin-right: 10px; flex-shrink: 0; line-height: 1.6;
}

#rNotesSection { margin-top: 30px; padding: 0 20px; }
.notes-header { margin-bottom: 8px; flex-shrink: 0; }
#rNotesDisplay { font-size: 0.95rem; color: var(--text-color); line-height: 1.6; }
#rNotesDisplay ul { list-style: none; margin: 0 !important; padding: 0 !important; border-left: none; }
#rNotesDisplay li {
    color: var(--text-color); font-size: 0.95rem; line-height: 1.8; margin-bottom: 4px;
    display: flex; align-items: baseline;
}
#rNotesDisplay li::before {
    content: ''; display: block; width: 6px; height: 6px; border-radius: 50%; 
    background-color: var(--accent-brown); margin-right: 12px; flex-shrink: 0; transform: translateY(-2px);
}
#rTipsSection { display: none !important; }

.recipe-footer { 
    position: absolute !important; bottom: 0 !important; left: 0 !important; width: 100% !important;
    z-index: 10 !important; background: transparent !important; border-top: none !important; 
    padding: 20px 30px !important; padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important;
    pointer-events: none; display: flex; justify-content: center; align-items: flex-end;
}

/* =========================================
   6. 适配 (Media Queries & Dark Mode)
   ========================================= */
/* PC 适配 */
@media (min-width: 768px) {
    .modal-overlay { padding: 40px; }
    .recipe-card {
        width: 100%; max-width: 420px; height: 85vh; max-height: 900px;
        border-radius: 24px; box-shadow: 0 20px 50px rgba(0,0,0,0.15); overflow: hidden;
    }
    .recipe-header { border-top-left-radius: 24px; border-top-right-radius: 24px; }
    
    .ios-sheet-overlay { justify-content: center; align-items: center; }
    .ios-sheet-container { width: 320px; margin-bottom: 0; transform: scale(0.9); opacity: 0; }
    .ios-sheet-overlay.active .ios-sheet-container { transform: scale(1); opacity: 1; }
    
    .recipe-content-scroll::-webkit-scrollbar { width: 6px; }
    .recipe-content-scroll::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }
    .recipe-content-scroll::-webkit-scrollbar-track { background: transparent; }
}

/* 暗黑模式适配 */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #000000;
        --card-bg: #1c1c1e;
        --text-color: #f5f5f7;
        --accent-brown: #ffffff;
        --link-text-color: #8e8e93;
        --border-color: rgba(255, 255, 255, 0.12);
        --border-light: rgba(255, 255, 255, 0.1);
    }

    /* 边框颜色覆盖 */
    .recipe-header, .section-title, .menu-item, 
    #rSteps li:not(.step-row-wrapper), .step-input,
    .ios-sheet-btn, .ios-sheet-group, .app-footer {
        border-color: var(--border-color) !important;
    }
    .menu-icon img.menu-thumb { border-color: rgba(255, 255, 255, 0.15) !important; }

    /* 输入框与背景 */
    .step-input:focus { background-color: #1c1c1e !important; color: #fff !important; }
    .upload-tile { background: #1c1c1e !important; border-color: rgba(255,255,255,0.2) !important; }
    .upload-tile .plus { color: #fff !important; }

    /* 激活与高亮状态 */
    .section-item.active-nav, #timeBtn.active-nav, #addCustomBtn.active-nav, .sidebar-item.active {
        background-color: #1c1c1e !important; color: #ffffff !important;
    }
    
    /* 置顶项深色适配 */
    .swipe-content.pinned-item {
    /* 1. 改为深灰色：比背景纯黑(#000000)稍微亮一点，像卡片一样浮起来 */
    background-color: #1c1c1e !important;
}
    
    /* 图片压暗 */
    img, .recipe-image { opacity: 0.9; transition: opacity 0.3s; }

    /* 按钮 & 弹窗：深色毛玻璃适配 */
    .save-btn, .small-btn, .add-step-bottom, .step-row-delete {
        background-color: rgba(40, 40, 40, 0.65) !important;
        border: 1px solid var(--border-light) !important;
        color: #ffffff !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important;
    }
    .save-btn:active, .small-btn:active, .add-step-bottom:active, .step-row-delete:active {
        background-color: rgba(60, 60, 60, 0.8) !important;
    }

    /* Action Sheet 深色适配 */
    .ios-sheet-group { background-color: rgba(40, 40, 40, 0.8) !important; }
    .ios-sheet-btn { color: #ffffff !important; border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important; }
    .ios-sheet-btn:active { background-color: rgba(255, 255, 255, 0.15) !important; }
    .ios-sheet-btn.destructive { color: #ff453a !important; }
    
    /* 底部栏 */
    .app-footer .divider { color: #444; }
}