:root {
    --primary: #FFC107;
    --primary-dark: #FFA000;
    --secondary: #03A9F4;
    --dark: #263238;
    --light: #ECEFF1;
    --text: #37474F;
    --text-light: #78909C;
    --success: #4CAF50;
    --error: #F44336;
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --radius: 12px;
    --radius-sm: 6px;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --border-color: #E0E0E0;
    --modal-bg: rgba(0, 0, 0, 0.85);
    --search-bg: linear-gradient(to right, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.95));
    --toggle-bg: #CFD8DC;
    --summary-bg: #f1f8ff;
    --button-bg: #f0f0f0;
    --button-hover: #e0e0e0;
    --button-text: #333;
    --primary-color: #ff9800;
    --primary-color-light: #fff3e0;
    --primary-color-light-hover: #ffe0b2;
}

[data-theme="dark"] {
    --card-bg: #2a2a2a;
    --summary-bg: #1e1e1e;
    --button-bg: #3a3a3a;
    --button-hover: #4a4a4a;
    --button-text: #e0e0e0;
    --primary-color: #ffb74d;
    --primary-color-light: #3d3224;
    --primary-color-light-hover: #4d3a24;
}

/* 深色模式變數 */
[data-theme="dark"] {
    --primary: #e9b200;
    --primary-dark: #FFCA28;
    --secondary: #29B6F6;
    --dark: #ECEFF1;
    --light: #263238;
    --text: #E0E0E0;
    --text-light: #90A4AE;
    --bg-color: #121212;
    --card-bg: #1E1E1E;
    --border-color: #424242;
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
    --modal-bg: rgba(0, 0, 0, 0.95);
    --search-bg: linear-gradient(to right, rgba(42, 42, 42, 0.9), rgba(42, 42, 42, 0.95));
    --toggle-bg: #455A64;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans TC', sans-serif;
    background-color: var(--bg-color);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem;
}

#searchWrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
    transition: var(--transition);
    position: relative;
}

#searchWrapper.pinned-top {
    justify-content: flex-start;
    padding-top: 2rem;
    min-height: auto;
    margin-bottom: 2rem;
}

.header {
    text-align: center;
    margin-bottom: 2rem;
    transition: var(--transition);
}

.search-area {
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
}

.search-container {
    display: flex;
    background: var(--card-bg);
    border-radius: 24px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 6px rgba(32, 33, 36, 0.08);
    padding: 4px;
    height: 46px;
    transition: all 0.3s ease;
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
    align-items: center;
}

.search-container:hover,
.search-container:focus-within {
    box-shadow: 0 1px 6px rgba(32, 33, 36, 0.2);
    border-color: rgba(223, 225, 229, 0);
    transform: none;
}

.search-container:before {
    display: none;
}

.search-container:focus-within:before {
    opacity: 1;
}

.search-input {
    flex: 1;
    border: none;
    font-size: 16px;
    outline: none;
    color: var(--text);
    min-width: 0;
    padding: 0 20px;
    font-family: inherit;
    background: transparent;
    letter-spacing: 0.5px;
    transition: color 0.3s ease, background-color 0.3s ease;
}

.search-input::placeholder {
    color: var(--text-light);
    opacity: 0.7;
    transition: opacity 0.3s ease, color 0.3s ease;
}

.search-input:focus::placeholder {
    opacity: 0.4;
}

/* 修復自動填充背景顏色問題 */
.search-input:-webkit-autofill,
.search-input:-webkit-autofill:hover, 
.search-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 30px var(--card-bg) inset !important;
    -webkit-text-fill-color: var(--text) !important;
    transition: background-color 5000s ease-in-out 0s, -webkit-box-shadow 0.3s ease !important;
}

.search-button {
    background: transparent;
    border: none;
    padding: 0 16px;
    font-weight: normal;
    font-size: 15px;
    color: var(--text-light);
    border-radius: 0;
    height: 48px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: none;
    margin: 0 2px;
}

.search-button:hover {
    background: transparent;
    transform: none;
    box-shadow: none;
    color: var(--text);
}

.search-button .icon {
    transition: transform 0.3s ease;
    fill: var(--text-light);
}

.search-button:hover .icon {
    transform: none;
    fill: var(--text);
}

.button-group {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 1rem 0;
}

.option-button {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 26px;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    height: 42px;
}

.option-button:hover {
    background: var(--light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.option-button svg {
    width: 18px;
    height: 18px;
    fill: var(--text-light);
}

.advanced-options {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1rem;
    box-shadow: var(--shadow-md);
    display: none;
    width: 100%;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.advanced-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border-color);
}

.advanced-header span {
    font-weight: 600;
    font-size: 16px;
    color: var(--text);
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.2rem;
    margin-bottom: 1.2rem;
}

.option-group {
    margin-bottom: 1rem;
}

.option-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.4rem;
    color: var(--text);
    font-size: 14px;
}

.option-description {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.option-select, .option-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    background: var(--card-bg);
    transition: border 0.2s;
    color: var(--text);
}

.option-select:focus, .option-input:focus {
    border-color: var(--secondary);
    outline: none;
}

.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.toggle-container {
    position: relative;
    width: 44px;
    height: 22px;
    margin-right: 12px;
}

.toggle-input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--toggle-bg);
    transition: .3s;
    border-radius: 22px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-input:checked + .toggle-slider {
    background-color: var(--secondary);
}

.toggle-input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

.error-message {
    background: #FFEBEE;
    color: var(--error);
    padding: 12px 16px;
    border-radius: var(--radius);
    text-align: center;
    margin: 1rem auto;
    max-width: 680px;
    display: none;
    font-size: 14px;
    animation: fadeIn 0.3s ease;
}

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

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 2rem 0;
    display: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(3, 169, 244, 0.2);
    border-top: 3px solid var(--secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.results-container {
    max-width: 1200px;
    margin: 2rem auto 0;
    padding: 0 10px;
    max-width: 1300px;
}

.results-summary {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-light);
    font-size: 14px;
    animation: fadeIn 0.5s ease;
    background-color: var(--summary-bg);
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
    display: inline-block;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    animation: fadeInUp 0.5s ease;
}

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

.grid-item {
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    height: 100%;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    transition: all 0.25s ease;
    position: relative;
}

.grid-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, 
                               rgba(var(--primary-color-rgb), 0.1), 
                               transparent);
    opacity: 1;
    transition: opacity 0.3s ease;
    z-index: 1;
    pointer-events: none;
}

.grid-item:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.grid-item img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.grid-item:hover img {
    transform: scale(1.08);
}

.grid-info {
    padding: 14px 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--card-bg);
}

.grid-code {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 15px;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.grid-text {
    font-size: 13px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
    line-height: 1.4;
    opacity: 0.9;
    max-height: 2.8em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    animation: zoomIn 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

@keyframes zoomIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-image {
    max-width: 100%;
    max-height: 80vh;
    border-radius: var(--radius);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3);
}

.modal-close {
    position: absolute;
    top: -50px;
    right: -10px;
    color: white;
    font-size: 32px;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.15);
    transition: var(--transition);
}

.modal-close:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.1) rotate(90deg);
}

.modal-info {
    color: white;
    text-align: center;
    margin-top: 20px;
    font-size: 16px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    max-width: 80vw;
}

/* 按鈕中的圖標 */
.icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* 底部的浮動按鈕 */
.fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--dark);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: var(--transition);
    z-index: 100;
    border: none;
}

.fab:hover {
    transform: scale(1.1);
    background: var(--primary-dark);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.fab svg {
    width: 24px;
    height: 24px;
}

#scrollTop {
    display: none;
}

/* 主題切換按鈕樣式 */
.theme-switch {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.theme-switch:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.theme-icon {
    width: 24px;
    height: 24px;
    fill: var(--text);
    transition: var(--transition);
}

@media (max-width: 768px) {
    .search-area {
        max-width: 95%;
    }
    
    .options-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .results-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 16px;
    }
    
    .grid-item img {
        object-position: center 90%;
        height: 150px;
    }
    
    .button-group {
        flex-wrap: wrap;
    }
    
    .option-button {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .search-container {
        height: 50px;
    }
    
    .search-button {
        height: 42px;
        padding: 0 16px;
    }
    
    .theme-switch {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
    
    .grid-item.single-item .grid-info {
        padding: 12px 16px;
    }
}

.logo {
    font-family: 'some_time_laterregular', sans-serif !important;
    font-size: 3em;
    display: inline-block;
    white-space: nowrap;
}

.logo span {
    display: inline-block;
    transition: transform 0.3s;
}

.logo span:hover {
    transform: scale(1.3) rotate(-5deg);
}

.grid-item.single-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    
}
.grid-item img {
   
    overflow: hidden
}

.grid-item.single-item:hover img {
    transform: scale(1.02);
    transition: transform 0.3s ease;
}

/* 單張圖片容器樣式優化 */
.single-image-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 12px;
    margin-top: 20px;
}

.grid-item.single-item .grid-code {
    font-size: 18px;
    margin-bottom: 8px;
}

.grid-item.single-item .grid-text {
    font-size: 14px;
    -webkit-line-clamp: initial;
    line-clamp: initial;
    max-height: none;
}

.grid-item.single-item .grid-info {
    padding: 16px 20px;
}

/* 單張圖片項目樣式 */
.grid-item.single-item {
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.grid-item.single-item img {
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-family: 'some_time_later', sans-serif;
    font-size: 3em;
    display: inline-block;
    white-space: nowrap;
}

.logo span {
    display: inline-block;
    transition: transform 0.3s;
}

.logo span:hover {
    transform: scale(1.3) rotate(-5deg);
}

/* 懸浮效果改進 */
@keyframes softPulse {
    0% { box-shadow: var(--shadow-sm); }
    50% { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15); }
    100% { box-shadow: var(--shadow-sm); }
}

.grid-item:hover {
    animation: softPulse 2s infinite;
}

#scrollLoadingIndicator {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin: 30px auto;
    padding: 16px;
    max-width: 200px;
}
.lazy-image {
    opacity: 0.6;
    transition: opacity 0.3s ease-in-out;
}

.fade-in {
    opacity: 1;
}

.image-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 100%; /* 或其他適合你圖片的比例 */
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.05);
}

.image-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}