* { box-sizing: border-box; }

:root {
    --bg: #f3f4f6;
    --card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #ef4444;
    --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
}

button, input, select {
    font: inherit;
}

button {
    cursor: pointer;
    border: 0;
}

a {
    color: var(--primary);
    text-decoration: none;
}

.container, .app-shell {
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    padding: 16px;
}

.card, .list-card, .quick-add-card, .items-card, .bulk-actions-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
}

.list-grid { display: grid; gap: 12px; }
.list-card { display: flex; flex-direction: column; gap: 6px; color: inherit; }
.form-row { display: flex; gap: 10px; }

input, select {
    width: 100%;
    min-height: 46px;
    padding: 11px 12px;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    background: #fff;
}

input:focus, select:focus {
    outline: 2px solid rgba(37, 99, 235, 0.25);
    border-color: var(--primary);
}

button, .primary-button {
    min-height: 48px;
    padding: 12px 16px;
    border-radius: 14px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
}

button:hover, .primary-button:hover { background: var(--primary-dark); }

.muted, .empty-state { color: var(--muted); }

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 12px 0 14px;
    background: linear-gradient(var(--bg) 80%, rgba(243,244,246,0));
}

.app-header h1 {
    margin: 0;
    font-size: 1.25rem;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.back-link {
    font-weight: 700;
    color: var(--text);
}

.header-total {
    padding: 7px 10px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1e40af;
    font-weight: 800;
    white-space: nowrap;
}

.quick-add-form {
    display: grid;
    gap: 12px;
}

.field {
    display: grid;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 700;
}

.product-field { position: relative; }

.compact-fields {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr;
    gap: 10px;
}

.suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 20;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--shadow);
}

.suggestion-item {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    min-height: 54px;
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
    text-align: left;
    border-bottom: 1px solid #f3f4f6;
}

.suggestion-item:last-child { border-bottom: 0; }
.suggestion-item:hover, .suggestion-item.active { background: #eff6ff; }
.suggestion-meta { color: var(--muted); font-size: 0.82rem; font-weight: 400; }
.suggestion-price { font-weight: 800; white-space: nowrap; }


.bulk-actions-card {
    padding: 12px 16px;
}

.bulk-actions-card form {
    margin: 0;
}

.danger-button {
    width: 100%;
    min-height: 52px;
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.danger-button:hover {
    background: #fecaca;
}

.items-card { padding: 0; overflow: hidden; }
.items-list { display: block; }

.category-heading {
    position: static;
    display: block;
    padding: 12px 16px;
    margin: 0;
    background: #f9fafb;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    line-height: 1.2;
    clear: both;
}

.category-heading:first-child { border-top: 0; }

.shopping-item {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 10px;
    align-items: center;
    min-height: 76px;
    padding: 14px 12px;
    background: #fff;
    border-bottom: 1px solid #f3f4f6;
}

.shopping-item:last-child { border-bottom: 0; }
.category-heading + .shopping-item { border-top: 0; }

.item-text { display: grid; gap: 2px; min-width: 0; }
.item-text strong { overflow-wrap: anywhere; }
.item-text span { color: var(--muted); font-size: 0.85rem; }

.shopping-item.checked .item-text {
    opacity: 0.5;
    text-decoration: line-through;
}

.item-price {
    font-weight: 800;
    white-space: nowrap;
}

.toggle-form, .delete-form { margin: 0; }

.check-button {
    width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 999px;
    border: 2px solid #d1d5db;
    background: #fff;
    color: #16a34a;
    font-size: 1.2rem;
}

.shopping-item.checked .check-button {
    border-color: #16a34a;
    background: #dcfce7;
}

.delete-button {
    width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    border-radius: 999px;
    background: #fee2e2;
    color: var(--danger);
    font-size: 1.5rem;
    line-height: 1;
}

.delete-button:hover { background: #fecaca; }

@media (max-width: 640px) {
    .container, .app-shell {
        padding: 10px 10px 22px;
    }

    .card, .list-card, .quick-add-card, .bulk-actions-card {
        border-radius: 18px;
        padding: 14px;
    }

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

    .compact-fields {
        grid-template-columns: 0.9fr 0.9fr 1.2fr;
        gap: 8px;
    }

    .field span { font-size: 0.82rem; }

    input, select {
        min-height: 48px;
        font-size: 16px;
    }

    .primary-button {
        width: 100%;
        min-height: 54px;
        font-size: 1.05rem;
    }

    .shopping-item {
        grid-template-columns: auto 1fr auto;
        gap: 9px;
        min-height: 78px;
        padding: 14px 10px;
    }

    .delete-form { display: none; }

    .item-price {
        font-size: 0.95rem;
    }
}

/* Bottom delete action + custom confirmation sheet */
.bottom-bulk-actions {
    margin-top: 14px;
    margin-bottom: calc(24px + env(safe-area-inset-bottom));
}

.confirm-backdrop[hidden] {
    display: none;
}

.confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.42);
}

.confirm-sheet {
    width: 100%;
    max-width: 520px;
    padding: 18px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
    border-radius: 24px;
    background: var(--card);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.confirm-sheet h2 {
    margin: 0 0 6px;
    font-size: 1.15rem;
}

.confirm-sheet p {
    margin: 0 0 16px;
    color: var(--muted);
    line-height: 1.4;
}

.confirm-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.secondary-button {
    width: 100%;
    min-height: 52px;
    background: #f3f4f6;
    color: var(--text);
    border: 1px solid var(--border);
}

.secondary-button:hover {
    background: #e5e7eb;
}

.confirm-actions .danger-button {
    min-height: 52px;
}

@media (max-width: 640px) {
    .bottom-bulk-actions {
        margin-top: 12px;
        margin-bottom: calc(18px + env(safe-area-inset-bottom));
    }

    .confirm-backdrop {
        padding: 10px;
    }

    .confirm-sheet {
        border-radius: 22px;
    }
}

/* Category management and store ordering */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.page-header h1 { margin: 8px 0 4px; }
.page-header p { margin: 0; }

.header-title {
    min-width: 0;
    text-align: center;
}

.header-title h1 { margin: 0; }
.header-title span {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.small-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 12px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1e40af;
    font-weight: 800;
    white-space: nowrap;
}

.create-list-form,
.category-form {
    display: grid;
    gap: 12px;
}

.quick-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.quick-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    color: var(--text);
    font-weight: 800;
    text-align: center;
    box-shadow: var(--shadow);
}

.two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.settings-list {
    display: grid;
    gap: 12px;
}

.settings-card,
.sort-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 14px;
    box-shadow: var(--shadow);
}

.settings-card {
    display: grid;
    gap: 12px;
}

.category-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 16px;
    background: color-mix(in srgb, var(--category-color) 22%, white);
}

.category-preview-icon,
.category-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: rgba(255,255,255,0.75);
    font-size: 1.1rem;
}

.category-heading {
    display: flex;
    align-items: center;
    gap: 9px;
    background: color-mix(in srgb, var(--category-color, #d1d5db) 22%, #f9fafb);
    color: #374151;
}

.sort-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    border-left: 8px solid var(--category-color, #d1d5db);
}

.sort-position {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    font-weight: 900;
    color: var(--muted);
}

.sort-label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.sort-label span { font-size: 1.35rem; }
.sort-label strong { overflow-wrap: anywhere; }

.sort-actions {
    display: flex;
    gap: 6px;
}

.sort-actions form { margin: 0; }

.icon-button {
    width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 999px;
    background: #f3f4f6;
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 1.1rem;
}

.icon-button:disabled {
    opacity: 0.35;
    cursor: default;
}

@media (max-width: 640px) {
    .page-header {
        align-items: stretch;
    }

    .quick-links,
    .two-cols {
        grid-template-columns: 1fr;
    }

    .sort-card {
        grid-template-columns: auto 1fr auto;
        padding: 12px;
    }
}

/* Home cleanup patch: clean front page + burger menu */
.home-container {
    min-height: 100vh;
    padding-top: max(16px, env(safe-area-inset-top));
}

.home-header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    gap: 8px;
    padding: 8px 0 16px;
    margin-bottom: 6px;
    background: linear-gradient(var(--bg) 78%, rgba(243,244,246,0));
}

.home-header h1 {
    grid-column: 2;
    margin: 0;
    text-align: center;
    font-size: 1.35rem;
    line-height: 1.2;
}

.burger-menu {
    grid-column: 3;
    justify-self: end;
    position: relative;
}

.burger-menu summary {
    list-style: none;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    cursor: pointer;
}

.burger-menu summary::-webkit-details-marker { display: none; }

.burger-menu summary span {
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: var(--text);
}

.menu-panel {
    position: absolute;
    right: 0;
    top: 54px;
    width: min(92vw, 390px);
    padding: 14px;
    border-radius: 22px;
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: 0 22px 50px rgba(15, 23, 42, 0.18);
}

.menu-section h2 {
    margin: 0 0 12px;
    font-size: 1.05rem;
}

.menu-links {
    display: grid;
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.menu-links a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 15px;
    background: #f9fafb;
    color: var(--text);
    font-weight: 800;
}

.menu-links a::after {
    content: '›';
    color: var(--muted);
    font-size: 1.4rem;
    line-height: 1;
}

.home-list-grid {
    gap: 10px;
}

.home-list-card {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
    padding: 16px;
}

.home-list-card div {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.home-list-card strong {
    font-size: 1.05rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-list-card span:not(.list-arrow) {
    color: var(--muted);
    font-size: 0.9rem;
}

.list-arrow {
    color: var(--muted);
    font-size: 1.8rem;
    line-height: 1;
}

.empty-home {
    text-align: center;
}

.empty-home p {
    margin: 6px 0;
}

/* Remove the old front-page helper blocks if an older view is cached/mixed. */
.quick-links {
    display: none;
}

@media (max-width: 520px) {
    .menu-panel {
        right: -2px;
        width: calc(100vw - 32px);
    }
}

/* Shared page headers and burger menu */
.page-app-header {
    grid-template-columns: auto 1fr auto;
}

.app-header .burger-menu {
    justify-self: end;
}

.app-header:has(.header-total) {
    grid-template-columns: auto 1fr auto auto;
}

.header-title span {
    display: block;
    text-align: center;
    color: var(--muted);
    font-size: 0.8rem;
    margin-top: 2px;
}

.menu-panel-simple {
    display: grid;
    gap: 8px;
}

.menu-panel-simple a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 15px;
    background: #f9fafb;
    color: var(--text);
    font-weight: 800;
}

.menu-panel-simple a::after {
    content: '›';
    color: var(--muted);
    font-size: 1.4rem;
    line-height: 1;
}

/* Categories */
.category-accordion-list {
    margin-bottom: 18px;
}

.category-accordion {
    padding: 0;
    overflow: hidden;
}

.category-accordion > summary {
    list-style: none;
    min-height: 64px;
    padding: 12px 14px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.category-accordion > summary::-webkit-details-marker {
    display: none;
}

.category-accordion .category-preview-icon {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--category-color) 22%, white);
    border: 1px solid color-mix(in srgb, var(--category-color) 44%, white);
    font-size: 1.2rem;
}

.accordion-chevron {
    color: var(--muted);
    font-weight: 900;
    transition: transform 0.18s ease;
}

.category-accordion[open] .accordion-chevron {
    transform: rotate(180deg);
}

.accordion-content {
    padding: 0 14px 14px;
}

.accordion-delete {
    padding: 0 14px 14px;
}

.create-category-card {
    margin-top: 18px;
}

.create-category-card h2 {
    margin-top: 0;
    font-size: 1.15rem;
}

/* Drag sorting */
.draggable-sort-list {
    user-select: none;
}

.draggable-card {
    grid-template-columns: auto auto 1fr;
    touch-action: none;
    transition: transform 0.14s ease, box-shadow 0.14s ease, opacity 0.14s ease;
}

.drag-handle {
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 14px;
    background: #eef2ff;
    color: var(--primary);
    font-size: 1.25rem;
    font-weight: 900;
    cursor: grab;
}

.drag-handle:active {
    cursor: grabbing;
}

.draggable-card.is-dragging {
    opacity: 0.72;
    transform: scale(1.015);
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.16);
    z-index: 5;
}

.sticky-save-button {
    position: sticky;
    bottom: 14px;
    width: 100%;
    margin: 14px 0 calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 14px 30px rgba(37, 99, 235, 0.25);
}

.sort-card .sort-actions {
    display: none;
}

@media (max-width: 520px) {
    .app-header:has(.header-total) {
        grid-template-columns: auto 1fr auto;
    }

    .app-header:has(.header-total) .header-total {
        grid-column: 2 / 3;
        justify-self: center;
        font-size: 0.9rem;
        padding: 5px 9px;
    }

    .app-header:has(.header-total) .burger-menu {
        grid-column: 3 / 4;
        grid-row: 1 / 2;
    }
}

/* Patch v12: category icons and drag sorting ergonomics */
.icon-field select {
    margin-bottom: 8px;
}

.custom-icon-input {
    font-size: 0.9rem;
}

.custom-icon-input::placeholder {
    color: var(--muted);
}

.draggable-sort-list {
    user-select: none;
    touch-action: pan-y;
    padding-bottom: 10px;
}

.draggable-card {
    touch-action: pan-y;
}

.drag-handle {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.sticky-save-button {
    position: static !important;
    bottom: auto !important;
    width: 100%;
    margin: 18px 0 calc(28px + env(safe-area-inset-bottom));
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.18);
}

.sort-help-text {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}


/* Patch v13: edit shopping list */
.settings-form-card {
    margin-top: 10px;
}

.settings-form {
    display: grid;
    gap: 16px;
}

.field-hint {
    color: var(--muted);
    font-weight: 400;
    line-height: 1.35;
}

.full-width-button {
    width: 100%;
    text-align: center;
}

/* Consistent app header/menu patch */
.top-app-bar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 60px;
    padding: max(8px, env(safe-area-inset-top)) 0 10px;
    margin-bottom: 10px;
    background: linear-gradient(var(--bg) 80%, rgba(243,244,246,0));
}

.app-brand {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--text);
    font-size: 1.25rem;
    font-weight: 900;
    letter-spacing: -0.02em;
}

.top-app-bar .burger-menu {
    grid-column: auto;
    justify-self: auto;
    flex: 0 0 auto;
    z-index: 50;
}

.top-app-bar .menu-panel {
    z-index: 60;
}

.page-heading,
.list-page-heading {
    margin: 2px 0 16px;
}

.page-heading h1,
.list-page-heading h1 {
    margin: 4px 0 2px;
    font-size: 1.55rem;
    line-height: 1.12;
    letter-spacing: -0.03em;
}

.page-heading p {
    margin: 4px 0 0;
    color: var(--muted);
}

.home-page-heading h1 {
    margin-top: 0;
}

.list-page-heading {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 10px;
}

.list-page-heading .back-link {
    grid-column: 1 / -1;
    width: fit-content;
}

.list-page-heading .header-title h1,
.list-page-heading .header-title span {
    text-align: left;
}

.list-page-heading .header-title {
    min-width: 0;
}

.list-page-heading .header-title h1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-panel .create-list-form {
    display: grid;
    gap: 10px;
}

.full-width-button {
    width: 100%;
}

/* Keep older headers from taking space if mixed with cached markup. */
.home-header,
.page-app-header {
    display: none;
}

@media (max-width: 520px) {
    .top-app-bar {
        margin-bottom: 8px;
    }

    .app-brand {
        font-size: 1.18rem;
    }

    .list-page-heading {
        grid-template-columns: 1fr;
    }

    .list-page-heading .header-total {
        width: fit-content;
    }
}


/* Navigation cleanup patch */
.menu-panel .menu-section { display: none; }
.menu-links { margin-top: 0; }
.home-create-card { margin-bottom: 16px; }
.home-create-card details summary {
    list-style: none;
    cursor: pointer;
    font-weight: 800;
    color: var(--primary);
    min-height: 44px;
    display: flex;
    align-items: center;
}
.home-create-card details summary::-webkit-details-marker { display: none; }
.inline-create-list-form {
    margin-top: 12px;
    display: grid;
    gap: 12px;
}
.small-text-link {
    display: inline-flex;
    margin-top: 6px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
}
.list-page-heading { align-items: flex-start; }
.page-heading .back-link { display: none; }
@media (max-width: 520px) {
    .list-page-heading {
        grid-template-columns: 1fr auto;
    }
}


/* Usage mode and navigation polish patch */
.home-create-card-bottom {
    margin-top: 18px;
    margin-bottom: max(20px, env(safe-area-inset-bottom));
}
.form-actions-stack {
    display: grid;
    gap: 10px;
}
a.secondary-button {
    text-decoration: none;
    text-align: center;
    box-sizing: border-box;
}
.list-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.list-title-row h1 {
    min-width: 0;
}
.icon-button {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    text-decoration: none;
    background: rgba(79, 70, 229, 0.10);
    color: var(--primary);
    font-weight: 900;
    line-height: 1;
}
.mode-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 5px;
    margin: 12px 0 14px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.06);
}
.mode-switch a {
    min-height: 42px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--muted);
    font-weight: 800;
    font-size: 0.95rem;
}
.mode-switch a.active {
    background: #fff;
    color: var(--text);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}
.quick-add-compact {
    margin-top: 18px;
}
.quick-add-compact details summary {
    list-style: none;
    cursor: pointer;
    font-weight: 900;
    color: var(--primary);
    min-height: 48px;
    display: flex;
    align-items: center;
}
.quick-add-compact details summary::-webkit-details-marker {
    display: none;
}
.quick-add-compact details[open] summary {
    margin-bottom: 12px;
}

.quick-add-compact details summary .toggle-open {
    display: none;
}
.quick-add-compact details[open] summary .toggle-closed {
    display: none;
}
.quick-add-compact details[open] summary .toggle-open {
    display: inline;
}
@media (max-width: 520px) {
    .icon-button {
        width: 36px;
        height: 36px;
    }
    .mode-switch {
        margin-top: 10px;
    }
}

/* Patch v17: consistent cancel button + preserve list mode polish */
.form-actions-stack .secondary-button,
.form-actions-stack .cancel-button {
    min-height: 52px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    background: #e5e7eb;
    color: #374151;
    border: 1px solid #d1d5db;
    font-weight: 900;
    line-height: 1;
    text-align: center;
    box-shadow: none;
}

.form-actions-stack .secondary-button:hover,
.form-actions-stack .cancel-button:hover {
    background: #d1d5db;
}


/* Patch: robust toggle label for mobile shopping mode */
.quick-add-compact details summary.quick-add-toggle {
    gap: 8px;
}
.quick-add-compact details summary.quick-add-toggle::before {
    content: "+";
    display: inline-flex;
    width: 22px;
    height: 22px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.10);
    color: var(--primary);
    font-weight: 900;
    line-height: 1;
}
.quick-add-compact details[open] summary.quick-add-toggle::before {
    content: "−";
}
.quick-add-compact details summary.quick-add-toggle .toggle-open,
.quick-add-compact details summary.quick-add-toggle .toggle-closed {
    display: none !important;
}


/* Patch v19: simpler item rows - product first, quantity in parentheses, no per-item delete icon */
.shopping-item {
    grid-template-columns: auto 1fr auto;
}

.item-text strong {
    display: block;
    font-size: 1.02rem;
    line-height: 1.25;
}

.item-quantity {
    color: var(--muted);
    font-weight: 800;
    white-space: nowrap;
}

.shopping-item.checked .item-quantity {
    color: inherit;
}

@media (max-width: 640px) {
    .shopping-item {
        grid-template-columns: auto 1fr auto;
    }
}


/* Patch v20: nicer empty list state inside item card */
.empty-list-state {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 34px 22px 36px;
    text-align: center;
    color: var(--muted);
}

.empty-list-state h2 {
    margin: 4px 0 0;
    color: var(--text);
    font-size: 1.12rem;
    line-height: 1.2;
}

.empty-list-state p {
    max-width: 310px;
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.45;
}

.empty-list-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border-radius: 999px;
    background: #f3f4f6;
    color: var(--muted);
    font-size: 1.45rem;
    font-weight: 900;
}

@media (max-width: 640px) {
    .empty-list-state {
        padding: 30px 18px 32px;
    }
}


/* Cleanup after unit-price update: keep compact form fields even on mobile */
.compact-fields {
    align-items: start;
}

.compact-fields .field {
    align-self: start;
}

.compact-fields input,
.compact-fields select {
    min-height: 46px;
}

/* Shop mode simplification: no category headers, category icon per item */
.shop-mode-item {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
}

.item-category-icon {
    width: 2.15rem;
    height: 2.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #f3f4f6;
    font-size: 1.15rem;
    flex: 0 0 auto;
}

@media (max-width: 520px) {
    .shop-mode-item {
        grid-template-columns: auto auto minmax(0, 1fr) auto;
        gap: 0.65rem;
    }

    .item-category-icon {
        width: 2rem;
        height: 2rem;
        font-size: 1.05rem;
    }
}


/* Fix shop-mode row layout: one icon, left aligned item text, right aligned price */
.shop-mode-item {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: center;
}

.shop-mode-item .item-text {
    justify-self: start;
    text-align: left;
    min-width: 0;
}

.shop-mode-item .item-text strong {
    display: block;
    text-align: left;
}

.shop-mode-item .item-price {
    justify-self: end;
    text-align: right;
}

.shop-mode-item .item-category-icon + .item-category-icon {
    display: none !important;
}

@media (max-width: 520px) {
    .shop-mode-item {
        grid-template-columns: auto auto minmax(0, 1fr) auto;
        gap: 0.65rem;
    }
}
