:root {
  --bg: #fff7ec;
  --card: #ffffff;
  --ink: #2b2d42;
  --muted: #7b7f99;
  --line: #f0e6d8;
  --accent: #ff7a59;
  --accent-2: #ffd166;
  --ok: #06d6a0;
  --radius: 22px;
  --shadow: 0 6px 20px rgba(60, 40, 20, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Rubik', 'Varela Round', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
h1, h2 { margin: 0; }
.hidden { display: none !important; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 20px 6px;
}
.top h1 { font-size: 26px; font-weight: 800; letter-spacing: -.3px; }
.top-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.top-actions { margin-inline-start: auto; display: flex; gap: 6px; }
.pill {
  background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow);
}
.pill.warn { background: #ffe9e3; }
.week-nav { display: flex; align-items: center; gap: 4px; }
.week-arrow {
  width: 30px; height: 30px; border-radius: 50%; background: #fff; box-shadow: var(--shadow);
  font-size: 12px; display: grid; place-items: center; transition: transform .15s;
}
.week-arrow:hover:not(:disabled) { transform: scale(1.12); }
.week-arrow:disabled { opacity: .3; cursor: default; box-shadow: none; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; font-size: 20px; background: #fff;
  box-shadow: var(--shadow); display: grid; place-items: center; transition: transform .15s;
}
.icon-btn:hover { transform: scale(1.08); }

/* ---------- days strip ---------- */
.days {
  display: flex; gap: 8px; padding: 10px 20px 4px; overflow-x: auto; scrollbar-width: none;
}
.days::-webkit-scrollbar { display: none; }
.day {
  flex: 1 0 96px; min-width: 96px; background: #fff; border-radius: 18px; padding: 10px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  box-shadow: var(--shadow); border: 3px solid transparent; transition: transform .15s, border-color .15s;
  position: relative;
}
.day:hover { transform: translateY(-2px); }
.day.active { border-color: var(--accent); }
.day .day-name { font-weight: 700; font-size: 15px; }
.day .day-foods { font-size: 18px; line-height: 1; min-height: 22px; letter-spacing: -2px; }
.day .day-status { font-size: 13px; font-weight: 500; color: var(--muted); }
.day.done .day-status { color: #0a9c73; }
.day.treat .day-status { color: #d9480f; }
.day .today-tag {
  position: absolute; top: -9px; inset-inline-end: 8px; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
}

/* ---------- layout ---------- */
.layout {
  display: grid; grid-template-columns: 380px 1fr; gap: 18px; padding: 14px 20px 40px; align-items: start;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .plate-section { position: static !important; }
}

/* ---------- plate ---------- */
.plate-section { padding: 18px; position: sticky; top: 12px; }
.plate-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.plate-header h2 { font-size: 20px; font-weight: 800; }
.small-btn {
  background: #fff3ee; border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 500;
  transition: background .15s;
}
.small-btn:hover { background: #ffe1d6; }
.plate {
  min-height: 120px; border-radius: 18px; padding: 12px;
  background: radial-gradient(circle at 50% 50%, #fff 55%, #f6f1e8 56%, #fffaf3 70%);
  border: 3px dashed var(--line);
  display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; justify-content: center;
}
.plate .empty { color: var(--muted); font-size: 15px; align-self: center; text-align: center; width: 100%; padding: 20px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: #fff; border-radius: 999px;
  padding: 6px 10px 6px 6px; box-shadow: var(--shadow); font-weight: 500; font-size: 15px;
  animation: pop .3s cubic-bezier(.2, 1.4, .4, 1);
}
.chip .chip-emoji { font-size: 22px; }
.chip .chip-x {
  width: 22px; height: 22px; border-radius: 50%; background: #f3f3f7; font-size: 12px; display: grid; place-items: center;
  color: var(--muted);
}
.chip .chip-x:hover { background: #ffd7cc; color: #c0392b; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.status {
  margin: 12px 0 8px; padding: 10px 12px; border-radius: 14px; font-size: 15px; font-weight: 500;
  background: #fff8e1; text-align: center; min-height: 42px; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.status.ok { background: #dff8ef; color: #0a7a5a; font-weight: 700; font-size: 17px; }
.status .miss {
  background: #fff; border-radius: 999px; padding: 4px 10px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow); border: 2px solid transparent; transition: transform .12s, border-color .15s;
}
.status .miss:hover { transform: scale(1.05); }
.status .miss.active { border-color: var(--accent); }
.status { flex-wrap: wrap; }
.status.treat { background: #ffe9e3; color: #c2410c; font-weight: 700; font-size: 17px; }

/* ---------- bars ---------- */
.bars { display: flex; flex-direction: column; gap: 9px; margin-top: 6px; }
.bar {
  display: grid; grid-template-columns: 96px 1fr 26px; align-items: center; gap: 8px;
  width: 100%; text-align: start; padding: 3px 4px; border-radius: 12px;
  border: 2px solid transparent; transition: background .15s, border-color .15s;
}
.bar:hover { background: #faf7f2; }
.bar.filtering { border-color: var(--accent); background: #fff3ee; }
.bar-label { font-size: 15px; font-weight: 700; white-space: nowrap; }
.bar-track { height: 22px; border-radius: 999px; background: #f0eee9; overflow: hidden; position: relative; }
.bar-fill {
  height: 100%; border-radius: 999px; width: 0;
  transition: width .5s cubic-bezier(.2, 1, .3, 1);
  background-image: linear-gradient(135deg, rgba(255,255,255,.35) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.35) 50%, rgba(255,255,255,.35) 75%, transparent 75%);
  background-size: 22px 22px;
}
.bar.full .bar-fill { animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: 22px 0; } }
.bar-check { font-size: 18px; text-align: center; opacity: 0; transform: scale(.3); transition: all .3s cubic-bezier(.2, 1.4, .4, 1); }
.bar.full .bar-check { opacity: 1; transform: scale(1); }

/* ---------- foods ---------- */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tab {
  background: #fff; border-radius: 999px; padding: 8px 14px; font-weight: 500; font-size: 15px;
  box-shadow: var(--shadow); border: 2px solid transparent; transition: all .15s;
}
.tab.active { border-color: var(--accent); background: #fff3ee; }
.nutrient-tabs { margin-top: -4px; }
.tab.nut { font-size: 14px; padding: 6px 12px; border-color: color-mix(in srgb, var(--nut) 35%, #fff); }
.tab.nut.active { border-color: var(--nut); background: color-mix(in srgb, var(--nut) 14%, #fff); }
.tab.nut.done { opacity: .55; }
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px;
}
.food {
  background: #fff; border-radius: 18px; padding: 12px 8px 10px; text-align: center;
  box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 4px;
  position: relative; border: 3px solid transparent;
  transition: transform .12s, border-color .15s, opacity .2s;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.food:hover { transform: translateY(-3px) scale(1.03); }
.food:active { transform: scale(.95); }
.food.selected { border-color: var(--ok); background: #f2fdf9; }
.food.disabled { opacity: .35; cursor: not-allowed; }
.food.disabled:hover { transform: none; }
.food .emoji { font-size: 40px; line-height: 1.1; }
.food .name { font-weight: 700; font-size: 15px; }
.food .hearts { font-size: 10px; position: relative; display: inline-block; line-height: 1.4; }
.food .hearts-base { white-space: nowrap; }
.food .hearts-fill { position: absolute; top: 0; inset-inline-start: 0; overflow: hidden; white-space: nowrap; }
.food .hearts.none { font-size: 12px; color: var(--muted); }
.food .tag { font-size: 11px; color: var(--muted); background: #f6f4ff; border-radius: 999px; padding: 1px 8px; }
.food .tag.nut { font-size: 11px; background: color-mix(in srgb, var(--nut) 16%, #fff); letter-spacing: -1px; }
.food .tag.treat { background: #ffe9e3; color: #c2410c; }
.food .badge {
  position: absolute; top: -8px; inset-inline-start: -6px; background: var(--ok); color: #fff; font-weight: 800;
  border-radius: 999px; padding: 2px 8px; font-size: 13px; animation: pop .3s;
}
.food.shake { animation: shake .4s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.food.bump { animation: bump .35s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes bump { 50% { transform: scale(1.15); } }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(43, 45, 66, .45); display: grid; place-items: center; z-index: 50; padding: 16px;
}
.modal-box { width: min(440px, 100%); padding: 20px; max-height: 90vh; overflow: auto; }
.modal-box.wide { width: min(640px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { font-size: 20px; font-weight: 800; }
.modal-head > div { display: flex; gap: 8px; align-items: center; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; font-weight: 500; }
.field input { width: 72px; font: inherit; font-size: 18px; padding: 6px 10px; border-radius: 12px; border: 2px solid var(--line); text-align: center; }
hr { border: 0; border-top: 2px solid var(--line); margin: 12px 0; }
.danger-btn { width: 100%; background: #ffe9e3; color: #c2410c; font-weight: 700; padding: 12px; border-radius: 14px; }
.danger-btn.confirm { background: #c2410c; color: #fff; }

.summary-day { display: grid; grid-template-columns: 80px 1fr 40px; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 2px solid var(--line); }
.summary-day:last-child { border-bottom: 0; }
.summary-day .sd-name { font-weight: 700; }
.summary-day .sd-foods { font-size: 15px; line-height: 1.6; }
.summary-day .sd-foods .muted { color: var(--muted); }
.summary-day .sd-status { font-size: 22px; text-align: center; }

/* ---------- toast / celebrate / confetti ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: 999px; font-weight: 500; font-size: 16px; z-index: 60; box-shadow: var(--shadow);
  animation: pop .3s;
}
.celebrate {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 55; pointer-events: none;
}
.celebrate span {
  background: #fff; border-radius: 30px; padding: 20px 36px; font-size: 36px; font-weight: 800; box-shadow: 0 12px 40px rgba(0,0,0,.2);
  animation: celebratePop 1.8s cubic-bezier(.2, 1.4, .4, 1) forwards;
}
@keyframes celebratePop {
  0% { transform: scale(.3); opacity: 0; } 15% { transform: scale(1.05); opacity: 1; } 80% { transform: scale(1); opacity: 1; } 100% { transform: scale(.9); opacity: 0; }
}
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 54; overflow: hidden; }
#confetti span { position: absolute; top: -40px; font-size: 26px; animation: fall linear forwards; }
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: .8; }
}

/* ---------- print ---------- */
@media print {
  body > *:not(#modal-summary) { display: none !important; }
  .modal { position: static; background: none; padding: 0; display: block; }
  .modal-box { box-shadow: none; width: 100%; max-height: none; }
  .modal-head button { display: none; }
}
