/* FitBase — Dark UI */
:root {
  --bg: #111512;
  --card: #1C241F;
  --surface: #263029;
  --surface2: #2E3A32;
  --accent: #B6F36B;
  --accent-ink: #0F1A06;
  --text: #F2F5F0;
  --muted: #929E95;
  --danger: #FF7A6B;
  --warn: #F2B36B;
  --line: rgba(255, 255, 255, .07);
  --r: 20px;
  --sab: env(safe-area-inset-bottom, 0px);
  --sat: env(safe-area-inset-top, 0px);
  --nav-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; max-width: 100vw; overflow-x: hidden; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
  overscroll-behavior: none; -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.danger-text { color: var(--danger); }
.warn-text { color: var(--warn); }
.small { font-size: 12.5px; }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrap { overflow-wrap: anywhere; }
.row { display: flex; align-items: center; gap: 12px; }
.row.top { align-items: flex-start; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.gap8 { gap: 8px; }

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
#demo-banner { background: #3a2f12; color: var(--warn); text-align: center; font-size: 12px; padding: calc(6px + var(--sat)) 12px 6px; }
#view {
  flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; outline: none;
  padding: calc(14px + var(--sat)) 16px calc(var(--nav-h) + var(--sab) + 24px);
}
#demo-banner:not([hidden]) + #view { padding-top: 14px; }
.view-in { animation: viewIn .22s ease both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Навигация */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + var(--sab)); padding-bottom: var(--sab);
  background: rgba(17, 21, 18, .94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.nav-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; position: relative; transition: color .15s; }
.nav-btn .ic { width: 24px; height: 24px; }
.nav-btn.active { color: var(--accent); }
.nav-btn.active::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 4px 4px; background: var(--accent); }
.nav-btn:active .ic { transform: scale(.9); }

.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; transition: transform .12s; }
.ic.fill { fill: currentColor; }
.ic.sm { width: 18px; height: 18px; }

/* Заголовки и карточки */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.h2 { font-size: 17px; font-weight: 650; }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card { background: var(--card); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.card.tight { padding: 12px 14px; }
.card-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.card-title h2 { font-size: 16px; font-weight: 650; }
.link { color: var(--accent); font-size: 14px; font-weight: 550; padding: 6px 0; }
.sep { height: 1px; background: var(--line); margin: 12px 0; }
.empty { text-align: center; color: var(--muted); padding: 22px 12px; }
.empty .big { font-size: 34px; margin-bottom: 6px; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border-radius: 14px; background: var(--surface); font-weight: 600; font-size: 15px; transition: transform .1s, opacity .15s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: rgba(255, 122, 107, .14); color: var(--danger); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 11px; }
.btn.block { display: flex; width: 100%; }
.btn[disabled], .btn.busy { opacity: .55; pointer-events: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--surface); display: inline-flex; align-items: center; justify-content: center; flex: none; transition: transform .1s; }
.icon-btn:active { transform: scale(.92); }
.icon-btn.plain { background: transparent; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }

/* Поля */
.field { display: block; margin-bottom: 12px; }
.field > span, .field > .lbl { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.inp {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 13px; background: var(--surface); border: 1.5px solid transparent;
  font-size: 16px; outline: none; transition: border-color .15s; appearance: none; -webkit-appearance: none;
}
select.inp { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.inp:focus { border-color: var(--accent); }
.inp::placeholder { color: #667069; }
textarea.inp { min-height: 90px; resize: vertical; }
input[type=date].inp { min-height: 48px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.search { position: relative; }
.search .ic { position: absolute; left: 13px; top: 13px; color: var(--muted); width: 20px; height: 20px; }
.search .inp { padding-left: 42px; }

.stepper { display: inline-flex; align-items: center; background: var(--surface); border-radius: 14px; }
.stepper button { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 500; }
.stepper button:active { background: var(--surface2); border-radius: 14px; }
.stepper b { min-width: 42px; text-align: center; font-size: 17px; }

/* Чипсы и сегменты */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 34px; padding: 0 14px; border-radius: 99px; background: var(--surface); color: var(--muted); font-size: 13.5px; font-weight: 550; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, color .15s; }
.chip.active { background: var(--accent); color: var(--accent-ink); }
.seg { display: flex; background: var(--surface); border-radius: 14px; padding: 3px; margin-bottom: 14px; }
.seg button { flex: 1; min-height: 38px; border-radius: 11px; font-size: 13.5px; font-weight: 600; color: var(--muted); transition: background .15s, color .15s; }
.seg button.active { background: var(--bg); color: var(--accent); }

/* Главная */
.date-nav { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 12px; }
.date-pill { position: relative; flex: 1; text-align: center; height: 40px; line-height: 40px; background: var(--card); border-radius: 12px; font-weight: 600; font-size: 14.5px; overflow: hidden; }
.date-pill input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; }
.ring-card { display: flex; gap: 16px; align-items: center; }
.ring { position: relative; width: 128px; height: 128px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .trk { stroke: var(--surface); }
.ring .val { stroke: var(--accent); transition: stroke-dashoffset .6s cubic-bezier(.2, .8, .2, 1); }
.ring.over .val { stroke: var(--warn); }
.ring-mid { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-mid b { font-size: 26px; line-height: 1.05; font-weight: 700; }
.ring-mid span { font-size: 11.5px; color: var(--muted); max-width: 84px; }
.macros { flex: 1; min-width: 0; }
.macro + .macro { margin-top: 11px; }
.macro .top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
.bar { height: 7px; border-radius: 99px; background: var(--surface); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.bar.over > i { background: var(--warn); }
.kc-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; text-align: center; }
.kc-strip div { background: var(--surface); border-radius: 12px; padding: 8px 4px; }
.kc-strip b { display: block; font-size: 16px; }
.kc-strip span { font-size: 11px; color: var(--muted); }
.qa { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.qa .btn { min-height: 54px; }
.meal-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 0 6px; }
.meal-head b { font-size: 15px; }
.entry { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.entry .nm { font-size: 14.5px; }
.entry .meta { font-size: 12px; color: var(--muted); }
.entry .kc { font-weight: 650; white-space: nowrap; }
.emo { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); display: flex; align-items: center; justify-content: center; font-size: 22px; flex: none; }
.next-w { display: flex; align-items: center; gap: 12px; }
.next-w .emo { background: rgba(182, 243, 107, .14); color: var(--accent); }
.plan-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.plan-item.done { opacity: .5; }
.plan-item.done .nm { text-decoration: line-through; }

/* Рецепты */
.recipe-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.rcard { background: var(--card); border-radius: 18px; overflow: hidden; text-align: left; display: flex; flex-direction: column; transition: transform .1s; }
.rcard:active { transform: scale(.98); }
.rimg { height: 84px; display: flex; align-items: center; justify-content: center; font-size: 42px; position: relative; }
.rimg .fav { position: absolute; top: 8px; right: 8px; color: var(--accent); }
.rbody { padding: 10px 12px 12px; }
.rtitle { font-weight: 650; font-size: 14px; line-height: 1.25; min-height: 35px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rmeta { margin-top: 6px; font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.hero { height: 130px; border-radius: 18px; display: flex; align-items: center; justify-content: center; font-size: 64px; margin-bottom: 14px; }
.macro-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.tile { background: var(--surface); border-radius: 14px; padding: 10px 4px; text-align: center; }
.tile b { display: block; font-size: 16px; }
.tile span { font-size: 11px; color: var(--muted); }
.ing { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.ing:first-child { border-top: 0; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: st; }
.steps li { counter-increment: st; position: relative; padding: 4px 0 12px 36px; }
.steps li::before { content: counter(st); position: absolute; left: 0; top: 2px; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); color: var(--accent); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }

/* Тренировки */
.sched-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.sched-row .d { width: 34px; font-weight: 650; color: var(--muted); }
.sched-row.today .d { color: var(--accent); }
.sched-row select { min-height: 42px; }
.prog { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.prog:first-of-type { border-top: 0; }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 99px; background: rgba(182, 243, 107, .14); color: var(--accent); font-size: 11.5px; font-weight: 650; }
.ex-edit { background: var(--surface); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.ex-edit .grid3 { margin-top: 8px; }
.w-top { position: sticky; top: 0; z-index: 3; background: #171d19; padding: 6px 0 10px; }
.w-prog { display: flex; gap: 4px; margin-top: 8px; }
.w-prog i { flex: 1; height: 4px; border-radius: 4px; background: var(--surface); transition: background .2s; }
.w-prog i.done { background: var(--accent); }
.w-prog i.cur { background: var(--muted); }
.set-head, .set-row { display: grid; grid-template-columns: 32px 1fr 1fr 52px; gap: 8px; align-items: center; }
.set-head { font-size: 11.5px; color: var(--muted); padding: 0 0 4px; text-align: center; }
.set-row { margin-bottom: 8px; }
.set-row .n { text-align: center; font-weight: 700; color: var(--muted); }
.set-row .inp { text-align: center; padding: 8px 6px; min-height: 50px; font-size: 18px; font-weight: 650; }
.set-row.done .inp { background: rgba(182, 243, 107, .12); color: var(--accent); }
.chk { width: 52px; height: 50px; border-radius: 13px; background: var(--surface); display: flex; align-items: center; justify-content: center; color: var(--muted); transition: background .15s, color .15s, transform .1s; }
.chk:active { transform: scale(.92); }
.chk.on { background: var(--accent); color: var(--accent-ink); }
.rest-bar { position: sticky; bottom: 0; background: #1d2620; border-radius: 16px; padding: 12px 14px; margin-top: 12px; box-shadow: 0 -6px 24px rgba(0, 0, 0, .35); }
.rest-bar .t { font-size: 28px; font-weight: 700; color: var(--accent); min-width: 78px; }
.hint { background: rgba(182, 243, 107, .1); color: var(--accent); border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px; }
.prev { font-size: 13px; color: var(--muted); margin: 4px 0 10px; }
.delta-up { color: var(--accent); }
.delta-down { color: var(--warn); }

/* Покупки */
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.totals .tile { text-align: left; padding: 12px; }
.totals .tile b { font-size: 19px; }
.cat-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 4px; font-weight: 650; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.cat-title + .item { border-top: 0; }
.cb { width: 26px; height: 26px; border-radius: 8px; border: 2px solid #4a574f; display: flex; align-items: center; justify-content: center; flex: none; color: transparent; transition: all .15s; }
.cb.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.item.checked .nm { text-decoration: line-through; color: var(--muted); }
.item .qty { font-size: 12.5px; color: var(--muted); }

/* Прогресс */
.stat3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat3 .tile { padding: 12px 6px; }
.chart { width: 100%; display: block; }
.chart text { fill: var(--muted); font-size: 10px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ln { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chart .dot { fill: var(--bg); stroke: var(--accent); stroke-width: 2; }
.chart .dot.last { fill: var(--accent); }
.meas { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.meas .vals { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--muted); }
.meas .vals b { color: var(--text); font-weight: 600; }

/* Шторки */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); opacity: 0; transition: opacity .22s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column;
  background: #171d19; border-radius: 24px 24px 0 0; transform: translateY(102%); transition: transform .26s cubic-bezier(.2, .8, .2, 1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .45);
}
.sheet.full { height: 100vh; height: 100dvh; max-height: none; border-radius: 0; padding-top: var(--sat); }
.sheet-wrap.open .sheet-bg { opacity: 1; }
.sheet-wrap.open .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 8px; }
.sheet-title { font-size: 18px; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.sheet-body { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 4px 16px calc(24px + var(--sab)); }
.sheet-grab { width: 38px; height: 4px; border-radius: 4px; background: var(--surface2); margin: 8px auto 0; }
.pick { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 0; border-top: 1px solid var(--line); text-align: left; }
.pick:first-child { border-top: 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--sab) + 14px); transform: translate(-50%, 12px); z-index: 80;
  max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: 14px; background: var(--surface2); color: var(--text);
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: #4a2420; color: #ffd3cc; }

/* Загрузка и ошибки */
.skel { background: linear-gradient(90deg, var(--card) 25%, var(--surface) 50%, var(--card) 75%); background-size: 200% 100%; animation: sh 1.3s infinite; border-radius: var(--r); }
@keyframes sh { to { background-position: -200% 0; } }
.fatal { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; padding: 24px; }
.fatal .big { font-size: 52px; }
.spin { width: 18px; height: 18px; border: 2.5px solid rgba(255, 255, 255, .25); border-top-color: currentColor; border-radius: 50%; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.code { width: 100%; min-height: 140px; font: 12px/1.35 ui-monospace, Menlo, monospace; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 350px) { .ring { width: 108px; height: 108px; } .ring-mid b { font-size: 22px; } .macro-tiles { grid-template-columns: repeat(2, 1fr); } }
