/* ==========================================================================
   1. 基础配置与全局变量
   ========================================================================== */
:root {
    --primary: #5856d6;
    --primary-light: #f0f0ff;
    --bg: #f2f2f7;
    --card: #ffffff;
    --text-main: #1c1c1e;
    --text-sub: #8e8e93;
    --text-done: #c7c7cc;
    --red: #ff3b30;
    --sidebar-w: 260px;
    --radius-lg: 28px;
    --radius-md: 18px;
    --shadow-soft: 0 4px 20px rgba(0,0,0,0.05);
    --shadow-deep: 0 20px 40px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin: 0; padding: 0; outline: none; }
body { background: var(--bg); font-family: -apple-system, "SF Pro Display", sans-serif; color: var(--text-main); overflow-x: hidden; }

/* ==========================================================================
   2. 登录模块 (磨砂玻璃/高级感)
   ========================================================================== */
.auth-center { 
    display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; 
    background: linear-gradient(135deg, #f2f2f7 0%, #d1d1d6 100%); 
}
.auth-card { 
    background: rgba(255, 255, 255, 0.75); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); 
    padding: 45px 30px; border-radius: var(--radius-lg); width: 100%; max-width: 400px; 
    box-shadow: var(--shadow-deep); border: 1px solid rgba(255, 255, 255, 0.4); text-align: center; 
}
.auth-title { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
.auth-card p { color: var(--text-sub); font-size: 14px; margin-bottom: 35px; }
.field-box { margin-bottom: 15px; }
.field-box input { 
    width: 100%; padding: 16px 20px; background: rgba(255, 255, 255, 0.9); border: 1px solid rgba(0, 0, 0, 0.05); 
    border-radius: var(--radius-md); font-size: 16px; transition: 0.3s;
}
.field-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); background: #fff; }
.auth-btn { 
    width: 100%; padding: 18px; background: var(--primary); color: white; border: none; 
    border-radius: var(--radius-md); font-size: 16px; font-weight: 700; cursor: pointer; 
    box-shadow: 0 10px 25px rgba(88, 86, 214, 0.3); transition: 0.3s;
}
.auth-btn:active { transform: scale(0.97); }
.sub-action { margin-top: 30px; font-size: 14px; color: var(--text-sub); }
.text-btn { background: none; border: none; color: var(--primary); font-weight: 700; cursor: pointer; padding: 0 5px; }

/* ==========================================================================
   3. 核心布局 (移动端优先)
   ========================================================================== */
.app-layout { display: flex; flex-direction: column; min-height: 100vh; }

.sidebar-pc { display: none; }

.main-content { flex: 1; display: flex; flex-direction: column; width: 100%; }

.main-header { 
    background: var(--card); padding: 20px; border-radius: 0 0 30px 30px; 
    box-shadow: var(--shadow-soft); position: sticky; top: 0; z-index: 50; 
}
@supports (padding-top: env(safe-area-inset-top)) {
    .main-header { padding-top: calc(15px + env(safe-area-inset-top)); }
}
.header-top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.page-title { font-size: 24px; font-weight: 800; }
.mobile-avatar a { color: var(--text-sub); font-size: 20px; }
.search-wrapper { background: #f2f2f7; border-radius: 14px; padding: 10px 15px; display: flex; align-items: center; gap: 10px; }
.search-wrapper input { border: none; background: transparent; width: 100%; font-size: 15px; outline: none; }

/* ==========================================================================
   4. 列表与折叠
   ========================================================================== */
.scroll-view { padding: 15px 16px 150px; }
.group-header { display: flex; justify-content: space-between; align-items: center; margin-top: 25px; cursor: pointer; }
.group-label { font-size: 12px; font-weight: 800; color: var(--text-sub); text-transform: uppercase; letter-spacing: 1px; }
.group-toggle { color: var(--text-sub); font-size: 14px; display: flex; align-items: center; gap: 8px; }
#toggle-arrow { transition: 0.3s; transform: rotate(-90deg); }
.completed-hidden { display: none !important; }

.task-item { 
    background: var(--card); border-radius: 20px; margin-top: 12px; 
    display: flex; padding: 16px; box-shadow: var(--shadow-soft); align-items: center; 
}
.check-area { padding-right: 15px; cursor: pointer; }
.check-box { width: 24px; height: 24px; border: 2px solid #e5e5ea; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: transparent; transition: 0.2s; }
.is-done { opacity: 0.5; }
.is-done .check-box { background: var(--primary); border-color: var(--primary); color: #fff; }
.is-done .task-title { text-decoration: line-through; }

.is-overdue { border: 1px solid rgba(255, 59, 48, 0.2); background: #fffcfc; }
.overdue-tag { color: var(--red); font-size: 10px; font-weight: 800; margin-left: 8px; }

.task-body { flex: 1; }
.tag-badge { background: var(--primary-light); color: var(--primary); font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 6px; }
.task-title { font-size: 16px; font-weight: 600; margin: 4px 0; }
.task-time-info { font-size: 11px; color: var(--text-sub); }

/* ==========================================================================
   5. 弹窗面板与语音功能
   ========================================================================== */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); opacity: 0; pointer-events: none; transition: 0.3s; z-index: 1000; }
.overlay.visible { opacity: 1; pointer-events: auto; }
.sheet-modal { 
    position: fixed; bottom: -100%; left: 0; right: 0; background: #fff; 
    border-radius: 30px 30px 0 0; padding: 25px; transition: 0.4s cubic-bezier(0.16, 1, 0.3, 1); z-index: 1001; 
}
.sheet-modal.visible { bottom: 0; }
.sheet-handle { width: 40px; height: 5px; background: #eee; border-radius: 10px; margin: 0 auto 20px; }
.sheet-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }

.sheet-del-btn { 
    border: none; background: #fff1f0; color: var(--red); 
    width: 44px; height: 44px; border-radius: 14px; 
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 18px; 
}

/* 语音输入容器 */
.voice-input-container {
    position: relative;
    width: 100%;
    margin-bottom: 15px;
}
#task-text { 
    width: 100%; 
    background: #f2f2f7; 
    border: none; 
    border-radius: 18px; 
    padding: 18px 50px 18px 18px; /* 右侧留出按钮空间 */
    font-size: 16px; 
    font-family: inherit; 
    resize: none;
}

/* 语音按钮样式 */
.mic-trigger {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 36px;
    height: 36px;
    background: white;
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: 0.3s;
}
.mic-trigger.active {
    background: var(--red);
    color: white;
    animation: mic-pulse 1.5s infinite;
}
@keyframes mic-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.4); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(255, 59, 48, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}

.opt-item { background: #f2f2f7; padding: 14px; border-radius: 14px; margin-bottom: 10px; display: flex; gap: 10px; align-items: center; }
.opt-item input { background: transparent; border: none; flex: 1; font-size: 14px; }
.confirm-btn { width: 100%; background: var(--primary); color: #fff; padding: 18px; border-radius: 16px; font-weight: 800; border: none; cursor: pointer; }

/* ==========================================================================
   6. 悬浮按钮 & 底部导航
   ========================================================================== */
.fab { position: fixed; right: 20px; bottom: 100px; width: 60px; height: 60px; background: var(--primary); color: #fff; border: none; border-radius: 50%; font-size: 24px; box-shadow: 0 8px 25px rgba(88, 86, 214, 0.4); z-index: 90; }
.bottom-tabbar { 
    position: fixed; bottom: 0; left: 0; right: 0; height: 80px; 
    background: rgba(255,255,255,0.9); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    display: flex; border-top: 1px solid #eee; z-index: 100; padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-sub); text-decoration: none; }
.tab-btn.active { color: var(--primary); }
.tab-btn span { font-size: 10px; font-weight: 700; margin-top: 4px; }

/* ==========================================================================
   7. PC 端覆盖样式
   ========================================================================== */
@media (min-width: 992px) {
    .app-layout { flex-direction: row; }
    .sidebar-pc { 
        display: flex; width: var(--sidebar-w); background: var(--card); border-right: 1px solid #e5e5ea; 
        flex-direction: column; padding: 40px 24px; position: fixed; height: 100vh; left: 0; top: 0; z-index: 100;
    }
    .sidebar-logo { font-size: 22px; font-weight: 800; color: var(--primary); margin-bottom: 40px; display: flex; align-items: center; gap: 12px; }
    .side-item { padding: 15px 20px; border-radius: 14px; margin-bottom: 8px; cursor: pointer; color: var(--text-sub); display: flex; align-items: center; gap: 12px; font-weight: 600; }
    .side-item.active { background: var(--primary-light); color: var(--primary); }
    .sidebar-footer { margin-top: auto; padding-top: 20px; border-top: 1px solid #f2f2f7; }
    .side-logout { color: var(--text-sub); text-decoration: none; display: flex; align-items: center; gap: 10px; }

    .main-content { margin-left: var(--sidebar-w); max-width: 900px; padding: 0 40px; }
    .main-header { position: static; background: transparent; box-shadow: none; padding: 60px 0 30px 0; }
    .page-title { font-size: 32px; }

    .mobile-avatar, .bottom-tabbar, .sheet-handle { display: none !important; }

    .sheet-modal { 
        top: 50%; left: 50%; transform: translate(-50%, -50%); bottom: auto; 
        width: 450px; border-radius: 24px; box-shadow: var(--shadow-deep); 
        visibility: hidden; opacity: 0;
    }
    .sheet-modal.visible { visibility: visible; opacity: 1; }
}