/*
 * GoTrace Mobile First — provenance passport UI
 * Keeps the original desktop application intact and gives real phone
 * viewports a focused, touch-friendly information hierarchy.
 */

:root {
    --font-title: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-data: "IBM Plex Mono", monospace;
    --mobile-canvas: #edf4f8;
    --mobile-ink: #102238;
    --mobile-blue: #0757d8;
    --mobile-green: #087a52;
    --mobile-hairline: rgba(35, 63, 91, 0.13);
    --mobile-shadow: 0 12px 32px rgba(20, 57, 91, 0.09);
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body,
button,
input,
textarea,
select {
    font-family: var(--font-body);
}

.font-mono,
.tech-spec-value.font-mono,
.ing-card-batch,
.hash-left,
.hash-right {
    font-family: var(--font-data) !important;
}

.ingredient-picker {
    display: none;
}

@media (max-width: 1024px) {
    html {
        background: var(--mobile-canvas);
        height: auto !important;
        min-height: 100%;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior-y: auto;
        touch-action: pan-y;
    }

    body.v7-liquid-glass {
        display: block;
        position: relative;
        width: 100%;
        height: auto !important;
        min-height: 100%;
        max-height: none !important;
        background:
            radial-gradient(circle at 12% 4%, rgba(53, 175, 220, 0.13), transparent 24rem),
            linear-gradient(180deg, #eaf5f9 0, #f5f8f7 34rem, #eef3f5 100%);
        color: var(--mobile-ink);
        padding: 0 0 calc(82px + env(safe-area-inset-bottom));
        overflow-x: hidden !important;
        overflow-y: visible !important;
        overscroll-behavior-y: auto;
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
    }

    body.v7-liquid-glass[data-theme="dark"] {
        background:
            radial-gradient(circle at 12% 4%, rgba(31, 120, 190, 0.2), transparent 24rem),
            #07101d;
    }

    /* Remove the desktop prototype frame: the phone itself is now the canvas. */
    body.v7-liquid-glass .simulator-wrapper {
        display: block;
        width: 100%;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        padding: 0 !important;
        overflow: visible !important;
        touch-action: pan-y;
    }

    body.v7-liquid-glass .simulator-container,
    body.v7-liquid-glass .simulator-container:not(.mobile-sim),
    body.v7-liquid-glass .simulator-container.mobile-sim {
        width: 100%;
        max-width: none;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        overflow: visible !important;
        background: transparent;
        touch-action: pan-y;
    }

    /* Compact masthead; identity first, secondary account action second. */
    body.v7-liquid-glass .app-header {
        position: sticky;
        top: 0;
        z-index: 80;
        min-height: 62px;
        padding: calc(9px + env(safe-area-inset-top)) 16px 9px;
        border: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.8);
        border-radius: 0;
        background: rgba(246, 251, 252, 0.88);
        box-shadow: 0 8px 28px rgba(24, 58, 84, 0.07);
        backdrop-filter: blur(20px) saturate(145%);
        -webkit-backdrop-filter: blur(20px) saturate(145%);
    }

    body.v7-liquid-glass[data-theme="dark"] .app-header {
        background: rgba(8, 18, 32, 0.9);
        border-bottom-color: rgba(255, 255, 255, 0.08);
    }

    .app-logo {
        gap: 7px;
        font-size: 20px;
        letter-spacing: -0.045em;
    }

    .app-logo svg {
        width: 25px;
        height: 25px;
        padding: 3px;
        border-radius: 9px;
        color: #fff;
        background: var(--mobile-blue);
        box-shadow: 0 5px 14px rgba(7, 87, 216, 0.26);
    }

    .app-nav {
        gap: 8px;
    }

    .app-header .btn-header:not(.btn-header-primary) {
        display: none;
    }

    .theme-toggle,
    .btn-header,
    .btn-header-primary {
        min-height: 42px;
    }

    .theme-toggle {
        width: 42px;
        padding: 0;
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.68);
    }

    .btn-header-primary {
        padding: 10px 14px;
        border: 0;
        border-radius: 14px;
        font-size: 12px;
        letter-spacing: -0.01em;
        box-shadow: 0 8px 18px rgba(7, 87, 216, 0.22);
    }

    /* Content rhythm */
    .app-body {
        width: 100%;
        height: auto !important;
        max-height: none !important;
        padding: 12px 12px 28px !important;
        overflow: visible !important;
        touch-action: pan-y;
    }

    .app-body > * {
        margin-bottom: 16px;
    }

    /* Hero becomes a single product passport card. */
    body.v7-liquid-glass .hero-section {
        display: flex;
        flex-direction: column;
        gap: 0;
        padding: 8px !important;
        border: 1px solid rgba(255, 255, 255, 0.82);
        border-radius: 24px !important;
        background: rgba(255, 255, 255, 0.84);
        box-shadow: var(--mobile-shadow);
        overflow: hidden;
        animation: mobile-passport-in 550ms cubic-bezier(.2, .8, .2, 1) both;
    }

    body.v7-liquid-glass[data-theme="dark"] .hero-section {
        background: rgba(15, 29, 48, 0.9);
        border-color: rgba(255, 255, 255, 0.08);
    }

    .hero-media {
        gap: 10px;
    }

    .main-image-container {
        aspect-ratio: 4 / 3;
        border: 0;
        border-radius: 19px;
        background: #dbe6ea;
    }

    .main-image {
        transform: scale(1.005);
    }

    .dynamic-island-badge {
        top: 12px;
        left: auto;
        right: 12px;
        transform: none;
        max-width: calc(100% - 24px);
        padding: 7px 11px !important;
        font-size: 10px !important;
        box-shadow: 0 8px 22px rgba(0, 0, 0, 0.25) !important;
    }

    .dynamic-island-badge:hover {
        transform: none;
    }

    .thumbnail-slider-wrapper {
        gap: 8px;
        padding: 2px 4px 0;
    }

    .thumbnail-row {
        flex: 1;
        justify-content: center;
        gap: 8px;
        padding: 3px 0 4px;
        scroll-snap-type: x mandatory;
    }

    .thumbnail-btn {
        flex-basis: 58px;
        border-radius: 13px;
        scroll-snap-align: center;
    }

    .thumbnail-btn.active {
        border-color: var(--mobile-blue);
        box-shadow: 0 0 0 2px rgba(7, 87, 216, 0.1);
    }

    .slider-arrow {
        width: 40px;
        height: 40px;
        border-radius: 14px;
        box-shadow: none;
    }

    .hero-info {
        padding: 18px 6px 6px;
    }

    .product-status-badge {
        display: none !important;
    }

    .hero-info .product-title {
        order: 1;
        max-width: 100%;
        margin: 0 0 13px !important;
        font-size: clamp(18px, 5.2vw, 21px) !important;
        line-height: 1.15;
        letter-spacing: -0.045em;
        text-wrap: balance;
    }

    .title-verified-check {
        width: 20px;
        height: 20px;
        margin-left: 2px;
    }

    /* Verification score and evidence metrics stay visible without a long scroll. */
    .metrics-card {
        order: 2;
        margin: 0 !important;
        padding: 14px !important;
        gap: 12px;
        border: 1px solid rgba(7, 87, 216, 0.14) !important;
        border-radius: 19px;
        background:
            linear-gradient(135deg, rgba(235, 244, 255, 0.96), rgba(247, 251, 255, 0.92)) !important;
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8) !important;
    }

    body[data-theme="dark"] .metrics-card {
        background: linear-gradient(135deg, rgba(13, 45, 78, 0.9), rgba(17, 30, 50, 0.92)) !important;
    }

    .metrics-card-main {
        display: grid;
        grid-template-columns: 88px minmax(0, 1fr) !important;
        gap: 14px;
        align-items: center;
    }

    .metrics-divider {
        display: none;
    }

    .trust-shield {
        width: 84px;
        height: 84px;
    }

    .trust-shield-num {
        font-size: 30px !important;
        line-height: 0.95;
        letter-spacing: -0.045em;
    }

    .trust-shield-label {
        font-size: 7px;
    }

    .metrics-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0;
        border: 1px solid rgba(7, 87, 216, 0.11);
        border-radius: 14px;
        overflow: hidden;
        background: rgba(255, 255, 255, 0.58);
    }

    body[data-theme="dark"] .metrics-stats-grid {
        background: rgba(255, 255, 255, 0.04);
    }

    .metric-stat-item {
        min-width: 0;
        padding: 9px 5px;
        border-right: 1px solid rgba(7, 87, 216, 0.1);
        border-bottom: 1px solid rgba(7, 87, 216, 0.1);
    }

    .metric-stat-item:nth-child(2n) {
        border-right: 0;
    }

    .metric-stat-item:nth-child(n+3) {
        border-bottom: 0;
    }

    .metric-num {
        font-size: 19px !important;
    }

    .metric-label {
        min-height: auto !important;
        margin-top: 1px;
        font-size: 9px !important;
        line-height: 1.25 !important;
    }

    .metric-subtext.success {
        margin-top: 4px;
        padding: 2px 5px;
        font-size: 7.5px !important;
        white-space: nowrap;
    }

    .metrics-card-footer {
        padding-top: 10px;
        align-items: flex-start;
        font-size: 9.5px;
        line-height: 1.45;
    }

    /* Technical facts are a compact 2 x 2 data plate. */
    .tech-specs-rail {
        order: 3;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0 !important;
        margin: 10px 0 0 !important;
        padding: 0 !important;
        border: 1px solid var(--mobile-hairline) !important;
        border-radius: 17px;
        box-shadow: none !important;
        overflow: hidden;
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .tech-spec-divider {
        display: none;
    }

    .tech-spec-col {
        min-width: 0;
        max-width: 100%;
        padding: 10px;
        border-right: 1px solid var(--mobile-hairline);
        border-bottom: 1px solid var(--mobile-hairline);
        overflow: hidden;
    }

    .tech-spec-col:nth-child(4n+3) {
        border-right: 0;
    }

    .tech-spec-col:nth-child(n+5) {
        border-bottom: 0;
    }

    .tech-spec-label {
        font-size: 9px !important;
        letter-spacing: 0.06em;
        line-height: 1.25;
        min-height: 20px;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .tech-spec-val-row {
        gap: 6px;
        min-width: 0;
        align-items: flex-start;
    }

    .spec-icon {
        width: 16px;
        height: 16px;
    }

    .tech-spec-value {
        min-width: 0;
        max-width: 100%;
        font-size: 13px !important;
        line-height: 1.3;
        white-space: nowrap !important;
        overflow-wrap: normal;
    }

    /* Trust promises stay fully visible; no horizontal slider on phones. */
    body.v7-liquid-glass .bottom-trust-banner {
        display: block;
        margin: 0 0 16px !important;
        padding: 16px !important;
        border-radius: 22px !important;
        background: rgba(255, 255, 255, 0.72) !important;
        box-shadow: 0 8px 24px rgba(20, 57, 91, 0.07) !important;
        overflow: visible;
    }

    .trust-banner-left {
        margin-bottom: 13px;
        gap: 10px;
        width: 100%;
        justify-content: center;
    }

    .banner-shield-icon {
        width: 36px;
        height: 36px;
    }

    .banner-big-title {
        font-size: 15px !important;
    }

    .banner-sub-title {
        font-size: 11px !important;
    }

    .banner-features-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin: 0;
        padding: 0;
        overflow: visible;
    }

    .banner-feature-item {
        min-width: 0;
        min-height: 58px;
        padding: 9px 0;
        border: none !important;
        border-radius: 0 !important;
        background: transparent !important;
    }

    body[data-theme="dark"] .banner-feature-item {
        background: transparent !important;
    }

    .feature-icon-wrapper svg {
        width: 21px;
        height: 21px;
    }

    .feature-title {
        font-size: 11px !important;
    }

    .feature-desc {
        font-size: 9.5px !important;
    }

    /* Reachable, app-like bottom navigation. */
    body.v7-liquid-glass .sticky-navbar {
        position: fixed;
        z-index: 95;
        top: auto !important;
        right: 10px !important;
        bottom: calc(8px + env(safe-area-inset-bottom)) !important;
        left: 10px !important;
        width: auto !important;
        max-width: none !important;
        height: 60px;
        margin: 0 !important;
        padding: 5px !important;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 3px;
        overflow: visible;
        transform: none !important;
        border: 1px solid rgba(255, 255, 255, 0.78);
        border-radius: 21px;
        background: rgba(248, 252, 252, 0.93);
        box-shadow: 0 14px 38px rgba(20, 45, 68, 0.2);
        backdrop-filter: blur(22px) saturate(145%);
        -webkit-backdrop-filter: blur(22px) saturate(145%);
    }

    body.v7-liquid-glass[data-theme="dark"] .sticky-navbar {
        background: rgba(12, 24, 41, 0.94);
        border-color: rgba(255, 255, 255, 0.08);
    }

    .sticky-navbar .navbar-slider {
        display: none !important;
    }

    body.v7-liquid-glass .sticky-navbar .navbar-item,
    body.v7-liquid-glass .sticky-navbar.collapsed .navbar-item {
        flex: 1 1 0 !important;
        width: auto !important;
        min-width: 0;
        min-height: 48px !important;
        padding: 4px 1px !important;
        border-radius: 14px !important;
        display: flex !important;
        flex-direction: column;
        align-items: center !important;
        justify-content: center !important;
        gap: 2px !important;
        color: var(--text-muted) !important;
        font-size: 8.5px !important;
        font-weight: 700 !important;
        line-height: 1 !important;
        box-shadow: none !important;
        transform: none !important;
        white-space: nowrap !important;
    }

    body.v7-liquid-glass .sticky-navbar .navbar-item svg,
    body.v7-liquid-glass .sticky-navbar.collapsed .navbar-item svg {
        display: block !important;
        width: 17px !important;
        height: 17px !important;
    }

    body.v7-liquid-glass .sticky-navbar .navbar-item.active {
        background: #e8f0ff !important;
        color: var(--mobile-blue) !important;
        box-shadow: inset 0 0 0 1px rgba(7, 87, 216, 0.08) !important;
    }

    body.v7-liquid-glass .sticky-navbar .navbar-item.active svg,
    body.v7-liquid-glass .sticky-navbar.collapsed .navbar-item.active svg {
        color: #0757d8 !important;
        stroke: currentColor !important;
        stroke-width: 2.7 !important;
        filter: drop-shadow(0 0 5px rgba(7, 87, 216, 0.48));
        transform: scale(1.1) !important;
    }

    body.v7-liquid-glass .sticky-navbar.collapsed {
        top: auto !important;
        left: 10px !important;
        right: 10px !important;
        bottom: calc(8px + env(safe-area-inset-bottom)) !important;
        width: auto !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 5px !important;
        transform: none !important;
    }

    body[data-theme="dark"].v7-liquid-glass .sticky-navbar .navbar-item.active {
        background: rgba(22, 104, 225, 0.2);
        color: #72a9ff;
    }

    body[data-theme="dark"].v7-liquid-glass .sticky-navbar .navbar-item.active svg {
        color: #8fc2ff !important;
        filter: drop-shadow(0 0 6px rgba(107, 174, 255, 0.72));
    }

    /* Sections become calm, readable dossier sheets. */
    body.v7-liquid-glass .app-section,
    body.v7-liquid-glass #reviews.app-section {
        padding: 20px 14px !important;
        border: 1px solid rgba(255, 255, 255, 0.78) !important;
        border-radius: 22px !important;
        background: rgba(255, 255, 255, 0.78) !important;
        box-shadow: 0 9px 26px rgba(20, 57, 91, 0.065);
        scroll-margin-top: 74px;
        overflow: hidden;
    }

    body.v7-liquid-glass[data-theme="dark"] .app-section,
    body.v7-liquid-glass[data-theme="dark"] #reviews.app-section {
        background: rgba(15, 29, 48, 0.88) !important;
        border-color: rgba(255, 255, 255, 0.07) !important;
    }

    .section-header {
        margin-bottom: 15px;
        gap: 8px;
    }

    .section-title {
        align-items: center;
        font-size: 18px;
        line-height: 1.25;
        letter-spacing: -0.035em;
    }

    .section-title svg {
        width: 19px;
        height: 19px;
        color: var(--mobile-blue);
    }

    /* Seven dishes fit in a compact 4 + 3 grid with no horizontal gesture. */
    .dishes-cards-grid {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        justify-content: stretch;
        gap: 7px;
        margin: 0;
        padding: 0;
        overflow: visible;
    }

    .dishes-cards-grid::-webkit-scrollbar {
        display: none;
    }

    .dish-card,
    .dish-card.active,
    body.v7-liquid-glass .dish-card.active {
        width: auto !important;
        min-width: 0;
        min-height: 88px;
        padding: 6px;
        align-items: center;
        justify-content: flex-start;
        text-align: center;
        gap: 4px;
        border-width: 1px !important;
        border-radius: 13px;
        background: var(--bg-card) !important;
        transform: none !important;
    }

    .dish-card.active,
    body.v7-liquid-glass .dish-card.active {
        border-color: var(--mobile-blue) !important;
        box-shadow: 0 8px 20px rgba(7, 87, 216, 0.12) !important;
    }

    .dish-img,
    .dish-card.active .dish-img {
        width: 48px;
        height: 48px;
        border: 0;
        border-radius: 12px;
        transform: none !important;
        box-shadow: none;
    }

    .dish-title {
        height: 2.5em;
        margin: 0;
        text-align: center;
        font-size: 8.5px;
        line-height: 1.25;
    }

    .dish-badge {
        display: none !important;
    }

    /* Six stages fit in a 3 x 2 matrix; no sideways scrolling required. */
    .pipeline-filter-container {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
        margin: 0 0 12px;
        padding: 0;
        border-radius: 0;
        background: transparent;
        overflow: visible;
    }

    .pipeline-step {
        flex: none;
        width: auto;
        min-width: 0;
        min-height: 48px;
        padding: 4px 3px;
        border-radius: 12px;
    }

    .pipeline-icon {
        width: 14px;
        height: 14px;
    }

    .pipeline-title {
        display: -webkit-box;
        overflow: hidden;
        font-size: 11px;
        line-height: 1.15;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .pipeline-connector {
        display: none;
    }

    .trace-workspace {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-top: 0;
    }

    .trace-scope-sidebar {
        position: static;
        padding: 10px;
        border-radius: 16px;
    }

    .trace-scope-sidebar .sidebar-title {
        display: none;
    }

    .scope-list {
        display: none;
    }

    .scope-list::-webkit-scrollbar {
        display: none;
    }

    .scope-list li {
        flex: 0 0 auto;
    }

    .scope-item-btn {
        width: auto;
        min-height: 40px;
        padding: 8px 11px;
        font-size: 10px;
        border-color: var(--mobile-hairline);
    }

    .ingredient-picker {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        gap: 8px;
    }

    .ingredient-picker-label {
        display: flex;
        align-items: center;
        gap: 6px;
        min-height: 42px;
        color: var(--text-main);
        font-size: 13px;
        font-weight: 600;
        line-height: 1;
        letter-spacing: 0;
        text-transform: none;
        white-space: nowrap;
    }

    .ingredient-picker-label svg {
        width: 16px;
        height: 16px;
        color: var(--mobile-blue);
    }

    .ingredient-picker-select {
        width: 100%;
        min-width: 0;
        min-height: 42px;
        height: 42px;
        padding: 0 38px 0 12px;
        border: 1px solid rgba(7, 87, 216, 0.2);
        border-radius: 12px;
        outline: 0;
        background-color: var(--bg-card);
        color: var(--text-main);
        font-size: 13px;
        font-weight: 600;
        line-height: 1;
        text-overflow: ellipsis;
    }

    .ingredient-picker-select:focus-visible {
        border-color: var(--mobile-blue);
        box-shadow: 0 0 0 3px rgba(7, 87, 216, 0.12);
    }

    .trace-tabs-header {
        align-items: stretch !important;
        gap: 0;
        padding-bottom: 10px;
        overflow: visible;
    }

    .trace-tabs-header > div:first-child {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        flex: 1 1 100%;
        width: 100%;
        gap: 7px !important;
    }

    .trace-tabs-header .tab-btn {
        width: 100%;
        min-width: 0;
        min-height: 44px;
        padding: 8px 10px;
        border: 1px solid var(--mobile-hairline);
        border-radius: 12px;
        font-size: 13.5px !important;
        font-weight: 600 !important;
        line-height: 1.2;
        white-space: nowrap;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }

    #btn-tab-timeline {
        font-size: 13.5px !important;
        font-weight: 600 !important;
    }

    /* Keep graph controls available and use a compact family-tree org chart. */
    .graph-toolbar {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
        width: 100%;
        margin-bottom: 10px;
    }

    .graph-toolbar > div[style*="flex-grow"] {
        display: none !important;
    }

    .btn-graph-action {
        min-width: 0;
        min-height: 38px;
        padding: 6px 8px !important;
        font-size: 10px;
        white-space: nowrap;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 4px !important;
    }

    .graph-legend {
        display: none !important;
    }

    .graph-legend .legend-item {
        min-width: 0;
        align-items: flex-start;
        line-height: 1.25;
    }

    .graph-legend .legend-color {
        flex: 0 0 9px;
        width: 9px;
        height: 9px;
        margin-top: 1px;
    }

    .provenance-tree-mobile {
        display: flex !important;
        min-width: 0;
        padding: 12px !important;
        overflow: hidden;
    }

    .family-tree-heading {
        display: flex;
        flex-direction: column;
        gap: 2px;
        padding-bottom: 10px;
        border-bottom: 1px solid var(--mobile-hairline);
        color: var(--text-main);
        font-size: 14px;
        font-weight: 600;
    }

    .family-tree-heading small {
        color: var(--text-muted);
        font-size: 10px;
        font-weight: 600;
    }

    .family-tree-viewport {
        width: 100%;
        min-width: 0;
        padding: 12px 0 2px;
        overflow-x: auto;
        overflow-y: visible;
        scrollbar-width: thin;
    }

    .family-tree-chart {
        width: 100%;
        min-width: 0;
        transform-origin: top center;
    }

    .family-node {
        position: relative;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        align-items: center;
        min-width: 0;
        padding: 9px 7px;
        border: 1px solid var(--mobile-hairline);
        border-radius: 12px;
        background: var(--bg-card);
        color: var(--text-main);
        text-align: center;
        box-shadow: 0 5px 14px rgba(20, 57, 91, 0.06);
    }

    .family-node-root,
    .family-node-batch {
        width: min(230px, 80%);
        margin-inline: auto;
    }

    .family-node-root {
        border-color: rgba(8, 122, 82, 0.36);
        background: rgba(8, 122, 82, 0.07);
    }

    .family-node-batch {
        border-color: rgba(124, 58, 237, 0.3);
        background: rgba(124, 58, 237, 0.06);
    }

    .family-node strong {
        max-width: 100%;
        font-size: 12px;
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .family-node-kicker {
        margin-bottom: 3px;
        color: var(--text-muted);
        font-size: 8px;
        font-weight: 600;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    .family-node-code,
    .family-node-source {
        max-width: 100%;
        margin-top: 3px;
        color: var(--text-muted);
        font-family: var(--font-data);
        font-size: 8.5px;
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .family-tree-stem {
        width: 1px;
        height: 16px;
        margin: 0 auto;
        background: var(--border-color);
    }

    .family-tree-branch {
        position: relative;
        width: 74%;
        height: 17px;
        margin: 0 auto;
        border-top: 1px solid var(--border-color);
    }

    .family-tree-branch::before {
        position: absolute;
        top: -17px;
        left: 50%;
        width: 1px;
        height: 17px;
        background: var(--border-color);
        content: "";
    }

    .family-tree-children {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px;
    }

    .family-node-ingredient::before {
        position: absolute;
        top: -18px;
        left: 50%;
        width: 1px;
        height: 18px;
        background: var(--border-color);
        content: "";
    }

    .family-status-pill {
        margin-top: 6px;
        padding: 3px 6px;
        border-radius: 999px;
        background: rgba(8, 122, 82, 0.1);
        color: var(--mobile-green);
        font-size: 8px;
        font-weight: 600;
    }

    .family-status-warning .family-status-pill {
        background: rgba(217, 119, 6, 0.12);
        color: #a65b05;
    }

    .trace-tabs-header .tab-btn.active {
        border-color: rgba(7, 87, 216, 0.28);
        background: #eaf1ff;
    }

    #timeline-density-controls {
        display: none !important;
    }

    #timeline-density-controls .toggle-group-sm {
        min-height: 42px;
    }

    #timeline-density-controls .toggle-btn-sm {
        padding: 5px 8px !important;
        font-size: 8px !important;
    }

    .timeline-view {
        padding-left: 28px;
    }

    .timeline-view::before,
    .timeline-view.simple::before {
        left: 9px;
        top: 20px;
        bottom: 20px;
        width: 1px;
        background: color-mix(in srgb, var(--border-color) 82%, var(--primary) 18%);
    }

    .timeline-node {
        margin-bottom: 0;
    }

    .timeline-marker,
    .timeline-marker.simple,
    .timeline-view.simple .timeline-marker.simple {
        top: 18px;
        left: -28px;
        width: 20px;
        height: 20px;
        border-width: 1.5px;
        transform: none;
    }

    .timeline-marker.simple svg,
    .timeline-view.simple .timeline-marker.simple svg {
        width: 10px;
        height: 10px;
    }

    .timeline-card {
        min-height: 92px;
        padding: 12px;
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 7px 10px;
        border-radius: 15px;
    }

    .timeline-card.simple {
        min-height: 78px;
        padding: 12px 22px 14px 8px;
        grid-template-columns: minmax(0, 1fr) 14px;
        grid-template-rows: auto auto;
        gap: 6px 8px;
        align-items: center;
        border: 0;
        border-bottom: 1px solid color-mix(in srgb, var(--border-color) 78%, transparent) !important;
        border-radius: 0;
        background: transparent;
        box-shadow: none !important;
    }

    body[data-theme="dark"] .timeline-card.simple {
        background: transparent;
    }

    .timeline-node.simple:last-child .timeline-card.simple {
        border-bottom-color: transparent !important;
    }

    .timeline-card.simple:hover {
        border-bottom-color: color-mix(in srgb, var(--primary) 24%, var(--border-color)) !important;
        background: color-mix(in srgb, var(--primary-light) 35%, transparent);
    }

    .timeline-card.simple.active {
        border-color: color-mix(in srgb, var(--primary) 18%, var(--border-color)) !important;
        border-radius: 0 10px 10px 0;
        background: linear-gradient(90deg, color-mix(in srgb, var(--primary-light) 64%, transparent), transparent 88%);
        box-shadow: inset 3px 0 0 var(--primary) !important;
    }

    body[data-theme="dark"] .timeline-card.simple.active {
        background: linear-gradient(90deg, rgba(42, 125, 247, 0.16), transparent 88%);
    }

    .timeline-card:hover {
        transform: none;
    }

    .event-time-col {
        grid-column: 1 / -1;
        width: auto;
        font-family: var(--font-data);
        font-size: 9px;
    }

    .event-time-col.simple {
        grid-column: 1;
        grid-row: 1;
        min-width: 0;
        width: auto;
        font-family: var(--font-data);
        color: var(--text-muted);
        font-size: 11px;
        font-weight: 650;
        line-height: 1.2;
        text-align: left;
        white-space: nowrap;
    }

    .event-details-col.simple {
        grid-column: 1;
        grid-row: 2;
        min-width: 0;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px;
        overflow: visible;
    }

    .event-title {
        font-size: 11.5px;
    }

    .event-title.simple {
        display: -webkit-box;
        overflow: hidden;
        color: var(--text-main);
        font-size: 13px;
        font-weight: 650;
        line-height: 1.28;
        white-space: normal;
        text-overflow: clip;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .event-badge,
    .event-meta-item,
    .event-action-col {
        font-size: 8.5px;
    }

    .event-badge.simple {
        justify-self: end;
        padding: 3px 7px;
        font-size: 9px;
        line-height: 1.2;
        text-transform: none;
        white-space: nowrap;
    }

    .event-action-col.simple {
        grid-column: 2;
        grid-row: 1 / -1;
        align-self: center;
        justify-self: end;
        width: 14px;
        overflow: hidden;
        color: transparent;
        font-size: 0;
        white-space: nowrap;
    }

    .event-action-col.simple::after {
        color: var(--mobile-blue);
        content: "›";
        font-family: var(--font-body);
        font-size: 24px;
        font-weight: 500;
        line-height: 1;
    }

    .event-metadata-row {
        gap: 7px;
    }

    .event-action-col {
        align-self: center;
    }

    /* Certificate is stacked, but keeps the source image comfortably visible. */
    .cert-layout {
        grid-template-columns: 1fr;
        gap: 16px;
        margin-top: 0;
        padding: 12px;
        border-radius: 17px;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }

    .cert-hero-image-wrapper {
        width: min(100%, 250px);
        height: 320px;
        margin-inline: auto;
        justify-content: center;
    }

    .cert-hero-image-wrapper img {
        display: block;
        width: auto;
        max-width: 100%;
        height: 100%;
        margin-inline: auto;
        object-fit: contain;
    }

    /* The supplied ATTP asset is a wider page capture; crop to the document itself. */
    .cert-hero-image-wrapper.cert-source-image {
        width: 210px;
        height: 320px;
    }

    .cert-hero-image-wrapper.cert-source-image img {
        flex: 0 0 auto;
        width: auto;
        max-width: none;
        height: 370px;
        margin: 0;
        transform: translate(-20px, 2px);
    }

    .cert-hero-image-wrapper.cert-source-image .cert-verified-stamp {
        display: none;
    }

    .cert-hero-image-wrapper .cert-verified-stamp {
        top: 12px !important;
        right: 10px !important;
        max-width: calc(100% - 20px) !important;
        padding: 3px 7px !important;
        border-width: 2px !important;
        font-size: 9px !important;
        letter-spacing: 0.06em !important;
        white-space: nowrap;
        transform: rotate(9deg) !important;
    }

    .cert-layout > div,
    .cert-slider-container,
    .cert-details-pane {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    .cert-slider-container {
        gap: 6px !important;
        overflow: hidden;
    }

    .cert-arrow-btn {
        flex: 0 0 28px;
    }

    .cert-thumbs-viewport {
        flex: 1 1 0 !important;
        width: 0 !important;
        min-width: 0 !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    .cert-thumbs-scroll {
        width: max-content;
        max-width: none;
    }

    .cert-details-pane,
    .cert-details-pane * {
        min-width: 0;
        max-width: 100%;
    }

    .cert-details-pane h3,
    .cert-details-pane p,
    .cert-details-pane div,
    .cert-details-pane strong,
    .cert-details-pane span {
        overflow-wrap: anywhere;
        word-break: normal;
    }

    .cert-details-pane h3 {
        flex-basis: auto !important;
        font-size: 18px !important;
    }

    .cert-details-pane > div:first-child {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start !important;
        gap: 8px !important;
        flex-wrap: nowrap !important;
    }

    .cert-details-pane > div:first-child > div:last-child {
        align-self: start;
        margin-top: 2px;
        white-space: nowrap;
    }

    .cert-grid-info {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .cert-grid-item.full-width {
        grid-column: auto;
    }

    .cert-main-title {
        font-size: 16px;
    }

    /* Reviews: score header is compact, feed remains readable. */
    #reviews .section-header {
        margin-bottom: 12px;
    }

    .reviews-layout {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .rating-dashboard {
        display: grid;
        grid-template-columns: 82px minmax(0, 1fr);
        gap: 8px;
        align-items: center;
    }

    .average-score-card {
        min-height: 100px;
        padding: 10px 6px;
        justify-content: center;
        border-radius: 14px;
    }

    .average-score-num {
        font-size: 30px;
    }

    .average-score-card .rating-stars-container span {
        font-size: 11px !important;
        letter-spacing: -1px;
    }

    .average-score-label {
        margin-top: 4px;
        font-size: 8px;
    }

    .rating-bars-list {
        margin: 0;
        padding: 7px 8px;
        border: 1px solid rgba(255, 255, 255, 0.58);
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.68);
    }

    .rating-bar-row {
        gap: 5px;
        padding: 1px 2px;
        font-size: 9px;
    }

    .rating-bar-label {
        width: 21px !important;
    }

    .rating-bar-count {
        min-width: 24px;
        font-size: 8px;
    }

    .review-card {
        margin-bottom: 10px;
        padding: 14px;
        border-radius: 16px;
    }

    .review-form-card {
        border-radius: 17px;
    }

    .review-form-card form > div,
    .review-form-card form > div:last-child {
        align-items: stretch !important;
    }

    .form-input,
    .form-textarea,
    .btn-submit-review {
        min-height: 44px;
    }

    .captcha-question-box,
    #review-form-captcha {
        box-sizing: border-box;
        min-height: 30px !important;
        height: 30px !important;
    }

    .captcha-question-box {
        display: inline-flex;
        align-items: center;
    }

    #review-form-captcha {
        width: 76px !important;
        padding: 5px 8px !important;
        line-height: 1.2;
    }

    .btn-submit-review {
        width: 100%;
    }

    /* True modal bottom sheet: fully hidden until explicitly opened. */
    .detail-drawer,
    body.v7-liquid-glass .detail-drawer {
        top: auto !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        max-width: none !important;
        height: 75vh !important;
        border: 0 !important;
        border-top: 1px solid rgba(255, 255, 255, 0.7) !important;
        border-radius: 26px 26px 0 0 !important;
        box-shadow: 0 -18px 50px rgba(7, 24, 40, 0.25) !important;
        transform: translateY(105%) !important;
        transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1) !important;
        pointer-events: none;
    }

    .detail-drawer.open,
    body.v7-liquid-glass .detail-drawer.open {
        transform: translateY(0) !important;
        pointer-events: auto;
    }

    .drawer-grab-handle {
        display: block !important;
        height: 4px;
        margin-top: 8px;
    }

    .detail-drawer .drawer-header {
        min-height: 58px;
        padding: 12px 16px !important;
    }

    .detail-drawer .btn-close-drawer,
    .cert-modal .btn-close-drawer {
        width: 42px !important;
        height: 42px !important;
    }

    .drawer-content {
        padding: 14px 14px calc(28px + env(safe-area-inset-bottom));
    }

    .drawer-field-grid {
        grid-template-columns: 1fr;
    }

    .drawer-field-card.full-width {
        grid-column: auto;
    }

    .modal-backdrop {
        background: rgba(6, 19, 33, 0.52);
    }

    .cert-modal {
        width: calc(100% - 20px);
        max-height: calc(100dvh - 24px);
        border-radius: 24px;
    }

    .cert-modal-body {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }

    /* Prototype commenting is intentionally absent from the consumer view. */
    .comments-sidebar,
    .comment-pin,
    .comment-popover {
        display: none !important;
    }

    .app-footer {
        margin: 0 12px 14px;
        padding: 24px 16px 32px;
        border: 0;
        border-radius: 22px !important;
        text-align: center;
        font-size: 11px;
        background: rgba(255, 255, 255, 0.6) !important;
    }

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

@media (max-width: 360px) {
    .app-logo {
        font-size: 18px;
    }

    .btn-header-primary {
        padding-inline: 11px;
        font-size: 11px;
    }

    .metrics-card-main {
        grid-template-columns: 80px minmax(0, 1fr) !important;
        gap: 8px;
    }

    .trust-shield {
        width: 76px;
        height: 76px;
    }

    .metric-subtext.success {
        font-size: 7px !important;
    }

    .tech-spec-col {
        padding-inline: 9px;
    }

    .tech-spec-value {
        font-size: 12.5px !important;
        white-space: nowrap !important;
    }

    .graph-toolbar {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .hero-section,
    .detail-drawer,
    .main-image,
    .dish-card,
    .timeline-card {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}
