/* TrayMath — tokens are law (see DESIGN.md). */
@property --fill { syntax: '<number>'; inherits: false; initial-value: 0; }

:root {
  --pan: #13191D;
  --pan-raised: #1A2227;
  --pan-high: #232D33;
  --seam: #2F3B42;
  --rice: #E8EDE9;
  --steam: #9DAAB0;
  --saffron: #F2B544;
  --saffron-ink: #1E1606;
  --basil: #6FCF8E;
  --radish: #FF6F7F;
  --yolk: #E9D46B;
  --ticket: #F1F0EA;
  --ticket-ink: #1B2125;
  --ticket-seam: #C9CCC6;

  --face: "Recursive", ui-sans-serif, system-ui, sans-serif;
  --t-13: .8125rem; --t-15: .9375rem; --t-17: 1.0625rem; --t-22: 1.375rem; --t-34: 2.125rem; --t-56: clamp(2.4rem, 1.6rem + 3.2vw, 3.5rem);
  --r-control: 3px;
  --gut: clamp(16px, 2.4vw, 32px);
  --ease-place: cubic-bezier(.2, .9, .3, 1.3);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { scrollbar-gutter: stable; }
body {
  background: var(--pan); color: var(--rice);
  font-family: var(--face); font-size: var(--t-15); line-height: 1.5;
  font-variation-settings: "CASL" 0, "MONO" 0; font-weight: 420;
  -webkit-font-smoothing: antialiased; overflow-x: clip; min-height: 100svh;
  display: flex; flex-direction: column;
}
main { flex: 1; outline: none; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--saffron); color: var(--saffron-ink); }
:focus-visible { outline: 2px solid var(--saffron); outline-offset: 2px; }

.num, .mono { font-variation-settings: "MONO" 1, "CASL" 0; font-variant-numeric: tabular-nums; }
.label-face { font-variation-settings: "CASL" 1, "MONO" 0; font-weight: 720; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- top bar ---------- */
.bar { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 18px var(--gut); border-bottom: 1px solid var(--seam); }
.wordmark { text-decoration: none; font-size: var(--t-22); font-weight: 800; font-variation-settings: "CASL" 1; letter-spacing: -.01em; }
.wordmark span { color: var(--saffron); }
.bar-caterer { color: var(--steam); font-size: var(--t-13); text-align: right; }
.bar-caterer b { color: var(--rice); font-weight: 600; }

/* ---------- hero ---------- */
.hero { padding: clamp(28px, 5vw, 64px) var(--gut) clamp(20px, 3vw, 36px); display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--gut); align-items: end; }
.hero h1 { font-size: var(--t-56); line-height: 1.02; font-weight: 560; font-variation-settings: "CASL" 1; letter-spacing: -.02em; text-wrap: balance; max-width: 16ch; }
.hero h1 .line { display: block; overflow: hidden; padding-bottom: .06em; }
.hero h1 .line > span { display: block; }
.hero h1 em { font-style: normal; color: var(--saffron); }
.hero p { color: var(--steam); font-size: var(--t-17); max-width: 46ch; }
.hero p b { color: var(--rice); font-weight: 600; }

/* ---------- planner layout ---------- */
.planner { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 0 var(--gut); padding: 0 var(--gut) 64px; align-items: start; }
.col-inputs { display: grid; gap: 28px; }
.col-board { position: sticky; top: 16px; display: grid; gap: 16px; }
.step { background: var(--pan-raised); padding: 20px; }
.step-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.step h2 { font-size: var(--t-17); font-weight: 680; display: flex; gap: 10px; align-items: baseline; }
.step h2 .idx { color: var(--steam); font-weight: 500; }
.hint { color: var(--steam); font-size: var(--t-13); }

/* party type: three slabs */
.party-types { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.ptype { text-align: left; background: var(--pan); border: 1px solid var(--seam); border-radius: var(--r-control); padding: 10px 12px; cursor: pointer; display: grid; gap: 2px; transition: border-color .16s, background-color .16s; }
.ptype:hover { border-color: var(--steam); }
.ptype[aria-pressed="true"] { border-color: var(--saffron); background: var(--pan-high); }
.ptype b { font-weight: 640; font-size: var(--t-15); }
.ptype span { color: var(--steam); font-size: var(--t-13); }
.guests-row { display: flex; align-items: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }
.guests-row label { font-weight: 600; }
.field-error { color: var(--radish); font-size: var(--t-13); margin-top: 8px; }

/* steppers & inputs */
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--seam); border-radius: var(--r-control); background: var(--pan); }
.stepper button { width: 36px; min-height: 36px; background: none; border: 0; cursor: pointer; font-size: 1.1rem; color: var(--steam); transition: color .14s, background-color .14s; }
.stepper button:hover { color: var(--rice); background: var(--pan-high); }
.stepper button:disabled { opacity: .35; cursor: default; background: none; }
.stepper input { width: 52px; text-align: center; background: none; border: 0; border-inline: 1px solid var(--seam); font-variation-settings: "MONO" 1; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.stepper.big input { width: 72px; font-size: var(--t-22); }
.text-in { width: 100%; background: var(--pan); border: 1px solid var(--seam); border-radius: var(--r-control); padding: 9px 11px; }
.text-in:hover { border-color: var(--steam); }

/* guest groups */
.groups { display: grid; gap: 8px; }
.group-ed { background: var(--pan); border-left: 2px solid var(--seam); padding: 12px 12px 12px 14px; display: grid; gap: 10px; }
.group-ed-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.group-ed-name { font-variation-settings: "CASL" 1; font-weight: 700; flex: 1; min-width: 10ch; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: none; border: 1px solid var(--seam); border-radius: var(--r-control); padding: 4px 9px; font-size: var(--t-13); color: var(--steam); cursor: pointer; transition: color .14s, border-color .14s, background-color .14s; }
.chip:hover { color: var(--rice); border-color: var(--steam); }
.chip[aria-pressed="true"] { color: var(--rice); background: var(--pan-high); border-color: var(--rice); }
.chip-set-label { font-size: var(--t-13); color: var(--steam); width: 100%; }
.remainder-line { color: var(--steam); font-size: var(--t-13); padding: 4px 2px; }
.btn-quiet { background: none; border: 1px dashed var(--seam); border-radius: var(--r-control); padding: 9px 12px; color: var(--steam); cursor: pointer; text-align: left; transition: color .14s, border-color .14s; }
.btn-quiet:hover { color: var(--rice); border-color: var(--steam); }
.btn-x { background: none; border: 0; color: var(--steam); cursor: pointer; font-size: var(--t-13); text-decoration: underline; text-underline-offset: 3px; padding: 6px 2px; }
.btn-x:hover { color: var(--radish); }

/* buttons */
.btn { border: 0; border-radius: var(--r-control); padding: 12px 18px; font-weight: 680; cursor: pointer; transition: transform .12s, background-color .16s, color .16s; }
.btn:active { transform: translateY(1px); }
.btn-main { background: var(--saffron); color: var(--saffron-ink); }
.btn-main:hover { background: #F7C565; }
.btn-main:disabled { background: var(--pan-high); color: var(--steam); cursor: not-allowed; }
.btn-line { background: none; color: var(--rice); box-shadow: inset 0 0 0 1px var(--seam); }
.btn-line:hover { box-shadow: inset 0 0 0 1px var(--rice); }

/* pennant (food pick flag) */
.picks { display: inline-flex; flex-wrap: wrap; gap: 3px 7px; vertical-align: middle; }
.pick { display: inline-flex; align-items: center; font-size: 10.5px; line-height: 1; font-weight: 700; font-variation-settings: "MONO" 1; letter-spacing: .02em; }
.pick::before { content: ""; width: 1px; height: 15px; background: var(--steam); margin-right: -1px; align-self: flex-start; }
.pick span { background: var(--rice); color: var(--pan); padding: 3px 9px 3px 5px; clip-path: polygon(0 0, 100% 0, 78% 50%, 100% 100%, 0 100%); align-self: flex-start; }

/* ---------- coverage board ---------- */
.board { background: var(--pan-raised); }
.board-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--seam); display: grid; gap: 4px; }
.verdict { font-size: var(--t-22); font-weight: 650; font-variation-settings: "CASL" 1; line-height: 1.2; }
.verdict.ok { color: var(--basil); }
.verdict.bad { color: var(--radish); }
.verdict-sub { color: var(--steam); font-size: var(--t-13); }
.verdict-sub .num { color: var(--rice); }
.board-empty { padding: 26px 20px 28px; display: grid; gap: 14px; justify-items: start; }
.board-empty p { color: var(--steam); max-width: 46ch; }
.board-cols { display: grid; grid-template-columns: minmax(0, 1fr) repeat(3, 64px); gap: 12px; padding: 10px 20px 6px; color: var(--steam); font-size: 11.5px; text-align: right; }
.board-cols span:first-child { text-align: left; }
.grow { display: grid; grid-template-columns: minmax(0, 1fr) repeat(3, 64px); gap: 4px 12px; padding: 14px 20px; border-top: 1px solid var(--seam); align-items: start; }
.grow:first-of-type { border-top: 0; }
.grow-name { font-variation-settings: "CASL" 1; font-weight: 720; font-size: var(--t-17); line-height: 1.25; }
.grow-name small { font-variation-settings: "CASL" 0, "MONO" 1; font-weight: 450; color: var(--steam); font-size: var(--t-13); margin-left: 6px; }
.grow .num { text-align: right; font-size: var(--t-17); }
.grow .num.dim { color: var(--steam); }
.grow.is-short .num.theirs { color: var(--radish); }
.grow.is-ok .num.theirs { color: var(--basil); }
.grow-detail { grid-column: 1 / -1; display: grid; gap: 8px; }
.plates { display: flex; flex-wrap: wrap; gap: 4px; }
.plate { --fill: 1; width: 20px; height: 20px; padding: 3px; border-radius: 50%; background: conic-gradient(var(--plate-c, var(--basil)) calc(var(--fill) * 360deg), var(--pan) 0) content-box; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--plate-c, var(--basil)) 70%, var(--pan)); transition: --fill .32s var(--ease-out); }
.plate, .plate::before { box-sizing: border-box; }
.plate.part, .plate.empty { --plate-c: var(--radish); }
.plate.anim { animation: place .2s var(--ease-place) both; animation-delay: calc(var(--i) * 14ms); }
@keyframes place { from { transform: translateY(-6px) scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.feeds { color: var(--steam); font-size: var(--t-13); }
.feeds b { color: var(--rice); font-weight: 520; }
.feeds .num, .fix .num, .verdict-sub .num, .flag-line .num, .tray-feeds .num, .remainder-line .num, .tray-meta .num, .ptype .num { font-size: .92em; }
.board-legend { padding: 12px 20px 2px; color: var(--steam); font-size: 12px; }
.board-legend b { color: var(--rice); font-weight: 560; }
.flag-line { font-size: var(--t-13); }
.fix-row { display: flex; gap: 8px; flex-wrap: wrap; }
.flag-line.short { color: var(--radish); }
.flag-line.note { color: var(--yolk); }
.flag-line.paper { color: var(--radish); }
.fix { text-align: left; background: none; border: 1px solid var(--radish); color: var(--rice); border-radius: var(--r-control); padding: 6px 10px; font-size: var(--t-13); cursor: pointer; transition: background-color .14s; }
.fix:hover { background: rgba(255, 111, 127, .14); }
.fix .num { color: var(--steam); }

/* ---------- tray order ---------- */
.trays { display: grid; }
.tray { display: grid; grid-template-columns: minmax(0, 1fr) auto 72px; gap: 6px 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--seam); }
.tray:first-child { border-top: 0; }
.tray-name { font-variation-settings: "CASL" 1; font-weight: 700; font-size: var(--t-17); line-height: 1.25; }
.tray-meta { grid-column: 1; display: flex; gap: 6px 12px; flex-wrap: wrap; align-items: center; color: var(--steam); font-size: var(--t-13); }
.tray .line-total { text-align: right; }
.tray .stepper { grid-row: 1 / span 2; grid-column: 2; }
.tray .line-total { grid-row: 1 / span 2; grid-column: 3; }
.tray-feeds { grid-column: 1 / -1; color: var(--steam); font-size: var(--t-13); }
.tray-feeds .spare { color: var(--yolk); }
.trays-empty { color: var(--steam); padding: 6px 0 2px; }
.menu-pick { margin-top: 14px; }
.menu-pick summary { cursor: pointer; color: var(--steam); padding: 8px 0; list-style: none; }
.menu-pick summary::-webkit-details-marker { display: none; }
.menu-pick summary::before { content: "+ "; color: var(--saffron); }
.menu-pick[open] summary::before { content: "− "; }
.menu-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 9px 0; border-top: 1px dashed var(--seam); align-items: center; }
.menu-row .tray-meta { grid-column: 1; }
.menu-row button { grid-row: 1 / span 2; grid-column: 2; }

/* ---------- send panel ---------- */
.send { background: var(--pan-raised); padding: 18px 20px 20px; display: grid; gap: 12px; }
.send h2 { font-size: var(--t-17); font-weight: 680; }
.send-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.send-fields label { display: grid; gap: 4px; font-size: var(--t-13); color: var(--steam); }
.send-fields .wide { grid-column: 1 / -1; }
.send-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.send-warn { color: var(--radish); font-size: var(--t-13); }
.send-out { display: grid; gap: 8px; }
.send-out input { font-variation-settings: "MONO" 1; font-size: var(--t-13); }
.toast { color: var(--basil); font-size: var(--t-13); }

/* ---------- kitchen ticket ---------- */
.ticket-wrap { padding: clamp(20px, 4vw, 48px) var(--gut) 64px; display: grid; justify-items: center; gap: 18px; }
.ticket-tools { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.ticket { width: min(820px, 100%); background: var(--ticket); color: var(--ticket-ink); padding: 32px clamp(18px, 4vw, 40px) 36px; position: relative;
  -webkit-mask: radial-gradient(circle 6px at 50% 0, transparent 98%, #000) 0 0 / 18px 100% repeat-x;
          mask: radial-gradient(circle 6px at 50% 0, transparent 98%, #000) 0 0 / 18px 100% repeat-x; }
.ticket h1 { font-size: var(--t-34); font-variation-settings: "CASL" 1; font-weight: 760; line-height: 1.1; letter-spacing: -.01em; }
.ticket .kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 20px; margin: 18px 0 8px; padding: 14px 0; border-block: 1.5px dashed var(--ticket-seam); }
.ticket .kv dt { font-size: 11.5px; color: #5A6469; }
.ticket .kv dd { font-weight: 640; }
.ticket h2 { font-size: var(--t-15); font-weight: 760; margin: 22px 0 6px; }
.ticket table { width: 100%; border-collapse: collapse; font-size: var(--t-15); }
.ticket th { text-align: left; font-size: 11.5px; color: #5A6469; font-weight: 600; padding: 6px 8px 6px 0; border-bottom: 1.5px solid var(--ticket-ink); }
.ticket td { padding: 9px 8px 9px 0; border-bottom: 1px solid var(--ticket-seam); vertical-align: top; }
.ticket td.num, .ticket th.num { text-align: right; }
.ticket .dish { font-variation-settings: "CASL" 1; font-weight: 720; }
.ticket .sub { color: #5A6469; font-size: var(--t-13); }
.ticket .picks { margin-left: 4px; }
.ticket .pick span { background: var(--ticket-ink); color: var(--ticket); }
.ticket .pick::before { background: #5A6469; }
.ticket .ok { color: #1F7A43; font-weight: 700; }
.ticket .bad { color: #B3263A; font-weight: 700; }
.ticket .total td { border-bottom: 0; font-weight: 760; font-size: var(--t-17); }
.ticket .note-box { margin-top: 14px; padding: 12px 14px; background: #E4E3DC; }
.ticket .fine { margin-top: 18px; font-size: var(--t-13); color: #5A6469; }
.incomplete { padding: 64px var(--gut); display: grid; gap: 14px; justify-items: start; max-width: 640px; }
.incomplete h1 { font-size: var(--t-34); font-variation-settings: "CASL" 1; }
.labels { display: none; }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--seam); padding: 18px var(--gut) 26px; color: var(--steam); font-size: var(--t-13); display: grid; gap: 4px; }

/* ---------- phone ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .planner { grid-template-columns: 1fr; gap: 20px; }
  .col-board { position: static; }
  .board-sticky { position: sticky; bottom: 0; z-index: 5; }
}
@media (max-width: 560px) {
  .party-types { grid-template-columns: 1fr; }
  .board-cols, .grow { grid-template-columns: minmax(0, 1fr) repeat(3, 44px); gap: 4px 8px; padding-inline: 14px; }
  .grow .num { font-size: var(--t-15); }
  .step, .send { padding: 16px 14px; }
  .send-fields { grid-template-columns: 1fr; }
  .tray { grid-template-columns: minmax(0, 1fr) auto; }
  .tray .stepper { grid-row: 1; grid-column: 2; }
  .tray .line-total { grid-row: 2; grid-column: 2; }
  .bar-caterer { max-width: 55%; }
  .bar-caterer .tagline { display: none; }
  .ptype { grid-template-columns: 1fr auto; align-items: baseline; padding: 9px 12px; }
  .hero p { font-size: var(--t-15); }
  .hero h1 { font-size: 2.35rem; }
}
.verdict-pin { display: none; }
@media (max-width: 900px) {
  .verdict-pin { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--pan-high); border-top: 1px solid var(--seam); padding: 10px var(--gut); justify-content: space-between; gap: 10px; font-size: var(--t-13); transform: translateY(110%); transition: transform .22s var(--ease-out); }
  .verdict-pin.show { transform: none; }
  .verdict-pin .ok { color: var(--basil); } .verdict-pin .bad { color: var(--radish); }
  .verdict-pin a { color: var(--rice); }
}

/* ---------- motion ---------- */
.hero h1 .line > span { animation: rise .7s var(--ease-out) both; }
.hero h1 .line:nth-child(2) > span { animation-delay: .08s; }
.hero h1 .line:nth-child(3) > span { animation-delay: .16s; }
.hero p { animation: settle .6s var(--ease-out) .25s both; }
@keyframes rise { from { transform: translateY(105%); } to { transform: none; } }
@keyframes settle { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}

/* ---------- print ---------- */
@media print {
  @page { margin: 12mm; }
  body { background: #fff; color: #000; }
  .bar, .foot, .ticket-tools, .verdict-pin { display: none !important; }
  .ticket-wrap { padding: 0; }
  .ticket { width: 100%; -webkit-mask: none; mask: none; padding: 0; background: #fff; }
  body.print-labels .ticket { display: none; }
  body.print-labels .labels { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
  .label-card { break-inside: avoid; height: 88mm; border: 1px dashed #999; display: grid; grid-template-rows: 1fr 1fr; color: #111; }
  .label-half { padding: 6mm 7mm; display: grid; align-content: center; gap: 2mm; }
  .label-half.top { transform: rotate(180deg); border-bottom: 1px dashed #bbb; }
  .label-card .dish { font-family: var(--face); font-variation-settings: "CASL" 1; font-weight: 760; font-size: 17pt; line-height: 1.1; }
  .label-card .suits { font-size: 10pt; font-weight: 700; }
  .label-card .contains { font-size: 9.5pt; }
  .label-card .fine { font-size: 7pt; color: #555; }
}
