        :root {
            --bg-color: #f1f3f7;
            --card-bg: #ffffff;
            --primary: #5865F2;
            --primary-dark: #4752c4;
            --green: #00b894;
            --orange: #e17055;
            --blue: #0984e3;
            --purple: #6c5ce7;
            --text: #2d3436;
            --text-muted: #636e72;
            --border: #e2e8f0;
        }
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
            background-color: var(--bg-color);
            color: var(--text);
            margin: 0;
            padding: 20px;
        }
        .container {
            max-width: 1000px;
            margin: 0 auto;
        }
        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: var(--card-bg);
            padding: 20px 25px;
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.05);
            margin-bottom: 20px;
        }
        .brand {
            display: flex;
            align-items: center;
            gap: 15px;
        }
        .brand h1 {
            margin: 0;
            font-size: 24px;
            color: var(--text);
        }
        .status-badge {
            background-color: #e3fcef;
            color: var(--green);
            padding: 6px 12px;
            border-radius: 20px;
            font-size: 13px;
            font-weight: 600;
        }
        .grid-4 {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
            gap: 15px;
            margin-bottom: 20px;
        }
        .card {
            background: var(--card-bg);
            padding: 20px;
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.05);
        }
        .card h3 {
            margin-top: 0;
            font-size: 15px;
            color: var(--text-muted);
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .stat-value {
            font-size: 28px;
            font-weight: 700;
            color: var(--primary);
            margin: 8px 0;
        }
        .stat-sub {
            font-size: 13px;
            color: var(--text-muted);
        }
        .section-title {
            font-size: 18px;
            font-weight: 600;
            margin: 25px 0 15px;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            background: var(--card-bg);
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 4px 12px rgba(0,0,0,0.05);
            margin-bottom: 20px;
        }
        th, td {
            padding: 12px 16px;
            text-align: left;
            border-bottom: 1px solid var(--border);
            font-size: 14px;
        }
        th {
            background: #fafbfc;
            font-weight: 600;
            color: var(--text-muted);
        }
        tr:last-child td {
            border-bottom: none;
        }
        .badge {
            display: inline-block;
            padding: 4px 8px;
            border-radius: 6px;
            font-size: 12px;
            font-weight: 600;
        }
        .badge-pee { background: #e0f2fe; color: #0284c7; }
        .badge-poop { background: #fef3c7; color: #d97706; }
        .badge-plant { background: #dcfce7; color: #15803d; }
        .badge-patrol { background: #ede9fe; color: #7c3aed; }
        
        .chat-bubble {
            background: var(--card-bg);
            padding: 12px 18px;
            border-radius: 10px;
            margin-bottom: 10px;
            box-shadow: 0 2px 6px rgba(0,0,0,0.03);
            border-left: 4px solid var(--primary);
        }
        .chat-bubble.bot {
            border-left-color: #9333ea;
            background: #faf5ff;
        }
        .chat-meta {
            font-size: 12px;
            color: var(--text-muted);
            margin-bottom: 4px;
        }
        .device-form {
            display: flex;
            gap: 10px;
            align-items: center;
        }
        .device-form input {
            padding: 6px 10px;
            border: 1px solid var(--border);
            border-radius: 6px;
            font-size: 13px;
        }
        .btn-sm {
            padding: 6px 12px;
            font-size: 13px;
            border-radius: 6px;
            border: none;
            background: var(--primary);
            color: white;
            cursor: pointer;
        }
        .btn-sm:hover { background: var(--primary-dark); }
        .test-box {
            background: #fff;
            padding: 20px;
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.05);
            margin-top: 25px;
        }
        .btn-group {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
            margin-top: 10px;
        }
        button {
            padding: 10px 16px;
            border-radius: 8px;
            border: none;
            background: var(--primary);
            color: white;
            font-weight: 600;
            cursor: pointer;
            transition: 0.2s;
        }
        button:hover { background: var(--primary-dark); }

        /* 🛠️ 後台管理中心 (Admin Control Center) */
        .admin-section {
            background: var(--card-bg);
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.05);
            padding: 22px;
            margin-top: 25px;
            margin-bottom: 25px;
        }
        .admin-nav {
            display: flex;
            gap: 10px;
            border-bottom: 2px solid var(--border);
            margin-bottom: 20px;
            flex-wrap: wrap;
        }
        .admin-tab {
            padding: 10px 18px;
            border: none;
            background: transparent;
            color: var(--text-muted);
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            border-bottom: 3px solid transparent;
            margin-bottom: -2px;
            border-radius: 0;
            transition: all 0.2s;
        }
        .admin-tab:hover {
            color: var(--primary);
            background: #f8fafc;
        }
        .admin-tab.active {
            color: var(--primary);
            border-bottom-color: var(--primary);
            background: transparent;
        }
        .admin-panel {
            display: none;
        }
        .admin-panel.active {
            display: block;
        }
        /* 第 3 層：小型分段切換 (與下方的動作按鈕區隔，視覺份量低於第 2 層底線分頁) */
        .sub-tab-bar {
            display: inline-flex;
            gap: 2px;
            margin-bottom: 14px;
            padding: 3px;
            background: #f1f5f9;
            border-radius: 999px;
            flex-wrap: wrap;
        }
        .sub-tab-btn {
            background: transparent;
            color: #64748b;
            border: none;
            padding: 5px 12px;
            border-radius: 999px;
            font-size: 12.5px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.15s ease;
            display: inline-flex;
            align-items: center;
            gap: 6px;
        }
        .sub-tab-btn:hover {
            color: #1e293b;
        }
        .sub-tab-btn.active {
            background: #ffffff;
            color: var(--primary);
            box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
        }
        .sub-tab-btn.is-empty:not(.active) {
            opacity: 0.45;
        }
        .sub-tab-btn .badge-count {
            background: rgba(0, 0, 0, 0.06);
            padding: 1px 7px;
            border-radius: 10px;
            font-size: 11px;
            font-weight: 700;
        }
        .sub-tab-btn.active .badge-count {
            background: #eef2ff;
            color: var(--primary);
        }
        /* 長訊息預設收合 */
        .msg-long > summary {
            cursor: pointer;
            list-style: none;
        }
        .msg-long > summary::-webkit-details-marker {
            display: none;
        }
        .msg-long .msg-more {
            color: var(--primary);
            font-size: 12px;
            font-weight: 600;
            margin-left: 4px;
            white-space: nowrap;
        }
        .msg-long[open] .msg-preview {
            display: none;
        }
        .msg-long[open] .msg-more::after {
            content: "收合";
        }
        .msg-long:not([open]) .msg-more::after {
            content: "展開全文";
        }
        /* 頁首唯一的 Debug 入口 (原生 details 下拉，不依賴 Bootstrap) */
        .debug-menu {
            position: relative;
        }
        .debug-link,
        .debug-menu > summary {
            list-style: none;
            cursor: pointer;
            font-size: 12.5px;
            color: var(--text-muted);
            padding: 5px 10px;
            border-radius: 16px;
            border: 1px solid var(--border);
            background: #ffffff;
        }
        .debug-link { text-decoration: none; }
        .debug-menu > summary::-webkit-details-marker {
            display: none;
        }
        .debug-menu[open] > summary,
        .debug-link:hover,
        .debug-menu > summary:hover {
            color: var(--text);
            background: #f8fafc;
        }
        .debug-menu-list {
            position: absolute;
            right: 0;
            top: calc(100% + 6px);
            z-index: 50;
            min-width: 210px;
            background: #ffffff;
            border: 1px solid var(--border);
            border-radius: 8px;
            box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
            padding: 6px;
        }
        .debug-menu-list a {
            display: block;
            padding: 7px 10px;
            border-radius: 6px;
            font-size: 13px;
            color: var(--text);
            text-decoration: none;
        }
        .debug-menu-list a:hover {
            background: #f1f5f9;
        }
        .event-thumb {
            width: 44px;
            height: 44px;
            border-radius: 6px;
            object-fit: cover;
            border: 1px solid var(--border);
            cursor: pointer;
            transition: transform 0.15s;
            vertical-align: middle;
            margin-right: 4px;
        }
        .event-thumb:hover {
            transform: scale(1.15);
            border-color: var(--primary);
            box-shadow: 0 2px 6px rgba(0,0,0,0.15);
        }
        /* 每列的刪除按鈕：平時低調的灰色，滑過才顯示紅色 (避免整頁都是紅色) */
        .btn-del-record {
            background: transparent;
            color: #94a3b8;
            border: 1px solid transparent;
            padding: 4px 9px;
            border-radius: 4px;
            font-size: 11px;
            cursor: pointer;
            font-weight: 600;
            transition: 0.15s;
            white-space: nowrap;
        }
        .btn-del-record:hover {
            background: #fff1f2;
            border-color: #fecdd3;
            color: #e11d48;
        }
        .admin-toolbar {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
            align-items: center;
            margin-bottom: 16px;
            padding: 12px 16px;
            background: #f8fafc;
            border-radius: 8px;
            border: 1px solid var(--border);
        }
        .btn-outline {
            background: white;
            color: #475569;
            border: 1px solid #cbd5e1;
            padding: 7px 14px;
            border-radius: 6px;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            transition: 0.15s;
        }
        .btn-outline:hover {
            background: #f1f5f9;
            color: #1e293b;
        }
        .btn-danger-soft {
            background: #fef2f2;
            color: #dc2626;
            border: 1px solid #fecaca;
            padding: 7px 14px;
            border-radius: 6px;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            transition: 0.15s;
        }
        .btn-danger-soft:hover {
            background: #fee2e2;
            color: #b91c1c;
        }
        .nl-box {
            background: #ffffff;
            border: 1px solid var(--border);
            border-radius: 10px;
            padding: 16px;
            margin-bottom: 16px;
        }
        .chip-list {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-top: 10px;
        }
        .prompt-chip {
            background: #eef2ff;
            color: #4f46e5;
            padding: 4px 10px;
            border-radius: 14px;
            font-size: 12px;
            cursor: pointer;
            border: 1px solid #c7d2fe;
            transition: 0.15s;
        }
        .prompt-chip:hover {
            background: #e0e7ff;
        }
        .preview-alert {
            background: #fffbeb;
            border: 1px solid #fde68a;
            border-radius: 8px;
            padding: 16px;
            margin-top: 16px;
            display: none;
        }
        .photo-container {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
            gap: 14px;
            margin-top: 16px;
        }
        .photo-card {
            background: white;
            border: 1px solid var(--border);
            border-radius: 8px;
            overflow: hidden;
            position: relative;
            box-shadow: 0 2px 6px rgba(0,0,0,0.02);
            transition: transform 0.15s, box-shadow 0.15s;
        }
        .photo-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0,0,0,0.08);
        }
        .photo-card img {
            width: 100%;
            height: 125px;
            object-fit: cover;
            display: block;
            cursor: pointer;
            background: #f1f5f9;
        }
        .photo-card .card-body {
            padding: 8px 10px;
            font-size: 11px;
        }
        .photo-card .chk-select {
            position: absolute;
            top: 8px;
            left: 8px;
            z-index: 2;
            width: 18px;
            height: 18px;
            cursor: pointer;
            accent-color: var(--primary);
        }
        .filter-pill {
            padding: 5px 12px;
            border-radius: 16px;
            border: 1px solid var(--border);
            background: white;
            color: #64748b;
            font-size: 12px;
            font-weight: 600;
            cursor: pointer;
            transition: 0.15s;
        }
        .filter-pill:hover, .filter-pill.active {
            background: var(--primary);
            color: white;
            border-color: var(--primary);
        }
        /* Modal Lightbox */
        .modal-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(15, 23, 42, 0.85);
            z-index: 99999;
            align-items: center;
            justify-content: center;
            padding: 20px;
            box-sizing: border-box;
        }
        .modal-content {
            background: white;
            border-radius: 12px;
            max-width: 900px;
            max-height: 90vh;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            box-shadow: 0 20px 25px -5px rgba(0,0,0,0.5);
        }
        .modal-content img {
            max-width: 100%;
            max-height: 75vh;
            object-fit: contain;
            background: #000;
        }
        .modal-footer {
            padding: 12px 18px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: #f8fafc;
            border-top: 1px solid var(--border);
        }
        /* 🔔 後台操作 Toast 浮動即時提示系統 */
        #admin-toast-container {
            position: fixed;
            top: 24px;
            right: 24px;
            z-index: 999999;
            display: flex;
            flex-direction: column;
            gap: 10px;
            pointer-events: none;
        }
        .admin-toast {
            min-width: 280px;
            max-width: 440px;
            padding: 12px 18px;
            border-radius: 8px;
            font-size: 13.5px;
            font-weight: 500;
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
            background: #ffffff;
            color: #1e293b;
            border-left: 5px solid #3b82f6;
            display: flex;
            align-items: center;
            gap: 12px;
            pointer-events: auto;
            animation: adminToastSlide 0.25s ease-out;
            transition: all 0.3s ease;
        }
        @keyframes adminToastSlide {
            from { transform: translateX(50px); opacity: 0; }
            to { transform: translateX(0); opacity: 1; }
        }
        .admin-toast.success { border-left-color: #10b981; background: #f0fdf4; color: #166534; }
        .admin-toast.error { border-left-color: #ef4444; background: #fef2f2; color: #991b1b; }
        .admin-toast.warning { border-left-color: #f59e0b; background: #fffbeb; color: #92400e; }
        .admin-toast.info { border-left-color: #3b82f6; background: #eff6ff; color: #1e40af; }
        .admin-toast.loading { border-left-color: #6366f1; background: #f5f3ff; color: #4338ca; }

/* 🧭 主情境切換導覽列 (SPA Main Tab Navigation) */
.main-tab-nav {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-bottom: 22px;
}

.main-tab-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    background: var(--card-bg);
    border: 2px solid transparent;
    border-radius: 14px;
    cursor: pointer;
    text-align: left;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.04);
    position: relative;
    user-select: none;
    outline: none;
}

.main-tab-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    border-color: #cbd5e1;
}

.main-tab-btn.active {
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 6px 18px rgba(88, 101, 242, 0.18);
}

.main-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 18%;
    right: 18%;
    height: 3px;
    background: var(--primary);
    border-radius: 3px 3px 0 0;
}

.main-tab-icon {
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #f1f5f9;
    transition: transform 0.2s ease, background-color 0.2s ease;
    flex-shrink: 0;
}

.main-tab-btn:hover .main-tab-icon {
    transform: scale(1.08);
}

.main-tab-btn.active .main-tab-icon {
    background: #eef2ff;
    transform: scale(1.12);
}

.main-tab-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.main-tab-text {
    font-size: 14.5px;
    font-weight: 700;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s ease;
}

.main-tab-btn.active .main-tab-text {
    color: var(--primary);
}

.main-tab-sub {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 分頁容器顯示與進場動畫 */
.main-tab-content {
    display: none;
}

.main-tab-content.active {
    display: block;
    animation: tabFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tabFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* RWD 響應式適配 */
@media (max-width: 860px) {
    .main-tab-nav {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 18px;
    }
    /* 6 個分頁排 2 欄剛好 3 列，不需要讓最後一個撐滿整列 */
    .main-tab-btn {
        padding: 10px 12px;
    }
    .main-tab-icon {
        font-size: 20px;
        min-width: 32px;
        height: 32px;
    }
    .main-tab-text {
        font-size: 13.5px;
    }
    .main-tab-sub {
        font-size: 10.5px;
    }
}

@media (max-width: 520px) {
    .main-tab-nav {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .main-tab-btn {
        padding: 8px 10px;
        gap: 8px;
    }
    .main-tab-sub {
        display: none; /* 小手機螢幕隱藏副標題，避免折行擠壓 */
    }
}

/* 🔔 群組授權與新成員極致顯眼動態跳動與呼吸閃爍提醒 */
.tab-alert-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 12px;
    margin-left: 6px;
    vertical-align: middle;
    letter-spacing: 0.2px;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
    animation: badgeBlinkPulse 1.4s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

.tab-alert-badge.sub-alert {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
    animation: badgeBlinkPulseAmber 1.6s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes badgeBlinkPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 4px rgba(239, 68, 68, 0.4);
    }
    50% {
        transform: scale(1.18);
        box-shadow: 0 0 18px rgba(239, 68, 68, 0.95);
        background: #b91c1c;
    }
}

@keyframes badgeBlinkPulseAmber {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 4px rgba(245, 158, 11, 0.4);
    }
    50% {
        transform: scale(1.15);
        box-shadow: 0 0 16px rgba(245, 158, 11, 0.85);
        background: #b45309;
    }
}

.main-tab-btn.tab-has-alert {
    border-color: #f87171 !important;
    background: linear-gradient(135deg, #ffffff 0%, #fef2f2 100%) !important;
    animation: tabGlowPulse 2.2s infinite ease-in-out;
}

@keyframes tabGlowPulse {
    0%, 100% {
        box-shadow: 0 2px 10px rgba(239, 68, 68, 0.15);
        border-color: #fca5a5;
    }
    50% {
        box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
        border-color: #ef4444 !important;
    }
}

/* 提示通知條 */
.unreviewed-alert-box {
    background: linear-gradient(135deg, #fffbeb 0%, #fef2f2 100%);
    border: 1.5px solid #f87171;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.08);
    animation: tabFadeIn 0.3s ease-out;
}

.unreviewed-row-highlight {
    background-color: #fff7ed !important;
    border-left: 4px solid #f97316;
}



/* ==========================================================================
   🧭 頁面層次：選單 → 頁首 → 內容容器
   選單卡片退到背景 (扁平、無陰影)，每一頁的內容統一包在一塊「內容容器」裡，
   讓「上面是選單、下面是本業資料」一眼就分得出來。
   ========================================================================== */
.main-tab-nav {
    gap: 10px;
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.main-tab-btn {
    padding: 9px 14px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid transparent;
    border-radius: 12px;
    box-shadow: none;
}
.main-tab-btn:hover {
    transform: none;
    background: #ffffff;
    box-shadow: none;
    border-color: var(--border);
}
.main-tab-btn.active {
    background: #eef2ff;
    border-color: #c7d2fe;
    box-shadow: none;
}
.main-tab-btn.active::after {
    display: none;
}
.main-tab-icon {
    font-size: 20px;
    min-width: 32px;
    height: 32px;
    background: rgba(241, 245, 249, 0.8);
}
.main-tab-btn.active .main-tab-icon {
    background: #ffffff;
    transform: none;
}

/* 有「新家人 / 待審核」提醒時標籤很長，以前會把五張分頁卡撐出畫面 (管理中心被擠到右邊外面)：
   卡片可以縮 (minmax(0, 1fr))，標籤放不下就換到標題下一行 */
@media (min-width: 861px) {
    .main-tab-nav {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}
.main-tab-btn {
    min-width: 0;
}
.main-tab-text {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 0;
    white-space: normal;
}
.main-tab-text .tab-alert-badge {
    white-space: nowrap;
}

/* 內容容器：比頁面背景深一階的「井」，裡面的白色卡片/表格自然浮出來 */
.main-tab-content.active {
    background: #d8dfeb;
    border: 1px solid #c3cddd;
    border-top: 3px solid #a5b4fc;
    box-shadow: inset 0 2px 6px rgba(15, 23, 42, 0.06);
    border-radius: 16px;
    padding: 20px 22px 6px;
}
.main-tab-content > :first-child,
.main-tab-content > :first-child .section-title:first-child {
    margin-top: 0;
}
/* 容器裡的白色面板稍微浮起來 */
.main-tab-content .card,
.main-tab-content .admin-section,
.main-tab-content table {
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
/* 內容容器裡的頁首標題 */
.main-tab-content .section-title {
    margin: 22px 0 12px;
}

/* 生活頁的四張感測器卡片：左側色條 + 無陰影，與上方選單卡明顯不同 */
.main-tab-content .grid-4 .card {
    box-shadow: none;
    border: 1px solid #e2e8f0;
    border-left: 4px solid var(--primary);
    border-radius: 10px;
    padding: 14px 16px;
}
.main-tab-content .grid-4 .card:nth-child(1) { border-left-color: #0ea5e9; }
.main-tab-content .grid-4 .card:nth-child(2) { border-left-color: #f59e0b; }
.main-tab-content .grid-4 .card:nth-child(3) { border-left-color: #22c55e; }
.main-tab-content .grid-4 .card:nth-child(4) { border-left-color: #8b5cf6; }
.main-tab-content .grid-4 .card h3 {
    font-size: 13.5px;
    margin-bottom: 4px;
}
.main-tab-content .grid-4 .stat-value {
    font-size: 24px;
    margin: 4px 0;
}

/* 空狀態提示 (取代原本的深色橫條) */
.empty-state {
    background: #ffffff;
    border: 1px dashed #cbd5e1;
    color: var(--text-muted);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
    font-size: 13px;
}

@media (max-width: 860px) {
    .main-tab-content.active {
        padding: 14px 12px 4px;
    }
}

/* ==========================================================================
   🎨 小步貼圖庫
   ========================================================================== */
.stk-section {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 22px;
    display: grid;
    gap: 14px;
}
.stk-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.stk-title { font-size: 15px; font-weight: 700; color: #334155; }
.stk-sub { font-size: 12.5px; color: var(--text-muted); max-width: 70ch; margin-top: 2px; }
.stk-status { font-size: 12px; font-weight: 600; }
.stk-tools { display: grid; gap: 10px; background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.stk-gen { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.stk-gen label { display: grid; gap: 3px; font-size: 11.5px; font-weight: 600; color: #475569; }
.stk-gen input, .stk-gen select, .stk-newemo input, .stk-img input[type="text"], .stk-img input[type="date"], .stk-emo-edit input {
    padding: 5px 8px; font-size: 12.5px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text);
}
.stk-dates { display: inline-flex; align-items: center; gap: 4px; }
.stk-tool-links { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.stk-details > summary { cursor: pointer; font-size: 12.5px; color: var(--primary); font-weight: 600; }
.stk-newemo, .stk-style { display: grid; gap: 6px; margin-top: 8px; }
.stk-newemo { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.stk-style textarea { width: min(640px, 100%); box-sizing: border-box; font-family: ui-monospace, Consolas, monospace; font-size: 12px; padding: 8px; border: 1px solid var(--border); border-radius: 6px; }

/* 貼圖庫：多欄方格 (九宮格)。每種情緒有幾張就佔幾格 (最多 3 格)，dense 自動補空位，不會一張一行留白 */
.stk-library { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); grid-auto-flow: row dense; align-items: start; }
/* 情緒外框與「家人名冊」卡片同色 (2px 紫藍框 + 淡陰影)，和裡面每張貼圖的細灰框一眼分得出來 */
.stk-emo { border: 2px solid #818cf8; background: #ffffff; box-shadow: 0 3px 10px rgba(79,70,229,0.08); border-radius: 10px; padding: 12px 14px; display: grid; gap: 8px; min-width: 0; }
.stk-emo.stk-span-2 { grid-column: span 2; }
.stk-emo.stk-span-3 { grid-column: span 3; }
@media (max-width: 760px) { .stk-emo.stk-span-3 { grid-column: span 2; } }
@media (max-width: 520px) { .stk-emo.stk-span-2, .stk-emo.stk-span-3 { grid-column: auto; } }
.stk-emo-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.stk-emo-edit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.stk-emo-edit .stk-key { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: #b45309; background: #fef3c7; padding: 2px 8px; border-radius: 6px; }
.stk-emo-edit input.stk-label { width: 110px; font-weight: 700; }
.stk-emo-edit input.stk-hint { width: 100%; box-sizing: border-box; }
.stk-emo-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.stk-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.stk-more summary { cursor: pointer; font-size: 11.5px; color: var(--primary); }
.stk-more[open] { display: grid; gap: 6px; }
.stk-more .stk-prompt-text { width: 100%; box-sizing: border-box; font-family: ui-monospace, Consolas, monospace; font-size: 11px; min-height: 110px; padding: 6px; border: 1px solid var(--border); border-radius: 6px; }
.stk-img { border: 1px solid var(--border); border-radius: 8px; padding: 8px; display: grid; gap: 6px; align-content: start; background: #fff; }
.stk-img.is-off { opacity: 0.55; }
.stk-thumb {
    height: 120px; border-radius: 6px; display: grid; place-items: center; overflow: hidden;
    background-color: #f5f7fb;
    background-image: radial-gradient(#dde2ec 1.1px, transparent 1.2px);
    background-size: 12px 12px;
}
.stk-thumb img { max-width: 100%; max-height: 120px; object-fit: contain; }
.stk-thumb .stk-empty { font-size: 12px; color: var(--text-muted); text-align: center; padding: 6px; }
.stk-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.stk-chip { font-size: 10.5px; padding: 1px 7px; border-radius: 999px; background: #f1f5f9; color: #475569; }
.stk-chip.live { background: #dcfce7; color: #15803d; }
.stk-chip.season { background: #fef3c7; color: #b45309; }
.stk-chip.idle { background: #fee2e2; color: #b91c1c; }
.stk-img .stk-row { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; font-size: 11.5px; color: #475569; }
.stk-img input[type="date"] { padding: 3px 4px; font-size: 11px; width: 118px; }
.stk-img .stk-variant { width: 100%; box-sizing: border-box; font-weight: 600; }
.stk-prompt summary { cursor: pointer; font-size: 11.5px; color: var(--primary); }
.stk-prompt textarea { width: 100%; box-sizing: border-box; font-family: ui-monospace, Consolas, monospace; font-size: 11px; min-height: 120px; margin-top: 4px; padding: 6px; border: 1px solid var(--border); border-radius: 6px; }
.stk-btns { display: flex; flex-wrap: wrap; gap: 4px; }
.stk-btns button, .stk-btns a, .stk-emo-actions button {
    font-size: 11px; padding: 3px 8px; border-radius: 5px; border: 1px solid var(--border); background: #f8fafc; color: #334155;
    cursor: pointer; text-decoration: none; font-weight: 600;
}
.stk-btns button:hover, .stk-btns a:hover, .stk-emo-actions button:hover { background: #eef2ff; color: var(--primary); }
.stk-btns .stk-danger:hover, .stk-emo-actions .stk-danger:hover { background: #fff1f2; color: #e11d48; border-color: #fecdd3; }
.stk-clear {
    font-size: 12px; padding: 4px 10px; border-radius: 6px; font-weight: 600;
    background: #ffffff; color: #b45309; border: 1px solid #fcd34d;
}
.stk-clear:hover { background: #fffbeb; color: #92400e; }
.stk-toolkit-result { margin: 0; font-size: 12px; white-space: pre-wrap; color: #334155; background: #ffffff; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; min-height: 1.5em; }
.stk-toolkit-result:empty { display: none; }
.stk-test-pick { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: #475569; }
.stk-test-pick select { padding: 3px 6px; font-size: 12px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.stk-trial { display: grid; gap: 10px; border: 1px dashed #c7d2fe; background: #f5f7ff; border-radius: 10px; padding: 12px 14px; }
.stk-trial-title { font-size: 13.5px; font-weight: 700; color: #334155; }
.stk-trial-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
/* 🧪 測試區的 LINE 聊天室模擬預覽 */
.stk-line-preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.stk-chat { border-radius: 10px; padding: 10px 12px 14px; display: grid; gap: 8px; align-content: start; min-height: 150px; }
.stk-chat-dark { background: #1e1f22; }
.stk-chat-light { background: #8cabd9; }   /* LINE 預設的淺藍聊天背景 */
.stk-chat-label { font-size: 11px; font-weight: 600; color: rgba(255,255,255,.75); }
.stk-chat-row { display: flex; align-items: flex-start; gap: 8px; }
.stk-chat-avatar { width: 30px; height: 30px; border-radius: 50%; background: #9aa1b1; flex-shrink: 0; }
.stk-bubble { width: 120px; max-width: 100%; border-radius: 16px; padding: 4px; box-sizing: border-box; transition: width .15s; }
.stk-bubble img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: contain; }
.stk-thumb-card { width: 120px; max-width: 100%; border-radius: 14px; padding: 4px; box-sizing: border-box; box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.stk-thumb-card img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: contain; max-height: none; }
/* 貼圖卡片樣式 (與 core/sticker_manager.py 的 STICKER_FLEX_BGS / STICKER_IG_GRADIENT 同色) */
.card-cream { background: #FFF7E6; }
.card-white { background: #FFFFFF; }
.card-ig { background: linear-gradient(45deg, #F9CE34, #EE2A7B, #6228D7); }
.card-ig img { background: #FFFFFF; border-radius: 12px; padding: 2px; box-sizing: border-box; }
.stk-style-pick { padding: 2px 4px; font-size: 11.5px; border: 1px solid var(--border); border-radius: 5px; background: #fff; }
/* 拍立得框：米白紙色相框 + 白色相片區細線 (與 core/sticker_manager.py 同色；預覽依卡片大小由 JS 設定留白) */
.card-polaroid { background: #F7F5F0; padding: 6px 6px 20px; }
.card-polaroid img { background: #FFFFFF; border: 1px solid #D9D4C8; border-radius: 2px; box-sizing: border-box; }

/* 💬 小步接話頻率 */
.hook-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 8px 18px; }
.hook-row { display: grid; grid-template-columns: 118px 1fr 92px; align-items: center; gap: 10px; cursor: help; padding: 4px 0; }
.hook-name { font-size: 13px; font-weight: 700; color: #334155; display: grid; line-height: 1.25; }
.hook-name small { font-size: 11px; font-weight: 500; color: var(--text-muted); }
.hook-row input[type="range"] { width: 100%; accent-color: var(--primary); cursor: pointer; }
.hook-val { font-size: 12.5px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.hook-val small { display: block; font-size: 10.5px; font-weight: 500; color: var(--text-muted); }
.hook-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.hook-actions .stk-sub { margin-right: auto; }
.hook-help { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: #e2e8f0; color: #475569; font-size: 11px; cursor: help; vertical-align: 1px; }

/* 🧬 小步的個性 */
.persona-tier-desc { font-size: 12.5px; color: #475569; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.persona-tier-desc:empty { display: none; }
.persona-interests { display: grid; grid-template-columns: 118px 1fr; gap: 10px; align-items: start; cursor: help; }
.persona-interests textarea { width: 100%; box-sizing: border-box; font-size: 12.5px; line-height: 1.6; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; }
@media (max-width: 520px) { .persona-interests, .hook-row { grid-template-columns: 1fr; } }

/* 🤖 AI 模型清單 */
.llm-table { width: 100%; font-size: 12.5px; }
.llm-table td, .llm-table th { padding: 8px 10px; vertical-align: top; }
.llm-table code { font-size: 12px; }
.llm-table tr.llm-off td { color: #94a3b8; }
.llm-note { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* 🧭 浮動主分頁面板 (電腦版)：貼最右側、可上下拖曳 (static/js/float_nav.js)；手機版有底部分頁列，隱藏 */
.float-nav {
    position: fixed;
    right: 0;
    top: 40%;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 4px 6px 8px 4px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 14px 0 0 14px;
    box-shadow: -4px 4px 16px rgba(15, 23, 42, 0.14);
    backdrop-filter: blur(6px);
    user-select: none;
}
.float-nav.dragging { box-shadow: -6px 8px 24px rgba(15, 23, 42, 0.28); }
.float-nav-header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 2px;
}
.float-nav-handle {
    flex: 1;
    text-align: center;
    font-size: 16px;
    line-height: 20px;
    color: #94a3b8;
    cursor: grab;
    touch-action: none;
    border-radius: 6px;
}
.float-nav-handle:hover { background: #f1f5f9; }
.float-nav-bug {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 15px;
    line-height: 20px;
    padding: 0 2px;
    border-radius: 6px;
}
.float-nav-bug:hover { background: #fee2e2; }
.float-nav-bugmenu {
    display: none;
    position: absolute;
    top: 0;
    right: calc(100% + 14px);
    min-width: 210px;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
    overflow: hidden;
}
.float-nav-bugmenu.open { display: flex; }
.float-nav-bugmenu a {
    padding: 9px 14px;
    font-size: 13px;
    color: #1e293b;
    text-decoration: none;
    white-space: nowrap;
}
.float-nav-bugmenu a:hover { background: #f1f5f9; }
.float-nav.dragging .float-nav-handle { cursor: grabbing; }
.float-nav-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    width: 52px;
    padding: 6px 0 5px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
}
.float-nav-btn:hover { background: #f1f5f9; }
.float-nav-btn.active { background: #eef2ff; border-color: #c7d2fe; }
.float-nav-icon { font-size: 20px; line-height: 24px; }
.float-nav-label { font-size: 11px; color: #64748b; }
.float-nav-btn.active .float-nav-label { color: #6366f1; font-weight: 600; }
.float-nav-btn.has-alert::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 8px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #fff;
}
@media (max-width: 760px), (pointer: coarse) {
    .float-nav { display: none; }
}

/* 浮動面板：有子功能的按鈕，左側小三角形展開子選單 */
.float-nav-item { position: relative; }
.float-nav-item .float-nav-btn { width: 52px; }
.float-nav-tri {
    position: absolute;
    left: 1px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    font-size: 8px;
    color: #6366f1;
    cursor: pointer;
    border-radius: 4px;
    z-index: 1;
}
.float-nav-tri:hover { background: #e0e7ff; }
.float-nav-submenu { top: 0; right: calc(100% + 14px); }

/* 📱 手機版：長按底部分頁按鈕彈出的子功能選單 (static/js/float_nav.js) */
.tab-longpress-menu {
    display: none;
    position: fixed;
    z-index: 10001;
    min-width: 230px;
    max-width: calc(100vw - 16px);
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.28);
    overflow: hidden;
}
.tab-longpress-menu.open { display: flex; }
.tab-longpress-menu a {
    padding: 13px 16px;
    font-size: 15px;
    color: #1e293b;
    text-decoration: none;
    border-bottom: 1px solid #f1f5f9;
}
.tab-longpress-menu a:last-child { border-bottom: none; }
.tab-longpress-menu a:active { background: #eef2ff; }
.main-tab-nav .main-tab-btn {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* 分頁列拿掉副標題後，按鈕高度跟著縮小 (只有標題一行，圖示框也縮) */
@media (min-width: 861px) {
    .main-tab-nav { gap: 8px; margin-bottom: 14px; padding-bottom: 12px; }
    .main-tab-btn { padding: 5px 12px; gap: 9px; }
    .main-tab-icon { font-size: 17px; min-width: 26px; height: 26px; border-radius: 8px; }
}

