@layer utilities {
    .content-auto { content-visibility: auto; }
    .backdrop-blur { backdrop-filter: blur(8px); }
    .text-shadow { text-shadow: 0 2px 4px rgba(0,0,0,0.3); }
    
    /* 动画类 */
    .mobile-menu-enter { animation: slideIn 0.3s ease-out forwards; }
    .mobile-menu-exit { animation: slideOut 0.3s ease-in forwards; }
    .modal-fade-in { animation: fadeIn 0.3s ease-out forwards; }
    .modal-fade-out { animation: fadeOut 0.3s ease-in forwards; }
    .video-scale-in { animation: scaleIn 0.4s ease-out forwards; }
    
    @keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
    @keyframes slideOut { from { transform: translateX(0); } to { transform: translateX(100%); } }
    @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
    @keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
    @keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
}

/* CSS 变量 - 统一管理颜色和尺寸 */
:root {
    --color-primary: #3B82F6;
    --color-secondary: #10B981;
    --color-dark: #1E293B;
    --color-light: #F8FAFC;
    --shadow-card: 0 4px 15px rgba(0,0,0,0.3);
    --radius-lg: 0.75rem;
    --transition-base: all 0.3s ease;
}

/* Import Fonts - 合并为一个请求 */
@import url('/fonts/fonts.css'); /* 本地自托管字体，替代 Google Fonts */

/* Base Styles */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

/* iPhone Fullscreen Hint */
#ios-fullscreen-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 12px 20px;
    border-radius: 30px;
    font-size: 14px;
    z-index: 100;
    display: none;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(4px);
}
#ios-fullscreen-hint i { font-size: 16px; }

/* Fullscreen Message */
.fullscreen-message {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    text-align: center;
    color: white;
    padding: 10px;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    font-size: 14px;
    z-index: 5;
}

/* Flip Clock Container - 可拖拽 */
.flip-clock-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    cursor: grab;
    user-select: none;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.flip-clock-container.dragging { cursor: grabbing; }

/* ==========================================================================
   Flip Clock Styles — flipclock.net 经典翻页样式（深色主题）
   --------------------------------------------------------------------------
   每个 .flip-card 由 4 个半区层组成（JS 驱动只写 front/back 的纯文本，
   静态层由 js/flip-sync.js 同步，因此无需改动任何现有时钟驱动脚本）：

     .flip-card-front      上扇叶：旧数字上半，翻页时向前翻开 rotateX(0 -> -90deg)
     .flip-static-top      静态层：新数字上半，上扇叶翻开后露出
     .flip-static-bottom   静态层：旧数字下半，翻页中被下扇叶覆盖
     .flip-card-back       下扇叶：新数字下半，延迟落下 rotateX(90deg -> 0)

   动画为两段式共 600ms（0.3s 上扇叶 + 0.3s 下扇叶），与驱动脚本的
   setTimeout(..., 600) 对齐；配色/比例对齐 flipclock.net：
   卡片 #1c1c1c、数字 #cccccc、圆点 #323434、卡片宽高比 0.8（160x200）、
   数字字号 0.65 倍卡高（130/200）、Helvetica Neue 粗体。
   ========================================================================== */
.flip-clock {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;

    /* 尺寸体系（随视口缩放，比例锁定 flipclock.net）*/
    --card-h: clamp(4rem, 12vw, 10rem);
    --card-w: calc(var(--card-h) * 0.8);
    --card-radius: calc(var(--card-h) * 0.06);
    --digit-size: calc(var(--card-h) * 0.65);
    --line-w: max(2px, calc(var(--card-h) * 0.015));
    --flip-card-bg: #1c1c1c;
    --flip-digit: #cccccc;
    --flip-dot: #323434;
}

.flip-unit {
    position: relative;
    width: var(--card-w);
    height: var(--card-h);
}

/* 卡片黑色背板 + 透视容器（透视作用于 4 个半区层）*/
.flip-card {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: var(--card-radius);
    perspective: calc(var(--card-h) * 1);
}

/* ---- 4 个半区层公共样式 ---- */
.flip-card-front,
.flip-card-back,
.flip-static-top,
.flip-static-bottom {
    position: absolute;
    left: 0;
    width: 100%;
    height: 50%;
    overflow: hidden;
    text-align: center;
    font-family: 'Helvetica Neue', Helvetica, Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    font-size: var(--digit-size);
    font-weight: 700;
    line-height: var(--card-h);
    color: var(--flip-digit);
    background: var(--flip-card-bg);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* 上半区：行框高 = 整卡高，顶部对齐 -> 露出数字上半 */
.flip-card-front,
.flip-static-top {
    top: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    border-radius: var(--card-radius) var(--card-radius) 0 0;
}

/* 下半区：行框高 = 整卡高，底部对齐 -> 露出数字下半 */
.flip-card-back,
.flip-static-bottom {
    bottom: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    border-radius: 0 0 var(--card-radius) var(--card-radius);
}

/* 层叠顺序：新上半 < 旧下半 < 下扇叶 < 上扇叶 */
.flip-static-top { z-index: 1; }
.flip-static-bottom { z-index: 2; }
.flip-card-back { z-index: 3; }
.flip-card-front { z-index: 4; }

/* 中线分割线（跟随上半区，参考站 .up::after）*/
.flip-card-front::after,
.flip-static-top::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: var(--line-w);
    background: rgba(0, 0, 0, 0.4);
    z-index: 5;
    pointer-events: none;
}

/* ---- 翻页阴影（参考站 flap shadow：翻走变暗、落定变亮）---- */
.flip-card-front::before,
.flip-static-top::before,
.flip-static-bottom::before,
.flip-card-back::before {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    z-index: 4;
    pointer-events: none;
}
.flip-card-front::before { background: linear-gradient(to bottom, rgba(0, 0, 0, 0.1), #000); }
.flip-static-top::before { background: linear-gradient(to bottom, rgba(0, 0, 0, 0.1), #000); }
.flip-static-bottom::before { background: linear-gradient(to bottom, #000, rgba(0, 0, 0, 0.1)); }
.flip-card-back::before { background: linear-gradient(to bottom, #000, rgba(0, 0, 0, 0.1)); }

/* ---- 两段式翻页动画（总时长 600ms）---- */
/* 上扇叶：旧数字上半向前翻开 */
.flip-card-front {
    transform-origin: 50% 100%;
    transform: rotateX(0deg);
}
.flip-card.flipping .flip-card-front {
    animation: flip-top-fall 0.3s linear both;
}
.flip-card.flipping .flip-card-front::before {
    animation: flip-shadow-show 0.3s linear both;
}

/* 下扇叶：新数字下半延迟 0.3s 落下 */
.flip-card-back {
    transform-origin: 50% 0%;
    transform: rotateX(90deg);
    opacity: 0;
}
.flip-card.flipping .flip-card-back {
    animation: flip-bottom-fall 0.3s 0.3s linear both;
}
.flip-card.flipping .flip-card-back::before {
    animation: flip-shadow-hide 0.3s 0.3s linear both;
}

/* 露出的新上半：由暗变亮 */
.flip-card.flipping .flip-static-top::before {
    animation: flip-shadow-hide 0.3s 0.1s linear both;
}
/* 被覆盖的旧下半：逐渐变暗 */
.flip-card.flipping .flip-static-bottom::before {
    animation: flip-shadow-show 0.3s linear both;
}

@keyframes flip-top-fall {
    from { transform: rotateX(0deg); }
    to { transform: rotateX(-90deg); }
}
@keyframes flip-bottom-fall {
    from { transform: rotateX(90deg); opacity: 1; }
    to { transform: rotateX(0deg); opacity: 1; }
}
@keyframes flip-shadow-show {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes flip-shadow-hide {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* 时间分隔符 — 参考站上下双圆点（无闪烁）*/
.separator {
    position: relative;
    width: calc(var(--card-h) * 0.1);
    height: var(--card-h);
    flex: none;
}
.separator::before,
.separator::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: calc(var(--card-h) * 0.05);
    height: calc(var(--card-h) * 0.05);
    border-radius: 50%;
    background: var(--flip-dot);
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}
.separator::before { top: 40%; }
.separator::after { bottom: 40%; }

/* Date below clock */
#date {
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
    margin-top: 1.25rem;
    font-size: clamp(1rem, 3vw, 1.5rem);
    font-weight: 400;
    text-align: center;
    font-family: 'Inter', sans-serif;
    letter-spacing: 1px;
}

/* Notifications */
#welcome-notification {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: none;
}

/* Upload Area */
.upload-area {
    transition: var(--transition-base);
}
.upload-area:hover {
    transform: translateY(-5px);
    border-color: var(--color-primary);
}

/* Screensaver Preview */
#screensaver-preview {
    transition: all 0.5s ease-in-out;
}

/* Loading Animation */
.loader {
    border: 4px solid #e2e8f0;
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Success Animation */
@keyframes successPop {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); box-shadow: 0 0 20px rgba(16, 185, 129, 0.4); }
}
.success-animation { animation: successPop 0.8s ease-in-out; }

/* Fade In */
.fade-in { animation: fadeIn 0.5s ease-in-out; }

/* Fullscreen Buttons */
#fullscreen-btn {
    transition: var(--transition-base);
    backdrop-filter: blur(8px);
}
#fullscreen-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
}

#exit-fullscreen-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}
#screensaver-preview:hover #exit-fullscreen-btn { opacity: 1; }

/* Mobile Menu */
.mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    width: min(70%, 300px);
    height: 100vh;
    background: white;
    z-index: 1000;
    transform: translateX(100%);
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    padding: 80px 20px 20px;
    transition: transform 0.3s ease;
}
.mobile-menu.active { transform: translateX(0); }

.mobile-menu a {
    display: block;
    padding: 12px 0;
    color: var(--color-dark);
    text-decoration: none;
    font-size: 16px;
    border-bottom: 1px solid #f0f0f0;
    transition: color 0.2s;
}
.mobile-menu a:hover { color: var(--color-primary); }

.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.menu-overlay.active { display: block; opacity: 1; }

.close-menu {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-dark);
}

/* Video Modal */
#video-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#video-modal.active { display: flex; }

.video-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    aspect-ratio: 16/9;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

#close-video {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.2s;
    z-index: 10;
}
#close-video:hover {
    transform: scale(1.1);
    color: #ef4444;
}

.youtube-embed {
    width: 100%;
    height: 100%;
    border: none;
}

/* Demo Button */
#watch-demo,
#desktop-watch-demo,
#mobile-watch-demo,
#footer-watch-demo {
    transition: var(--transition-base);
}
#watch-demo:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(234, 179, 8, 0.3);
}

/* Hero Buttons */
.hero-buttons {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.5rem 0;
    scrollbar-width: none;
}
.hero-buttons::-webkit-scrollbar { display: none; }

.hero-button {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    border-radius: 9999px;
    transition: var(--transition-base);
}

@media (max-width: 360px) {
    .hero-button {
        padding: 0.65rem 1rem;
        font-size: 0.8rem;
    }
}

/* Popular Images */
.popular-image-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.3s ease;
}
.popular-image-wrapper:hover { transform: translateY(-2px); }

.popular-image {
    flex: 1;
    position: relative;
    overflow: hidden;
}
.popular-image img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.popular-image-wrapper:hover img { transform: scale(1.05); }

.popular-image-title {
    padding: 0.75rem 0.5rem;
    background: white;
    color: var(--color-dark);
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    transition: background-color 0.3s;
}
.popular-image-wrapper:hover .popular-image-title { background: #f8fafc; }

/* Upload Section - 紧凑化 */
#upload {
    padding: 1rem;
    margin-bottom: 1.25rem;
}
#upload h2 { font-size: 1.375rem; margin-bottom: 0.75rem; }

#upload-notification {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.upload-area {
    padding: 1rem;
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-lg);
}
.upload-area i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--color-primary);
}
.upload-area h3 { font-size: 1rem; margin-bottom: 0.25rem; }
.upload-area p { font-size: 0.75rem; color: #64748b; }

#image-url {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #cbd5e1;
    border-radius: 0 0.375rem 0.375rem 0;
    width: 100%;
}
#image-url:focus {
    outline: none;
    border-color: var(--color-primary);
    ring: 2px solid rgba(59, 130, 246, 0.2);
}

#url-submit {
    padding: 0.5rem 0.875rem;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 0 0.375rem 0.375rem 0;
    cursor: pointer;
    transition: background 0.2s;
}
#url-submit:hover { background: rgba(59, 130, 246, 0.9); }

#preview-btn, #clear-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: var(--transition-base);
}
#preview-btn {
    background: var(--color-secondary);
    color: white;
    border: none;
}
#preview-btn:hover { background: rgba(16, 185, 129, 0.9); }
#clear-btn {
    background: #e2e8f0;
    color: #475569;
    border: none;
}
#clear-btn:hover { background: #cbd5e1; }

/* Hero Section 紧凑化 */
.hero-section { margin-bottom: 1rem; }

/* Popular Images Grid */
#popular-images-container {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 0.75rem;
}
@media (min-width: 640px) { #popular-images-container { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 768px) { #popular-images-container { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { #popular-images-container { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1280px) { #popular-images-container { grid-template-columns: repeat(5, 1fr); } }

/* 拖拽提示 - 修复 font-weight: 999 */
#drag-instruction {
    font-weight: 600;
    text-align: center;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #dc2626; /* 使用标准红色 */
}

/* 语言切换列表 */
#languages ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1rem;
}
#languages li { display: inline-block; }
#languages a {
    color: var(--color-primary);
    text-decoration: none;
    transition: opacity 0.2s;
}
#languages a:hover { opacity: 0.8; text-decoration: underline; }

/* 返回上传按钮 */
#back-to-upload-btn {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--color-primary);
    color: white;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 50;
}
#back-to-upload-btn.visible {
    opacity: 1;
    pointer-events: auto;
}
#back-to-upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
}
#back-to-upload-btn i { font-size: 1.25rem; }

@media (max-width: 640px) {
    #back-to-upload-btn {
        bottom: 1rem;
        right: 1rem;
        width: 2.75rem;
        height: 2.75rem;
    }
    #back-to-upload-btn i { font-size: 1.1rem; }
}

/* 主题切换 */
#theme-toggle, #mobile-theme-toggle {
    transition: var(--transition-base);
}
.dark body {
    background: linear-gradient(145deg, #0f172a, #1e293b);
    color: #f8fafc;
}
.dark .bg-white { background: #1e293b; }
.dark .text-dark { color: #f8fafc; }
.dark .text-slate-600 { color: #94a3b8; }

/* 辅助类 */
.hidden { display: none !important; }
/* tools 模块：PC 端(≥768px)显示，移动端隐藏
   元素上带有 hidden md:block，但 .hidden 的 !important 会压过 Tailwind 的 md:block，
   这里用 ID 选择器 + !important 提高优先级，仅在 PC 端恢复显示 */
@media (min-width: 768px) {
    #tools { display: block !important; }
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 打印样式 */
@media print {
    #ios-fullscreen-hint, #welcome-notification, nav, .hero-buttons,
    #upload, #popular, #advantages, #languages, footer,
    #fullscreen-btn, #exit-fullscreen-btn, #back-to-upload-btn {
        display: none !important;
    }
    #screensaver-container {
        aspect-ratio: auto;
        height: 100vh;
    }
}