/* Large kitchen 5-pane layout — device-local ratios only. */

.kitchen-screen {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.kitchen-screen[hidden] {
  display: none !important;
}

.kitchen-layout {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-rows:
    minmax(72px, var(--kitchen-allfood-fr, 16fr))
    minmax(160px, var(--kitchen-bottom-fr, 84fr));
  background: var(--bg, #1a1a1a);
  touch-action: manipulation;
}

.kitchen-allfood-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: row;
  border-bottom: 1px solid var(--border-soft, #3a3a3a);
  overflow: hidden;
}

.kitchen-handle--allfood {
  flex: 0 0 28px;
  width: 28px;
  align-self: stretch;
  margin: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--border-soft, #3a3a3a);
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg-muted, #aaa);
  font-size: 0.85rem;
  line-height: 1;
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 4;
}

.kitchen-handle--allfood:active,
.kitchen-layout.is-resizing .kitchen-handle--allfood {
  background: rgba(255, 255, 255, 0.14);
}

.kitchen-allfood-wrap .kitchen-overview-pane,
.kitchen-allfood-wrap .kitchen-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

/* Kitchen B (allfood) — history chrome hidden; #dishup route unchanged. */
#kitchen-allfood-pane .dishup-history {
  display: none;
}

.kitchen-quad {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns:
    minmax(120px, var(--kitchen-col-left-fr, 55fr))
    minmax(120px, var(--kitchen-col-right-fr, 45fr));
  grid-template-rows:
    minmax(120px, var(--kitchen-row-top-fr, 50fr))
    minmax(120px, var(--kitchen-row-bottom-fr, 50fr));
  overflow: hidden;
}

.kitchen-cell {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-soft, #3a3a3a);
  border-bottom: 1px solid var(--border-soft, #3a3a3a);
}

.kitchen-cell--udon,
.kitchen-cell--fry {
  border-right: 0;
}

.kitchen-cell--side,
.kitchen-cell--fry {
  border-bottom: 0;
}

.kitchen-cell > .kitchen-overview-pane,
.kitchen-cell > .kitchen-pane,
.kitchen-cell > .dishup-mount,
.kitchen-cell > .udon-mount,
.kitchen-cell > .side-mount,
.kitchen-cell > .fry-mount {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.kitchen-topband-wrap > .kitchen-overview-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.kitchen-overview-pane .kitchen-overview-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#kitchen-unserved-pane .kitchen-overview-body {
  overflow-x: auto;
  overflow-y: hidden;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.55rem;
  padding: 0.45rem 0.65rem 0.55rem;
}

.kitchen-overview-pane .overview-panel-head {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Independent scroll inside overview line panels */
.kitchen-cell .overview-panel-body {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.kitchen-split {
  position: absolute;
  z-index: 5;
  background: transparent;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.kitchen-split--col {
  top: 0;
  bottom: 0;
  left: var(--kitchen-col-pct, 50%);
  width: 20px;
  margin-left: -10px;
  cursor: ew-resize;
}

.kitchen-split--col::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: var(--border-soft, #555);
  pointer-events: none;
}

.kitchen-split--row {
  left: 0;
  right: 0;
  top: var(--kitchen-row-pct, 50%);
  height: 20px;
  margin-top: -10px;
  cursor: ns-resize;
}

.kitchen-split--row::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  background: var(--border-soft, #555);
  pointer-events: none;
}

.kitchen-handle--cross {
  position: absolute;
  z-index: 6;
  left: var(--kitchen-col-pct, 50%);
  top: var(--kitchen-row-pct, 50%);
  width: 28px;
  height: 28px;
  margin-left: -14px;
  margin-top: -14px;
  border: 1px solid var(--border-soft, #666);
  border-radius: 4px;
  background: rgba(40, 40, 40, 0.92);
  color: var(--fg-muted, #ccc);
  font-size: 0.7rem;
  line-height: 1;
  cursor: move;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  padding: 0;
}

.kitchen-layout.is-resizing .kitchen-split::after,
.kitchen-layout.is-resizing .kitchen-handle--cross {
  background: #c45c26;
  border-color: #c45c26;
  color: #fff;
}

body.kitchen-resizing {
  cursor: grabbing;
  user-select: none;
  -webkit-user-select: none;
}

body.kitchen-resizing .kitchen-cell,
body.kitchen-resizing .kitchen-allfood-wrap {
  pointer-events: none;
}

body.kitchen-resizing .kitchen-handle--allfood,
body.kitchen-resizing .kitchen-split,
body.kitchen-resizing .kitchen-handle--cross {
  pointer-events: auto;
}

/* Layout lock — ratios stay; resize handles inert. */
.kitchen-layout.is-layout-locked .kitchen-handle--allfood,
.kitchen-layout.is-layout-locked .kitchen-split,
.kitchen-layout.is-layout-locked .kitchen-handle--cross,
.kitchen-layout.is-pane-expanded .kitchen-handle--allfood,
.kitchen-layout.is-pane-expanded .kitchen-split,
.kitchen-layout.is-pane-expanded .kitchen-handle--cross {
  pointer-events: none;
  opacity: 0.35;
  cursor: default;
}

.kitchen-pane-expand-btn {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--border-soft, #555);
  border-radius: 0.3rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg-muted, #ccc);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
}

.kitchen-pane-expand-btn.is-active {
  background: rgba(196, 92, 38, 0.35);
  border-color: #c45c26;
  color: #fff;
}

.dishup-pane-head .kitchen-pane-expand-btn,
.udon-pane-head .kitchen-pane-expand-btn,
.fry-pane-head .kitchen-pane-expand-btn,
.side-pane-head .kitchen-pane-expand-btn,
.longcook-pane-head .kitchen-pane-expand-btn,
.kitchen-overview-head .kitchen-pane-expand-btn {
  align-self: center;
}

/* Temporary single-pane expand — ratios unchanged in storage. */
.kitchen-layout.is-pane-expanded {
  grid-template-rows: 1fr;
}

.kitchen-layout.is-pane-expanded[data-expanded="unserved"] .kitchen-quad {
  display: none;
}

.kitchen-layout.is-pane-expanded[data-expanded="unserved"] .kitchen-handle--allfood {
  display: none;
}

.kitchen-layout.is-pane-expanded:not([data-expanded="unserved"]) .kitchen-allfood-wrap {
  display: none;
}

.kitchen-layout.is-pane-expanded:not([data-expanded="unserved"]) .kitchen-quad {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.kitchen-layout.is-pane-expanded[data-expanded="all"] .kitchen-cell--udon,
.kitchen-layout.is-pane-expanded[data-expanded="all"] .kitchen-cell--side,
.kitchen-layout.is-pane-expanded[data-expanded="all"] .kitchen-cell--fry,
.kitchen-layout.is-pane-expanded[data-expanded="udon"] .kitchen-cell--all,
.kitchen-layout.is-pane-expanded[data-expanded="udon"] .kitchen-cell--side,
.kitchen-layout.is-pane-expanded[data-expanded="udon"] .kitchen-cell--fry,
.kitchen-layout.is-pane-expanded[data-expanded="side"] .kitchen-cell--all,
.kitchen-layout.is-pane-expanded[data-expanded="side"] .kitchen-cell--udon,
.kitchen-layout.is-pane-expanded[data-expanded="side"] .kitchen-cell--fry,
.kitchen-layout.is-pane-expanded[data-expanded="fry"] .kitchen-cell--all,
.kitchen-layout.is-pane-expanded[data-expanded="fry"] .kitchen-cell--udon,
.kitchen-layout.is-pane-expanded[data-expanded="fry"] .kitchen-cell--side {
  display: none;
}

.kitchen-layout.is-pane-expanded .kitchen-split,
.kitchen-layout.is-pane-expanded .kitchen-handle--cross {
  display: none;
}

/* Portrait large display (1080×1920) — prefer ratio + vars */
@media (orientation: portrait) and (min-height: 1600px) {
  .kitchen-layout {
    grid-template-rows:
      minmax(96px, var(--kitchen-allfood-fr, 16fr))
      minmax(200px, var(--kitchen-bottom-fr, 84fr));
  }
  .kitchen-overview-pane {
    --ov-table-no: clamp(1.8rem, 3.6vw, 2.8rem);
    --ov-line-name: clamp(1.15rem, 1.9vw, 1.55rem);
    --ov-line-table: clamp(1.2rem, 2.1vw, 1.75rem);
    --ov-line-qty: clamp(1.25rem, 2.1vw, 1.85rem);
  }
}

/* Unserved band only may be display-only; station mounts keep mutation controls. */
body[data-kds-screen="kitchen"] #kitchen-unserved-pane[data-display-only="true"] button:not(.kitchen-pane-expand-btn):not(.overview-new-badge) {
  /* no mutation controls expected in unserved band */
}

/*
 * KDS-KITCHEN-TIMER-PAUSE-AND-1LINE-FIX-001
 * Kitchen Station mounts: single-line row (name | timer group | 済).
 * Explicit 停止/再開 button (see dishup-item-timer-ui.js). No 2-row grid.
 * Scope: .kitchen-cell only — full #side / #udon / #fry screens unchanged.
 *
 * KDS-KITCHEN-TIMER-ROW-OVERFLOW-CLIP-FIX-001
 * Narrow column: timer group must shrink/scroll inside its own pane.
 * Do not let controls layout-overflow into the neighboring cell (hit-test steal).
 * Priority: operable > no cross-pane overflow > readable > single line.
 */
.kitchen-cell .side-row:has(.item-timer-cell),
.kitchen-cell .fry-row:has(.item-timer-cell),
.kitchen-cell .udon-row:has(.item-timer-cell) {
  max-height: none;
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  /* x must not escape pane; y may grow for narrow wrap fallback */
  overflow-x: hidden;
  overflow-y: auto;
  align-items: center;
  column-gap: 0.28rem;
  padding-top: 0.18rem;
  padding-bottom: 0.22rem;
}

.kitchen-cell .side-row:has(.item-timer-cell) {
  display: flex;
  flex-wrap: nowrap;
}

.kitchen-cell .side-row:has(.item-timer-cell) > .side-item-name {
  flex: 1 1 0;
  min-width: 0;
}

.kitchen-cell .side-row:has(.item-timer-cell) > .item-timer-cell {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

.kitchen-cell .side-row:has(.item-timer-cell) > .item-handoff-cell {
  flex: 0 0 auto;
  margin-left: 0;
}

.kitchen-cell .fry-row:has(.item-timer-cell) {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.28rem 0.32rem;
}

.kitchen-cell .fry-row:has(.item-timer-cell) > .fry-item-name {
  flex: 1 1 0;
  min-width: 0;
}

.kitchen-cell .fry-row:has(.item-timer-cell) > .item-timer-cell {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

.kitchen-cell .fry-row:has(.item-timer-cell) > .item-handoff-cell {
  flex: 0 0 auto;
}

.kitchen-cell .udon-row:has(.item-timer-cell) {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.28rem 0.32rem;
}

.kitchen-cell .udon-row:has(.item-timer-cell) > .udon-item-name {
  flex: 1 1 0;
  min-width: 0;
}

.kitchen-cell .udon-row:has(.item-timer-cell) > .item-timer-cell {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

.kitchen-cell .udon-row:has(.item-timer-cell) > .item-handoff-cell,
.kitchen-cell .udon-row:has(.item-timer-cell) > .udon-merge-btn {
  flex: 0 0 auto;
}

/*
 * Timer group: shrink to remaining pane width.
 * Wide: single line. Narrow: wrap controls inside the cell (not into neighbor).
 */
.kitchen-cell .side-row .item-timer-cell,
.kitchen-cell .fry-row .item-timer-cell,
.kitchen-cell .udon-row .item-timer-cell {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.14rem 0.18rem;
  max-width: 100%;
  width: auto;
  min-width: 0;
  flex-shrink: 1;
  overflow-x: hidden;
  overflow-y: hidden;
  box-sizing: border-box;
}

.kitchen-cell .side-row .item-timer-start-btn,
.kitchen-cell .fry-row .item-timer-start-btn,
.kitchen-cell .udon-row .item-timer-start-btn,
.kitchen-cell .side-row .item-timer-adj-btn,
.kitchen-cell .fry-row .item-timer-adj-btn,
.kitchen-cell .udon-row .item-timer-adj-btn,
.kitchen-cell .side-row .item-timer-remain-hit,
.kitchen-cell .fry-row .item-timer-remain-hit,
.kitchen-cell .udon-row .item-timer-remain-hit,
.kitchen-cell .side-row .item-timer-pause-btn {
  min-height: 2rem;
  min-width: 2rem;
  padding: 0.22rem 0.34rem;
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1.15;
  flex-shrink: 0;
}

.kitchen-cell .side-row .item-timer-adj-btn,
.kitchen-cell .fry-row .item-timer-adj-btn,
.kitchen-cell .udon-row .item-timer-adj-btn {
  font-size: 0.72rem;
  border: 1px solid #c4c4c4;
  background: #f7f7f7;
  border-radius: 0.25rem;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}

.kitchen-cell .side-row .item-timer-remain-hit,
.kitchen-cell .fry-row .item-timer-remain-hit,
.kitchen-cell .udon-row .item-timer-remain-hit {
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kitchen-cell .side-row .item-timer-pause-btn {
  border: 1px solid #6b8cae;
  background: #eef5fb;
  color: #2a5080;
  border-radius: 0.25rem;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
  min-width: 2.4rem;
}

.kitchen-cell .side-row .item-timer-pause-btn.is-paused {
  border-color: #c4a020;
  background: #fff8dc;
  color: #8a5a10;
}

.kitchen-cell .side-row .item-timer-pause-btn:active {
  background: #e0ebf5;
}

.kitchen-cell .side-row .item-timer-pause-btn.is-paused:active {
  background: #f5eec0;
}

.kitchen-cell .side-row .item-timer-started,
.kitchen-cell .fry-row .item-timer-started,
.kitchen-cell .udon-row .item-timer-started {
  display: inline;
  width: auto;
  font-size: 0.62rem;
  white-space: nowrap;
}

/* Long names shrink; timer + 済 never pushed out */
.kitchen-cell .side-item-name,
.kitchen-cell .fry-item-name,
.kitchen-cell .udon-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow-wrap: normal;
}

.kitchen-cell .side-row .item-handoff-cell,
.kitchen-cell .fry-row .item-handoff-cell,
.kitchen-cell .udon-row .item-handoff-cell {
  flex-shrink: 0;
  white-space: nowrap;
  z-index: 1;
}

.kitchen-cell .side-row .item-handoff-btn,
.kitchen-cell .fry-row .item-handoff-btn,
.kitchen-cell .udon-row .item-handoff-btn,
.kitchen-cell .side-row .item-handoff-undo-btn,
.kitchen-cell .fry-row .item-handoff-undo-btn,
.kitchen-cell .udon-row .item-handoff-undo-btn {
  min-height: 2rem;
  min-width: 2.4rem;
}
