:root {
    --primary-color: #007AFF;
    --primary-hover: #0056CC;
    --bg-color: #FFFFFF;
    --secondary-bg: #F2F2F7;
    --text-color: #000000;
    --text-secondary: #8E8E93;
    --border-color: #E5E5EA;
    --success-color: #34C759;
    --danger-color: #FF3B30;
    --border-radius: 12px;
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --header-height: 60px;
    --footer-height: 80px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--secondary-bg);
    color: var(--text-color);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    height: 100vh;
    height: 100dvh;
    max-width: 600px;
    margin: 0 auto;
    background: linear-gradient(180deg, #fafafa 0%, #f5f5f7 50%, #ffffff 100%);
    position: relative;
    overflow: hidden;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-color);
    border-radius: var(--border-radius);
    padding: 24px;
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

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

.modal-content h2 {
    margin: 0 0 8px 0;
    font-size: 20px;
    text-align: center;
}

.modal-hint {
    color: var(--text-secondary);
    font-size: 14px;
    text-align: center;
    margin-bottom: 20px;
}

/* Crop Modal Specific */
.crop-modal-content {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    z-index: 1001;
}

.crop-modal-content > .footer-action {
    background: #2a2a2a;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
    position: relative;
}

.crop-modal-content .btn.primary {
    background: #007AFF;
    color: white;
    font-size: 18px;
    padding: 18px;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
}

/* Crop Page Styles */
#page-crop {
    background: #1a1a1a;
}

#page-crop .crop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    border-bottom: 1px solid #333;
    background: #2a2a2a;
    flex-shrink: 0;
    height: var(--header-height);
}

#page-crop .crop-header h1 {
    flex: 1;
    font-size: 17px;
    color: white;
    text-align: center;
    margin: 0;
}

#page-crop .crop-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

#page-crop .cropper-container {
    flex: 1;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

#page-crop .cropper-container img {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

/* 裁剪页面Loading遮罩 */
.crop-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #000000;
    z-index: 10;
    color: white;
    font-size: 14px;
    gap: 12px;
}

.crop-loading-overlay.hidden {
    display: none !important;
}

/* 裁剪图片隐藏状态（遮罩显示时使用） */
.crop-image-hidden {
    visibility: hidden !important;
}

.crop-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

#page-crop .crop-info-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    font-size: 14px;
    font-weight: 500;
    flex-shrink: 0;
}

#page-crop #current-spec-label {
    color: #007AFF;
    font-weight: 600;
}

#page-crop .footer-action {
    background: #2a2a2a;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
}

#page-crop .btn.primary {
    background: #007AFF;
    color: white;
}

/* Icon Button in Crop Page */
#page-crop .icon-btn {
    border: none;
    background: none;
    padding: 8px;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border-radius: 8px;
}

#page-crop .icon-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

/* Header */
.header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 100;
    flex-shrink: 0;
    position: relative;
}

.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(0, 122, 255, 0.1), transparent);
}

.header h1 {
    flex: 1;
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: linear-gradient(135deg, #1a1a1a 0%, #4a4a4a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 自定义语言选择器 */
.lang-selector {
    position: relative;
}

.lang-current {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: var(--secondary-bg);
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
}

.lang-current:active {
    background: var(--border-color);
}

.lang-current.active {
    background: var(--primary-color);
    color: white;
}

.lang-current.active svg {
    transform: rotate(180deg);
}

.lang-current svg {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 140px;
    overflow: hidden;
    z-index: 200;
    animation: dropdownSlideIn 0.2s ease;
}

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

.lang-dropdown.hidden {
    display: none;
}

.lang-option {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 14px;
    text-align: left;
}

.lang-option:hover {
    background: var(--secondary-bg);
}

.lang-option.selected {
    background: rgba(0, 122, 255, 0.1);
    color: var(--primary-color);
    font-weight: 600;
}

.lang-option:first-child {
    border-radius: 12px 12px 0 0;
}

.lang-option:last-child {
    border-radius: 0 0 12px 12px;
}

.back-btn {
    border: none;
    background: none;
    padding: 8px;
    cursor: pointer;
    color: var(--primary-color);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-btn:active {
    opacity: 0.6;
}

.hidden {
    display: none !important;
}

/* 分类标签栏 */
.tab-bar {
    flex-shrink: 0;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
}

/* Content Area */
#content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.page {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: flex;
}

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

/* Home Page Tabs */
.tabs {
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
    padding: 10px 18px;
    margin-right: 8px;
    border-radius: 20px;
    background: var(--secondary-bg);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    flex-shrink: 0;
}

.tab:active {
    opacity: 0.7;
}

.tab.active {
    background: var(--primary-color);
    color: white;
}

/* Style List - 可滚动区域 */
.page-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

/* 页面滚动容器 - 确保底部按钮始终可见 */
.page-scrollable {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    min-height: 0;
    height: 0;
    display: flex;
    flex-direction: column;
    padding-bottom: 16px;
}

/* 自定义滚动条样式 */
.page-scrollable::-webkit-scrollbar {
    width: 4px;
}

.page-scrollable::-webkit-scrollbar-track {
    background: transparent;
}

.page-scrollable::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

.page-scrollable::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 122, 255, 0.3);
}

.page-scrollable > * {
    flex-shrink: 0;
}

.page-scrollable > .item-list,
.page-scrollable > .spec-list,
.page-scrollable > .upload-container,
.page-scrollable > .ai-status,
.page-scrollable > .device-list,
.page-scrollable > .result-img-container {
    flex: 1;
    min-height: 0;
}

/* 首页样式列表特殊处理 */
#page-home .item-list {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 20px;
    padding-bottom: calc(var(--footer-height) + 20px);
    overflow-y: auto;
    align-content: flex-start;
}

/* 风格卡片样式 */
.style-item {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: calc(50% - 8px);
    position: relative;
}

.style-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 122, 255, 0.15);
}

.style-item:active {
    transform: scale(0.96);
    transition: transform 0.1s ease;
}

/* 正方形图片容器 */
.style-item .img-wrap {
    position: relative;
    width: 100%;
    padding-bottom: 100%;
    background: linear-gradient(135deg, #f5f5f7 0%, #e8e8ed 100%);
    overflow: hidden;
}

.style-item .img-wrap img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

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

/* 渐变遮罩效果 */
.style-item .img-wrap::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(to top, rgba(0,0,0,0.4), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.style-item:hover .img-wrap::after {
    opacity: 1;
}

/* 信息区域 */
.style-item .info {
    padding: 14px 16px 16px;
    position: relative;
}

.style-item .title {
    font-weight: 600;
    font-size: 15px;
    color: #1a1a1a;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.style-item .desc {
    font-size: 12px;
    color: #8E8E93;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Upload Page */
.upload-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    min-height: 0;
    overflow: hidden;
}

.upload-box {
    width: 220px;
    height: 220px;
    border: 2px dashed var(--border-color);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--secondary-bg);
}

.upload-box:active {
    background: #E5E5EA;
    border-color: var(--primary-color);
}

.upload-icon {
    font-size: 64px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1;
}

.upload-box p {
    color: var(--text-secondary);
    font-size: 15px;
    margin: 0;
    font-weight: 500;
}

#preview-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.preview-wrapper {
    position: relative;
    max-width: 100%;
}

#preview-container img {
    max-width: 100%;
    max-height: 55vh;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.preview-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border-radius: 12px;
    font-size: 11px;
    backdrop-filter: blur(4px);
}

/* Image Actions */
.image-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 24px 0;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    border-radius: 24px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.action-btn:active {
    background: var(--secondary-bg);
    transform: scale(0.95);
}

.action-btn svg {
    flex-shrink: 0;
}

/* Spec List */
.spec-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.spec-item {
    display: flex;
    align-items: center;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.spec-item:active {
    background: var(--secondary-bg);
}

.spec-item.active {
    border-color: var(--primary-color);
    background: rgba(0, 122, 255, 0.08);
}

.spec-radio {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.spec-item.active .spec-radio {
    border-color: var(--primary-color);
    background: var(--primary-color);
}

.spec-item.active .spec-radio::after {
    content: '';
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
}

.spec-info {
    flex: 1;
}

.spec-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
}

.spec-dimension {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Page Hint Text */
.page-hint {
    color: var(--text-secondary);
    font-size: 14px;
    text-align: center;
    margin: 0 0 20px 0;
}

/* 规格选择页面布局 */
#page-spec h2 {
    margin: 0 0 8px 0;
    font-size: 20px;
    text-align: center;
    flex-shrink: 0;
}

#page-spec .page-hint {
    margin: 0 0 20px 0;
    flex-shrink: 0;
}

#page-spec .spec-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    margin-bottom: 16px;
}

/* 上传页面布局 */
#page-upload .upload-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    min-height: 0;
    overflow: hidden;
}

#page-upload .image-actions {
    flex-shrink: 0;
    margin: 20px 0;
}

/* AI页面布局 */
#page-ai .ai-status {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    min-height: 0;
}

.ai-processing-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

/* 大号旋转加载动画 */
.spinner-large {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid rgba(0, 122, 255, 0.1);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spinLarge 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.spinner-dot {
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: dotPulse 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

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

@keyframes dotPulse {
    0%, 100% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; }
}

/* 计时器样式 */
.ai-timer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.timer-label {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 500;
}

.timer-value {
    font-size: 48px;
    font-weight: 700;
    color: var(--primary-color);
    font-variant-numeric: tabular-nums;
    letter-spacing: 2px;
    text-shadow: 0 2px 12px rgba(0, 122, 255, 0.3);
}

#page-ai #ai-result {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#page-ai .result-img-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-height: 0;
    overflow: hidden;
}

/* 设备页面布局 */
.device-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    margin-bottom: 16px;
}

.device-page-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
}

/* 简化页面标题样式 */
.page-header-simple {
    padding: 20px 16px 16px;
    text-align: center;
}

.page-header-simple h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-color);
}

.refresh-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: var(--secondary-bg);
    border-radius: 12px;
    cursor: pointer;
    color: var(--primary-color);
    transition: all 0.2s ease;
}

.refresh-btn:active {
    transform: rotate(180deg);
    background: var(--border-color);
}

.refresh-btn.loading svg {
    animation: spin 1s linear infinite;
}

#page-device .device-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 16px;
}

/* 完成页面布局 */
#page-finish .finish-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    min-height: 0;
}

/* Footer Action */
.footer-action {
    padding: 16px 16px calc(16px + var(--safe-area-inset-bottom));
    background: var(--bg-color);
    flex-shrink: 0;
    z-index: 10;
}

.btn {
    width: 100%;
    padding: 16px;
    border-radius: var(--border-radius);
    border: none;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-appearance: none;
}

.btn.primary {
    background: var(--primary-color);
    color: white;
}

.btn.primary:active {
    background: var(--primary-hover);
    transform: scale(0.98);
}

.btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* AI Page */
.ai-status {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(0, 122, 255, 0.15);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 24px;
}

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

.progress-bar {
    width: 80%;
    max-width: 300px;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 20px;
}

/* 上传进度容器 */
.upload-progress-container {
    width: 100%;
    max-width: 320px;
    margin: 20px auto;
    padding: 0 16px;
}

.upload-progress-container.hidden {
    display: none !important;
}

.upload-progress-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 122, 255, 0.1);
}

.upload-progress-icon {
    margin-bottom: 16px;
}

.upload-spinner {
    color: var(--primary-color);
    animation: spin 1s linear infinite;
}

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

.upload-progress-text {
    color: var(--text-color);
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 20px 0;
}

.progress-bar-wrapper {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar {
    flex: 1;
    height: 10px;
    background: var(--secondary-bg);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

#ai-progress-inner, #upload-progress-inner, .progress-inner {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, #34C759 100%);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

#ai-progress-inner::after, #upload-progress-inner::after, .progress-inner::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-percent {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
    min-width: 40px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.upload-progress-size {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.upload-progress-size span {
    font-weight: 600;
    color: var(--text-color);
}

.result-img-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
}

#ai-result-img {
    max-width: 100%;
    max-height: 60vh;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

/* AI重新生成按钮 */
.ai-regenerate-action {
    display: flex;
    justify-content: center;
    padding: 0 20px 20px;
    flex-shrink: 0;
}

.ai-regenerate-action .action-btn {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
}

.ai-regenerate-action .action-btn:active {
    background: var(--secondary-bg);
}

/* Device Page */
.device-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 16px;
    min-height: 0;
}

.device-item {
    display: flex;
    align-items: center;
    padding: 20px;
    margin: 0 16px 12px;
    border-radius: 16px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border: 2px solid transparent;
}

.device-item:active {
    transform: scale(0.98);
    background: var(--secondary-bg);
}

.device-item.selected {
    border-color: var(--primary-color);
    background: rgba(0, 122, 255, 0.05);
}

.device-item.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.device-item input[type="radio"] {
    width: 24px;
    height: 24px;
    margin-right: 16px;
    accent-color: var(--primary-color);
    flex-shrink: 0;
}

.device-info {
    flex: 1;
    min-width: 0;
}

.device-name {
    font-weight: 600;
    font-size: 17px;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    margin-top: 4px;
}

.device-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.device-status.online {
    color: var(--success-color);
}

.device-status.offline {
    color: var(--text-secondary);
}

/* Finish Page */
.finish-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    text-align: center;
}

.success-icon {
    width: 80px;
    height: 80px;
    background: var(--success-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    box-shadow: 0 4px 16px rgba(52, 199, 89, 0.3);
}

.finish-content h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

.finish-content p {
    color: var(--text-secondary);
    font-size: 15px;
}

/* Mobile Responsive */
@media (max-width: 380px) {
    .item-list {
        grid-template-columns: 1fr;
    }

    .action-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .tab {
        padding: 8px 14px;
        font-size: 13px;
    }
}

/* Landscape Mode */
@media (orientation: landscape) and (max-height: 500px) {
    .header {
        height: 50px;
    }

    .upload-box {
        width: 140px;
        height: 140px;
    }

    .item-list {
        grid-template-columns: repeat(4, 1fr);
    }

    #preview-container img {
        max-height: 40vh;
    }
}

/* Safe Area for iPhone X+ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .header {
        padding-top: env(safe-area-inset-top);
    }

    .footer-action {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

/* Touch Feedback */
@media (hover: none) and (pointer: coarse) {
    .btn:active,
    .action-btn:active,
    .tab:active,
    .style-item:active,
    .spec-item:active,
    .device-item:active {
        transform: scale(0.97);
    }
}

/* Toast Message */
#toast-message {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    max-width: 80%;
    text-align: center;
    word-wrap: break-word;
}

#toast-message.show {
    opacity: 1;
    visibility: visible;
}

/* 自定义确认弹窗 */
.custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-modal.hidden {
    display: none;
}

.custom-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.custom-modal-content {
    position: relative;
    background: var(--bg-color);
    border-radius: 16px;
    width: 90%;
    max-width: 320px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

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

.custom-modal-body {
    padding: 24px 20px;
    text-align: center;
    font-size: 16px;
    color: var(--text-color);
    line-height: 1.5;
}

.custom-modal-actions {
    display: flex;
    border-top: 1px solid var(--border-color);
}

.custom-modal-actions .btn {
    flex: 1;
    padding: 16px;
    border: none;
    background: transparent;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.custom-modal-actions .btn:first-child {
    border-right: 1px solid var(--border-color);
}

.custom-modal-actions .btn:active {
    background: var(--secondary-bg);
}

.custom-modal-actions .btn.primary {
    background: transparent;
    color: var(--primary-color);
}

/* 上传失败错误提示 - 可点击关闭 */
.upload-error-container {
    width: 100%;
    max-width: 320px;
    margin: 16px auto;
    padding: 0 16px;
}

.upload-error-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid rgba(255, 59, 48, 0.3);
    border-radius: 12px;
    color: var(--danger-color);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    animation: errorShake 0.4s ease;
}

.upload-error-content:active {
    background: rgba(255, 59, 48, 0.2);
    transform: scale(0.98);
}

.upload-error-hint {
    text-align: center;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.8;
}

.upload-error-container.hidden {
    display: none !important;
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

@keyframes errorPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ========== 分类筛选栏样式 ========== */
.classify-bar-wrapper {
    flex-shrink: 0;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 0;
    overflow: hidden;
}

.classify-bar {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding: 0 16px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.classify-bar::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.classify-bar::-webkit-scrollbar-thumb {
    display: none;
    background: transparent;
}

.classify-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    margin-right: 10px;
    border-radius: 20px;
    background: var(--secondary-bg);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    flex-shrink: 0;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.classify-item:active {
    opacity: 0.7;
    transform: scale(0.95);
}

.classify-item.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.classify-item .classify-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 分类加载状态 */
.classify-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.classify-loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin-right: 8px;
    animation: spin 0.8s linear infinite;
}

/* 分类错误状态 */
.classify-error {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    color: var(--danger-color);
    font-size: 13px;
}

/* 分类为空状态 */
.classify-empty {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    color: var(--text-secondary);
    font-size: 14px;
}
