:root {
  --bg: #0b0b0b; --bg2: #151515; --bg3: #1e1e1e; --line: #2a2a2a;
  --cream: #f5e6bf; --text: #f3efe6; --muted: #9b958a;
  --red: #d62828; --red2: #ef3b3b; --ok: #3ccf7a; --warn: #e5a93c;
  --r: 14px; --nav-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-top: env(safe-area-inset-top);
}
body.modal-open { overflow: hidden; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; letter-spacing: .01em; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.4rem; margin-top: 4px; } h3 { font-size: 1.05rem; }
p { margin: 0 0 10px; }
a { color: var(--cream); text-decoration: none; }
code { background: var(--bg3); padding: 2px 6px; border-radius: 6px; font-size: .9em; }
[hidden] { display: none !important; }

#topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: rgba(11,11,11,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand-ic { width: 30px; height: 30px; border-radius: 8px; }
.brand { font-weight: 800; letter-spacing: .18em; flex: 1; }
#view { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); min-height: 70vh; }
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(15,15,15,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
#tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .72rem; color: var(--muted); max-width: 140px; }
#tabbar a span { font-size: 1.35rem; filter: grayscale(1) opacity(.7); }
#tabbar a.on { color: var(--cream); }
#tabbar a.on span { filter: none; }

.center { display: flex; justify-content: center; padding: 40px 0; }
.center-t { text-align: center; }
.muted { color: var(--muted); } .small-t { font-size: .85rem; } .pre { white-space: pre-wrap; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; } .row.end { justify-content: flex-end; margin-top: 14px; }
.row.wrap, .wrap { flex-wrap: wrap; } .row.center { justify-content: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.grid2 .card { margin: 0; display: flex; flex-direction: column; gap: 2px; }
.big { font-size: 1.8rem; }

.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.card.link { color: var(--text); display: block; }
.card.link.row { display: flex; }
.card.dim { opacity: .6; }
.chev { color: var(--muted); font-size: 1.4rem; }
.hero-card { background: linear-gradient(135deg, #2a0d0d, #151515 70%); border: 1px solid #3a1a1a; border-radius: 18px; padding: 20px; margin-bottom: 14px; }
.eyebrow { text-transform: uppercase; letter-spacing: .2em; font-size: .72rem; color: var(--red2); margin: 0 0 2px; }
.stat { display: flex; align-items: center; gap: 16px; }
.num { font-size: 2.2rem; font-weight: 800; color: var(--cream); min-width: 48px; text-align: center; }
.today-item { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.today-item:first-of-type { border-top: 0; }
.today-item > div:nth-child(2) { flex: 1; }
.time { background: var(--bg3); color: var(--cream); border-radius: 10px; padding: 6px 10px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 58px; text-align: center; }
.time.ok { color: var(--ok); min-width: 40px; }
.back { display: inline-block; margin-bottom: 8px; color: var(--muted); }

.btn {
  font: inherit; font-weight: 600; color: var(--text); background: var(--bg3); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 16px; cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:active { background: var(--red2); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: #ff7676; border-color: #5a2323; }
.btn.small { padding: 7px 12px; min-height: 36px; font-size: .88rem; border-radius: 10px; }
.btn.tiny { padding: 4px 9px; min-height: 30px; font-size: .8rem; border-radius: 8px; }
.btn.block { display: flex; width: 100%; margin: 8px 0; }

.tag { display: inline-block; background: var(--bg3); border: 1px solid var(--line); color: var(--muted); font-size: .72rem; padding: 2px 8px; border-radius: 99px; vertical-align: middle; }
.tag.ok { color: var(--ok); border-color: #1f5a3a; } .tag.off { color: #ff9a6a; border-color: #5a3a23; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; min-height: 44px;
}
input[type=file] { padding: 9px; } input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--red); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: 0; border-color: var(--red); }
.check { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.hint { font-size: .78rem; color: var(--muted); margin: -8px 0 12px; }
.search { margin-bottom: 12px; }
.form-error { background: #3a1515; border: 1px solid #6a2a2a; color: #ffb4b4; border-radius: 10px; padding: 9px 12px; margin-bottom: 10px; font-size: .9rem; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 10px -16px 14px; padding: 0 16px 4px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { white-space: nowrap; padding: 8px 14px; border-radius: 99px; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.tabs a.on { background: var(--red); border-color: var(--red); color: #fff; }

.block-card .day { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.block-card .item { padding: 8px 0; align-items: flex-start; gap: 8px; border-top: 1px dashed var(--line); }
.block-card .item:first-of-type { border-top: 0; }
.block-card > .btn { margin-top: 10px; }
.thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: var(--bg3); flex: none; }
.thumb.ph { display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }

.ex { padding: 0; overflow: hidden; }
.ex-media { position: relative; aspect-ratio: 16 / 10; background: var(--bg3); }
.ex-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ex-media .ph { height: 100%; display: flex; align-items: center; justify-content: center; font-size: 3rem; }
.ex-n { position: absolute; top: 10px; left: 10px; background: var(--red); color: #fff; font-weight: 800; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.ex-body { padding: 14px; }
.meta { color: var(--cream); margin: 6px 0; }
.note { background: var(--bg3); border-left: 3px solid var(--red); padding: 8px 10px; border-radius: 6px; color: var(--text); }
details { margin: 8px 0; } summary { cursor: pointer; color: var(--muted); }
.macros { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 8px; margin-bottom: 12px; }
.macro { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px; text-align: center; }
.macro b { display: block; font-size: 1.3rem; color: var(--cream); } .macro span { font-size: .72rem; color: var(--muted); }
.meal h3 { margin: 0; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty-ic { font-size: 2.6rem; margin-bottom: 6px; }

.auth { max-width: 420px; margin: 6vh auto 0; text-align: center; }
.auth-logo { width: 96px; height: 96px; border-radius: 22px; margin-bottom: 10px; }
.auth h1 { letter-spacing: .22em; margin-bottom: 4px; }
.auth .card { text-align: left; }

.modal-wrap { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.7); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--bg2); border: 1px solid var(--line); border-radius: 20px 20px 0 0; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.modal.small { max-width: 400px; } .modal.wide { max-width: 640px; }
.modal video { width: 100%; max-height: 62vh; border-radius: 12px; background: #000; }
.confirm-text { font-size: 1.05rem; }
.timer { text-align: center; padding: 10px 0; }
.timer-num { font-size: 4rem; font-weight: 800; color: var(--cream); font-variant-numeric: tabular-nums; margin: 6px 0 14px; }
@media (min-width: 600px) {
  .modal-wrap { align-items: center; } .modal { border-radius: 20px; }
}

.spin { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: #222; border: 1px solid var(--line); color: var(--text); padding: 10px 16px; border-radius: 12px; max-width: 92vw; box-shadow: 0 6px 20px rgba(0,0,0,.5); transition: opacity .4s; }
.toast.err { background: #3a1515; border-color: #6a2a2a; color: #ffb4b4; } .toast.out { opacity: 0; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
