@layer reset, layout, components, responsive;
@layer reset {
    :root {
        color-scheme: light;
        font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
        color: #17221b;
        background: #f7f7ef;
        --paper: #fffefa;
        --ink: #17221b;
        --muted: #536157;
        --line: #d9ded4;
        --sage: #e8ede1;
        --green: #184531;
        --danger: #912f30;
        --radius: 1rem;
    }
    *, *::before, *::after { box-sizing: border-box; }
    [hidden] { display: none !important; }
    .visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    body { margin: 0; }
    button, input, select, textarea { font: inherit; }
    a { color: var(--green); }
    button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
    :focus-visible { outline: 3px solid #617e63; outline-offset: 3px; }
    h1, h2, p { margin: 0; }
    h1 { font-size: clamp(2rem, 5vw, 2.85rem); line-height: 1.1; letter-spacing: -.055em; }
    h2 { font-size: 1.23rem; letter-spacing: -.025em; }
    svg { width: 1.3rem; height: 1.3rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
}
@layer layout {
    .shell { display: grid; grid-template-columns: 14rem minmax(0, 1fr); min-height: 100dvh; }
    .sidebar { display: flex; flex-direction: column; align-items: stretch; gap: 1.75rem; padding: 2rem 1.2rem; background: var(--paper); border-right: 1px solid var(--line); }
    .brand, .nav-link { display: flex; align-items: center; gap: .65rem; text-decoration: none; }
    .brand { color: var(--ink); font-size: 1.5rem; font-weight: 800; letter-spacing: -.06em; padding-inline: .65rem; }
    .brand svg { width: 1.6rem; height: 1.6rem; }
    .sidebar nav { display: grid; gap: .3rem; }
    .nav-link { min-height: 2.75rem; padding: .55rem .65rem; border-radius: .65rem; font-weight: 600; }
    .nav-link:hover, .nav-link.current { background: var(--sage); }
    .logout { margin-top: auto; padding-inline: .65rem; }
    .main { width: min(100%, 64rem); padding: 3rem clamp(1.25rem, 5vw, 4rem) 4rem; }
    .offline-main { margin-inline: auto; }
    .shell-guest { grid-template-columns: 1fr; }
    .shell-guest .sidebar { gap: 0; border-right: 0; border-bottom: 1px solid var(--line); }
    .shell-guest .main { margin-inline: auto; max-width: 33rem; }
    .page-heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.6rem; }
    .detail-heading p { margin-top: .45rem; }
    .breadcrumb { margin-bottom: .75rem; font-size: .94rem; }
    .breadcrumb a { text-underline-offset: .18em; }
    .stack { display: grid; gap: 1rem; align-items: start; }
    .stack > .button { justify-self: start; }
    .login h1 { margin-bottom: 1.6rem; }
    .split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
}
@layer components {
    .card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1rem, 3vw, 1.55rem); }
    .muted { color: var(--muted); }
    .actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
    .button { min-height: 2.75rem; display: inline-flex; align-items: center; justify-content: center; padding: .6rem 1rem; color: var(--green); background: var(--paper); border: 1px solid var(--line); border-radius: .65rem; font-weight: 650; text-decoration: none; cursor: pointer; }
    .button:hover { background: var(--sage); }
    .button.primary { color: white; background: var(--green); border-color: var(--green); }
    .button.primary:hover { background: #21563c; }
    .button:disabled { opacity: .5; cursor: default; }
    .button.danger { color: var(--danger); }
    .button.small { min-height: 2.35rem; min-width: 2.45rem; padding: .15rem .4rem; }
    .text-link { color: var(--green); text-underline-offset: .2em; text-decoration: underline; background: none; border: 0; padding: .25rem 0; cursor: pointer; }
    label { display: grid; gap: .38rem; min-width: 0; font-size: .9rem; font-weight: 630; }
    input:not([type=hidden], [type=checkbox]), select, textarea { background: var(--paper); color: var(--ink); width: 100%; min-width: 0; min-height: 2.75rem; padding: .55rem .65rem; border: 1px solid #bec9bd; border-radius: .58rem; font-size: 1rem; }
    textarea { resize: vertical; }
    input[readonly] { background: var(--sage); }
    .validation { color: var(--danger); }
    .validation:empty, .validation-summary-valid, .field-validation-valid { display: none; }
    .validation ul { margin: .25rem 0 1rem; padding-left: 1.25rem; }
    .status { background: var(--sage); color: var(--green); border-radius: .7rem; margin-bottom: 1rem; padding: .65rem .8rem; }
    .create-form, .search-form { display: flex; align-items: end; gap: .7rem; flex-wrap: wrap; }
    .create-form label, .search-form label { flex: 1 1 14rem; }
    .create-form .validation { flex-basis: 100%; }
    .quick-form { margin-bottom: 1rem; }
    .create-form .quick-quantity { flex: 0 1 5rem; }
    .quick-add-launcher { position: fixed; inset-inline-end: max(1rem, env(safe-area-inset-right)); inset-block-end: max(1rem, env(safe-area-inset-bottom)); z-index: 4; display: grid; place-items: center; width: 3.4rem; height: 3.4rem; border: 0; border-radius: 50%; color: #fff; background: var(--green); box-shadow: 0 .3rem 1rem #14271d38; cursor: pointer; }
    .quick-add-launcher:hover { background: #21563c; }
    .quick-add-launcher svg { width: 1.65rem; height: 1.65rem; }
    .quick-add-dialog { width: min(31rem, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); padding: 0; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: var(--paper); }
    .quick-add-dialog::backdrop { background: #14271db3; }
    .quick-add-panel { display: grid; gap: 1rem; padding: 1.2rem; }
    .quick-add-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
    .quick-add-header button { font-size: 1.25rem; }
    .quick-add-status { margin: 0; overflow-wrap: anywhere; }
    .quick-add-status.validation { color: var(--danger); background: #f8eded; }
    .quick-add-spinner { width: .95rem; height: .95rem; margin-inline-end: .55rem; border: .13rem solid #ffffff60; border-top-color: white; border-radius: 50%; animation: quick-add-spin .7s linear infinite; }
    @keyframes quick-add-spin { to { transform: rotate(1turn); } }
    @media (prefers-reduced-motion: reduce) { .quick-add-spinner { animation: none; } }
    .purchase-suggestions { display: grid; gap: .45rem; font-size: .875rem; }
    .suggestion-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
    .suggestion-chip { min-height: 2rem; color: var(--green); background: var(--sage); border: 1px solid var(--line); border-radius: 1rem; padding: .28rem .65rem; cursor: pointer; text-align: left; overflow-wrap: anywhere; }
    .suggestion-chip:hover { border-color: var(--green); }
    .product-card { display: grid; gap: 1rem; justify-items: start; }
    .product-image { display: block; width: min(100%, 26rem); max-height: 26rem; object-fit: contain; }
    .product-thumbnail { display: grid; place-items: center; flex: 0 0 3.15rem; align-self: center; min-height: 2.75rem; }
    .product-thumbnail img { display: block; width: 2.75rem; height: 2.75rem; padding: .12rem; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: .5rem; }
    .photo-dialog { width: min(32rem, calc(100% - 2rem)); max-height: 90dvh; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: var(--paper); }
    .photo-dialog::backdrop { background: #14271dcc; }
    .photo-panel { position: relative; display: grid; gap: .75rem; justify-items: center; padding: 1rem; padding-top: 3.65rem; text-align: center; }
    .photo-panel img { width: 100%; max-height: min(55dvh, 28rem); object-fit: contain; }
    .photo-close { position: absolute; top: .65rem; right: .65rem; font-size: 1.35rem; }
    .share-steps { display: grid; gap: .6rem; margin: 0; padding-left: 1.25rem; }
    .offer-heading { margin-bottom: .5rem; }
    .offer-source { margin-bottom: 1.5rem; font-size: .9rem; }
    .offer-browser, .offer-results { display: grid; gap: 1rem; }
    .offer-recommended { background: #edf1e8; }
    .offer-recommended header + p { margin-top: .55rem; }
    .offer-ai-feedback { margin: -.5rem 0 0; font-size: .9rem; }
    .offer-spinner { display: inline-block; width: .9em; height: .9em; margin-inline-end: .35em; border: .12em solid currentColor; border-right-color: transparent; border-radius: 50%; animation: offer-spin .7s linear infinite; }
    @keyframes offer-spin { to { transform: rotate(360deg); } }
    @media (prefers-reduced-motion: reduce) { .offer-spinner { animation: none; } }
    .offer-destination { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .55rem; font-size: .9rem; }
    .offer-destination a { font-weight: 700; }
    .offer-store-pages { display: flex; flex-wrap: wrap; gap: .4rem; }
    .offer-filters { display: flex; flex-wrap: wrap; align-items: end; gap: .8rem 1rem; }
    .offer-search { flex: 1 1 14rem; }
    .offer-store { flex: 0 1 12rem; }
    .offer-period { margin: 0; padding: 0; border: 0; }
    .offer-period legend { padding: 0; margin-bottom: .38rem; font-size: .9rem; font-weight: 630; }
    .offer-period-options { display: flex; gap: .25rem; padding: .18rem; border: 1px solid var(--line); border-radius: .6rem; background: var(--sage); }
    .offer-period-options label { position: relative; cursor: pointer; }
    .offer-period-options input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; opacity: 0; }
    .offer-period-options span { display: grid; place-items: center; min-height: 2.25rem; padding: .38rem .7rem; border-radius: .42rem; }
    .offer-period-options input:checked + span { color: #fff; background: var(--green); }
    .offer-period-options input:focus-visible + span { outline: 3px solid #617e63; outline-offset: 2px; }
    .offer-category-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
    .offer-category-chip { display: inline-flex; align-items: center; flex-wrap: wrap; gap: .35rem; min-height: 2.25rem; padding: .28rem .62rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--paper); font-size: .875rem; font-weight: 600; color: var(--green); text-decoration: none; }
    .offer-category-chip span { padding-inline: .3rem; border-radius: .6rem; background: var(--sage); color: var(--green); font-variant-numeric: tabular-nums; }
    .offer-category-chip:hover { background: var(--sage); }
    .offer-category-chip[aria-current] { border-color: var(--green); color: white; background: var(--green); }
    .offer-results-header { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .45rem; }
    .offer-results[aria-busy="true"] { opacity: .7; }
    .offer-feedback, .offer-empty { font-size: .9rem; color: var(--muted); }
    .offer-empty { margin-top: .75rem; }
    .offer-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); gap: .85rem; margin: .85rem 0 0; padding: 0; list-style: none; }
    .offer-card { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); border-radius: .85rem; background: var(--paper); overflow: hidden; }
    .offer-variant { display: flex; flex: 1; flex-direction: column; }
    .offer-variant-header { display: grid; gap: .45rem; padding: .75rem; border-bottom: 1px solid var(--line); }
    .offer-variant-header select { min-width: 0; width: 100%; }
    .offer-media { position: relative; aspect-ratio: 4 / 3; background: white; border-bottom: 1px solid var(--line); }
    .offer-media img { width: 100%; height: 100%; padding: .65rem; object-fit: contain; }
    .offer-card-body { display: flex; flex: 1; flex-direction: column; gap: .35rem; padding: .75rem; overflow-wrap: anywhere; }
    .offer-card-body p { margin: 0; font-size: .88rem; }
    .offer-name { margin: 0; font-size: 1rem; font-weight: 700; }
    .offer-name a { color: inherit; text-decoration-thickness: .06em; text-underline-offset: .15em; }
    .offer-price { color: var(--green); }
    .offer-price strong { font-size: 1.1rem; }
    .offer-reason { color: var(--green); }
    .offer-badges { display: flex; flex-wrap: wrap; gap: .3rem; }
    .offer-badges span { padding: .13rem .45rem; border-radius: .55rem; background: var(--sage); color: var(--green); font-size: .82rem; }
    .offer-media .offer-discount, .offer-badges .offer-discount { padding: .22rem .55rem; border-radius: .55rem; background: #922c30; color: white; font-size: .8rem; font-weight: 700; }
    .offer-media .offer-discount { position: absolute; inset: .5rem auto auto .5rem; }
    .offer-actions { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-top: auto; padding-top: .35rem; }
    .offer-actions button { padding-inline: .55rem; font-size: .85rem; }
    .offer-actions button:disabled { opacity: .48; cursor: default; }
    .offer-actions [data-offer-count] { font-size: .82rem; }
    .list-section { margin-top: 1.65rem; }
    .list-section h2 { margin-bottom: .6rem; }
    .link-list { padding: .25rem .9rem; }
    .link-list a { display: flex; justify-content: space-between; gap: .75rem; align-items: center; min-height: 3.6rem; padding: .65rem .35rem; color: var(--ink); text-decoration: none; }
    .link-list a + a { border-top: 1px solid var(--line); }
    .link-list a:hover strong { text-decoration: underline; }
    .link-list span { color: var(--muted); font-size: .9rem; }
    .list-summary-meta { display: inline-flex; flex-wrap: wrap; justify-content: end; gap: .3rem .55rem; }
    .upcoming-list-badge, .link-list .upcoming-list-badge { display: inline-flex; width: fit-content; padding: .18rem .55rem; border-radius: 1rem; color: var(--green); background: var(--sage); font-size: .82rem; font-weight: 700; }
    .empty, .create-form + .muted { color: var(--muted); margin-top: 1rem; }
    .shop-section { margin-bottom: 1.15rem; }
    .shop-section :is(h2, h3) { color: var(--green); background: var(--sage); border-radius: .65rem; padding: .5rem .8rem; font-size: .95rem; letter-spacing: 0; }
    .shopping-store-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: 1.25rem 0 .75rem; }
    .shopping-store-filters { margin-bottom: .75rem; }
    .shopping-store-filters [aria-pressed="true"] { background: var(--green); color: white; }
    .offer-more { margin-top: 1rem; }
    .shop-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
    .check-form { flex: 1; min-width: 0; }
    .check-button { display: flex; align-items: center; gap: .75rem; min-height: 3.4rem; width: 100%; padding: .5rem .55rem .5rem .8rem; text-align: left; border: none; background: transparent; color: var(--ink); }
    button.check-button { cursor: pointer; }
    button.check-button:hover, .edit-link:hover { background: #edf0e7; }
    .check-circle { display: grid; place-items: center; border: 1.5px solid #748778; flex: 0 0 1.4rem; height: 1.4rem; border-radius: 50%; font-size: .85rem; }
    .item-name { flex: 1; overflow-wrap: anywhere; }
    .amount { color: var(--muted); }
    .edit-link { display: grid; place-items: center; width: 2.85rem; flex: 0 0 2.85rem; }
    button.edit-link { height: 100%; min-height: 2.75rem; border: 0; color: var(--green); background: transparent; cursor: pointer; }
    .edit-link svg { width: 1.05rem; height: 1.05rem; }
    .done .item-name { text-decoration: line-through; color: var(--muted); }
    .done .check-circle { background: var(--green); color: white; border-color: var(--green); }
    .shop-row:is(.checking, .unchecking) { animation: check-row .22s ease-out; }
    .checking .check-circle { background: var(--green); color: white; border-color: var(--green); animation: check-pop .22s ease-out; }
    .checking .check-circle:empty::after { content: "✓"; }
    @keyframes check-pop {
        35% { transform: scale(.8); }
        72% { transform: scale(1.2); }
    }
    .unchecking .check-circle { animation: uncheck-pop .22s ease-out both; }
    @keyframes uncheck-pop {
        55% { transform: scale(.8); }
        to { color: transparent; background-color: transparent; border-color: #748778; }
    }
    @keyframes check-row {
        45% { background: var(--sage); }
    }
    @media (prefers-reduced-motion: reduce) {
        .shop-row:is(.checking, .unchecking), :is(.checking, .unchecking) .check-circle { animation: none; }
    }
    .checked-group h2 { color: var(--muted); }
    .freezer-section, .list-settings { margin-top: 1.45rem; }
    .freezer-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .75rem 0; }
    .freezer-row + .freezer-row { border-top: 1px solid var(--line); }
    .freezer-row span { display: block; font-size: .93rem; }
    summary { color: var(--green); cursor: pointer; padding: .25rem 0; }
    .manage { display: grid; gap: .8rem; padding-top: .85rem; }
    .delete-item { margin-top: 1rem; }
    .tabs { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: 1rem; }
    .tabs a { display: inline-flex; align-items: center; min-height: 2.75rem; padding: .45rem .8rem; border-radius: .6rem; text-decoration: none; font-weight: 650; }
    .tabs a:hover, .tabs a[aria-current=page] { background: var(--sage); }
    .search-form, .pagination { margin-bottom: .75rem; }
    .recipe-picker { position: relative; }
    .recipe-search { margin-top: .38rem; }
    .recipe-options { position: absolute; z-index: 1; inset-inline: 0; top: 100%; margin-top: .25rem; padding: .3rem; border: 1px solid var(--line); border-radius: .65rem; background: var(--paper); box-shadow: 0 .5rem 1.5rem #17221b18; }
    .recipe-options ul { max-height: 15rem; overflow-y: auto; padding: 0; margin: 0; list-style: none; }
    .recipe-options li { cursor: pointer; padding: .65rem .75rem; border-radius: .4rem; overflow-wrap: anywhere; }
    .recipe-options li:hover, .recipe-options .active { background: var(--sage); }
    .recipe-options p:not(:empty) { padding: .55rem .75rem; }
    .recipe-options > button { margin: .25rem; }
    .serving-input { max-width: 10rem; }
    .proposal h2 { margin-bottom: .35rem; }
    .proposal p { margin: .5rem 0; }
    .proposal-items { margin: .9rem 0; }
    .proposal-row { display: grid; gap: .55rem; padding: .9rem 0; border-top: 1px solid var(--line); }
    .proposal-row:last-child { border-bottom: 1px solid var(--line); }
    .proposal-remove { justify-self: end; font-size: .9rem; }
    .item-fields { display: grid; gap: .75rem; }
    .item-grid, .freezer-fields { display: grid; gap: .6rem; }
    .item-grid { grid-template-columns: minmax(10rem, 2fr) minmax(5rem, .8fr) minmax(5rem, .8fr) minmax(9rem, 1.3fr); }
    .origin-fields { display: grid; gap: .65rem; border-radius: .65rem; padding: .65rem; background: var(--sage); }
    .origin-fields > label { max-width: 14rem; }
    .freezer-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .freezer-fields p { grid-column: 1 / -1; font-size: .9rem; }
    .servings { display: flex; flex-wrap: wrap; gap: .65rem; align-items: end; margin: .9rem 0; }
    .servings label { flex: 0 1 11rem; }
    .servings [role=status] { flex-basis: 100%; }
    .servings [role=status]:empty { display: none; }
    .route-list { padding-left: 1.6rem; }
    .card > h2 + .muted { margin-top: .45rem; }
    .route-list li { padding: .45rem 0; border-bottom: 1px solid var(--line); }
    .route-list li span { display: inline-block; min-width: 8.5rem; margin-right: .15rem; }
}
@layer responsive {
    @media (max-width: 64rem) {
        .detail-heading { flex-wrap: wrap; }
        .split { grid-template-columns: 1fr; }
        .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .item-input-name { grid-column: 1 / -1; }
    }
    @media (max-width: 46rem) {
        .shell { display: block; }
        .sidebar { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .45rem 1rem; padding: max(.85rem, env(safe-area-inset-top)) 1rem .7rem; border: 0; border-bottom: 1px solid var(--line); }
        .brand, .logout { padding: 0; }
        .sidebar nav { display: flex; flex-wrap: wrap; order: 1; gap: .35rem; width: 100%; }
        .nav-link { padding: .4rem .55rem; font-size: .9rem; }
        .nav-link svg { width: 1.05rem; height: 1.05rem; }
        .logout { margin-top: 0; font-size: .9rem; }
        .main { padding: 1.25rem 1rem max(2rem, env(safe-area-inset-bottom)); }
        .shell:not(.shell-guest) .main { padding-bottom: calc(5rem + env(safe-area-inset-bottom)); }
        .page-heading { margin-bottom: 1rem; }
        .actions { gap: .4rem; }
        .freezer-fields { grid-template-columns: 1fr; }
    }
}
