:root {
    color-scheme: light dark;
    font-family: system-ui, sans-serif;
}

body {
    margin: 0;
    background: canvas;
    color: canvastext;
}

.cookie-banner {
    position: sticky;
    top: 0;
    z-index: 1001;
    border-bottom: 1px solid #8884;
    background: color-mix(in srgb, #1d6fd6 10%, canvas);
    backdrop-filter: blur(8px);
}

.cookie-banner-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.85rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.cookie-banner-copy {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.45;
}

.cookie-banner-copy a {
    color: inherit;
}

.cookie-banner-button {
    flex-shrink: 0;
}

.site-header {
    border-bottom: 1px solid #8884;
}

.site-header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.site-title {
    font-weight: 600;
    font-size: 1.15rem;
    text-decoration: none;
    color: inherit;
}

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}

.site-footer {
    border-top: 1px solid #8884;
    margin-top: 2rem;
}

.site-footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
    opacity: 0.85;
}

.footer-copy {
    margin: 0;
}

.footer-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: inherit;
}

.header-search-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-search {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    flex: 1;
    margin-bottom: 1rem;
}

.header-search-input-row {
    width: 100%;
    min-width: 520px;
}

.header-search-filters-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 10px;
}

.product-row-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.track-toggle-form,
.favorite-toggle-form {
    align-self: flex-start;
}

.track-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    opacity: 0.85;
    cursor: pointer;
}

.track-toggle input[type="checkbox"] {
    cursor: pointer;
}

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

.favorite-toggle input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.heart-icon {
    font-size: 1.4rem;
    line-height: 1;
    color: #8888;
    transition: color 0.15s ease;
}

.heart-icon::before {
    content: "\2661";
}

.favorite-toggle:hover .heart-icon {
    color: #d94841;
}

.favorite-toggle input[type="checkbox"]:checked ~ .heart-icon {
    color: #d94841;
}

.favorite-toggle input[type="checkbox"]:checked ~ .heart-icon::before {
    content: "\2665";
}

.favorite-toggle input[type="checkbox"]:focus-visible ~ .heart-icon {
    outline: 2px solid #1d6fd6;
    outline-offset: 2px;
}

.heart-button {
    background: none;
    border: none;
    padding: 0;
    font-size: 1.4rem;
    line-height: 1;
    color: #d94841;
    cursor: pointer;
}

.heart-button:hover {
    filter: brightness(1.15);
}

.header-search input {
    width: min(520px, 100%);
    max-width: 100%;
    border: 1px solid #8884;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    padding: 0.65rem 0.95rem;
    font: inherit;
}

.sort-control {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

.sort-control select {
    border: 1px solid #8884;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    padding: 0.55rem 0.85rem;
    font: inherit;
}

.header-search button {
    border: 1px solid #8884;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    padding: 0.55rem 0.95rem;
    font: inherit;
    cursor: pointer;
}

.flash-messages {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
}

.flash-message {
    padding: 0.75rem 0.9rem;
    border: 1px solid #2f7d32;
    border-radius: 8px;
    background: color-mix(in srgb, #2f7d32 12%, canvas);
    margin-bottom: 0.5rem;
}

.flash-message.error {
    border-color: #b33;
    background: color-mix(in srgb, #b33 12%, canvas);
}

.flash-message.warning {
    border-color: #c47f00;
    background: color-mix(in srgb, #c47f00 12%, canvas);
}

.toast-stack {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: min(32rem, calc(100vw - 2rem));
    pointer-events: none;
}

.toast-message {
    border: 1px solid #2f7d32;
    border-radius: 10px;
    background: color-mix(in srgb, #2f7d32 14%, canvas);
    color: inherit;
    padding: 0.85rem 1rem;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast-message.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-message.error {
    border-color: #b33;
    background: color-mix(in srgb, #b33 12%, canvas);
}

.action-button {
    border: 1px solid #1d6fd6;
    border-radius: 999px;
    background: #1d6fd6;
    color: #fff;
    padding: 0.55rem 0.95rem;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.action-button:hover {
    filter: brightness(1.05);
}

.danger-button {
    background: #b33;
    border-color: #b33;
}

.bulk-action-form {
    margin: 0 0 1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-left: auto;
}

.session-email {
    font-size: 0.85rem;
    opacity: 0.8;
    color: inherit;
    text-decoration: none;
}

.session-email:hover {
    text-decoration: underline;
}

.link-button {
    background: none;
    border: none;
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
    font: inherit;
    padding: 0;
    opacity: 0.8;
}

.auth-card {
    max-width: 420px;
    margin: 2rem auto;
    padding: 1.5rem;
    border: 1px solid #8884;
    border-radius: 10px;
}

.auth-hint {
    font-size: 0.85rem;
    opacity: 0.7;
}

.legal-card {
    max-width: 72ch;
    margin: 2rem auto;
    padding: 1.75rem;
    border: 1px solid #8884;
    border-radius: 10px;
    line-height: 1.55;
}

.legal-card h1,
.legal-card h2 {
    line-height: 1.15;
}

.profile-card {
    padding: 1.5rem;
    border: 1px solid #8884;
    border-radius: 10px;
    margin-bottom: 2rem;
}

.help-details {
    margin: 0.5rem 0 1.25rem;
    padding: 0.85rem 1rem;
    border: 1px solid #8884;
    border-radius: 10px;
}

.help-details summary {
    cursor: pointer;
    font-weight: 600;
}

.help-details[open] summary {
    margin-bottom: 0.6rem;
}

.help-details ul {
    margin: 0;
    padding-left: 1.25rem;
    line-height: 1.5;
}

.help-details li + li {
    margin-top: 0.6rem;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 1rem 0;
}

.share-actions {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.share-send-form {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.share-send-form .auth-field {
    margin: 0;
}

.auth-field input {
    border: 1px solid #8884;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    padding: 0.6rem 0.8rem;
    font: inherit;
}

.profile-fields {
    margin: 0;
}

.profile-fields dt {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 1rem;
}

.profile-fields dt:first-child {
    margin-top: 0;
}

.profile-fields dd {
    margin: 0.15rem 0 0;
    font-size: 1rem;
}

.category-section {
    margin-bottom: 2.5rem;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.2rem;
    margin: 1.5rem 0 2.5rem;
    font-size: 0.9rem;
}

.pagination a {
    color: inherit;
}

.pagination-disabled {
    opacity: 0.4;
}

.category-section h2 {
    font-size: 1.1rem;
    border-bottom: 1px solid #8884;
    padding-bottom: 0.4rem;
    margin-bottom: 1rem;
}

.product-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.product-row {
    display: grid;
    grid-template-columns: minmax(240px, 360px) minmax(0, 1fr);
    gap: 1rem;
    border: 1px solid #8884;
    border-radius: 10px;
    padding: 0.9rem;
    align-items: stretch;
}

.product-row-summary {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.product-row-link {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 0.9rem;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

.product-row-link img {
    width: 88px;
    height: 88px;
    border-radius: 8px;
    object-fit: cover;
    display: block;
}

.no-image {
    border: 1px solid #8884;
    background: color-mix(in srgb, canvastext 4%, canvas);
}

.product-row-body h3 {
    font-size: 1rem;
    margin: 0 0 0.25rem;
}

.product-row-history {
    min-width: 0;
    min-height: 150px;
}

.inline-history-chart {
    width: 100%;
    height: 150px;
}

.vendor {
    font-size: 0.8rem;
    opacity: 0.7;
    margin: 0 0 0.5rem;
}

.price {
    font-weight: 600;
}

.pricing-unit {
    font-weight: 400;
    font-size: 0.75rem;
    opacity: 0.7;
}

.retailer-tag {
    opacity: 0.9;
}

.compare-at {
    font-weight: 400;
    text-decoration: line-through;
    opacity: 0.6;
    margin-left: 0.4rem;
}

.badge.sold-out {
    display: inline-block;
    margin-top: 0.4rem;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    background: #b33;
    color: #fff;
    font-size: 0.75rem;
}

.status-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.badge.status-ok {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    background: #2f7d32;
    color: #fff;
    font-size: 0.75rem;
}

.badge.status-failed {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    background: #b33;
    color: #fff;
    font-size: 0.75rem;
    cursor: help;
}

.badge.status-unknown {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    background: #8884;
    font-size: 0.75rem;
}

.badge.in-progress {
    display: inline-block;
    margin: 0;
    padding: 0.4rem 0.7rem;
    border-radius: 999px;
    background: color-mix(in srgb, #c47f00 15%, canvas);
    border: 1px solid #c47f00;
    font-size: 0.85rem;
}

.back-link {
    display: inline-block;
    margin-bottom: 1rem;
}

.product-detail-header {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.product-detail-header img {
    width: 220px;
    height: 220px;
    object-fit: cover;
    border-radius: 8px;
}

.product-description {
    margin-top: 1rem;
    max-width: 70ch;
    line-height: 1.5;
}

.variant-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
}

.variant-table th,
.variant-table td {
    text-align: left;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid #8884;
}

@media (max-width: 800px) {
    .site-header-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .header-search {
        align-items: stretch;
    }

    .header-search input {
        width: 100%;
    }

    .header-search-input-row {
        min-width: 0;
    }

    .header-search-filters-row {
        align-items: stretch;
    }

    .product-detail-header {
        flex-direction: column;
    }

    .product-detail-header img {
        width: 100%;
        height: auto;
        max-width: 220px;
    }

    .product-row {
        grid-template-columns: 1fr;
    }

    .product-row-history {
        min-height: 190px;
    }

    .inline-history-chart {
        height: 190px;
    }
}

@media (max-width: 520px) {
    .product-row-link {
        grid-template-columns: 72px minmax(0, 1fr);
    }

    .product-row-link img {
        width: 72px;
        height: 72px;
    }
}
