/* Preparation uses the shared PROCENTER day and night palette. */
.prep {
  --prep-bg: var(--paper);
  --prep-panel: var(--canvas);
  --prep-raised: var(--panel);
  --prep-border: var(--line);
  --prep-text: var(--ink);
  --prep-muted: var(--muted);
  --prep-accent: var(--brand);
  --prep-highlight: var(--coral-wash);
  color-scheme: inherit;
  color: var(--prep-text);
  background: var(--prep-bg);
  border: 1px solid var(--prep-border);
  border-top: 3px solid var(--brand);
  border-radius: 2px;
  box-shadow: 0 14px 42px var(--petrol-shadow);
  min-width: 0;
}

.prep :is(h2, h3) {
  color: var(--prep-text);
  min-width: 0;
}

.prep .muted {
  color: var(--prep-muted);
}

.prep :is(button, input, select) {
  min-height: 48px;
  border-radius: 2px;
}

.prep button {
  border-color: var(--prep-border);
  background: var(--prep-raised);
  color: var(--prep-text);
  transition: background-color .13s ease, border-color .13s ease;
}

.prep button:enabled:hover {
  background: var(--prep-raised);
  border-color: var(--prep-muted);
}

.prep :is(input, select) {
  color: var(--prep-text);
  background: var(--prep-bg);
  border-color: var(--prep-muted);
}

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

.prep button:disabled {
  opacity: .62;
}

.prep :is(button, input, select, a):focus-visible,
.prep [tabindex]:focus-visible {
  outline-color: var(--prep-accent);
}

.prep .prep-action-primary {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--action-ink);
}

.prep .prep-action-primary:enabled:hover {
  border-color: var(--prep-accent);
  background: var(--brand-hover);
}

.prep a {
  color: var(--prep-accent);
}

.prep-grid {
  display: grid;
  grid-template-columns: minmax(240px, .78fr) minmax(0, 1.62fr);
  gap: 1px;
  background: var(--prep-border);
  min-width: 0;
}

.prep-queue, .prep-detail {
  min-width: 0;
  background: var(--prep-bg);
}

.prep-queue {
  align-self: stretch;
  padding: clamp(13px, 1.8vw, 21px);
}

.prep-detail {
  padding: clamp(14px, 2.2vw, 26px);
}

.prep-detail > * + * {
  margin-top: 16px;
}

.prep-feedback {
  color: var(--prep-text);
  border: 1px solid var(--prep-border);
  border-left: 3px solid var(--prep-accent);
  background: var(--prep-panel);
  padding: .68rem .8rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.prep-feedback.is-error {
  color: var(--prep-accent);
  border-left-color: var(--prep-accent);
  background: var(--prep-highlight);
}

@media (prefers-reduced-motion: reduce) {
  .prep :is(button, a, progress) { transition: none; }
}

.prep-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 145px), 1fr));
  gap: 1px;
  background: var(--prep-border);
  border-bottom: 1px solid var(--prep-border);
}

.prep-stat {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
  align-items: center;
  padding: 11px clamp(14px, 2vw, 24px);
  background: var(--prep-panel);
  color: var(--prep-muted);
  font-size: .82rem;
  line-height: 1.27;
}

.prep-stat strong {
  color: var(--prep-text);
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.25rem, 2.15vw, 1.75rem);
  font-weight: 780;
  letter-spacing: -.035em;
}

.prep-queue-head, .prep-progress-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 5px 12px;
}

.prep-queue-head {
  margin-bottom: 11px;
}

.prep-queue-count {
  min-width: 24px;
  color: var(--prep-accent);
  font-size: .92rem;
  font-weight: 740;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.prep-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 9px;
}

.prep-filters button {
  flex: 1 0 auto;
  padding-inline: 8px;
  font-size: .81rem;
}

.prep-filters button[aria-pressed=true] {
  color: var(--prep-accent);
  border-color: var(--prep-accent);
  background: var(--prep-highlight);
}

.prep-search {
  display: block;
  margin-bottom: 12px;
  min-width: 0;
}

.prep-queue-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: min(60dvh, 600px);
  overflow: auto;
  padding: 5px;
  margin: -5px;
  scrollbar-width: thin;
  scrollbar-color: var(--prep-muted) var(--prep-bg);
}

.prep button.prep-queue-row {
  display: grid;
  align-items: start;
  justify-items: stretch;
  gap: 6px;
  width: 100%;
  min-width: 0;
  min-height: 78px;
  padding: 10px 12px;
  text-align: left;
  background: var(--prep-panel);
  border-left: 2px solid var(--prep-border);
  overflow-wrap: anywhere;
}

.prep button.prep-queue-row[aria-pressed=true] {
  border-color: var(--prep-accent);
  border-left-color: var(--prep-accent);
  background: var(--prep-highlight);
}

.prep button.prep-queue-row:enabled:hover {
  border-color: var(--prep-muted);
}

.prep-queue-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 8px;
  color: var(--prep-text);
  font-size: .99rem;
  font-weight: 740;
  line-height: 1.24;
}

.prep-queue-meta, .prep-queue-progress {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 9px;
  color: var(--prep-muted);
  font-size: .79rem;
  font-weight: 530;
  font-variant-numeric: tabular-nums;
}

.prep-queue-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.prep .prep-queue-progress progress {
  height: 4px;
  margin: 0;
}

.prep-status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  min-height: 24px;
  padding: 2px 7px;
  border: 1px solid var(--prep-border);
  border-radius: 1px;
  background: var(--prep-raised);
  color: var(--prep-text);
  font-size: .72rem;
  font-weight: 720;
  line-height: 1.2;
}

.prep-status[data-state=in_progress] {
  color: var(--prep-accent);
  border-color: var(--prep-accent);
  background: var(--prep-highlight);
}

.prep-status:is([data-state=paused], [data-state=ready]) {
  color: var(--prep-accent);
  border-color: var(--prep-accent);
  background: var(--prep-highlight);
}

.prep-status[data-state=finished] {
  color: var(--prep-text);
  border-color: var(--prep-muted);
  background: var(--prep-raised);
}

.prep-back {
  display: none;
}

.prep-order-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px 15px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--prep-border);
}

.prep-meta {
  display: grid;
  justify-items: start;
  gap: 6px;
  min-width: 0;
  color: var(--prep-muted);
  overflow-wrap: anywhere;
}

.prep-meta h2 {
  color: var(--prep-text);
  font-size: clamp(1.25rem, 2.5vw, 2.06rem);
  font-weight: 765;
  letter-spacing: -.043em;
  line-height: 1.12;
}

.prep-timer {
  display: grid;
  align-items: center;
  justify-items: end;
  min-width: max-content;
  gap: 2px;
  padding: 8px 12px;
  border: 1px solid var(--prep-border);
  border-right: 2px solid var(--prep-accent);
  border-radius: 1px;
  background: var(--prep-bg);
  color: var(--prep-muted);
  font-size: .74rem;
  line-height: 1.18;
}

.prep-timer time {
  color: var(--prep-text);
  letter-spacing: -.04em;
  font-size: clamp(1.55rem, 3.3vw, 2.65rem);
  font-weight: 770;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.prep-timer[data-state=paused] {
  background: var(--prep-highlight);
}

.prep-progress {
  padding: 10px 12px;
  border: 1px solid var(--prep-border);
  border-radius: 1px;
  background: var(--prep-panel);
  color: var(--prep-muted);
  font-size: .83rem;
  font-variant-numeric: tabular-nums;
}

.prep-progress strong {
  color: var(--prep-text);
  font-size: 1.02rem;
}

.prep progress {
  display: block;
  width: 100%;
  height: 7px;
  margin-top: 8px;
  appearance: none;
  border: 0;
  border-radius: 0;
  background: var(--prep-bg);
  color: var(--prep-accent);
  accent-color: var(--prep-accent);
}

.prep progress::-webkit-progress-bar {
  background: var(--prep-bg);
}

.prep progress::-webkit-progress-value {
  background: var(--prep-accent);
}

.prep progress::-moz-progress-bar {
  background: var(--prep-accent);
}

.prep-scan {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--prep-border);
  border-left: 3px solid var(--prep-accent);
  border-radius: 2px;
  background: var(--prep-raised);
}

.prep-scanner-slot:empty {
  display: none;
}

.prep-scan h3, .prep-lines h3 {
  font-size: 1rem;
  letter-spacing: -.015em;
}

.prep-scan :is(input, button) {
  min-height: 52px;
}

.prep-scan input {
  font-size: 1.07rem;
  font-variant-numeric: tabular-nums;
}

.prep-scan-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 6px;
}

.prep-scanner-options, .prep-scan-recovery {
  display: flex;
  align-items: start;
  flex-wrap: wrap;
  gap: 6px;
}

.prep-scan-recovery > .prep-feedback {
  flex-basis: 100%;
}

.prep-camera {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--prep-border);
}

.prep-camera video {
  display: block;
  width: min(100%, 560px);
  max-height: 50dvh;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: var(--prep-bg);
  border: 1px solid var(--prep-border);
}

.prep-lines > h3 {
  margin-bottom: 7px;
}

.prep-line-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--prep-border);
  background: var(--prep-panel);
}

.prep-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 48px;
  align-items: center;
  gap: 8px 11px;
  min-width: 0;
  min-height: 61px;
  padding: 7px 10px;
}

.prep-line + .prep-line {
  border-top: 1px solid var(--prep-border);
}

.prep-line:nth-child(even) {
  background: var(--prep-raised);
}

.prep-line.is-complete {
  box-shadow: inset 2px 0 var(--prep-accent);
}

.prep-line-title :is(strong, span) {
  display: block;
  overflow-wrap: anywhere;
}

.prep-line-title span {
  margin-top: 3px;
  color: var(--prep-muted);
  font-size: .78rem;
}

.prep-line-complete {
  color: var(--prep-accent);
  font-size: 1.05rem;
  font-weight: 760;
  text-align: center;
}

.prep-count {
  color: var(--prep-text);
  font-size: .92rem;
  font-weight: 730;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.prep-line.is-complete .prep-count {
  color: var(--prep-accent);
}

.prep-line button {
  min-width: 48px;
  padding-inline: 9px;
}

.prep-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.prep-finish {
  flex: 1 0 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  align-items: end;
  padding: 11px;
  border: 1px solid var(--prep-border);
  background: var(--prep-panel);
}

.prep-finish input::file-selector-button {
  min-height: 34px;
  margin: -4px 5px -4px -4px;
  border: 1px solid var(--prep-muted);
  border-radius: 1px;
  background: var(--prep-raised);
  color: var(--prep-text);
}

.prep-proof img {
  display: block;
  max-width: min(100%, 160px);
  max-height: 120px;
  object-fit: contain;
  border: 1px solid var(--prep-border);
}

.prep-empty {
  padding: 18px 13px;
  border: 1px dashed var(--prep-muted);
  background: var(--prep-panel);
  color: var(--prep-muted);
  overflow-wrap: anywhere;
}

@media (max-width: 960px) {
  .prep-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .prep-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .prep:not(.has-selection) .prep-detail,
  .prep.show-queue .prep-detail,
  .prep.has-selection:not(.show-queue) .prep-queue {
    display: none;
  }

  .prep-queue-list {
    max-height: none;
  }

  .prep-actions {
    position: sticky;
    z-index: 1;
    bottom: 0;
    padding-top: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    background: var(--prep-bg);
    box-shadow: 0 -1px var(--prep-border);
  }

  .prep-actions button {
    flex: 1 1 9rem;
  }
}

@media (max-width: 560px) {
  .prep-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .prep-stat {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3px;
    padding: 8px 10px;
    font-size: .75rem;
  }

  .prep-order-head {
    align-items: start;
  }

  .prep-timer {
    padding: 7px 8px;
  }

  .prep-line {
    gap: 5px 7px;
  }

  .prep-finish {
    grid-template-columns: minmax(0, 1fr);
  }
}

:root[data-om-theme="night"] .prep { --prep-accent: #ffc7cf; }
