:root {
    --bg-color: #f5f5f7;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --accent-color: #0071e3;
    --accent-hover: #0077ed;
    --card-bg: #ffffff;
    --border-color: #d2d2d7;
    --nav-height: 44px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
    /* Offset for fixed header */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.47059;
    font-weight: 400;
    letter-spacing: -0.022em;
}

/* Navbar */
.global-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.16);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.nav-content {
    width: 100%;
    max-width: 980px;
    padding: 0 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Space out brand and links */
}

.brand {
    font-size: 19px;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    opacity: 0.9;
    transition: opacity 0.3s;
}

.brand:hover {
    opacity: 1;
}

.nav-links {
    display: flex;
    gap: 24px;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 400;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--text-primary);
}

/* Main Layout */
main {
    padding-top: 100px;
    padding-bottom: 60px;
    max-width: 980px;
    margin: 0 auto;
    padding-left: 22px;
    padding-right: 22px;
    text-align: center;
}

/* Hero Section */
.hero {
    margin-bottom: 80px;
    animation: fadeUp 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.headline {
    font-size: 56px;
    line-height: 1.07143;
    font-weight: 600;
    letter-spacing: -0.005em;
    margin-bottom: 16px;
    color: #1d1d1f;
}

.subhead {
    font-size: 24px;
    line-height: 1.2;
    font-weight: 400;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Upload Section */
.upload-container {
    background: var(--card-bg);
    border-radius: 18px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
    padding: 60px 20px;
    transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), box-shadow 0.3s;
    cursor: pointer;
    max-width: 600px;
    margin: 0 auto;
    border: 1px solid transparent;
}

.upload-container:hover {
    transform: scale(1.01);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.08);
}

.upload-container.dragover {
    border-color: var(--accent-color);
    background-color: #f5f9ff;
}

.icon-wrapper {
    width: 64px;
    height: 64px;
    margin: 0 auto 24px;
    color: var(--accent-color);
}

.icon-wrapper svg {
    width: 100%;
    height: 100%;
}

.upload-content h2 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 17px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* Buttons */
.btn-primary {
    background-color: var(--accent-color);
    color: #fff;
    font-size: 17px;
    font-weight: 400;
    padding: 12px 26px;
    border-radius: 980px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

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

.btn-link {
    background: none;
    border: none;
    color: var(--accent-color);
    font-size: 17px;
    cursor: pointer;
    margin-top: 20px;
    text-decoration: none;
}

.btn-link:hover {
    text-decoration: underline;
}

/* Loading */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

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

/* Results */
.result-section {
    display: none;
    margin-top: 40px;
    animation: fadeUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    justify-content: center;
}

.result-card {
    background: var(--card-bg);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.image-wrapper {
    background: #f5f5f7;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    position: relative;
}

.image-wrapper img {
    max-width: 100%;
    max-height: 500px;
    height: auto;
    display: block;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.analysis-content {
    padding: 40px;
    text-align: left;
    display: flex;
    flex-direction: column;
}

.analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

.analysis-header h3 {
    font-size: 24px;
    font-weight: 600;
}

.badge {
    background: #e8f2ff;
    color: var(--accent-color);
    font-size: 11px;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detection-list {
    list-style: none;
    margin-bottom: 20px;
    flex-grow: 1;
    max-height: 400px;
    overflow-y: auto;
}

.detection-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

.detection-list li:last-child {
    border-bottom: none;
}

.defect-info {
    display: flex;
    flex-direction: column;
}

.defect-name {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
}

.defect-id {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.defect-score {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.score-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.score-value {
    font-size: 17px;
    font-weight: 500;
    font-feature-settings: "tnum";
}

.score-value.high {
    color: #10b981;
}

.score-value.medium {
    color: #f59e0b;
}

.score-value.low {
    color: #ef4444;
}

.no-defect {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
    font-style: italic;
}

/* Blog Styles */
.blog-separator {
    height: 1px;
    background: var(--border-color);
    margin: 80px auto;
    max-width: 200px;
}

.blog-container {
    text-align: left;
    max-width: 800px;
    margin: 0 auto;
    animation: fadeUp 1s ease-out;
}

.team-info {
    text-align: center;
    margin-bottom: 60px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.team-info h3 {
    font-size: 14px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}

.team-info p {
    font-size: 17px;
    font-weight: 500;
}

.blog-section {
    margin-bottom: 80px;
    scroll-margin-top: 100px;
    /* For smooth scroll offset */
}

.blog-section h2 {
    font-size: 40px;
    font-weight: 700;
    margin-bottom: 30px;
    letter-spacing: -0.01em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.section-content h3 {
    font-size: 24px;
    font-weight: 600;
    margin-top: 40px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.section-content p {
    font-size: 17px;
    line-height: 1.6;
    color: #333;
    margin-bottom: 24px;
}

.feature-list,
.process-list,
.ref-list {
    margin-bottom: 24px;
    padding-left: 20px;
}

.feature-list li,
.process-list li,
.ref-list li {
    margin-bottom: 10px;
    font-size: 17px;
    line-height: 1.5;
}

.blog-image {
    margin: 40px 0;
    text-align: center;
}

.blog-image img {
    max-width: 100%;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

.caption {
    display: block;
    margin-top: 12px;
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
}

.code-block {
    background: #1e1e1e;
    color: #f8f8f2;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 24px 0;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
}

.grid-images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 40px 0;
}

.global-footer {
    border-top: 1px solid var(--border-color);
    padding: 40px 0;
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 80px;
}

/* Animations */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Responsive */
@media (min-width: 768px) {
    .result-card {
        flex-direction: row;
        align-items: stretch;
    }

    .image-wrapper {
        flex: 1.5;
        border-right: 1px solid var(--border-color);
    }

    .analysis-content {
        flex: 1;
        border-left: none;
    }

    .headline {
        font-size: 64px;
    }
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
        /* Hide nav links on mobile for simplicity */
    }

    .grid-images {
        grid-template-columns: 1fr;
    }

    .headline {
        font-size: 40px;
    }
}