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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.95;
}

main {
    max-width: 1200px;
    margin: 0 auto;
}

/* Upload Section */
.upload-section {
    background: white;
    border-radius: 16px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.upload-area {
    border: 3px dashed #667eea;
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.upload-area:hover {
    border-color: #764ba2;
    background: #f8f9ff;
}

.upload-area.drag-over {
    border-color: #764ba2;
    background: #f0f0ff;
    transform: scale(1.02);
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    color: #667eea;
}

.upload-content p {
    font-size: 1.1rem;
    color: #667eea;
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 0.9rem;
    color: #999;
}

.camera-section {
    text-align: center;
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.camera-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 50px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    user-select: none;
}

.camera-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.camera-btn:active {
    transform: translateY(0);
}

/* Realtime Section */
.realtime-section {
    background: white;
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.realtime-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.video-wrapper,
.canvas-wrapper {
    text-align: center;
}

.video-wrapper h4,
.canvas-wrapper h4 {
    margin-bottom: 10px;
    color: #667eea;
    font-size: 1.1rem;
}

#realtimeVideo {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    background: #000;
    object-fit: cover;
    display: block;
}

#realtimeCanvas {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    background: #000;
    display: block;
}

/* Display Section */
.display-section {
    background: white;
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.image-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.image-container canvas {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: block;
}

.controls h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.3rem;
}

.filter-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.filter-btn {
    background: white;
    border: 2px solid #e0e0e0;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    color: #555;
    user-select: none;
}

.filter-btn:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.filter-btn:active {
    transform: scale(0.98);
}

.filter-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

/* 严重度滑块 */
.severity-control {
    background: #f8f9ff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #e8e8f0;
}

.severity-control h4 {
    color: #667eea;
    margin-bottom: 12px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.severity-control h4 span {
    font-weight: 600;
    color: #764ba2;
}

.severity-control input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.severity-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
    transition: transform 0.2s;
}

.severity-control input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.severity-control input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
    transition: transform 0.2s;
}

.severity-control input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.1);
}

.severity-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.8rem;
    color: #999;
}

.info-panel {
    background: #f8f9ff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
}

.info-panel h4 {
    color: #667eea;
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.info-panel p {
    color: #666;
    line-height: 1.6;
}

.action-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.action-btn {
    background: white;
    border: 2px solid #667eea;
    color: #667eea;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    user-select: none;
}

.action-btn:hover {
    background: #667eea;
    color: white;
}

.action-btn:active {
    transform: scale(0.98);
}

/* Info Section */
.info-section {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.info-section h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

.info-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.info-card {
    background: linear-gradient(135deg, #f8f9ff 0%, #fff 100%);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid #e8e8f0;
}

.info-card h3 {
    color: #667eea;
    margin-bottom: 12px;
    font-size: 1.2rem;
}

.info-card p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 12px;
}

.prevalence {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
}

footer {
    text-align: center;
    color: white;
    margin-top: 40px;
    opacity: 0.9;
    padding-bottom: 20px;
}

/* Responsive - 平板 */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    header {
        margin-bottom: 20px;
    }

    header h1 {
        font-size: 2.2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .upload-section {
        padding: 25px;
        margin-bottom: 20px;
    }

    .upload-area {
        padding: 40px 20px;
        margin-bottom: 15px;
    }

    .upload-icon {
        width: 52px;
        height: 52px;
    }

    .upload-content p {
        font-size: 1rem;
    }

    .upload-hint {
        font-size: 0.85rem;
    }

    .camera-section {
        gap: 12px;
    }

    .camera-btn {
        padding: 14px 30px;
        font-size: 1rem;
        min-width: 200px;
    }

    /* 实时预览 - 移动端垂直布局 */
    .realtime-section {
        padding: 20px;
        margin-bottom: 20px;
    }

    .realtime-container {
        grid-template-columns: 1fr;
        gap: 20px;
        margin-bottom: 20px;
    }

    .video-wrapper,
    .canvas-wrapper {
        width: 100%;
    }

    .video-wrapper h4,
    .canvas-wrapper h4 {
        font-size: 1rem;
        margin-bottom: 8px;
    }

    #realtimeVideo,
    #realtimeCanvas {
        max-width: 100%;
        height: auto !important;
    }

    .display-section {
        padding: 20px;
        margin-bottom: 20px;
    }

    .image-container {
        grid-template-columns: 1fr;
        gap: 15px;
        margin-bottom: 20px;
    }

    .controls h3 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }

    .filter-buttons {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 15px;
    }

    .filter-btn {
        font-size: 0.9rem;
        padding: 12px 10px;
        min-height: 44px; /* iOS 触摸最小尺寸 */
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .info-panel {
        padding: 16px;
        margin-bottom: 15px;
    }

    .info-panel h4 {
        font-size: 1rem;
        margin-bottom: 6px;
    }

    .info-panel p {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    .action-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .action-btn {
        width: 100%;
        padding: 14px 20px;
        font-size: 1rem;
        min-height: 48px;
    }

    .info-section {
        padding: 25px;
    }

    .info-section h2 {
        font-size: 1.3rem;
        margin-bottom: 20px;
    }

    .info-cards {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .info-card {
        padding: 20px;
    }

    .info-card h3 {
        font-size: 1.1rem;
        margin-bottom: 10px;
    }

    .info-card p {
        font-size: 0.9rem;
    }

    footer {
        margin-top: 30px;
        font-size: 0.9rem;
    }
}

/* 小屏幕手机 */
@media (max-width: 480px) {
    body {
        padding: 8px;
    }

    header {
        margin-bottom: 15px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .upload-section {
        padding: 20px;
        border-radius: 12px;
    }

    .upload-area {
        padding: 30px 15px;
        border-width: 2px;
    }

    .upload-icon {
        width: 44px;
        height: 44px;
    }

    .upload-content p {
        font-size: 0.95rem;
    }

    .upload-hint {
        font-size: 0.8rem;
    }

    .camera-section {
        flex-direction: column;
        gap: 10px;
    }

    .camera-btn {
        width: 100%;
        padding: 12px 20px;
        font-size: 0.95rem;
        min-height: 48px;
    }

    .realtime-section,
    .display-section {
        padding: 15px;
        border-radius: 12px;
    }

    .realtime-container {
        gap: 15px;
    }

    .video-wrapper h4,
    .canvas-wrapper h4 {
        font-size: 0.95rem;
    }

    .filter-buttons {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .filter-btn {
        font-size: 0.9rem;
        padding: 12px;
    }

    .info-panel {
        padding: 12px;
    }

    .info-panel h4 {
        font-size: 0.95rem;
    }

    .info-panel p {
        font-size: 0.85rem;
    }

    .action-btn {
        padding: 12px 16px;
        font-size: 0.95rem;
    }

    .info-section {
        padding: 20px;
    }

    .info-section h2 {
        font-size: 1.2rem;
    }

    .info-card {
        padding: 16px;
    }

    .info-card h3 {
        font-size: 1rem;
    }

    .info-card p {
        font-size: 0.85rem;
    }

    .prevalence {
        font-size: 0.8rem;
        padding: 3px 10px;
    }
}

/* 超小屏幕优化 */
@media (max-width: 360px) {
    header h1 {
        font-size: 1.5rem;
    }

    .upload-content p {
        font-size: 0.9rem;
    }

    .camera-btn,
    .action-btn,
    .filter-btn {
        font-size: 0.85rem;
    }
}
