* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Figma Color Palette */
    --primary-green: #34C759;
    --primary-green-hover: #2D9A46;
    --primary-green-click: #1E6B2E;
    --secondary-dark: #363636;
    --neutral-black: #000000;
    --neutral-grey-dark: #333333;
    --neutral-grey: #666666;
    --neutral-grey-light: #999999;
    --neutral-grey-blue: #B3B3B3;
    --neutral-white: #FFFFFF;
    --error-red: #DC3545;
    --success-green: #28A745;
    --warning-yellow: #FFC107;
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    min-height: 100vh;
    font-family: var(--font-family);
    background: var(--neutral-white);
    color: var(--neutral-black);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Screen Management */
.screen {
    display: none;
    width: 100%;
    min-height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
}

.screen.active {
    display: block;
}

/* Navigation */
.main-nav {
    padding: 24px 0;
    border-bottom: 1px solid #E5E5E5;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-green);
}

.brand-icon {
    width: 24px;
    height: 24px;
    display: inline-block;
    flex-shrink: 0;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-link {
    font-size: 16px;
    font-weight: 500;
    color: var(--neutral-grey-dark);
    text-decoration: none;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--primary-green);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.toggle-switch-minimal {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--neutral-grey-blue);
    border-radius: 12px;
    transition: background 0.3s ease;
}

.toggle-switch-minimal::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-toggle input {
    display: none;
}

.header-toggle input:checked + .toggle-switch-minimal {
    background: var(--primary-green);
}

.header-toggle input:checked + .toggle-switch-minimal::after {
    transform: translateX(20px);
}

.btn-header {
    padding: 10px 24px;
    font-size: 14px;
}

/* Homepage Wrapper */
.homepage-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 40px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* About Section */
.about-section {
    padding: 80px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.about-content {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

.about-title {
    font-size: 36px;
    font-weight: 600;
    line-height: 44px;
    color: var(--neutral-black);
    margin-bottom: 24px;
    letter-spacing: -0.5px;
}

.about-text {
    font-size: 18px;
    line-height: 28px;
    color: var(--neutral-grey);
    font-weight: 400;
}

/* Hero Section */
.hero-section {
    padding: 80px 0;
}

.hero-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: center;
}

.hero-content {
    max-width: 600px;
    text-align: left;
}

.hero-title {
    font-size: 64px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--primary-green);
    margin-bottom: 24px;
    letter-spacing: -1.5px;
}

.hero-description {
    font-size: 18px;
    line-height: 28px;
    color: var(--neutral-grey);
    margin-bottom: 40px;
    font-weight: 400;
}

.hero-image {
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-illustration {
    width: 100%;
    max-width: 500px;
    height: auto;
    object-fit: contain;
}

/* Buttons - Figma Style */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 14px 32px;
    font-size: 16px;
    font-weight: 500;
    color: var(--neutral-white);
    background: var(--primary-green);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-green-hover);
}

.btn-primary:active:not(:disabled) {
    background: var(--primary-green-click);
}

.btn-primary:focus {
    outline: 2px solid var(--primary-green);
    outline-offset: 2px;
}

.btn-primary:disabled {
    background: var(--neutral-grey-blue);
    color: var(--neutral-grey-light);
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 14px 32px;
    font-size: 16px;
    font-weight: 500;
    color: var(--primary-green);
    background: var(--neutral-white);
    border: 1px solid var(--primary-green);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
}

.btn-secondary:hover {
    background: #F0F9F2;
}

.btn-secondary:active {
    background: #E0F3E5;
}

.btn-secondary:focus {
    outline: 2px solid var(--primary-green);
    outline-offset: 2px;
}

/* Features Section */
.features-section {
    padding: 80px 0;
}

.section-header {
    margin-bottom: 48px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.section-title {
    font-size: 36px;
    font-weight: 600;
    line-height: 44px;
    color: var(--neutral-black);
    margin-bottom: 16px;
    letter-spacing: -0.5px;
}

.section-subtitle {
    font-size: 18px;
    line-height: 28px;
    color: var(--neutral-grey);
    font-weight: 400;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 32px;
}

.feature-card {
    padding: 32px;
    background: var(--neutral-white);
    border: 1px solid #E5E5E5;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.feature-card:hover {
    box-shadow: 0 4px 12px rgba(52, 199, 89, 0.1);
    transform: translateY(-2px);
}

.feature-icon-wrapper {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
}

.feature-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.feature-title {
    font-size: 24px;
    font-weight: 600;
    line-height: 32px;
    color: var(--neutral-black);
    margin-bottom: 12px;
}

.feature-text {
    font-size: 16px;
    line-height: 24px;
    color: var(--neutral-grey);
    font-weight: 400;
}

/* Control Section */
.control-section {
    padding: 80px 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.control-card {
    max-width: 600px;
    width: 100%;
    padding: 48px;
    background: var(--neutral-white);
    border: 1px solid #E5E5E5;
    border-radius: 8px;
    text-align: center;
}

.control-header {
    margin-bottom: 32px;
}

.control-title {
    font-size: 32px;
    font-weight: 600;
    line-height: 40px;
    color: var(--neutral-black);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.control-subtitle {
    font-size: 16px;
    line-height: 24px;
    color: var(--neutral-grey);
    font-weight: 400;
}

.toggle-wrapper {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid #E5E5E5;
}

.custom-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 0;
}

.toggle-label-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--neutral-black);
    flex: 1;
}

.toggle-switch-custom {
    position: relative;
    width: 52px;
    height: 28px;
    background: var(--neutral-grey-blue);
    border-radius: 14px;
    transition: background 0.3s ease;
}

.toggle-switch-custom::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--neutral-white);
    top: 2px;
    left: 2px;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.custom-toggle input {
    display: none;
}

.custom-toggle input:checked + .toggle-label-text + .toggle-switch-custom {
    background: var(--primary-green);
}

.custom-toggle input:checked + .toggle-label-text + .toggle-switch-custom::after {
    transform: translateX(24px);
}

/* Footer */
.main-footer {
    padding: 60px 0 40px;
    text-align: center;
    border-top: 1px solid #E5E5E5;
    margin-top: auto;
}

.main-footer p {
    font-size: 14px;
    line-height: 20px;
    color: var(--neutral-grey-light);
    font-weight: 400;
}

/* Permission Screen */
.permission-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.permission-content {
    max-width: 500px;
    width: 100%;
    text-align: center;
}

.permission-icon-wrapper {
    width: 100%;
    max-width: 300px;
    margin: 0 auto 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.permission-illustration {
    width: 100%;
    height: auto;
    max-width: 300px;
    object-fit: contain;
}

.permission-title {
    font-size: 32px;
    font-weight: 600;
    line-height: 40px;
    color: var(--neutral-black);
    margin-bottom: 16px;
    letter-spacing: -0.5px;
}

.permission-text {
    font-size: 16px;
    line-height: 24px;
    color: var(--neutral-grey);
    margin-bottom: 8px;
    font-weight: 400;
}

.permission-note {
    font-size: 14px;
    line-height: 20px;
    color: var(--neutral-grey-light);
    font-style: italic;
    margin-bottom: 40px;
}

/* Detection Screen */
#detection-screen {
    background-color: #000000;
    position: relative;
}

#webcam {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    pointer-events: none;
    user-select: none;
}

#canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 5;
    pointer-events: none;
    transform: scaleX(-1);
}

#status-panel {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    padding: 16px 32px;
    border-radius: 4px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    z-index: 10;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.control-panel {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    align-items: center;
    z-index: 10;
    background: rgba(0, 0, 0, 0.8);
    padding: 16px 24px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sound-toggle-wrapper {
    display: flex;
    align-items: center;
}

.custom-toggle-inline {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.toggle-label-text-inline {
    font-size: 14px;
    font-weight: 500;
    color: white;
}

.custom-toggle-inline .toggle-switch-custom {
    width: 44px;
    height: 24px;
}

.custom-toggle-inline .toggle-switch-custom::after {
    width: 20px;
    height: 20px;
    top: 2px;
    left: 2px;
}

.custom-toggle-inline input:checked + .toggle-label-text-inline + .toggle-switch-custom::after {
    transform: translateX(20px);
}

.status-safe {
    border-color: rgba(52, 199, 89, 0.3);
    color: var(--primary-green);
}

.status-danger {
    background-color: rgba(220, 53, 69, 0.9);
    color: white;
    animation: pulse 1s infinite;
    border-color: rgba(220, 53, 69, 0.5);
}

@keyframes pulse {
    0%, 100% { 
        transform: translateX(-50%) scale(1);
        opacity: 1;
    }
    50% { 
        transform: translateX(-50%) scale(1.02);
        opacity: 0.9;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .homepage-wrapper {
        padding: 0 24px;
    }

    .nav-container {
        padding: 0 24px;
        flex-direction: column;
        gap: 16px;
    }

    .nav-right {
        flex-direction: column;
        gap: 16px;
        width: 100%;
    }

    .header-controls {
        width: 100%;
        justify-content: space-between;
    }

    .hero-section {
        padding: 40px 0 60px;
    }

    .hero-container {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .hero-image {
        order: -1;
    }

    .hero-illustration {
        max-width: 300px;
    }

    .hero-title {
        font-size: 40px;
    }

    .hero-description {
        font-size: 16px;
        line-height: 24px;
    }

    .features-section {
        padding: 60px 0;
    }

    .section-title {
        font-size: 28px;
        line-height: 36px;
    }

    .features-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .control-card {
        padding: 32px 24px;
    }

    .control-title {
        font-size: 24px;
        line-height: 32px;
    }

    .control-panel {
        flex-direction: column;
        width: calc(100% - 48px);
        bottom: 24px;
    }

    .permission-wrapper {
        padding: 24px;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 32px;
    }

    .control-card {
        padding: 24px 20px;
    }
}

/* Picture-in-Picture Button */
.btn-pip {
    background: var(--primary-green);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-pip:hover {
    background: #2db84e;
    transform: scale(1.02);
}

.btn-pip.active {
    background: #ff9500;
}

.btn-pip.active span::before {
    content: '✓ ';
}

.pip-info {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(52, 199, 89, 0.9);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    max-width: 400px;
    text-align: center;
    z-index: 100;
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}
