/* ============================================================
   Мой рацион — дизайн-система (пастельные темы, нативный стиль)
   Все цвета берутся из CSS-переменных, которые выставляет JS-тема.
   ============================================================ */
:root{
  --bg:#f7f3ec; --surface:#fffdf9; --surface-2:#f1ece2; --surface-3:#e8e1d4;
  --text:#312e2a; --text-muted:#756f66; --border:#e2dacb;
  --primary:#6f9c8c; --primary-soft:#dcebe4; --on-primary:#ffffff;
  --accent:#c98d6b; --accent-soft:#f6e3d6;
  --ring-p:#7fa8c9; --ring-f:#d9b06a; --ring-c:#9fbf8f;
  --success:#6f9c76; --warn:#c9a227; --danger:#c2736b;
  --radius:20px; --radius-sm:14px; --radius-xs:10px;
  --shadow:0 8px 24px rgba(49,46,42,.08); --shadow-sm:0 2px 8px rgba(49,46,42,.06);
  --tabbar-h:64px; --font:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0;height:100%}
body{
  font-family:var(--font);background:var(--bg);color:var(--text);
  font-size:16px;line-height:1.45;overscroll-behavior-y:none;
  transition:background .25s ease,color .25s ease;
  -webkit-font-smoothing:antialiased;
}
button,input,select,textarea{font-family:inherit;font-size:inherit;color:inherit}
h1,h2,h3,h4{margin:0;font-weight:700;letter-spacing:-.01em}
p{margin:0 0 8px}
a{color:var(--primary);text-decoration:none}
#app{max-width:620px;margin:0 auto;min-height:100%;padding:0 16px calc(var(--tabbar-h) + 28px);}
.boot{display:flex;flex-direction:column;align-items:center;justify-content:center;height:80vh;gap:14px;color:var(--text-muted)}
.boot-logo{width:64px;height:64px;border-radius:20px;background:var(--primary);color:var(--on-primary);
  display:grid;place-items:center;font-weight:800;font-size:24px;box-shadow:var(--shadow)}

/* ---------- layout ---------- */
.screen{padding-top:12px;animation:fade .22s ease}
@keyframes fade{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.page-head{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 2px 6px}
.page-head h1{font-size:26px}
.page-head .sub{font-size:13px;color:var(--text-muted)}
.section{margin:18px 0}
.section-title{display:flex;align-items:center;justify-content:space-between;margin:0 2px 10px;font-size:15px;color:var(--text-muted);font-weight:600;text-transform:uppercase;letter-spacing:.04em}
.card{background:var(--surface);border-radius:var(--radius);padding:16px;box-shadow:var(--shadow-sm);border:1px solid var(--border)}
.card + .card{margin-top:12px}
.row{display:flex;align-items:center;gap:12px}
.row.between{justify-content:space-between}
.col{display:flex;flex-direction:column;gap:10px}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.grid3{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.muted{color:var(--text-muted)}
.small{font-size:13px}
.tiny{font-size:11.5px}
.bold{font-weight:700}
.center{text-align:center}
.spacer{flex:1}
.hidden{display:none!important}

/* ---------- buttons ---------- */
.btn{
  border:none;border-radius:999px;padding:13px 20px;font-weight:650;font-size:15.5px;
  background:var(--primary);color:var(--on-primary);cursor:pointer;
  transition:transform .12s ease,filter .15s ease,background .2s ease;
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
}
.btn:active{transform:scale(.97)}
.btn.secondary{background:var(--surface-2);color:var(--text)}
.btn.ghost{background:transparent;color:var(--primary);border:1.5px solid var(--primary)}
.btn.accent{background:var(--accent)}
.btn.danger{background:transparent;color:var(--danger);border:1.5px solid var(--danger)}
.btn.block{width:100%}
.btn.sm{padding:8px 14px;font-size:13.5px}
.btn:disabled{opacity:.45;pointer-events:none}
.chip{
  display:inline-flex;align-items:center;gap:6px;padding:8px 13px;border-radius:999px;
  background:var(--surface-2);border:1.5px solid transparent;cursor:pointer;font-size:13.5px;
  font-weight:600;color:var(--text);transition:all .15s ease;user-select:none;
}
.chip.on{background:var(--primary-soft);border-color:var(--primary);color:var(--text)}
.chip.sm{padding:5px 10px;font-size:12px}
.tag{display:inline-block;padding:3px 9px;border-radius:8px;background:var(--surface-2);font-size:11.5px;color:var(--text-muted);font-weight:600}
.tag.good{background:var(--primary-soft);color:var(--text)}
.tag.warn{background:var(--accent-soft);color:var(--text)}

/* ---------- inputs ---------- */
.field{display:flex;flex-direction:column;gap:6px;margin-bottom:12px}
.field label{font-size:13px;font-weight:650;color:var(--text-muted)}
.field input,.field select,.field textarea{
  width:100%;background:var(--surface);border:1.5px solid var(--border);
  border-radius:var(--radius-xs);padding:12px 13px;outline:none;transition:border .15s ease;
}
.field input:focus,.field select:focus,.field textarea:focus{border-color:var(--primary)}
.seg{display:flex;background:var(--surface-2);border-radius:999px;padding:4px;gap:4px}
.seg button{flex:1;border:none;background:transparent;padding:9px 6px;border-radius:999px;font-weight:650;font-size:13.5px;cursor:pointer;color:var(--text-muted)}
.seg button.on{background:var(--surface);color:var(--text);box-shadow:var(--shadow-sm)}

/* ---------- tabbar ---------- */
.tabbar{
  position:fixed;left:0;right:0;bottom:0;z-index:40;
  padding:6px max(12px,calc((100vw - 620px)/2 + 12px)) calc(6px + env(safe-area-inset-bottom));
  background:color-mix(in srgb,var(--surface) 92%,transparent);
  backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);
  border-top:1px solid var(--border);display:flex;gap:4px;
}
.tabbar button{
  flex:1;border:none;background:transparent;cursor:pointer;padding:6px 2px;
  display:flex;flex-direction:column;align-items:center;gap:3px;color:var(--text-muted);
  font-size:11px;font-weight:600;border-radius:14px;
}
.tabbar button .ico{font-size:20px;line-height:1}
.tabbar button.on{color:var(--primary);background:var(--primary-soft)}

/* ---------- rings ---------- */
.rings{display:flex;align-items:center;gap:18px}
.ring-wrap{position:relative;width:132px;height:132px;flex:0 0 auto}
.ring{width:100%;height:100%;border-radius:50%;
  background:conic-gradient(var(--ring-c) 0 calc(var(--pc,0) * 1%), var(--surface-2) 0);
  display:grid;place-items:center;transition:background .4s ease}
.ring::before{content:"";position:absolute;inset:9px;border-radius:50%;background:var(--surface)}
.ring-inner{position:relative;text-align:center;z-index:1}
.ring-inner .kcal{font-size:24px;font-weight:800;line-height:1}
.ring-inner .lbl{font-size:10.5px;color:var(--text-muted)}
.macro-bars{flex:1;display:flex;flex-direction:column;gap:9px}
.mbar .cap{display:flex;justify-content:space-between;font-size:11.5px;color:var(--text-muted);margin-bottom:3px;font-weight:600}
.mbar .track{height:7px;border-radius:99px;background:var(--surface-2);overflow:hidden}
.mbar .fill{height:100%;border-radius:99px;transition:width .4s ease}

/* ---------- meal cards ---------- */
.meal-card{
  display:flex;gap:12px;align-items:center;padding:12px;border-radius:var(--radius-sm);
  background:var(--surface);border:1px solid var(--border);cursor:pointer;
  transition:transform .12s ease,box-shadow .15s ease;box-shadow:var(--shadow-sm);
}
.meal-card:active{transform:scale(.985)}
.meal-thumb{width:52px;height:52px;border-radius:14px;background:var(--surface-2);display:grid;place-items:center;font-size:24px;flex:0 0 auto}
.meal-body{flex:1;min-width:0}
.meal-body .name{font-weight:700;font-size:15px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.meal-body .meta{font-size:12px;color:var(--text-muted);margin-top:2px}
.meal-kcal{font-weight:800;font-size:14px;white-space:nowrap}
.slot-label{font-size:12px;font-weight:700;color:var(--text-muted);text-transform:uppercase;letter-spacing:.06em;margin:14px 2px 6px}

/* ---------- calendar ---------- */
.week-strip{display:grid;grid-template-columns:repeat(7,1fr);gap:6px}
.day-pill{background:var(--surface);border:1.5px solid var(--border);border-radius:14px;padding:8px 2px;text-align:center;cursor:pointer;transition:all .15s ease}
.day-pill .dow{font-size:10.5px;color:var(--text-muted);font-weight:700}
.day-pill .num{font-size:16px;font-weight:800}
.day-pill .dot{width:5px;height:5px;border-radius:50%;background:var(--primary);margin:3px auto 0;opacity:0}
.day-pill.has .dot{opacity:1}
.day-pill.sel{background:var(--primary);border-color:var(--primary);color:var(--on-primary)}
.day-pill.sel .dow,.day-pill.sel .num{color:var(--on-primary)}
.day-pill.today .num{color:var(--primary)}
.day-pill.sel.today .num{color:var(--on-primary)}
.week-grid{display:flex;flex-direction:column;gap:8px}
.wg-row{display:grid;grid-template-columns:56px repeat(7,1fr);gap:4px;align-items:stretch}
.wg-cell{background:var(--surface);border:1px solid var(--border);border-radius:9px;font-size:10px;padding:5px 4px;min-height:46px;cursor:pointer;overflow:hidden;line-height:1.2;color:var(--text-muted)}
.wg-cell.has{background:var(--primary-soft);color:var(--text);font-weight:600}
.wg-head{font-size:10px;font-weight:700;text-align:center;color:var(--text-muted);padding:2px}
.wg-label{font-size:10.5px;font-weight:700;color:var(--text-muted);display:flex;align-items:center}
.month-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:4px}
.mcell{aspect-ratio:1;border-radius:10px;background:var(--surface);border:1px solid var(--border);display:grid;place-items:center;font-size:12.5px;cursor:pointer;position:relative}
.mcell.has::after{content:"";position:absolute;bottom:5px;width:4px;height:4px;border-radius:50%;background:var(--primary)}
.mcell.today{border-color:var(--primary);font-weight:800}
.mcell.sel{background:var(--primary);color:var(--on-primary)}
.mcell.dim{opacity:.35}
.chart{width:100%;height:150px;background:var(--surface-2);border-radius:var(--radius-sm)}
.chart polyline{fill:none;stroke:var(--primary);stroke-width:2.5;stroke-linejoin:round;stroke-linecap:round}
.chart .area{fill:var(--primary-soft);stroke:none;opacity:.6}
.chart text{font-size:9px;fill:var(--text-muted)}

/* ---------- sheet / modal ---------- */
.sheet-backdrop{position:fixed;inset:0;background:rgba(30,28,25,.35);z-index:60;display:flex;align-items:flex-end;justify-content:center;animation:fade .18s ease}
.sheet{
  width:100%;max-width:620px;max-height:92vh;overflow:auto;background:var(--bg);
  border-radius:24px 24px 0 0;padding:10px 18px calc(24px + env(safe-area-inset-bottom));
  animation:up .26s cubic-bezier(.2,.9,.3,1);box-shadow:0 -10px 40px rgba(0,0,0,.18);
}
@keyframes up{from{transform:translateY(40px);opacity:.5}to{transform:none;opacity:1}}
.sheet-grip{width:42px;height:5px;border-radius:99px;background:var(--border);margin:6px auto 12px}
.sheet h2{font-size:22px;margin-bottom:4px}

/* ---------- toast ---------- */
#toast-root{position:fixed;left:0;right:0;bottom:calc(var(--tabbar-h) + 20px);z-index:80;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none}
.toast{background:var(--text);color:var(--bg);padding:11px 18px;border-radius:999px;font-size:13.5px;font-weight:600;box-shadow:var(--shadow);animation:up .22s ease}

/* ---------- misc ---------- */
.progress-line{height:6px;border-radius:99px;background:var(--surface-2);overflow:hidden}
.progress-line>div{height:100%;background:var(--primary);border-radius:99px;transition:width .3s ease}
.stat{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-sm);padding:12px;text-align:center}
.stat .v{font-size:20px;font-weight:800}
.stat .k{font-size:11px;color:var(--text-muted);font-weight:600}
.list-item{display:flex;align-items:center;gap:10px;padding:11px 2px;border-bottom:1px solid var(--border)}
.list-item:last-child{border-bottom:none}
.list-item .grow{flex:1;min-width:0}
.chev{color:var(--text-muted);font-size:18px}
.dragging{opacity:.45;transform:scale(.97)}
.drop-target{outline:2px dashed var(--primary);outline-offset:2px}
.theme-swatch{display:flex;gap:4px;margin-top:6px}
.theme-swatch span{width:16px;height:16px;border-radius:6px;display:block}
.theme-card{border:2px solid var(--border);border-radius:var(--radius-sm);padding:10px;cursor:pointer;background:var(--surface)}
.theme-card.on{border-color:var(--primary)}
.water-dots{display:flex;gap:6px;flex-wrap:wrap}
.water-dot{width:26px;height:26px;border-radius:50%;border:2px solid var(--ring-p);cursor:pointer;background:transparent;transition:background .15s ease}
.water-dot.on{background:var(--ring-p)}
.badge{min-width:20px;height:20px;border-radius:10px;background:var(--accent);color:#fff;font-size:11px;font-weight:800;display:grid;place-items:center;padding:0 5px}
.disclaimer{background:var(--accent-soft);border-radius:var(--radius-sm);padding:12px;font-size:12px;color:var(--text);border:1px solid color-mix(in srgb,var(--accent) 35%,transparent)}

/* ---------- иконки ---------- */
.i{stroke:currentColor;fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;flex:0 0 auto;display:block}
.ico{display:inline-flex;align-items:center;justify-content:center;line-height:0}
.meal-thumb .i{width:26px;height:26px;stroke-width:1.6}
.meal-thumb .ico{line-height:0}
.chip .i{width:15px;height:15px}
.btn .i{width:17px;height:17px}
.section-title .i{width:16px;height:16px;margin-right:6px}
.stat .k{display:flex;align-items:center;justify-content:center;gap:4px}
.brand{display:flex;align-items:center;gap:10px}
.brand-mark{width:40px;height:40px;border-radius:13px;background:var(--primary);color:var(--on-primary);display:grid;place-items:center;box-shadow:var(--shadow-sm)}
.brand-mark .i{width:22px;height:22px;stroke-width:1.9}
.brand h1{font-size:21px;letter-spacing:-.02em}
.brand .sub{font-size:11.5px;color:var(--text-muted)}

/* ---------- адаптив: полноразмерный сайт / вертикальный телефон ---------- */
@media (min-width:900px){
  #app{max-width:1080px;padding:0 28px 40px}
  .page-head h1{font-size:30px}
  .two-col{display:grid;grid-template-columns:1.4fr 1fr;gap:20px;align-items:start}
  .two-col > .col{min-width:0;display:flex;flex-direction:column;gap:14px}
  .two-col .section{margin:0}
  .section{margin:22px 0}
  .tabbar{left:50%;transform:translateX(-50%);width:min(1080px,100%);max-width:1080px;border-radius:18px 18px 0 0;border:1px solid var(--border);border-bottom:none}
  .theme-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
  .rings{gap:28px}
  .boot{height:60vh}
  .sheet{max-width:760px;border-radius:24px;margin-bottom:4vh}
  .sheet-backdrop{align-items:center;padding:20px}
  .month-grid{max-width:620px}
  .week-grid{font-size:11px}
  .wg-cell{min-height:58px;font-size:11px;padding:6px}
}
@media (min-width:1280px){
  #app{max-width:1180px}
}
@media (max-width:400px){
  .page-head h1{font-size:22px}
  .grid3{gap:6px}
}