/* Additive selection controls: the approved menu geometry and photo ratio stay intact. */
:root { --selection-bar-height: 116px; }
#menu-grid .dish-open { display: flex; flex-direction: column; align-items: stretch; flex: 1 1 auto; width: 100%; min-width: 0; padding: 0; margin: 0; border: 0; background: transparent; text-align: left; }
#menu-grid .dish-open:focus-visible { outline-offset: -3px; }
#menu-grid .dish-open:focus-visible .image-expand { opacity: 1; }
#menu-grid .dish-actions { display: flex; justify-content: flex-end; flex: 0 0 auto; min-width: 0; padding: 0 17px 13px; }
.quantity-control { width: 128px; max-width: 100%; min-height: 44px; flex: 0 0 auto; }
.quantity-control button { min-height: 44px; padding: 0; margin: 0; border: 0; color: var(--red); touch-action: manipulation; }
.quantity-control svg { display: block; width: 17px; height: 17px; stroke-width: 2; pointer-events: none; }
.dish-add { display: flex; align-items: center; justify-content: center; gap: 5px; width: 100%; border-radius: 5px; background: #faecd8; font-size: 13px; font-weight: 600; line-height: 1.4; }
.dish-add:hover { background: #f3ddc3; }
.quantity-stepper { display: grid; grid-template-columns: 44px minmax(0,1fr) 44px; align-items: center; width: 100%; min-height: 44px; border-radius: 5px; background: var(--cream); box-shadow: inset 0 0 0 1px var(--line); }
.quantity-stepper button { display: flex; align-items: center; justify-content: center; width: 44px; border-radius: 5px; background: transparent; }
.quantity-stepper button:hover { background: #faecd8; }
.quantity-stepper button:disabled { opacity: .35; }
.quantity-value { color: var(--ink); text-align: center; font: 600 14px/1.4 var(--sans); font-variant-numeric: tabular-nums; }
.dish-unavailable { display: flex; align-items: center; justify-content: center; min-height: 44px; font-size: 12px; color: var(--muted); }
#detail-selection-control { margin-block: 14px; }

/* Keep the compact list's original image and text columns, with controls below its text. */
#menu-grid[data-view=list] .dish-card { display: flex; flex-direction: column; gap: 0; padding: 12px; }
#menu-grid[data-view=list] .dish-open { display: grid; grid-template-columns: 120px minmax(0,1fr); align-items: start; gap: 14px; }
#menu-grid[data-view=list] .dish-actions { margin-left: 134px; padding: 7px 0 0; }

body.has-selection { padding-bottom: calc(var(--selection-bar-height) + 28px); }
.selection-bar { position: fixed; z-index: 23; left: 50%; bottom: 18px; width: min(560px,calc(100% - 32px)); transform: translateX(-50%); border: 1px solid #b61926; border-radius: 10px; background: var(--red); color: var(--cream); box-shadow: 0 6px 26px #71352d30; }
#open-selection { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 74px; padding: 12px 18px; border: 0; border-radius: inherit; background: transparent; color: inherit; text-align: left; }
#open-selection:focus-visible { outline-color: var(--cream); outline-offset: -5px; }
.selection-bar-summary { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#selection-bar-count { font-size: 12px; line-height: 1.5; }
.selection-bar-money { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 7px; line-height: 1.35; }
#selection-bar-price-label { font-size: 11px; }
#selection-bar-total { font: 500 23px/1.2 Georgia,serif; font-variant-numeric: tabular-nums; }
.selection-bar-money small { font-size: 9px; }
.selection-bar-market { font-size: 10px; line-height: 1.5; color: #ffe1b5; }
.selection-bar-open { display: flex; align-items: center; justify-content: flex-end; gap: 7px; max-width: 40%; font-size: 13px; font-weight: 600; line-height: 1.5; }
.selection-bar-open svg { width: 16px; height: 16px; }

#selection-dialog { width: min(620px,calc(100% - 40px)); max-height: 90vh; max-height: 90dvh; padding: 0; border-radius: 12px; overflow: hidden; }
#selection-dialog[open] { display: flex; flex-direction: column; }
.selection-header { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px 14px; background: var(--paper); }
.selection-header > div { min-width: 0; }
.selection-header h2 { font-family: var(--serif); font-size: 25px; font-weight: 600; line-height: 1.4; }
html[lang=zh-CN] .selection-header h2 { font-weight: 700; }
html[lang=en] .selection-header h2 { font-family: Georgia,serif; }
html[lang=km] .selection-header h2 { font-family: var(--sans); font-size: 21px; line-height: 1.65; }
#selection-purpose { margin-top: 5px; font-size: 12px; line-height: 1.6; color: var(--muted); }
.selection-close { position: static; display: inline-flex; flex: 0 0 44px; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--cream); color: var(--red); touch-action: manipulation; }
.selection-close svg { display: block; width: 20px; height: 20px; stroke-width: 2; pointer-events: none; }
.selection-tools { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 0 22px; border-block: 1px solid var(--line); background: var(--cream); }
#selection-count { font-size: 12px; color: var(--muted); }
#clear-selection { flex: 0 0 auto; min-height: 44px; padding: 0 2px; border: 0; background: transparent; color: var(--red); font-size: 12px; }
.selection-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 0 22px; }
.selection-items { list-style: none; margin: 0; padding: 0; }
.selection-item { padding: 16px 0; border-bottom: 1px solid var(--line); }
.selection-item:last-child { border-bottom: 0; }
.selection-item-main { display: grid; grid-template-columns: 70px minmax(0,1fr) 44px; align-items: start; gap: 11px; }
.selection-item-main > img { display: block; width: 70px; height: auto; aspect-ratio: 744 / 468; object-fit: contain; object-position: center; background: white; border: 1px solid #f0e4d5; border-radius: 4px; }
.selection-name { overflow-wrap: anywhere; font-family: var(--serif); font-size: 17px; font-weight: 600; line-height: 1.5; }
.selection-name[lang=zh-CN] { font-weight: 700; }
.selection-name[lang=en] { font-family: Georgia,serif; }
.selection-name[lang=km] { font-family: var(--sans); line-height: 1.7; }
.selection-name.secondary { margin-top: 3px; font-family: var(--sans); font-size: 12px; font-weight: 400; line-height: 1.6; color: var(--muted); }
.selection-name.secondary[lang=zh-CN] { font-size: 14px; font-weight: 600; }
.selection-name.secondary[lang=km] { font-size: 13px; line-height: 1.75; }
.selection-remove { display: flex; align-items: center; justify-content: center; width: 44px; min-height: 44px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--muted); touch-action: manipulation; }
.selection-remove:hover { color: var(--red); background: var(--cream); }
.selection-remove svg { width: 18px; height: 18px; pointer-events: none; }
.selection-item-bottom { display: grid; grid-template-columns: minmax(0,1fr) 128px; align-items: center; gap: 14px; margin-top: 10px; }
.selection-item-price { min-width: 0; }
.selection-item-price > p:first-child { font-size: 11px; line-height: 1.7; color: var(--muted); }
.selection-item-subtotal { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px; margin-top: 2px; line-height: 1.5; }
.selection-item-subtotal span { font-size: 12px; }
.selection-item-subtotal strong { font-family: var(--sans); font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--red); overflow-wrap: anywhere; }
.selection-empty { padding: 28px 0 34px; text-align: center; }
.selection-empty > svg { width: 36px; height: 36px; color: var(--red); margin-bottom: 12px; }
.selection-empty h3 { font-size: 19px; }
.selection-empty p { margin: 7px 0 18px; font-size: 13px; color: var(--muted); }
.selection-empty .button { font-size: 13px; }
.selection-footer { flex: 0 0 auto; padding: 16px 22px 20px; border-top: 1px solid var(--line); background: var(--cream); }
.selection-total-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.selection-total-row > span { font-size: 13px; }
.selection-total-row > div { flex-shrink: 0; }
#selection-total { font: 500 29px/1.2 Georgia,serif; font-variant-numeric: tabular-nums; color: var(--red); }
.selection-total-row > div > span { font-size: 10px; color: var(--muted); margin-left: 7px; }
.selection-market-note { font-size: 12px; line-height: 1.7; color: var(--red); margin-top: 6px; }
.selection-staff-guide { margin: 4px 0 18px; padding: 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--cream); }
.selection-staff-note { font-size: 12px; line-height: 1.7; color: var(--ink); }
.selection-disclaimer { margin-top: 5px; font-size: 11px; line-height: 1.7; color: var(--muted); }
.selection-header h2, #selection-purpose, #selection-count, .selection-staff-note, .selection-disclaimer, .selection-market-note { overflow-wrap: anywhere; }
.selection-storage-note { padding: 10px 0; font-size: 12px; color: var(--red); }
.selection-copy-tools { margin: 0 0 18px; }
#copy-selection { min-height: 44px; max-width: 100%; padding: 8px 16px; border: 1px solid var(--line); border-radius: 5px; color: var(--red); background: var(--cream); font: inherit; font-size: 13px; overflow-wrap: anywhere; }
#selection-copy-status, #selection-copy-fallback label { font-size: 12px; line-height: 1.7; color: var(--muted); }
#selection-copy-status:empty { display: none; }
#selection-copy-status { margin-top: 8px; }
#selection-copy-text { display: block; box-sizing: border-box; width: 100%; max-width: 100%; margin-top: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); color: var(--ink); font: 16px/1.6 var(--sans); resize: vertical; }
.clear-selection-confirm { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.clear-selection-confirm > p:first-child { font-size: 14px; font-weight: 600; line-height: 1.6; }
.clear-selection-confirm > p:nth-child(2) { margin-top: 3px; font-size: 12px; color: var(--muted); }
.clear-selection-confirm > div { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.clear-selection-confirm button { min-height: 44px; padding: 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); font-size: 13px; line-height: 1.6; }
#confirm-clear-selection { background: var(--red); color: var(--paper); border-color: var(--red); }

@media(max-width:900px) {
  #menu-grid[data-view=list] .dish-open { grid-template-columns: 110px minmax(0,1fr); gap: 16px; }
  #menu-grid[data-view=list] .dish-actions { margin-left: 126px; }
}
@media(max-width:650px) {
  #menu-grid .dish-actions { padding: 0 9px 9px; }
  #menu-grid[data-view=list] .dish-card { padding: 10px; }
  #menu-grid[data-view=list] .dish-open { grid-template-columns: 91px minmax(0,1fr); gap: 12px; }
  #menu-grid[data-view=list] .dish-actions { margin-left: 103px; padding: 7px 0 0; }
  body.has-selection { padding-bottom: calc(var(--selection-bar-height) + 16px); }
  body.has-selection .mobile-actions { display: none; }
  .selection-bar { left: 0; right: 0; bottom: 0; width: auto; transform: none; border: 0; border-top: 1px solid #b61926; border-radius: 0; }
  #open-selection { min-height: 74px; gap: 12px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom,0px)); }
  #selection-bar-total { font-size: 22px; }
  .selection-bar-open { font-size: 12px; gap: 4px; }
  #selection-dialog { inset: auto 0 0; margin: 0; width: 100%; max-width: none; max-height: calc(100vh - 12px); max-height: calc(100dvh - 12px); border-radius: 14px 14px 0 0; }
  .selection-header { padding: 16px 16px 12px; }
  .selection-header h2 { font-size: 23px; }
  .selection-tools, .selection-scroll { padding-inline: 16px; }
  .selection-item-main { grid-template-columns: 64px minmax(0,1fr) 44px; gap: 9px; }
  .selection-item-main > img { width: 64px; }
  .selection-item-bottom { gap: 12px; }
  .selection-footer { padding: 13px 16px calc(14px + env(safe-area-inset-bottom,0px)); }
  #selection-total { font-size: 27px; }
}
@media(max-width:360px) {
  #menu-grid .dish-actions { padding-inline: 8px; }
  #menu-grid[data-view=list] .dish-open { grid-template-columns: 81px minmax(0,1fr); gap: 10px; }
  #menu-grid[data-view=list] .dish-actions { margin-left: 91px; padding-inline: 0; }
  .selection-item-main { grid-template-columns: 52px minmax(0,1fr) 44px; gap: 8px; }
  .selection-item-main > img { width: 52px; }
  .selection-item-bottom { gap: 8px; }
  .selection-bar-open { max-width: 36%; }
}
@media(max-height:560px) {
  #selection-dialog[open] { display: block; overflow: auto; }
  .selection-header { position: sticky; top: 0; z-index: 1; }
  .selection-scroll { overflow: visible; }
}

/* Recovery notices sit in the document flow and never block browsing. */
.selection-restored-banner { margin: 0 0 16px; padding: 13px 16px; border: 1px solid var(--line); border-left: 3px solid var(--red); border-radius: 5px; background: var(--cream); }
.selection-restored-banner p, .selection-restored-note { font-size: 12px; line-height: 1.8; color: var(--ink); overflow-wrap: anywhere; }
.selection-restored-actions { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 3px; }
.selection-restored-actions button { min-height: 44px; padding: 6px 0; border: 0; background: transparent; color: var(--red); font-size: 12px; text-align: left; }
#review-restored-selection { font-weight: 600; }
.selection-restored-note { margin: 14px 0 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--cream); }

/* V4.1: specification controls fit the existing card action area. */
#menu-grid .dish-price .dish-price-unit { font: 400 11px/1.5 var(--sans); color: var(--muted); margin-left: 5px; overflow-wrap: anywhere; }
#menu-grid .dish-price { flex-wrap: wrap; }
.spec-choose { padding: 5px 6px !important; overflow-wrap: anywhere; }
.spec-selected-count { display: inline-flex; justify-content: center; align-items: center; min-width: 20px; padding: 1px 4px; border-radius: 10px; background: var(--red); color: var(--paper); font: 600 11px/1.5 var(--sans); }
.selection-spec-name { margin-top: 7px; color: var(--red); font: 600 13px/1.6 var(--sans); overflow-wrap: anywhere; }
#detail-unit { font: 400 13px/1.6 var(--sans); color: var(--muted); }
#spec-dialog { width: min(520px,calc(100% - 32px)); max-height: 90vh; max-height: 90dvh; padding: 0; border-radius: 12px; overflow: hidden; }
#spec-dialog[open] { display: flex; flex-direction: column; }
#spec-title { font-size: 22px; overflow-wrap: anywhere; }
.spec-eyebrow { margin-bottom: 4px; color: var(--red); font: 600 12px/1.5 var(--sans); }
#spec-guide { flex: 0 0 auto; margin: 0; padding: 0 22px 14px; color: var(--muted); font-size: 12px; line-height: 1.7; }
#spec-options { min-height: 0; overflow: auto; overscroll-behavior: contain; list-style: none; margin: 0; padding: 0 22px; }
.spec-option { display: grid; grid-template-columns: minmax(0,1fr) 128px; align-items: center; gap: 14px; padding: 16px 0; border-top: 1px solid var(--line); }
.spec-option h3 { font: 700 16px/1.6 var(--sans); overflow-wrap: anywhere; }
.spec-secondary { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.spec-option p { margin-top: 4px; font-size: 13px; color: var(--red); overflow-wrap: anywhere; }
.spec-option p span { color: var(--muted); font-size: 11px; }
.spec-footer { flex: 0 0 auto; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--cream); }
.spec-footer .button { width: 100%; min-height: 44px; font-size: 13px; }
@media(max-width:650px) {
  #spec-dialog { inset: auto 0 0; margin: 0; width: 100%; max-width: none; max-height: calc(100dvh - 16px); border-radius: 14px 14px 0 0; }
  #spec-guide, #spec-options { padding-inline: 16px; }
  .spec-footer { padding: 14px 16px calc(14px + env(safe-area-inset-bottom,0px)); }
}
@media(max-height:480px) {
  #spec-dialog[open] { display: block; overflow: auto; }
  #spec-options { overflow: visible; }
}
