/* ===== 動物森友會風格 (Animal Crossing Style) ===== */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/earlyaccess/cwtexyen.css');
@import url('https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c:wght@400;500;700;800&display=swap');

/* ===== 重置與基礎樣式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 色彩系統 - 動森配色 */
    --color-primary: #2BA185; /* NookPhone Green */
    --color-primary-hover: #1F8A6E;
    --color-text: #5E5340; /* 溫暖的深褐色文字 */
    --color-text-light: #8B7E6A;
    --color-text-lighter: #B0A695;
    
    /* 背景色階 */
    --color-bg: #FFFAFA; /* 象牙白/米白 */
    --color-bg-light: #E0F5E9; /* 淺綠色背景 */
    --color-bg-alt: #F7F3E3; /* 淺米色 */
    --color-bg-dark: #E8E2D2;
    
    /* 邊框色階 */
    --color-border-light: #E8E2D2;
    --color-border: #D4CDBA; /* 淺褐色邊框 */
    --color-border-dark: #A69B85;
    
    /* 功能色 - 柔和粉蠟筆色調 */
    --color-success: #5CBF77; /* 樹葉綠 */
    --color-danger: #FF7B7B; /* 鮭魚紅 */
    --color-warning: #F4CE5C; /* 鈴錢黃 */
    
    /* 陰影 - 3D 卡通感 */
    --shadow-xs: 0 2px 0 rgba(94, 83, 64, 0.1);
    --shadow-sm: 0 4px 0 rgba(94, 83, 64, 0.1);
    --shadow-md: 0 6px 0 rgba(94, 83, 64, 0.15);
    --shadow-lg: 0 8px 0 rgba(94, 83, 64, 0.2);

    /* 間距系統 */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 3rem;
    --space-2xl: 4rem;

    /* 字體 - 圓體 */
    --font-sans: 'Nunito', 'cwTeXYen', 'M PLUS Rounded 1c', 'Varela Round', 'Microsoft JhengHei', sans-serif;

    /* 圓角 - 極度圓潤 */
    --radius-sm: 1rem;
    --radius-md: 1.5rem;
    --radius-lg: 2rem;
    --radius-full: 9999px;

    /* 動畫 - 彈跳感 */
    --transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html {
    scroll-behavior: smooth;
    font-size: 18px; /* 提升基礎字體大小 */
    overflow-x: hidden; /* 防止水平捲軸 */
}

body {
    font-family: var(--font-sans);
    color: var(--color-text);
    /* 動森風格背景圖案 (波點) */
    background-color: #D7F5E8;
    background-image: 
        radial-gradient(#A8E6CF 15%, transparent 16%),
        radial-gradient(#A8E6CF 15%, transparent 16%);
    background-size: 40px 40px;
    background-position: 0 0, 20px 20px;
    line-height: 1.7; /* 稍微增加行高以配合較大字體 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    overflow-x: hidden; /* 絕對防止水平捲軸 */
    width: 100%;
    position: relative; /* 確保 body 也是定位基準之一 */
}

/* ===== 淡入浮出動畫 ===== */
.fade-in-up {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in-up.visible {
    opacity: 1;
    transform: translateY(0);
}

.fade-in-up.delay-1 { transition-delay: 0.1s; }
.fade-in-up.delay-2 { transition-delay: 0.2s; }
.fade-in-up.delay-3 { transition-delay: 0.3s; }
.fade-in-up.delay-4 { transition-delay: 0.4s; }

/* ===== 容器 ===== */
.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-top: 80px; /* 全域增加頂部內距，適配固定導航列 */
}

/* ===== 導航列 - 木頭吊牌風格 (Wood Sign Style) ===== */
.navbar {
    position: absolute; /* 改為絕對定位，隨頁面滾動 */
    top: 20px;
    left: 50%; /* 居中定位 */
    transform: translateX(-50%) rotate(-2deg); /* 水平居中並微微傾斜 */
    width: auto; /* 自適應寬度 */
    height: auto;
    background: #e6b980; /* 淺木頭色 */
    background-image: linear-gradient(90deg, rgba(255,255,255,0.1) 50%, transparent 50%),
                      linear-gradient(rgba(255,255,255,0.1) 50%, transparent 50%);
    background-size: 20px 20px; /* 簡單的木紋質感 */
    border: 4px solid #8b5a2b; /* 深褐色木框 */
    border-radius: 15px;
    padding: 10px 30px; /* 增加左右內距，讓吊牌更長 */
    display: inline-flex; /* 內容撐開寬度 */
    align-items: center;
    justify-content: center; /* 內容居中 */
    z-index: 1000;
    box-shadow: 
        0 6px 0 #6d4c41, /* 立體厚度 */
        0 10px 10px rgba(0,0,0,0.2); /* 陰影 */
    transform-origin: center top; /* 以頂部中心為旋轉點 */
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.navbar:hover {
    transform: translateX(-50%) rotate(0deg) scale(1.05); /* 懸停時回正並放大 */
}

/* 吊繩效果 (偽元素) */
.navbar::before,
.navbar::after {
    content: '';
    position: absolute;
    top: -40px; /* 繩子更長一點 */
    width: 4px;
    height: 45px;
    background: #8b5a2b; /* 繩子顏色 */
    border-radius: 4px;
    z-index: -1;
}

.navbar::before { left: 20px; transform: rotate(-10deg); }
.navbar::after { right: 20px; transform: rotate(10deg); }

/* 釘子效果 */
.nav-logo::before,
.nav-logo::after {
    content: '';
    position: absolute;
    top: -5px;
    width: 8px;
    height: 8px;
    background: #5d4037; /* 釘子顏色 */
    border-radius: 50%;
    box-shadow: inset 1px 1px 2px rgba(255,255,255,0.3);
}

.nav-logo::before { left: 5px; }
.nav-logo::after { right: 5px; }

/* Logo 文字調整 */
.nav-logo {
    font-size: 1.2rem;
    font-weight: 800;
    color: #5d4037; /* 深褐色文字 */
    letter-spacing: 0.05em;
    text-decoration: none;
    display: flex;
    align-items: center;
    cursor: pointer;
    text-shadow: 0 1px 0 rgba(255,255,255,0.4);
    position: relative; /* 為釘子定位 */
    padding: 0 10px; /* 留空間給釘子 */
}

.nav-logo img {
    height: 32px;
    width: 32px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 8px;
    border: 2px solid #8b5a2b;
    background: #fff;
}

/* 隱藏不需要的元素 */
.navbar-result-spacer {
    display: none !important;
}

/* 結果頁導航：只顯示 Logo */
.navbar.result-nav {
    justify-content: center;
}

/* 移除之前的全域置中樣式 */
.navbar.home-nav, 
.navbar.home-nav .nav-logo,
.navbar.result-nav .nav-logo {
    margin: 0;
    justify-content: flex-start;
}

/* 手機版調整 */
@media (max-width: 768px) {
    .navbar {
        position: absolute !important; /* 確保手機版也是絕對定位 */
        top: 15px !important;
        left: 15px !important;
        right: auto !important;
        width: auto !important;
        margin: 0 !important;
        transform: rotate(-2deg) !important;
        border-radius: 15px !important;
        padding: 8px 16px;
        background: #e6b980;
        border: 3px solid #8b5a2b;
        box-sizing: border-box;
        height: auto;
}

    /* 確保內容不被遮擋 */
    .container {
        padding-top: 80px;
}

    /* Logo 文字大小微調 */
    .nav-logo {
        font-size: 1rem;
}

    .nav-logo img {
        height: 28px;
        width: 28px;
    }
}

/* 返回按鈕 - 圓形按鈕 */
.btn-back {
    width: 40px;
    height: 40px;
    background: #fff;
    color: var(--color-text-light);
    text-decoration: none;
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--color-border);
    cursor: pointer;
    box-shadow: var(--shadow-xs);
}

.btn-back:hover {
    background: var(--color-primary) !important;
    color: #fff !important;
    border-color: var(--color-primary) !important;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* ===== 主要內容區 ===== */
.main-content {
    flex: 1;
    max-width: 860px;
    width: 100%;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
}

/* ===== Hero 區域 ===== */
.hero {
    text-align: center;
    margin-bottom: var(--space-2xl);
}

.hero-title {
    font-size: 2.8rem;
    font-weight: 800;
    color: var(--color-text);
    margin-bottom: var(--space-sm);
    text-shadow: 2px 2px 0 #fff; /* 卡通感文字描邊效果 */
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--color-text-light);
    font-weight: 600;
}

/* 警示框 - 便利貼風格 */
.hero-alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    width: 100%; /* 寬度填滿 */
    max-width: 100%; /* 移除原有寬度限制，使其與容器同寬 */
    margin: var(--space-md) auto 0;
    padding: var(--space-md);
    background: #FFF8D6; /* 淺黃便利貼 */
    border: 2px dashed var(--color-warning); /* 虛線邊框 */
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transform: rotate(-1deg); /* 微微傾斜，更活潑 */
}

.hero-alert-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.hero-alert-text {
    font-size: 1rem;
    line-height: 1.6;
    color: #8A6D3B;
    margin: 0;
    text-align: left;
    font-weight: 500;
}

/* ===== 上傳區域 - 縫線風格 ===== */
.upload-container {
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    border: 4px solid #fff;
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-md);
}

.upload-zone {
    border: 3px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-2xl);
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    background: var(--color-bg-alt);
}

.upload-zone:hover {
    border-color: var(--color-primary);
    background: #fff;
    transform: scale(1.02);
}

.upload-zone.dragover {
    border-color: var(--color-primary);
    background: var(--color-bg-light);
    transform: scale(0.98);
}

.upload-zone.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.upload-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto var(--space-md);
    color: var(--color-primary);
    stroke-width: 2;
}

.upload-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: var(--space-xs);
}

.upload-hint {
    font-size: 0.95rem;
    color: var(--color-text-light);
    margin-bottom: var(--space-lg);
    font-weight: 500;
}

.btn-upload {
    background: #fff;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-full);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 0 var(--color-bg-light);
}

.btn-upload:hover {
    background: var(--color-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 rgba(43, 161, 133, 0.3);
}

.btn-upload:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(43, 161, 133, 0.3);
}

/* ===== 預覽區域 ===== */
.preview-zone {
    margin-top: var(--space-lg);
    display: none;
}

.preview-zone.show {
    display: block;
}

.preview-container {
    display: grid;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.preview-container.single-image {
    grid-template-columns: 1fr;
}

.preview-container.two-images {
    grid-template-columns: repeat(2, 1fr);
}

.preview-wrapper {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 4px solid #fff;
    aspect-ratio: 1;
    box-shadow: var(--shadow-sm);
}

.preview-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.btn-close {
    position: absolute;
    top: var(--space-xs);
    right: var(--space-xs);
    width: 36px;
    height: 36px;
    background: var(--color-danger);
    border: 2px solid #fff;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: 0 2px 0 rgba(0,0,0,0.2);
}

.btn-close:hover {
    transform: scale(1.1);
}

.btn-close svg {
    width: 20px;
    height: 20px;
    stroke-width: 3;
}

.btn-add-more {
    width: 100%;
    background: #fff;
    color: var(--color-text-light);
    border: 2px dashed var(--color-border);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
}

.btn-add-more svg {
    width: 22px;
    height: 22px;
}

.btn-add-more:hover {
    background: var(--color-bg-light);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

@media (max-width: 480px) {
    .preview-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== 按鈕 - 3D 風格 ===== */
.btn-primary {
    width: 100%;
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 1.2rem;
    border-radius: var(--radius-full);
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition);
    margin-top: var(--space-lg);
    box-shadow: 0 6px 0 #1F8A6E; /* 深綠色陰影 */
    text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 0 #1F8A6E;
    background: #34bfa0;
}

.btn-primary:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #1F8A6E;
}

.btn-primary:disabled {
    background: #cccccc;
    box-shadow: 0 6px 0 #999;
    cursor: not-allowed;
    transform: none;
    opacity: 0.8;
}

/* ===== 載入狀態 ===== */
.loading-state {
    text-align: center;
    padding: var(--space-xl) 0;
    display: none;
}

.loading-state.show {
    display: block;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--space-md);
    border: 5px solid var(--color-bg-light);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.2rem;
    color: var(--color-primary);
    font-weight: 700;
}

/* ===== 快速參考區 ===== */
.quick-ref {
    margin-bottom: var(--space-xl);
}

.section-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--color-text);
    margin-bottom: var(--space-lg);
    text-align: center;
    text-shadow: 2px 2px 0 #fff;
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    max-width: 900px;
    margin: 0 auto;
}

.item-card {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #fff;
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    text-align: center;
    transition: var(--transition);
    cursor: default;
    box-shadow: var(--shadow-sm);
}

.item-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-md);
}

.item-icon {
    font-size: 3rem;
    margin-bottom: var(--space-sm);
    display: block;
    filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.1));
    /* 動畫設定 */
    animation-name: iconScale;
    animation-duration: 2s;
    animation-iteration-count: infinite;
    animation-timing-function: ease-in-out;
}

/* 第1個icon - 肉類製品 🥩 */
.item-card:nth-child(1) .item-icon { animation-delay: 0s; }
/* 第2個icon - 新鮮蔬果 🍎 */
.item-card:nth-child(2) .item-icon { animation-delay: 0.2s; }
/* 第3個icon - 植物種子 🌱 */
.item-card:nth-child(3) .item-icon { animation-delay: 0.4s; }
/* 第4個icon - 藥品 💊 */
.item-card:nth-child(4) .item-icon { animation-delay: 0.6s; }
/* 第5個icon - 菸酒 🚬 */
.item-card:nth-child(5) .item-icon { animation-delay: 0.8s; }
/* 第6個icon - 乳製品 🧀 */
.item-card:nth-child(6) .item-icon { animation-delay: 1s; }

/* 縮放旋轉動畫 */
@keyframes iconScale {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.1) rotate(5deg);
    }
    75% {
        transform: scale(1.1) rotate(-5deg);
    }
}

.item-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: var(--space-sm);
}

.item-status {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.4rem 1rem;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}

.item-status.prohibited {
    background: #FFEEEE;
    color: #FF5555;
    border: 2px solid #FFBDBD;
}

.item-status.limited {
    background: #FFF8D6;
    color: #D99E0B;
    border: 2px solid #FFE58F;
}

/* ===== 系統說明 ===== */
.info-box {
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid #fff;
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-sm);
}

.info-content {
    max-width: 600px;
    margin: 0 auto;
}

.info-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--color-text);
    margin-bottom: var(--space-md);
}

.info-list {
    list-style: none;
    padding: 0;
}

.info-list li {
    padding: var(--space-xs) 0;
    padding-left: var(--space-lg);
    position: relative;
    font-size: 1rem;
    color: var(--color-text);
    font-weight: 500;
}

.info-list li::before {
    content: "🍃"; /* 用葉子代替圓點 */
    position: absolute;
    left: 0;
    color: var(--color-success);
    font-size: 0.9rem;
}

/* ===== 警告框 ===== */
.alert-box {
    background: #FFF8D6;
    border: 2px dashed var(--color-warning);
    border-radius: var(--radius-md);
    padding: 1.5rem; /* 統一增加內距 */
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-xs);
}

.alert-box.system-warning {
    margin-bottom: 2rem;
}

/* 浮水印圖標與容器設定 */
.alert-box, .recommendations-box {
    position: relative;
    overflow: hidden;
}

.box-watermark {
    position: absolute;
    top: -15px;
    right: -10px; /* 改放在右上角 */
    width: 100px;
    height: 100px;
    opacity: 0.1;
    transform: rotate(15deg); /* 調整旋轉角度 */
    pointer-events: none;
    z-index: 0;
}

.alert-box .box-watermark {
    color: #D99E0B;
}

.recommendations-box .box-watermark {
    color: var(--color-success);
}

.alert-box h3, .alert-box ul, .alert-box p,
.recommendations-box h3, .recommendations-box ul {
    position: relative;
    z-index: 1;
}

.alert-box h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #D99E0B;
    margin-bottom: var(--space-sm);
}

.alert-box.result-page h3 {
    font-size: 1.4rem;
    font-weight: 800;
    color: #D99E0B;
    margin-bottom: var(--space-sm);
}

.alert-box.result-page {
    background: #FFF8D6;
    border: 3px solid var(--color-warning);
    box-shadow: var(--shadow-sm);
}

.alert-box.system-warning h3 {
    color: #D99E0B;
    margin-bottom: 0.5rem;
}

.alert-box ul {
    list-style: none;
    padding: 0;
}

.alert-box li {
    padding: 0.25rem 16px; /* 回復左右內距 */
    font-size: 1rem;
    line-height: 1.5; /* 回復行距 */
    color: #8A6D3B;
    font-weight: 500;
    text-align: justify; /* 保持分散對齊 */
}

.alert-box.system-warning li {
    padding: 0.25rem 0;
    color: #8A6D3B;
}

.alert-box.system-warning p {
    margin-top: 0.5rem;
    color: #8A6D3B;
}

.alert-box.system-warning a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 700;
}

/* 建議框 */
.recommendations-box {
    background: #E0F5E9;
    border: 3px solid var(--color-success);
    border-radius: var(--radius-md);
    padding: 1.5rem; /* 統一內距 */
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-sm);
}

.recommendations-box h3 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--color-success);
    margin-bottom: var(--space-sm);
}

.recommendations-box ul {
    list-style: none;
    padding: 0;
}

.recommendations-box li {
    padding: 0.25rem 16px; /* 回復左右內距 */
    font-size: 1rem;
    line-height: 1.5; /* 回復行距 */
    color: #2D6A4F;
    font-weight: 500;
    text-align: justify; /* 保持分散對齊 */
}

/* ===== 頁尾 ===== */
.footer {
    background: rgba(255, 255, 255, 0.8);
    border-top: 2px dashed var(--color-border);
    padding: var(--space-xl) var(--space-lg);
    text-align: center;
    margin-top: auto;
}

.footer-text {
    font-size: 0.9rem;
    color: var(--color-text-light);
    margin: var(--space-xs) 0;
    font-weight: 500;
}

.footer-text a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 700;
}

/* ===== 結果頁面專用樣式 ===== */
.result-container {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-lg);
}

.result-hero {
    text-align: center;
    margin-bottom: var(--space-2xl);
    padding-top: var(--space-xl);
}

.result-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius-full);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: var(--space-md);
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    border: 2px solid #fff;
}

.result-badge.success {
    background: var(--color-success);
    color: #fff;
}

.result-badge.danger {
    background: var(--color-danger);
    color: #fff;
}

.result-badge.warning {
    background: var(--color-warning);
    color: #fff;
}

.result-badge.unknown {
    background: #6c757d;
    color: #fff;
}

.result-title {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.3;
    color: var(--color-text);
    margin-bottom: var(--space-sm);
    
    /* 改為背景框以提升閱讀清晰度 */
    text-shadow: none;
    background: rgba(255, 255, 255, 0.85);
    padding: 1.2rem 1.5rem;
    border-radius: 24px;
    border: 3px solid #fff;
    box-shadow: 0 6px 15px rgba(0,0,0,0.08);
    display: inline-block;
    width: 100%;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

.result-summary {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--color-text-light);
    font-weight: 500;
}

.image-section {
    background: #fff;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-md);
}

.image-section img {
    width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 2px solid var(--color-bg-light);
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-md);
    margin-bottom: 0; /* 移除下方邊距以確保四邊留白一致 */
}

.image-item {
    position: relative;
}

.image-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.image-label {
    display: none; /* 隱藏照片標籤 */
    position: absolute;
    top: var(--space-xs);
    left: var(--space-xs);
    background: var(--color-primary);
    color: white;
    padding: 0.4rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 700;
    box-shadow: 0 2px 0 rgba(0,0,0,0.2);
}

.image-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85); /* 改為深黑色遮罩 */
    backdrop-filter: blur(5px); /* 增加背景模糊提升質感 */
    align-items: center;
    justify-content: center;
}

.image-modal.show {
    display: flex;
}

.image-modal-content {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: var(--radius-lg);
    border: 4px solid #fff;
    box-shadow: var(--shadow-lg);
}

.image-modal-close {
    position: absolute;
    top: 30px;
    right: 40px;
    color: #fff;
    font-size: 50px;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition);
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.image-modal-close:hover {
    color: var(--color-warning);
    transform: rotate(90deg);
}

.description-text {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: var(--color-bg-alt);
    border-radius: var(--radius-md);
    font-size: 1rem;
    color: var(--color-text);
    border: 2px dashed var(--color-border);
}

.items-section {
    margin-bottom: var(--space-xl);
}

.section-heading {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: var(--space-md);
    color: var(--color-text);
    text-align: center;
    text-shadow: 2px 2px 0 #fff;
}

.result-card {
    background: #fff;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-xs);
    position: relative;
    overflow: hidden;
}

.result-card::after {
    /* 葉子背景浮水印 */
    content: "🍃";
    position: absolute;
    bottom: -10px;
    right: 10px;
    font-size: 80px;
    opacity: 0.05;
    transform: rotate(-20deg);
    pointer-events: none;
}

.result-card.prohibited {
    border-left: 6px solid var(--color-danger);
}

.result-card.allowed {
    border-left: 6px solid var(--color-success);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: var(--space-md);
    gap: var(--space-md);
}

.card-title {
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1.4;
    color: var(--color-text);
}

.card-badge {
    flex-shrink: 0;
    padding: 0.4rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}

.card-badge.allowed {
    background: var(--color-success);
    color: #fff;
}

.card-badge.prohibited {
    background: var(--color-danger);
    color: #fff;
}

.card-row {
    padding: var(--space-sm) 0;
    border-top: 2px dashed var(--color-border-light);
}

.card-value.danger {
    color: var(--color-danger);
    font-weight: 800;
}

.card-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-text-light);
    margin-bottom: 0.25rem;
}

.card-value {
    font-size: 1.05rem;
    color: var(--color-text);
    line-height: 1.55;
    font-weight: 500;
}

/* 信心度進度條 */
.confidence-bar {
    margin-top: var(--space-md);
    background: var(--color-border-light);
    height: 12px;
    border-radius: var(--radius-full);
    overflow: hidden;
    border: 2px solid #fff;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.confidence-fill {
    height: 100%;
    transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s ease;
    border-radius: var(--radius-full);
}

.confidence-fill.high { background: var(--color-success); }
.confidence-fill.medium { background: var(--color-warning); }
.confidence-fill.low { background: var(--color-danger); }

.confidence-text {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    margin-top: var(--space-xs);
    font-size: 0.95rem;
    color: var(--color-text-light);
    font-weight: 600;
}

.confidence-level {
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.2;
}

.confidence-level.high {
    background: #E0F5E9;
    color: #2D6A4F;
}

.confidence-level.medium {
    background: #FFF8D6;
    color: #8A6D3B;
}

.confidence-level.low {
    background: #FFEEEE;
    color: #B91C1C;
}

.low-confidence-warning {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: #FFF8D6;
    border-left: 4px solid var(--color-warning);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    color: #8A6D3B;
    text-align: left;
    box-shadow: var(--shadow-sm);
}

.low-confidence-warning strong {
    display: block;
    margin-bottom: var(--space-xs);
    color: #D99E0B;
    text-align: left;
}

/* 操作按鈕 */
.action-bar {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    margin-top: var(--space-2xl);
}

.btn-action {
    padding: 0.8rem 2rem; /* 稍微增加內距配合字體放大 */
    border-radius: var(--radius-full);
    font-size: 18px; /* 放大字體 */
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex; /* 改為 flex 佈局以確保垂直置中 */
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 0 rgba(0,0,0,0.15);
    border: 2px solid transparent;
    letter-spacing: 0.02em;
    line-height: 1.4; /* 調整行高 */
    font-family: inherit;
}

.btn-action.primary {
    background: var(--color-primary);
    color: white;
    border: none;
    box-shadow: 0 4px 0 #1F8A6E;
}

.btn-action.primary:hover {
    background: #34bfa0;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #1F8A6E;
}

.btn-action.primary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #1F8A6E;
}

.btn-action.secondary {
    background: #fff;
    color: var(--color-text);
    border: 2px solid var(--color-border);
}

.btn-action.secondary:hover {
    background: #fff;
    border-color: var(--color-text);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 var(--color-border-dark);
}

.btn-action.secondary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 var(--color-border-dark);
}

/* ===== 報告錯誤區域 ===== */
.report-error-section {
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 2px dashed var(--color-border);
    text-align: center;
}

.btn-report-error {
    display: inline-flex !important;
    align-items: center;
    gap: var(--space-xs);
    padding: 0.6rem 1.5rem;
    background: #fff;
    color: var(--color-text-light) !important;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-full);
    font-size: 16px; /* 改用 px 固定大小 */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none !important;
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
    letter-spacing: 0.02em; /* 統一字距 */
    line-height: 1.5; /* 統一長高 */
    font-family: inherit; /* 確保字體一致 */
}

.btn-report-error:hover {
    background: #fff !important;
    border-color: var(--color-primary) !important;
    color: var(--color-primary) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 0 rgba(0,0,0,0.15);
}

.report-hint {
    margin-top: var(--space-sm);
    font-size: 0.85rem;
    color: var(--color-text-light);
    font-weight: 500;
}

/* ===== 自定義彈窗 - 對話框風格 ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(94, 83, 64, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: #fff;
    border: 4px solid var(--color-primary);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 90%;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10001;
}

.modal-header {
    padding: var(--space-lg) var(--space-lg) var(--space-md);
    text-align: center;
    border-bottom: 2px dashed var(--color-border-light);
    background: var(--color-bg-alt);
}

.modal-icon {
    font-size: 56px;
    margin-bottom: var(--space-xs);
    animation: bounce 0.6s ease;
}

.modal-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--color-text);
    margin: 0;
}

.modal-body {
    padding: var(--space-lg);
}

.modal-message {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--color-text);
    margin: 0;
    text-align: center;
    white-space: pre-line;
    font-weight: 500;
}

.modal-footer {
    padding: var(--space-md) var(--space-lg) var(--space-lg);
    display: flex;
    justify-content: center;
}

.modal-btn {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 12px 36px;
    border-radius: var(--radius-full);
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 0 #1F8A6E;
}

.modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #1F8A6E;
}

.modal-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #1F8A6E;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* ===== 跳轉頁面 ===== */
.redirect-page {
    background-color: #D7F5E8;
    background-image: 
        radial-gradient(#A8E6CF 15%, transparent 16%),
        radial-gradient(#A8E6CF 15%, transparent 16%);
    background-size: 40px 40px;
    background-position: 0 0, 20px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: var(--space-lg);
}

.redirect-box {
    background: #fff;
    border: 4px solid #fff;
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow-md);
    animation: fadeIn 0.3s ease-out;
}

.redirect-icon {
    font-size: 60px;
    margin-bottom: var(--space-lg);
}

.redirect-title {
    font-size: 28px;
    color: var(--color-text);
    margin-bottom: var(--space-sm);
    font-weight: 800;
}

.redirect-description {
    font-size: 18px;
    color: var(--color-text-light);
    margin-bottom: var(--space-lg);
    line-height: 1.6;
}

.redirect-status {
    font-size: 16px;
    color: var(--color-primary);
    font-weight: 700;
}

.redirect-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 4px solid var(--color-bg-light);
    border-top: 4px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}

/* ===== 響應式設計 ===== */
@media (max-width: 768px) {
    /* Logo 調整 */
    .nav-logo {
        font-size: 1.1rem;
    }

    .nav-logo img {
        height: 32px;
        width: 32px;
    }

    /* 增加容器頂部內距 */
    .container {
        padding-top: 90px; /* 調整上方空白 */
    }

    /* 結果頁圖片區塊：減少內距，放大圖片 */
    .image-section {
        padding: var(--space-sm); /* 手機版大幅減少內距 */
        border-radius: var(--radius-md); /* 稍微減小圓角 */
    }

    .image-section img {
        border-radius: var(--radius-sm);
    }

    /* 讓結果頁主要內容區左右內距變小，增加可視寬度 */
    .result-container {
        padding: var(--space-sm);
    }
    
    /* 縮小手機版各區塊間距 */
    .result-hero {
        margin-bottom: var(--space-md); /* 縮小標題與圖片間距 */
        padding-top: 0;
    }
    
    .result-title {
        margin-bottom: var(--space-xs);
    }

    /* 結果頁導航：左 Logo 右按鈕 */
    .navbar.result-nav {
        justify-content: space-between;
    }

    /* 隱藏結果頁左側佔位符，釋放空間 */
    .navbar.result-nav .navbar-result-spacer:first-child {
        display: none;
    }

    /* 右側按鈕區域不拉伸 */
    .navbar.result-nav .navbar-result-spacer.right {
        flex: 0 0 auto;
    }

    /* Logo 調整 */
    .nav-logo {
        font-size: 1.1rem;
        flex: 1; /* 佔滿剩餘空間 */
        justify-content: flex-start; /* 靠左對齊 */
        margin: 0 !important; /* 覆寫原本的 margin: 0 auto */
    }

    /* 首頁 Logo 保持居中 */
    .navbar.home-nav .nav-logo {
        justify-content: center;
    }

    .nav-logo img {
        height: 32px;
        width: 32px;
    }

    /* 強制手機版導航列置中與縮小，並補回格子紋路 */
    .navbar {
        position: absolute !important;
        top: 15px !important;
        left: 50% !important;
        /* 使用 translateX(-50%) 確保從中心點位移，配合 scale 縮小 */
        transform: translateX(-50%) scale(0.85) rotate(-2deg) !important;
        transform-origin: center top !important;
        width: max-content !important;
        max-width: 90vw !important;
        margin: 0 !important;
        right: auto !important;
        
        /* 顯式補回格子紋路 */
        background-color: #e6b980 !important;
        background-image: linear-gradient(90deg, rgba(255,255,255,0.1) 50%, transparent 50%),
                          linear-gradient(rgba(255,255,255,0.1) 50%, transparent 50%) !important;
        background-size: 20px 20px !important;
        
        /* 樣式調整 */
        padding: 8px 16px !important;
        border: 3px solid #8b5a2b !important;
        border-radius: 12px !important;
        box-sizing: border-box !important;
        white-space: nowrap !important;
        display: inline-flex !important;
    }

    /* 其他響應式樣式 */
    .hero-title {
        font-size: 2.2rem;
    }

    .hero-subtitle {
        font-size: 1rem; /* 縮小字體避免斷行 */
        line-height: 1.5;
        padding: 0 5px;
    }

    .hero-alert {
        padding: var(--space-sm);
        margin-bottom: 0 !important; /* 移除警告框下邊距 */
    }

    .hero {
        margin-bottom: 40px !important; /* 設定與下方上傳區的間距為 40px */
    }

    .hero-alert-text {
        font-size: 0.95rem;
    }

    .main-content {
        padding: var(--space-md) var(--space-sm); /* 減少主內容區外距 */
    }

    .upload-container {
        padding: var(--space-sm); /* 減少上傳容器內距 */
        padding-bottom: var(--space-lg); /* 增加底部留白 */
    }

    /* 手機版開始檢查按鈕 */
    .btn-primary {
        padding: 0.8rem 1.5rem !important;
        font-size: 1.1rem !important;
        width: 100% !important; /* 恢復全寬 */
        max-width: 100% !important;
        margin: 1.5rem auto 0 !important; /* 增加上方間距 */
        display: block !important;
        box-sizing: border-box !important;
    }

    .upload-zone {
        padding: var(--space-lg); /* 減少虛線框內距 */
    }

    .items-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .image-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .action-bar {
        flex-direction: column;
    }

    .btn-action {
        width: 100%;
        text-align: center;
    }

    .card-header {
        flex-direction: column;
    }
    }

@media (max-width: 640px) {
    .result-title {
        font-size: 1.6rem;
        line-height: 1.3;
    }

    .result-summary {
        font-size: 1rem;
        line-height: 1.6;
    }

    .card-title {
        font-size: 1.3rem;
    }

    .card-label {
        font-size: 0.85rem;
    }

    .card-value {
        font-size: 1rem;
    }

    .alert-box.result-page li,
    .recommendations-box li {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 1.8rem;
    }

    .items-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* 移除這裡的 .navbar 設定，避免覆蓋上面的樣式 */

    .result-title {
        font-size: 1.4rem;
        line-height: 1.3;
    }
}

/* ===== 列印樣式 ===== */
@media print {
    .navbar,
    .footer,
    .btn-upload,
    .btn-primary,
    .report-error-section,
    .action-bar {
        display: none;
    }

    .container {
        max-width: 100%;
    }
    
    body {
        background: white;
    }
    
    .result-card {
        break-inside: avoid;
        border: 1px solid #000;
        box-shadow: none;
    }
}
