:root {
    --md-sys-color-primary: #006e1c;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #90f891;
    --md-sys-color-on-primary-container: #002204;
    
    --md-sys-color-secondary: #52634f;
    --md-sys-color-on-secondary: #ffffff;
    --md-sys-color-secondary-container: #d5e8cf;
    --md-sys-color-on-secondary-container: #111f0f;
    
    --md-sys-color-surface: #fcfdf6;
    --md-sys-color-on-surface: #1a1c18;
    --md-sys-color-surface-variant: #e0e4d6;
    --md-sys-color-on-surface-variant: #43483e;
    
    --md-sys-color-outline: #73796d;
    --md-sys-color-outline-variant: #c3c8bb;
    
    --md-sys-elevation-1: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-2: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-3: 0px 1px 3px 0px rgba(0, 0, 0, 0.3), 0px 4px 8px 3px rgba(0, 0, 0, 0.15);
    
    --md-sys-shape-corner-extra-large: 28px;
    --md-sys-shape-corner-large: 16px;
    --md-sys-shape-corner-medium: 12px;
    --md-sys-shape-corner-small: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.header {
    text-align: center;
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 8px;
}

.subtitle {
    font-size: 1.125rem;
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 400;
}

.main {
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: center;
}

.image-container {
    width: 100%;
    position: relative;
    margin: 16px 0;
    display: flex;
    justify-content: center;
}

.image-wrapper {
    position: relative;
    max-width: 100%;
    max-height: 80vh;
    border-radius: var(--md-sys-shape-corner-large);
    overflow: hidden;
    box-shadow: var(--md-sys-elevation-2);
    background-color: var(--md-sys-color-surface-variant);
    transition: all 0.3s var(--md-sys-motion-easing-standard);
    cursor: zoom-in;
    display: inline-flex;
}

.random-image {
    max-width: 100%;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: all 0.3s var(--md-sys-motion-easing-standard);
}

/* 全屏样式 */
.image-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background-color: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.image-fullscreen img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
}

/* 下载按钮样式 */
.download-btn {
    position: absolute;
    bottom: 16px;
    right: 16px;
    z-index: 10;
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--md-sys-elevation-2);
    cursor: pointer;
    transition: all 0.3s var(--md-sys-motion-easing-standard);
}

.download-btn:hover {
    transform: scale(1.1);
}

.random-image.loading {
    opacity: 0.5;
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-overlay.show {
    opacity: 1;
}

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--md-sys-color-outline-variant);
    border-top: 4px solid var(--md-sys-color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.image-info {
    margin-top: 16px;
    text-align: center;
}

.description {
    font-size: 1rem;
    color: var(--md-sys-color-on-surface-variant);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 16px 32px;
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    border-radius: var(--md-sys-shape-corner-extra-large);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: var(--md-sys-elevation-1);
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-primary:hover {
    box-shadow: var(--md-sys-elevation-2);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: var(--md-sys-elevation-1);
}

.btn-primary:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-large);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-secondary:hover {
    background-color: var(--md-sys-color-secondary);
    color: var(--md-sys-color-on-secondary);
}

.btn-secondary:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

.controls {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.footer {
    text-align: center;
    padding-top: 16px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}

.footer p {
    font-size: 0.875rem;
    color: var(--md-sys-color-on-surface-variant);
}

.footer a {
    color: var(--md-sys-color-primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* 历史记录样式 */
.history-section {
    width: 100%;
    margin-top: 32px;
    padding: 24px;
    background-color: var(--md-sys-color-surface-variant);
    border-radius: var(--md-sys-shape-corner-large);
    box-shadow: var(--md-sys-elevation-1);
}

.history-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 16px;
    text-align: center;
}

.history-controls {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
}

.history-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--md-sys-shape-corner-medium);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease;
    box-shadow: var(--md-sys-elevation-1);
}

.history-item:hover {
    transform: scale(1.05);
}

.history-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.history-item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.history-item:hover .history-item-overlay {
    opacity: 1;
}

.history-item-date {
    color: white;
    font-size: 0.75rem;
    text-align: center;
    padding: 4px;
}

.empty-history {
    text-align: center;
    color: var(--md-sys-color-on-surface-variant);
    font-style: italic;
    grid-column: 1 / -1;
}

/* 主题选择器样式 */
.theme-section {
    width: 100%;
    margin-top: 32px;
    padding: 24px;
    background-color: var(--md-sys-color-surface-variant);
    border-radius: var(--md-sys-shape-corner-large);
    box-shadow: var(--md-sys-elevation-1);
}

.theme-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 16px;
    text-align: center;
}

.theme-controls {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.theme-group h4 {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 12px;
    text-align: center;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 12px;
    max-width: 500px;
    margin: 0 auto;
}

.theme-option {
    aspect-ratio: 1;
    border-radius: var(--md-sys-shape-corner-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--md-sys-elevation-1);
    position: relative;
    overflow: hidden;
}

.theme-option:hover {
    transform: scale(1.05);
    box-shadow: var(--md-sys-elevation-2);
}

.theme-option.active {
    outline: 3px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

.theme-option span {
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.theme-option input[type="color"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

@media (max-width: 480px) {
    .title {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .image-wrapper {
        height: 300px;
    }
    
    .btn-primary {
        padding: 14px 28px;
        font-size: 0.875rem;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
    }
    
    .history-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }
    
    .theme-grid {
        grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
        gap: 8px;
    }
}

/* MD3风格toast通知 */
.md3-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    padding: 12px 24px;
    border-radius: var(--md-sys-shape-corner-large);
    box-shadow: var(--md-sys-elevation-2);
    z-index: 1100;
    opacity: 0;
    transition: all 0.3s var(--md-sys-motion-easing-standard);
}

.md3-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* 响应式调整 */
@media (max-width: 480px) {
    .md3-toast {
        width: calc(100% - 32px);
        text-align: center;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --md-sys-color-primary: #6dd86e;
        --md-sys-color-on-primary: #00390a;
        --md-sys-color-primary-container: #005313;
        --md-sys-color-on-primary-container: #90f891;
        
        --md-sys-color-secondary: #bbcbb4;
        --md-sys-color-on-secondary: #263422;
        --md-sys-color-secondary-container: #3c4b38;
        --md-sys-color-on-secondary-container: #d7e8cf;
        
        --md-sys-color-surface: #111411;
        --md-sys-color-on-surface: #e1e4d9;
        --md-sys-color-surface-variant: #43483e;
        --md-sys-color-on-surface-variant: #c3c8bb;
        
        --md-sys-color-outline: #8d9387;
        --md-sys-color-outline-variant: #43483e;
    }
}