:root {
    color-scheme: light;
    --paper: #f6f5ef;
    --ink: #242c26;
    --muted: #566057;
    --green: #285c38;
    --border: #cccfc3;
    --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    color: var(--ink);
    font: 1rem/1.5 system-ui, sans-serif;
}

.content-width {
    width: calc(100% - 2rem);
    max-width: 64rem;
    margin-inline: auto;
}

a { color: var(--green); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
    outline: 3px solid var(--green);
    outline-offset: 3px;
}

.skip-link {
    position: absolute;
    top: -5rem;
    left: 1rem;
    padding: 0.5rem 0.75rem;
    background: var(--paper);
    z-index: 1;
}
.skip-link:focus { top: 0.5rem; }

.site-header {
    background: var(--ink);
    border-bottom: 3px solid var(--green);
}
.site-header nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 2rem;
    padding-block: 0.7rem;
}
.site-header a { color: var(--paper); }
.site-header :focus-visible { outline-color: #c3e0ad; }
.wordmark { font-weight: 750; letter-spacing: 0.02em; text-decoration: none; }
.wordmark:hover { text-decoration: underline; }

main { flex: 1 0 auto; padding-block: 1.5rem 3rem; }
h1, h2 { line-height: 1.25; overflow-wrap: anywhere; }
h1 { margin: 0 0 0.75rem; font-size: 1.6rem; }
h2 {
    margin: 1.75rem 0 0.75rem;
    padding-bottom: 0.45rem;
    border-bottom: 2px solid var(--border);
    font-size: 1.15rem;
}
p { margin: 0.75rem 0; }
.intro, .empty-state { color: var(--muted); }

/* Tracking uses ordinary server-rendered form validation. */
.tracking-form { margin-block: 1rem 1.75rem; }
label { display: block; margin-bottom: 0.35rem; font-weight: 650; }
.tracking-controls { display: flex; gap: 0.5rem; }
input, button { font: inherit; border-radius: 2px; }
input {
    width: 100%;
    min-width: 0;
    padding: 0.5rem 0.65rem;
    color: var(--ink);
    background: #fff;
    border: 1px solid #7b8579;
}
input::placeholder { color: var(--muted); opacity: 1; }
button {
    flex-shrink: 0;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--green);
    background: var(--green);
    color: #fff;
    font-weight: 650;
    cursor: pointer;
}
button:hover { background: #1c4328; }
.input-validation-error { border: 2px solid #993526; }
.field-validation-error, .validation-summary-errors {
    display: block;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-left: 3px solid #993526;
    background: #f9eae4;
    color: #802c20;
}
.field-validation-valid, .validation-summary-valid { display: none; }

/* Current deals share the product page's price styling. */
.deal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 1rem; }
.deal-card { min-width: 0; padding: 1.25rem; border: 1px solid var(--border); border-top: 3px solid var(--green); background: #fffef9; }
.deal-card h3 { margin: 0 0 1rem; font-size: 1.05rem; overflow-wrap: anywhere; }
.deal-retailer, .deal-variant, .deal-additional { color: var(--muted); font-size: 0.85rem; }
.deal-retailer { margin-top: 0; font-weight: 700; }

/* Definitions keep the price, status and recorded metadata easy to scan. */
dl { margin: 0; }
dt { color: var(--muted); font-size: 0.85rem; }
dd { margin: 0.2rem 0 0; overflow-wrap: anywhere; }
/* Product details: price and recorded range lead into the SVG chart. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
.product-heading { margin-bottom: 1.5rem; }
.product-heading .retailer-name {
    margin: 0 0 0.35rem;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.product-heading h1 { max-width: 52rem; font-size: clamp(1.4rem, 3vw, 2rem); }
.product-heading-meta { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; font-size: 0.9rem; }
.product-heading-meta span { color: var(--muted); }
.product-details h3, .product-details h4 { margin: 1.5rem 0 0.65rem; font-size: 1rem; }
.comparison-note { color: var(--muted); font-size: 0.85rem; }
.store-comparison small { display: block; color: var(--muted); font-size: 0.75rem; }
.store-listing { margin-top: 2.5rem; padding-top: 1rem; border-top: 3px solid var(--border); scroll-margin-top: 1rem; }
.listing-heading { margin-bottom: 1rem; }
.listing-heading h2 { margin-bottom: 0.35rem; }
.listing-heading > p { margin-top: 0; color: var(--muted); }
.product-details .variant-links { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-block: 1rem 1.5rem; }
.variant-links a {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    align-items: baseline;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    background: #fffef9;
    font-size: 0.85rem;
    text-decoration: none;
}
.variant-links a:hover { border-color: var(--green); }
.variant-links strong { font-variant-numeric: tabular-nums; }
.variant-links small { color: var(--muted); }
.product-variant { scroll-margin-top: 1rem; }
.product-variant + .product-variant { margin-top: 2.5rem; padding-top: 0.5rem; border-top: 3px solid var(--border); }
.observation-notice { padding: 0.65rem 0.9rem; border-left: 3px solid #916820; background: #f4ecd8; font-size: 0.9rem; }
.price-overview {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    border: 1px solid var(--border);
    background: #fffef9;
}
.price-overview > dl { padding: 1.1rem 1.25rem; }
.price-card { border-top: 3px solid var(--green); }
.current-price { margin: 0.3rem 0 0.65rem; color: var(--green); font: 750 clamp(1.9rem, 4vw, 2.65rem)/1.2 var(--mono); }
.current-price span { font-size: 0.95rem; font-weight: 500; }
.reference-price { font: 0.9rem var(--mono); color: var(--muted); }
.price-discount { margin-top: 0.65rem; color: var(--green); font-size: 0.85rem; font-weight: 650; }
.recorded-prices, .variant-status { border-left: 1px solid var(--border); display: grid; align-content: start; gap: 1.1rem; }
.recorded-prices dd { font: 650 1.15rem var(--mono); }
.variant-status dd { font-size: 0.9rem; }
.stock-status { font-weight: 650; }
.in-stock { color: var(--green); }
.out-of-stock { color: #802c20; }
.history-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 1rem; margin-top: 1.5rem; }
.product-details .history-heading h4 { margin: 0 0 0.65rem; }
.history-heading p { margin: 0 0 0.65rem; font-size: 0.8rem; color: var(--muted); }
.price-drop { color: var(--green); }
.price-rise { color: #802c20; }
.initial-observation { font: 0.8rem system-ui, sans-serif; color: var(--muted); }
.metadata-history, .tracking-diagnostics {
    margin-top: 1.5rem;
    padding: 0.85rem 0;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--muted);
}
.product-details summary { cursor: pointer; font-weight: 600; }
.tracking-diagnostics dl { display: grid; grid-template-columns: minmax(10rem, 1fr) 2fr; gap: 0.5rem 1rem; margin-top: 1rem; }
.tracking-diagnostics dd { margin: 0; }

/* Scroll regions preserve table structure and readable chart labels on phones. */
.table-scroll, .chart-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.9rem; }
caption { padding-bottom: 0.5rem; text-align: left; color: var(--muted); }
th, td { padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #eaece2; font-weight: 650; }
tbody tr:hover { background: #eef0e7; }
.numeric { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.numeric, .timestamp { font-family: var(--mono); }
.timestamp { white-space: nowrap; }
.product-table { min-width: 30rem; }
.product-table td:first-child { width: 70%; overflow-wrap: anywhere; }
.product-table td:first-child a { font-weight: 600; }
.back-link { margin-top: 1.25rem; font-size: 0.9rem; }

.price-history-chart { margin: 0 0 1.25rem; }
.chart-scroll { background: #fffef9; border: 1px solid var(--border); padding: 0.5rem 0; }
.price-history-chart svg { display: block; width: 100%; min-width: 40rem; height: auto; }
.price-history-chart text { font: 14px var(--mono); fill: var(--muted); }
.price-history-chart .chart-axis-title { font-weight: 600; }
.price-history-chart .chart-date-range { font: 13px system-ui, sans-serif; }
.chart-axis { stroke: #929b8d; stroke-width: 1; vector-effect: non-scaling-stroke; }
.price-grid { stroke: #e1e4d9; stroke-width: 1; vector-effect: non-scaling-stroke; }
.price-line { fill: none; stroke: var(--green); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.price-point { fill: #fffef9; stroke: var(--green); stroke-width: 1.25; vector-effect: non-scaling-stroke; }
.history-series .price-line, .history-series .price-point { stroke: var(--series-color); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem; padding: 0; list-style: none; font-size: 0.85rem; }
.chart-legend a { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.chart-legend small { color: var(--muted); }
.series-swatch { display: inline-block; width: 1.8rem; border-top: 3px solid; }
.variant-history { border-top: 1px solid var(--border); padding: 0.85rem 0; scroll-margin-top: 1rem; }
.variant-history > summary { display: list-item; }
.history-summary-price { margin-left: 0.5rem; font: 0.85rem var(--mono); }
.variant-history > summary small { margin-left: 0.5rem; color: var(--muted); font-weight: 400; }
.history-facts { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; margin-block: 1rem; font-size: 0.85rem; }
figcaption { margin-top: 0.5rem; color: var(--muted); font-size: 0.85rem; }
.scroll-hint { display: none; }

.retailer-metadata-entry {
    margin-block: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    background: #fffef9;
}
.retailer-metadata-entry summary { cursor: pointer; }
.retailer-metadata-entry pre {
    margin: 0.75rem 0 0;
    max-height: 32rem;
    overflow: auto;
    font: 0.85rem/1.5 var(--mono);
}
.retailer-metadata-entry code { font: inherit; }

@media (max-width: 42rem) {
    .scroll-hint { display: inline; }
    .price-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .price-card { grid-column: 1 / -1; border-bottom: 1px solid var(--border); }
    .recorded-prices { border-left: 0; }
    .price-overview > dl { padding: 1rem; }
}

@media (max-width: 32rem) {
    .tracking-controls { flex-direction: column; align-items: stretch; }
    .recorded-prices dd { font-size: 0.95rem; }
    .tracking-diagnostics dl { grid-template-columns: 1fr; gap: 0.25rem; }
    .tracking-diagnostics dd { margin-bottom: 0.65rem; }
    th, td { padding: 0.5rem; }
}
