@media (max-width: 768px) {
    html, body {
        width: 100%;
        max-width: 100%;
        overflow-x: clip;
    }

    main, section, .container, .nav-container, .footer-container,
    .hero-container, .hero-columns, .tool-shell, .live-tool-shell,
    .cheek-upload-stage, .tool-panel, .cheek-tool-panel,
    .results-wrap, .live-results-wrap, .content-wrap, .guide-wrap {
        min-width: 0;
        max-width: 100%;
    }

    .container {
        width: 100%;
        padding-inline: max(16px, env(safe-area-inset-left));
    }

    #navbar {
        padding-top: max(10px, env(safe-area-inset-top));
    }

    .nav-container {
        width: 100%;
        gap: 10px;
        padding-inline: 16px;
    }

    .nav-links {
        min-width: 0;
        gap: 8px;
    }

    .nav-link {
        padding: 9px 13px;
        font-size: .78rem;
    }

    .nav-cta {
        flex: 0 0 auto;
        min-height: 44px;
        padding: 11px 16px;
        white-space: nowrap;
    }

    h1, h2, h3, p, a, button, label, summary {
        overflow-wrap: anywhere;
    }

    #hero h1, .live-tool-hero h1, .tool-hero h1, .guide-hero h1 {
        max-width: 100%;
        font-size: 2.25rem;
        line-height: 1.12;
        letter-spacing: 0;
    }

    .hero-subtitle, .live-lead, .tool-lead, .guide-lead {
        width: 100%;
        max-width: 100%;
        font-size: 1rem;
        line-height: 1.65;
    }

    .hero-columns, .tool-shell, .live-tool-shell, .cheek-upload-stage {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 24px;
        width: 100%;
        max-width: 100% !important;
    }

    .hero-demo, .hero-upload, .visual-panel, .live-visual,
    .cheek-demo, .cheek-tool-panel, .tool-panel {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .demo-image-wrapper, .visual-panel, .cheek-demo-image,
    .live-comparison, .comparison, .face-analysis-visual {
        max-width: 100%;
        border-radius: 16px;
    }

    .portrait-upload-template, .cheek-upload-box, .upload-card,
    .hero-upload .upload-box {
        width: 100%;
        min-width: 0;
        min-height: 230px;
        padding: 22px 18px;
        border-radius: 18px;
    }

    .portrait-upload-choose, .cheek-choose-btn, .upload-choose-btn,
    .live-primary, .live-secondary, .primary-action, .secondary-action,
    .btn-primary, .btn-secondary, .change-photo, .live-change {
        min-height: 44px;
        touch-action: manipulation;
    }

    input, select, textarea, button {
        font-size: 16px;
    }

    input[type="range"] {
        min-height: 44px;
        touch-action: pan-y;
    }

    .live-handle:after, .compare-handle:after {
        width: 48px;
        height: 48px;
    }

    .live-result-actions, .result-actions {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .live-results, .results-section, #results-section,
    .live-content, .content-section, .guide-section {
        padding-block: 48px;
    }

    .feature-grid, .steps, .live-grid, .guide-grid,
    .before-after-showcase, .face-shape-result {
        grid-template-columns: minmax(0, 1fr);
    }

    .feature-card, .step, .live-card, .guide-card,
    .analysis-result, .tip-box, .note-box, .related-box {
        min-width: 0;
        padding: 20px 18px;
    }

    .footer-top, .footer-bottom {
        align-items: flex-start;
        gap: 20px;
    }

    .footer-links {
        width: 100%;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .nav-link {
        display: none;
    }

    .logo {
        min-width: 0;
        gap: 7px;
    }

    .logo-text {
        font-size: .95rem;
    }

    #hero, .live-tool-hero, .tool-hero, .guide-hero {
        padding-top: calc(92px + env(safe-area-inset-top));
        padding-bottom: 42px;
    }

    #hero h1, .live-tool-hero h1, .tool-hero h1, .guide-hero h1 {
        font-size: 2rem;
    }

    .live-kicker, .tool-kicker, .guide-kicker, .hero-badge {
        max-width: 100%;
        white-space: normal;
        text-align: center;
    }

    .hero-stats {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat-divider {
        display: none;
    }

    .live-compare-label, .compare-label {
        top: 10px;
        padding: 6px 9px;
        font-size: .65rem;
    }

    .hair-colour-options {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .nav-link {
        display: none;
    }

    .nav-container {
        justify-content: space-between;
    }
}

@media (max-width: 360px) {
    .container, .nav-container {
        padding-inline: 12px;
    }

    #navbar .logo svg {
        display: none;
    }

    #hero h1, .live-tool-hero h1, .tool-hero h1, .guide-hero h1 {
        font-size: 1.75rem;
    }

    .nav-cta {
        padding-inline: 13px;
        font-size: .78rem;
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    #hero, .live-tool-hero, .tool-hero, .guide-hero {
        padding-top: 76px;
    }

    .hero-columns, .tool-shell, .live-tool-shell, .cheek-upload-stage {
        margin-top: 26px;
    }
}
