/* Pantry quantities share one quiet editor, on the page's paper. */
.notebook .group-head { gap: 12px; }
.notebook .group-label { color: var(--ink); background: var(--sage); padding: 3px 6px; border-radius: 4px; line-height: 1.2; }
.notebook .group-label.g-dairy, .notebook .group-label.g-baking { background: var(--wheat); }
.notebook .group-label.g-meat, .notebook .group-label.g-canned { background: color-mix(in srgb, var(--red) 11%, var(--paper)); }
.notebook .group-label.g-drinks, .notebook .group-label.g-vegfruit, .notebook .group-label.g-prepared { background: var(--blue); }
.notebook .group-label.g-dried, .notebook .group-label.g-spices, .notebook .group-label.g-oils { background: color-mix(in srgb, var(--ochre) 30%, var(--paper)); }
.notebook .pantry-table .row[data-id] .c-name, .notebook .pantry-table .row.parent .c-name { padding-left: calc(var(--step) + 42px); }
.notebook .pantry-table .row.child .c-name { padding-left: calc(var(--step) + 52px); }
/* Desktop is an inventory table with an inline editor. Pointer capability keeps
   a wide touch tablet on the roomy layout; width alone is not a device type. */
@media (min-width: 701px) and (hover: hover) and (pointer: fine) {
 #app .pantry-head { margin-bottom: 12px; gap: 16px; }
 #app .pantry-head h1 { font-size: 32px; }
 #app .pantry-head button { min-height: 32px; padding: 6px 12px; font-size: 13px; }
 .notebook .pantry-edit-help { display: none; }
 .notebook .place-anchors { display: flex; gap: 18px; margin: 0 0 12px; padding: 0 0 8px; }
 .notebook .place-anchors a { min-height: 32px; padding: 4px 0; gap: 7px; font-size: 13px; }
 .notebook .place-anchors .place-mark, .notebook .place-anchors .place-mark img { width: 20px; height: 20px; }
 .notebook .pantry-table { display: table; width: 100%; margin-top: 0; border-collapse: collapse; }
 .notebook .pantry-table tbody { display: table-row-group; }
 .notebook .pantry-table tr, .notebook .pantry-table .amount-edit-row,
 .notebook .pantry-table .group-row, .notebook .pantry-table .add-tr,
 .notebook .pantry-table .hint-row, .notebook .pantry-table .guess-tr { display: table-row; }
 .notebook .pantry-table .group-row th, .notebook .pantry-table .add-tr td { display: table-cell; }
 .notebook .pantry-table td, .notebook .pantry-table th { display: table-cell; padding: 0 8px; width: auto; }
 .notebook .pantry-table .place-row th { height: 48px; padding: 18px 0 7px; border-bottom: 1px solid var(--line-strong); }
 .notebook .pantry-table tbody:first-of-type .place-row th { height: 34px; padding-top: 4px; }
 .notebook .place-title { font-size: 23px; gap: 8px; }
 .notebook .place-title .place-mark, .notebook .place-title .place-mark img { width: 24px; height: 24px; }
 .notebook .place-title .place-count { font-size: 12px; }
 .notebook .pantry-table .group-row th { height: 34px; padding: 8px 0 5px 16px; border-bottom: 1px solid var(--line); }
 .notebook .pantry-table .group-head { gap: 12px; }
 .notebook .pantry-table .group-mark, .notebook .pantry-table .group-mark img { width: 20px; height: 20px; }
 .notebook .pantry-table .row td { height: 36px; border-bottom: 1px solid var(--line); }
 .notebook .pantry-table .row[data-id] .c-name, .notebook .pantry-table .row.parent .c-name { padding: 5px 8px 5px 54px; }
 .notebook .pantry-table .row.child .c-name { padding-left: 66px; }
 .notebook .pantry-table .name { font-size: 17px; }
 .notebook .pantry-table .qty-word { min-height: 28px; font-size: 14px; }
 .notebook .pantry-table .c-qty { width: 150px; text-align: right; }
 .notebook .pantry-table .c-age { display: table-cell; width: 66px; padding-left: 16px; text-align: right; font-size: 12px; }
 .notebook .pantry-table .c-actions { display: table-cell; width: 1px; padding: 0; }
 .notebook .pantry-table .row.amount-open td { border-bottom: 0; }
 .notebook .pantry-table .amount-edit-row > td { display: table-cell; padding: 3px 0 10px 54px; border-bottom: 1px solid var(--line); }
 .notebook .pantry-table .add-tr td { padding: 0 0 0 16px; height: 36px; border-bottom: 0; }
 .notebook .pantry-table .add-tr.open td { height: auto; }
 #app .pantry-table .add-quiet { min-height: 32px; padding: 5px 0; font-size: 13px; }
 .notebook .pantry-table .add-tr:not(.open):hover { background: transparent; }
 .notebook .pantry-table .add-line input, #app .pantry-table .add-line button { min-height: 32px; height: 32px; font-size: 14px; padding-top: 4px; padding-bottom: 4px; }
}


/* An edit stays next to the food, in a bounded work area with one action scope. */
.notebook .pantry-table .row.amount-open { display: none; }
.notebook .pantry-table .amount-edit-row { display: table-row; }
.notebook .pantry-table .amount-edit-row > td { display: table-cell; padding: 12px 0 14px calc(var(--step) + 42px); height: auto; border-bottom: 1px solid var(--line); }
.amount-edit-layout { width: 100%; max-width: 500px; }
.pantry-amount-form, .pantry-location-form { margin: 0; width: 100%; text-align: left; }
.pantry-amount-form [hidden], .pantry-location-form [hidden] { display: none !important; }
.amount-editor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
#app .pantry-editor-title { margin: 0; color: var(--ink); font: 18px/1.3 Georgia,serif; }
.pantry-editor-title:focus { outline: none; }
.amount-mode { display: flex; flex: none; width: max-content; padding: 2px; gap: 0; border: 1px solid var(--line); border-radius: 6px; margin: 0; background: transparent; }
.amount-mode label, .location-places label { display: flex; align-items: center; position: relative; margin: 0; cursor: pointer; }
.amount-mode input, .location-places input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.amount-mode span { display: grid; place-items: center; min-height: 44px; padding: 8px 10px; border-radius: 3px; border: 1px solid transparent; color: var(--ink); font: 400 13px/1.2 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; box-sizing: border-box; }
.amount-mode input:checked + span { background: var(--green); color: var(--white); font-weight: 650; }
.amount-mode input:focus-visible + span, .location-places input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }
.amount-control-row { display: block; }
.amount-exact { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.amount-fields { display: grid; grid-template-columns: minmax(72px,1fr) minmax(108px,1fr); gap: 10px; width: 280px; max-width: 100%; align-items: end; }
.amount-fields label, .amount-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; margin: 0; font-size: 12px; }
.amount-field > label { margin: 0; font-weight: 400; }
#app .pantry-amount-form input[type=number] { appearance: textfield; width: 100%; min-width: 0; min-height: 44px; height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); color: var(--ink); text-align: left; font: 16px/1.3 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; }
.pantry-amount-form input[type=number]::-webkit-inner-spin-button, .pantry-amount-form input[type=number]::-webkit-outer-spin-button { appearance: none; margin: 0; }
#app .pantry-amount-form input[type=number]:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; box-shadow: none; }
.amount-select { display: block; min-width: 0; }
.amount-package { margin: 0; }
.amount-package-label { display: block; font-size: 12px; margin-bottom: 4px; }
.amount-package-label > span { color: var(--muted); }
.amount-package .visually-hidden { position: absolute; }
.amount-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin-top: 12px; }
#app .amount-actions button { min-height: 44px; padding: 8px 10px; font-size: 13px; border-radius: 6px; }
#app .amount-actions .text-button { background: transparent; text-decoration: none; color: var(--muted); }
#app .amount-actions .text-button:hover { color: var(--ink); text-decoration: underline; }
.amount-row-actions { display: inline-flex; gap: 4px; margin-left: 12px; }
.amount-error { margin: 10px 0 0; color: var(--red); font-size: 13px; }
.amount-rough { display: grid; grid-template-columns: minmax(0,1fr) 132px; grid-template-rows: 34px 40px; column-gap: 14px; width: 380px; max-width: 100%; }
.amount-estimate { display: contents; }
.amount-estimate output { grid-column: 1; grid-row: 1; align-self: end; font: 20px/1.2 Georgia,serif; text-transform: capitalize; color: var(--ink); }
.amount-illustration { grid-column: 2; grid-row: 1/span 2; width: 132px; height: 74px; display: grid; justify-content: center; place-items: center; align-self: center; }
.amount-illustration img { display: block; width: 62px; height: 62px; object-fit: contain; transform: scale(var(--art-scale,1)); }
.amount-illustration.amount-pile { grid-template-columns: repeat(3,22px); grid-auto-rows: 28px; align-content: center; }
.amount-illustration.amount-pile img { width: 29px; height: 29px; transform: rotate(calc((var(--piece) - 2) * 5deg)); }
.amount-illustration.amount-pile:not(.amount-retail-packs):has(img:nth-child(2)):not(:has(img:nth-child(3))) { grid-template-columns: repeat(2,30px); }
.amount-illustration.amount-pile:not(.amount-retail-packs):has(img:nth-child(2)):not(:has(img:nth-child(3))) img { width: 38px; height: 38px; }
.amount-illustration.amount-retail-packs img { width: 72px; height: 72px; transform: none; }
.amount-illustration.amount-retail-packs.amount-pile { grid-template-columns: repeat(2,64px); grid-auto-rows: 74px; gap: 4px; }
.amount-illustration.amount-retail-packs.amount-pile img { width: 64px; height: 64px; transform: none; }
#app .pantry-amount-form input[type=range] { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 44px; min-height: 44px; align-self: center; padding: 0 2px; margin: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; outline: none; cursor: pointer; }
#app .pantry-amount-form input[type=range]::-webkit-slider-runnable-track { height: 3px; border: 0; border-radius: 2px; background: linear-gradient(to right,var(--red) 0 var(--rough-fill,50%),var(--line) var(--rough-fill,50%) 100%); }
#app .pantry-amount-form input[type=range]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6.5px; border-radius: 50%; border: 2px solid var(--red); background: var(--wheat); box-shadow: 0 0 0 3px var(--paper); }
#app .pantry-amount-form input[type=range]::-moz-range-track { height: 3px; border: 0; border-radius: 2px; background: linear-gradient(to right,var(--red) 0 var(--rough-fill,50%),var(--line) var(--rough-fill,50%) 100%); }
#app .pantry-amount-form input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--red); background: var(--wheat); box-shadow: 0 0 0 3px var(--paper); }
#app .pantry-amount-form input[type=range]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--ink); outline-offset: 4px; }
#app .pantry-amount-form input[type=range]:focus-visible::-moz-range-thumb { outline: 2px solid var(--ink); outline-offset: 4px; }
.pantry-location-form .pantry-editor-title { margin-bottom: 12px !important; }
.location-fields { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px 20px; }
.location-places { display: flex; border: 0; padding: 0; margin: 0; min-width: 0; }
.location-places legend, .location-category > label { padding: 0; font-size: 12px; font-weight: 400; margin: 0 0 4px; }
.location-places label span { min-height: 44px; display: flex; align-items: center; padding: 8px 10px; border: 1px solid transparent; border-radius: 4px; font-size: 13px; }
.location-places input:checked + span { background: var(--sage); border-color: var(--green); font-weight: 650; }
.location-category { flex: 1; min-width: 180px; max-width: 240px; }
.location-category > label { display: block; }
.pantry-table .qty-word { white-space: nowrap; text-align: right; line-height: 1.35; }
.pantry-table .package-detail { display: block; font: 12px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; color: var(--muted); }
@media (min-width:701px) and (hover:hover) and (pointer:fine) {
 .notebook .pantry-table .amount-edit-row > td { padding: 10px 0 12px 54px; }
 #app .pantry-editor-title { font-size: 17px; }
 .amount-mode span { min-height: 28px; padding: 5px 9px; font-size: 12px; }
 .amount-fields { grid-template-columns: 72px 108px; width: auto; gap: 8px; }
 .amount-package .amount-fields { grid-template-columns: 72px 88px; }
 #app .pantry-amount-form input[type=number] { height: 32px; min-height: 32px; font-size: 14px; padding: 5px 10px; }
 #app .amount-actions button { min-height: 32px; padding: 5px 8px; font-size: 12px; }
 .location-places label span { min-height: 32px; padding: 5px 9px; }
 .amount-actions { gap: 6px 8px; }
 #app .pantry-amount-form input[type=range] { height: 28px; min-height: 28px; }
}
@media (max-width:700px) {
 .notebook .pantry-table .amount-edit-row, .notebook .pantry-table .amount-edit-row > td { display: block; }
 .notebook .pantry-table .amount-edit-row > td { padding: 12px 8px 14px 16px; }
 .notebook .pantry-table .row[data-id] .c-name, .notebook .pantry-table .row.parent .c-name { padding-left: 16px; }
 .notebook .pantry-table .row.child .c-name { padding-left: 26px; }
 .amount-editor-head { flex-wrap: wrap; }
 .amount-mode { margin-left: auto; }
 .amount-row-actions { margin-left: 0; }
 .notebook:has(.pantry-table) .page-footer { padding-right: 88px; }
}
@media (forced-colors:active) {
 .amount-mode input:checked + span, .location-places input:checked + span { forced-color-adjust: none; background: Highlight; color: HighlightText; border-color: Highlight; }
 #app .pantry-amount-form input[type=range]::-webkit-slider-runnable-track { background: CanvasText; }
 #app .pantry-amount-form input[type=range]::-webkit-slider-thumb { background: Highlight; border-color: CanvasText; }
 #app .pantry-amount-form input[type=range]::-moz-range-track { background: CanvasText; }
 #app .pantry-amount-form input[type=range]::-moz-range-thumb { background: Highlight; border-color: CanvasText; }
}

/* Compact visible controls keep full touch targets, including on a narrow phone. */
.amount-range { grid-column: 1; grid-row: 2; display: flex; align-items: center; min-width: 0; }
.quantity-stepper { display: flex; align-items: center; min-width: 0; }
#app .amount-step, .intake .amount-step { flex: 0 0 44px; width: 44px; min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--ink); font-size: 18px; border-radius: 6px; }
#app .amount-step:hover, .intake .amount-step:hover { background: var(--sage); }
.amount-range input { min-width: 0; flex: 1; }
.quantity-stepper input { min-width: 0; }
/* Exact parts of one (F01): five buttons under the quantity, because a phone's number pad has no slash. Typing 1/2,
   1 1/2, 0.5 or the single-character half all work too. taste-gate: allow T12 because these are 44px buttons on touch and 32px only for a fine pointer on desktop, per the desktop density rule. */
.amount-fractions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#app .amount-fraction { min-width: 44px; height: 44px; min-height: 44px; padding: 0 6px; border: 1px solid var(--line); border-radius: var(--button-radius); background: var(--white); color: var(--ink); font: normal 20px/1 Georgia, serif; cursor: pointer; }
#app .amount-fraction:hover { border-color: var(--green); background: var(--sage); }
#app .amount-fraction:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.amount-qty-error { margin: 6px 0 0; color: var(--red); font-size: 14px; }
.amount-qty-error[hidden] { display: none; }
/* The exact field holds text now, and a mixed fraction such as 123 7/8 must be readable whole. It is a boxed field with
   room for eight characters; 16px on a phone so iOS does not zoom, compact for a fine pointer on desktop. */
#app .pantry-amount-form input.qty-input[type=text] { box-sizing: border-box; width: 9ch; min-width: 104px; height: 44px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--button-radius); background: var(--white); text-align: center; font: normal 18px/1 Georgia, serif; }
#app .pantry-amount-form input.qty-input:focus-visible { border-color: var(--green); box-shadow: 0 0 0 2px var(--green); }
#app .pantry-amount-form input.qty-input[type=text][aria-invalid="true"] { border-color: var(--red); box-shadow: 0 0 0 1px var(--red); }
@media (hover: hover) and (pointer: fine) and (min-width: 701px) { #app .pantry-amount-form input.qty-input[type=text] { height: 32px; min-width: 92px; font-size: 16px; } }
/* While a refusal shows, Quantity takes the full row so the sentence reads on one or two lines; Unit drops below it. */
.amount-fields:has(.amount-qty-error:not([hidden])) > .amount-field:first-child { grid-column: 1 / -1; }
@media (hover: hover) and (pointer: fine) and (min-width: 701px) { #app .amount-fraction { min-width: 32px; height: 32px; min-height: 32px; font-size: 17px; } }
.amount-fields { grid-template-columns: minmax(140px,1.4fr) minmax(108px,1fr); width: 320px; }
/* Save is the ordinary go-ahead, so it is evergreen like every other save (Chief's review, November 9). Brick is kept
   for the refusal sentence and the approved rough slider. */
#app .amount-actions .primary { background: var(--green); color: var(--white); border-color: var(--green); }
#app .amount-actions .primary:hover { background: var(--green-hover); }
#app .amount-actions .text-button { padding-left: 5px; padding-right: 5px; font-size: 12px; }
.amount-actions { gap: 4px; }
.amount-row-actions { margin-left: 0; gap: 0; }
@media (min-width:701px) and (hover:hover) and (pointer:fine) {
 #app .amount-step { flex-basis: 28px; width: 28px; min-height: 32px; font-size: 16px; }
 .amount-fields { grid-template-columns: 128px 108px; width: auto; }
}
@media (max-width:700px) {
 .notebook .place-tabs { margin-right: 0; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 2px; }
 .notebook .place-tabs [role=tab] { min-width: 0; gap: 3px; padding: 0 2px; font-size: 12px; }
 .notebook .place-tabs .place-mark, .notebook .place-tabs .place-mark img { width: 19px; height: 19px; }
 .notebook .place-tabs .place-count { font-size: 10px; }
 .notebook .pantry-table .amount-edit-row > td { padding: 12px 0 14px; }
 .amount-rough { width: 100%; grid-template-columns: minmax(0,1fr) 132px; grid-template-rows: 74px 44px; column-gap: 0; }
 .amount-illustration { grid-row: 1; }
 .amount-estimate output { align-self: center; }
 .amount-range { grid-column: 1 / -1; }
 #app .amount-actions .primary { font-weight: 650; }
}

/* Review stays in the existing paper dialog and uses the app's real unit lists. */
.intake .intake-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 4px 8px; }
.intake .intake-row > .check { min-width: 0; }
.intake .intake-row > .row-editor, .intake .sheet-source-line { grid-column: 1 / -1; }
.intake .row-editor { padding: 12px 0; min-width: 0; }
.intake .row-editor [hidden] { display: none !important; }
.intake .row-editor label { display: flex; flex-direction: column; gap: 5px; margin: 0 0 12px; font-size: 12px; }
.intake .row-editor .amount-mode { margin: 0 0 12px; }
.intake .row-editor .amount-mode label { margin: 0; }
.intake .row-editor .form-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 12px; }
.intake .row-editor .amount-fields { width: 100%; }
.intake .row-editor input { min-width: 0; width: 100%; min-height: 44px; font-size: 16px; }
.intake .quantity-stepper input { text-align: center; padding: 8px 2px; }
.intake .quantity-stepper { border: 1px solid var(--line); border-radius: 6px; background: var(--white); }
.intake .quantity-stepper input { border: 0; background: transparent; }
.intake .row-editor .amount-step { margin: 0; }
.intake .optional { color: var(--muted); }
.intake .review-add { margin-top: 16px; }
.intake .review-add > label { display: block; font-size: 13px; margin-bottom: 5px; }
.intake .review-add-line { display: flex; gap: 8px; }
.intake .review-add-line input { flex: 1; min-width: 0; font-size: 16px; }
.intake .review-add-line button { flex: none; }
.intake .form-actions { flex-wrap: wrap; }
.intake .row-edit, .intake .form-actions button { min-height: 44px; }
@media (max-width:380px) {
 .intake .review-exact.amount-fields { grid-template-columns: minmax(130px,1.2fr) minmax(100px,1fr); gap: 6px; }
 .intake .review-add-line { flex-wrap: wrap; }
 .intake .row-editor .form-grid { gap: 8px; }
}

.amount-package { min-width: 0; max-width: 100%; }
.amount-package .amount-fields { width: 280px; }
@media (min-width:701px) and (hover:hover) and (pointer:fine) { .amount-package .amount-fields { width: auto; } }

.intake .row-editor { border: 0; background: transparent; border-radius: 0; }
.intake .row-editor > label { margin-bottom: 12px; }
.intake .row-editor .amount-field > label { margin-bottom: 0; }
.intake .row-editor .amount-fields > label { margin-bottom: 0; }
.intake .row-editor .amount-fields { margin-bottom: 12px; }
.intake .row-editor .amount-mode label { flex-direction: row; }
.intake .row-editor .review-details { margin-top: 4px; }
.intake .review-details > summary { display: flex; align-items: center; min-height: 44px; color: var(--muted); font-size: 13px; cursor: pointer; }
.intake .review-details > summary:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.intake .review-details[open] > summary { font-weight: 650; color: var(--ink); }
@media (min-width:701px) and (hover:hover) and (pointer:fine) {
 .intake .row-editor input:not([type=radio]) { min-height: 32px; height: 32px; font-size: 14px; padding-top: 5px; padding-bottom: 5px; }
 .intake .row-editor .amount-step { flex-basis: 28px; width: 28px; min-height: 32px; font-size: 16px; }
}

/* Review provenance and refusals stay with the food at every width. */
.intake .intake-row > .sheet-tag { grid-column: 1 / -1; justify-self: start; }
.intake .review-field-error { color: var(--red); margin: 6px 0 0; overflow-wrap: anywhere; }
.intake .review-field-error[hidden] { display: none; }
.intake .quantity-stepper input[type=text] { min-width: 9ch; }
.amount-edit-layout > .pantry-item-note { display: block; margin: 0 0 10px; overflow-wrap: anywhere; }

/* Enlarged text needs an intrinsic field height, including at fixed desktop widths. */
.intake .row-editor input:not([type=radio]) { height: auto; line-height: 1.3; }

/* The sheet stays inside the visible viewport while the phone keyboard is up. */
@media (max-width:768px) {
 body.form-keyboard-open dialog.pantry-update.intake {
  top: calc(var(--form-visible-top,0px) + 12px);
  bottom: auto;
  margin-block: 0;
  max-height: calc(var(--form-visible-height,100dvh) - 24px);
 }
}

/* A refusal belongs to the actual field, including Place/Group in the grid. */
.intake .review-field-error { grid-column: 1 / -1; }

/* Uncertain checks keep their item, current facts and intentional next step readable. */
.intake .confirm-row { grid-template-columns: minmax(0,1fr); gap: 8px; }
.intake .confirm-row > * { min-width: 0; max-width: 100%; }
.intake .confirm-row > p { margin: 0; }
.intake .confirm-row > button { justify-self: start; min-height: 44px; white-space: normal; }
