@font-face {
  font-family: 'Sticker Black';
  src: url('fonts/ariblk.ttf') format('truetype');
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #FFF8E8;
  --card: #FFFFFF;
  --ink: #3A2616;
  --muted: #7B6654;
  --line: #EFE2C8;
  --yolk: #FFD43B;
  --yolk-deep: #F2A900;
  --tint: #FFFBEF;
  --ok: #2F6B32;
  --warn-ink: #8A4200;
  --warn-bg: #FFEFD6;
  --err: #B3261E;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #1C7ED6; outline-offset: 2px; }

/* ---- header ---- */

.top {
  background: var(--yolk);
  border-bottom: 3px solid var(--ink);
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
}
.top-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.logo { width: 40px; height: 40px; flex: none; }
.brand h1 {
  margin: 0;
  font-family: 'Sticker Black', 'Arial Black', system-ui, sans-serif;
  font-weight: 400;
  font-size: clamp(15px, 4.4vw, 26px);
  line-height: 1.1;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.brand p { margin: 2px 0 0; font-size: clamp(11.5px, 3.2vw, 13px); font-weight: 600; color: #6B4E00; }
.today-chip {
  margin-left: auto;
  padding: 4px 10px 5px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  text-align: right;
  white-space: nowrap;
  line-height: 1.25;
}
.today-chip span { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.today-chip strong { font-size: 14px; }

/* ---- layout ---- */

.layout {
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 16px;
}
.col { display: grid; gap: 16px; align-content: start; min-width: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 1px 2px rgba(74, 47, 27, 0.06);
}
.card h2 {
  margin: 0 0 14px;
  font-size: 19px;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 10px;
}
.card h2 small { font-size: 14px; font-weight: 500; color: var(--muted); }
.card h2.plain { font-size: 16px; color: var(--muted); }
.step {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--yolk);
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 800;
}

/* ---- date ---- */

.date-row { display: flex; gap: 10px; }
#dateInput {
  flex: 1;
  min-width: 0;
  height: 56px;
  padding: 0 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--tint);
  font-size: 19px;
  font-weight: 700;
  -webkit-appearance: none;
  appearance: none;
}
#dateInput:focus { border-color: var(--yolk-deep); }
.today-btn {
  flex: none;
  height: 56px;
  padding: 0 18px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  font-weight: 700;
}
.today-btn.active { background: var(--ink); color: #fff; }
.today-btn.active::before { content: '✓ '; }
.hint { margin: 10px 0 0; font-size: 14.5px; color: var(--muted); }
.hint.warn {
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-weight: 700;
}

/* ---- trays ---- */

.egg-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  grid-template-areas: 'icon name stepper' '. sub sub';
  align-items: center;
  column-gap: 10px;
  row-gap: 4px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.egg-row:first-child { border-top: 0; padding-top: 0; }
.egg-row:last-child { padding-bottom: 0; }
.egg-icon { grid-area: icon; width: 36px; height: 36px; }
.egg-info { display: contents; }
.egg-name { grid-area: name; font-size: 18px; font-weight: 700; line-height: 1.15; }
.egg-sub { grid-area: sub; font-size: 14.5px; color: var(--muted); }

.stepper { grid-area: stepper; display: flex; align-items: center; gap: 6px; }
.step-btn {
  width: 48px;
  height: 48px;
  padding: 0 0 3px;
  border: 0;
  border-radius: 14px;
  background: var(--yolk);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}
.step-btn:active { background: var(--yolk-deep); transform: scale(0.95); }
.stepper input {
  width: 62px;
  height: 48px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--tint);
  text-align: center;
  font-size: 22px;
  font-weight: 800;
}
.stepper input:focus { border-color: var(--yolk-deep); }

/* ---- sticker drawing: shared by the result tiles and the sheet preview ---- */

.st-cell { fill: #FFFF00; stroke: #000; stroke-width: 1; }
.st-big, .st-small {
  font-family: 'Sticker Black', 'Arial Black', Arial, sans-serif;
  text-anchor: middle;
  fill: #000;
}
.st-big { font-size: 9px; }
.st-small { font-size: 7px; }

/* ---- results ---- */

.groups { display: grid; gap: 10px; }
.group {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--tint);
}
.sticker { flex: none; width: 132px; height: auto; filter: drop-shadow(0 2px 3px rgba(74, 47, 27, 0.25)); }
.group-info { min-width: 0; line-height: 1.25; }
.group-count { font-family: 'Sticker Black', 'Arial Black', system-ui, sans-serif; font-size: 26px; line-height: 1.1; white-space: nowrap; }
.group-label { margin-top: 2px; font-weight: 700; }
.group-note { font-size: 14px; color: var(--muted); }
.group.is-empty .group-count { color: #C9BBA5; }

.totals { margin: 14px 0; }
.totals span { font-size: 14px; color: var(--muted); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  flex: 1 1 150px;
  height: 58px;
  padding: 0 16px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 800;
}
.btn svg { width: 22px; height: 22px; flex: none; }
.btn.primary { background: var(--ink); color: #fff; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn[hidden] { display: none; }

.status { margin: 10px 0 0; min-height: 1.45em; font-size: 14.5px; font-weight: 600; color: var(--ok); }
.status.error { color: var(--err); }

/* ---- sheet preview ---- */

.preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.page { margin: 0; width: 100%; max-width: 440px; justify-self: center; }
.sheet-wrap { position: relative; }
.sheet {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid #DDD3BF;
  border-radius: 3px;
  box-shadow: 0 4px 14px rgba(74, 47, 27, 0.12);
}
.sheet-empty {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 16px;
  display: grid;
  place-items: center;
  text-align: center;
  color: #B5A68F;
}
.page figcaption { margin-top: 6px; text-align: center; font-size: 13px; color: var(--muted); }

.foot {
  max-width: 1040px;
  margin: 0 auto;
  padding: 4px 16px calc(28px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ---- wider screens: inputs on the left, stickers on the right ---- */

@media (min-width: 900px) {
  .top { padding: 16px 24px; }
  .logo { width: 54px; height: 54px; }
  .brand { gap: 12px; }
  .today-chip { padding: 6px 14px 7px; }
  .today-chip strong { font-size: 16px; }
  .layout { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 20px; padding: 24px; align-items: start; }
  .col { gap: 20px; }
  .card { padding: 22px; }
  .sticker { width: 170px; }
  .group-count { font-size: 30px; }
}
