@font-face { font-family: Vazirmatn; src: url(fonts/vazirmatn_regular.ttf) format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(fonts/vazirmatn_medium.ttf) format('truetype'); font-weight: 500 600; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(fonts/vazirmatn_bold.ttf) format('truetype'); font-weight: 700 900; font-display: swap; }

:root {
  --cream: #F7F3EE; --paper: #FFFFFF; --sand: #EFE9E1; --ink: #17131A; --muted: #8A8189; --hair: #E6DFD6;
  --ruby: #C8102E; --ruby-deep: #9E0B23; --ruby-soft: #FBE4E7; --leaf: #2E9E6A; --leaf-soft: #E2F4EA;
  --saffron: #F0A202; --coral: #FF6F61; --lapis: #4A5FC1; --aqua: #1FA8D8; --turq: #1C9AA0;
  --protein: #E8475B; --carbs: #F0A202; --fat: #3B8FE0; --sugar: #D9638F;
  --radius: 26px; --shadow: 0 6px 24px rgba(23, 19, 26, .07);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--cream); color: var(--ink); font-family: Vazirmatn, Tahoma, sans-serif; }
body { min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
img { display: block; }
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding-bottom: 110px; }

.splash { height: 100vh; display: grid; place-content: center; text-align: center; font-weight: 800; font-size: 28px; }
.splash img { width: 120px; margin: 0 auto 8px; }

.page { padding: 16px 16px 0; display: flex; flex-direction: column; gap: 14px; }
h1 { font-size: 26px; margin: 4px 0 0; font-weight: 800; }
h2 { font-size: 17px; margin: 0; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.card { background: var(--paper); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }

/* ---------- hero ---------- */
.hero { position: relative; height: 340px; border-radius: 36px 36px 28px 28px; overflow: hidden; }
.hero > img.scene { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero .veil { position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(255,255,255,.62), rgba(255,255,255,0) 55%); }
.hero.night .veil { background: linear-gradient(to bottom, rgba(11,18,48,.8), rgba(16,24,64,.3) 60%); }
.hero .numbers { position: absolute; top: 88px; left: 0; right: 0; text-align: center; }
.hero .left { font-size: 46px; font-weight: 900; line-height: 1.1; }
.hero .avatar { position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); height: 140px; }
.hero svg.crown { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.hero .scene-btn { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.85); font-size: 18px; }
.hero.night { color: #fff; }
.bubble { background: var(--paper); border-radius: 22px; padding: 14px 16px; box-shadow: var(--shadow); font-weight: 600; line-height: 1.7; }

/* ---------- macros ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.tile { border-radius: 20px; padding: 10px; display: flex; align-items: center; gap: 8px; }
.tile .val { font-size: 20px; font-weight: 800; }
.ring { width: 46px; height: 46px; flex: none; position: relative; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }

/* ---------- meals ---------- */
.plates { display: flex; justify-content: space-between; margin-top: 12px; }
.plate { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 25%; font-size: 13px; }
.plate .disc { width: 66px; height: 66px; border-radius: 50%; border: 4px solid; display: grid; place-items: center; position: relative; font-size: 26px; }
.plate .disc img { width: 42px; height: 42px; object-fit: contain; }
.badge { position: absolute; bottom: -4px; left: -4px; color: #fff; background: var(--ruby); border-radius: 12px; padding: 0 6px; font-size: 11px; }
.meal-block { border-radius: 18px; padding: 8px 10px; margin-top: 8px; }
.pill { color: #fff; border-radius: 999px; padding: 1px 9px; font-size: 12px; }
.item { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.item img, .avatar-dot { width: 34px; height: 34px; object-fit: contain; flex: none; }
.avatar-dot { border-radius: 50%; display: grid; place-items: center; font-weight: 800; }
.x { width: 32px; height: 32px; border-radius: 50%; color: var(--muted); font-size: 18px; }

/* ---------- buttons & inputs ---------- */
.btn { background: var(--ruby); color: #fff; border-radius: 18px; padding: 13px 18px; font-weight: 700; width: 100%; font-size: 16px; }
.btn:disabled { opacity: .45; }
.btn.secondary { background: var(--sand); color: var(--ink); }
.chip { background: var(--sand); border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--ink); color: #fff; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.chips.wrap { flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field input, .field select, .search { background: var(--paper); border: 1px solid var(--hair); border-radius: 16px; padding: 12px 14px; font-size: 16px; color: var(--ink); width: 100%; }
.search { border: 0; box-shadow: var(--shadow); }

/* ---------- bottom bar ---------- */
.bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: center; pointer-events: none; }
.bar-inner { pointer-events: auto; width: 100%; max-width: 560px; background: var(--paper); border-radius: 26px 26px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.08);
  display: grid; grid-template-columns: 1fr 1fr 84px 1fr 1fr; align-items: end; padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); }
.tab { display: flex; flex-direction: column; align-items: center; font-size: 12px; color: var(--muted); padding: 6px 0; gap: 2px; }
.tab .ic { font-size: 22px; line-height: 1; }
.tab.on { color: var(--ink); font-weight: 700; }
.plus { justify-self: center; width: 66px; height: 66px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #E8334F, var(--ruby) 55%, var(--ruby-deep));
  color: #fff; font-size: 36px; margin-top: -34px; box-shadow: 0 6px 16px rgba(158,11,35,.4); }

/* ---------- modal / sheets ---------- */
#modal:empty { display: none; }
.screen { position: fixed; inset: 0; z-index: 40; background: var(--cream); overflow-y: auto; animation: up .18s ease-out; }
.screen-inner { max-width: 560px; margin: 0 auto; padding: 12px 16px 120px; display: flex; flex-direction: column; gap: 12px; }
.sheet-back { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--cream); width: 100%; max-width: 560px; border-radius: 28px 28px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 90vh; overflow-y: auto; animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.topbar { display: flex; align-items: center; gap: 8px; }
.close { width: 40px; height: 40px; border-radius: 50%; font-size: 22px; }
.food-row { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-radius: 16px; width: 100%; text-align: right; }
.food-row:active { background: var(--sand); }
.food-row img, .food-row .avatar-dot { width: 46px; height: 46px; }
.add { width: 34px; height: 34px; border-radius: 50%; background: var(--ruby-soft); color: var(--ruby); display: grid; place-items: center; font-size: 22px; flex: none; }
.section-title { color: var(--muted); font-size: 14px; font-weight: 700; margin: 12px 0 2px; }
.qty { display: flex; align-items: center; justify-content: center; gap: 18px; }
.round { width: 48px; height: 48px; border-radius: 50%; background: var(--paper); box-shadow: var(--shadow); font-size: 24px; }

#toast { position: fixed; bottom: 110px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 14px; font-size: 14px;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: 90%; text-align: center; }
#toast.show { opacity: 1; }

.scene-card { position: relative; border-radius: 32px 32px 24px 24px; overflow: hidden; height: 230px; }
.scene-card > img.scene { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scene-card .char { position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); height: 165px; }
.sign { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: #7A4E2D; color: #fff; border-radius: 10px; padding: 4px 14px; font-weight: 700; font-size: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pick { background: var(--paper); border-radius: 18px; padding: 6px; text-align: center; font-size: 13px; border: 2px solid transparent; }
.pick.on { border-color: var(--ruby); background: var(--ruby-soft); }
.pick img { width: 100%; height: 86px; object-fit: contain; }
.pick.scene img { object-fit: cover; border-radius: 12px; }
.strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; }
.day { flex: none; width: 54px; border-radius: 18px; background: var(--paper); padding: 8px 0; text-align: center; font-size: 12px; }
.day.on { background: var(--ruby-soft); color: var(--ruby); font-weight: 700; }
.day .bar-mini { width: 8px; height: 22px; border-radius: 4px; background: var(--sand); margin: 4px auto 0; position: relative; overflow: hidden; }
.day .bar-mini span { position: absolute; bottom: 0; left: 0; right: 0; background: var(--ruby); }
.steps li { margin: 4px 0; line-height: 1.7; }
.tipbox { background: #FDF1D8; color: var(--ruby-deep); border-radius: 12px; padding: 8px 10px; font-size: 13px; }
