:root {
  --bg: #17131f;
  --panel: #1e1928;
  --panel-2: #241e31;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f3f0fb;
  --muted: #a79fc0;
  --food: #ffab3d;
  --water: #46c8ff;
  --activity: #5ee08a;
  --mood: #ff7ac1;
  --accent: #8f7bff;
  --danger: #ff6b6b;
  --radius: 18px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(900px 500px at 15% -10%, #2a2140 0%, transparent 60%),
    radial-gradient(700px 400px at 110% 10%, #1b2b3d 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  min-height: 100vh;
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(23, 19, 31, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar__cat {
  font-size: 34px;
  line-height: 1;
  animation: catBounce 3.4s ease-in-out infinite;
  filter: drop-shadow(0 4px 10px rgba(255, 171, 61, 0.35));
}
@keyframes catBounce {
  0%, 88%, 100% { transform: translateY(0) rotate(0); }
  92% { transform: translateY(-7px) rotate(-8deg); }
  96% { transform: translateY(0) rotate(6deg); }
}
.topbar__title { margin: 0; font-size: 17px; letter-spacing: 0.4px; color: var(--muted); }
.topbar__name {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  background: transparent;
  border: 1px dashed transparent;
  border-radius: 10px;
  padding: 2px 6px;
  width: 200px;
  max-width: 40vw;
}
.topbar__name:hover, .topbar__name:focus { border-color: var(--line); outline: none; background: var(--panel); }
.topbar__right { display: flex; align-items: center; gap: 10px; }
.cat-switch { display: flex; align-items: center; gap: 6px; }
.cat-switch select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  max-width: 170px;
  cursor: pointer;
}
.cat-switch select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.icon-btn--plus { font-weight: 700; font-size: 18px; }
.topbar__date {
  font-size: 14px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 7px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.icon-btn {
  font-size: 16px;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  transition: transform 0.15s;
}
.icon-btn:hover { transform: translateY(-2px); }
.icon-btn.is-off { filter: grayscale(1); opacity: 0.55; }

/* ---------- layout ---------- */
.wrap { max-width: 1060px; margin: 0 auto; padding: 22px 18px 60px; }
.section { margin-bottom: 30px; animation: rise 0.5s ease both; }
.section:nth-of-type(2) { animation-delay: 0.06s; }
.section:nth-of-type(3) { animation-delay: 0.12s; }
.section:nth-of-type(4) { animation-delay: 0.18s; }
.section:nth-of-type(5) { animation-delay: 0.24s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.section__title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 20px;
  margin: 0 0 14px;
}
.section__sub { font-size: 13px; font-weight: 400; color: var(--muted); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat {
  display: flex;
  gap: 12px;
  background: linear-gradient(160deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  transition: transform 0.18s, box-shadow 0.18s;
}
.stat:hover { transform: translateY(-4px); box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35); }
.stat__icon { font-size: 26px; }
.stat__body { flex: 1; min-width: 0; }
.stat__label { font-size: 13px; color: var(--muted); }
.stat__value { display: flex; align-items: baseline; gap: 6px; margin: 3px 0 8px; }
.stat__value b { font-size: 26px; line-height: 1; }
.stat__goal { font-size: 13px; color: var(--muted); }
.stat__hint { font-size: 12px; color: var(--muted); margin-top: 7px; min-height: 15px; }
.bar { height: 9px; border-radius: 99px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.bar__fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  transition: width 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.stat--food .bar__fill { background: linear-gradient(90deg, #ff8a2b, var(--food)); }
.stat--water .bar__fill { background: linear-gradient(90deg, #2b9fff, var(--water)); }
.stat--activity .bar__fill { background: linear-gradient(90deg, #29c66c, var(--activity)); }
.stat--mood .bar__fill { background: linear-gradient(90deg, #ff4fa3, var(--mood)); }
.stat--food .stat__value b { color: var(--food); }
.stat--water .stat__value b { color: var(--water); }
.stat--activity .stat__value b { color: var(--activity); }
.stat--mood .stat__value b { color: var(--mood); }

/* ---------- tabs & forms ---------- */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tab {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 15px;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.16s;
}
.tab:hover { color: var(--text); transform: translateY(-2px); }
.tab.is-active { background: var(--accent); border-color: var(--accent); color: #17131f; font-weight: 700; }

.panel {
  display: none;
  gap: 14px;
  align-items: end;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.panel.is-active { display: flex; animation: rise 0.3s ease both; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 150px; }
.field--wide { min-width: 100%; }
.field label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); }
.field input, .field select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 16px;
  font-family: inherit;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 22px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  color: #17131f;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn--food { background: var(--food); }
.btn--water { background: var(--water); }
.btn--activity { background: var(--activity); }
.btn--mood { background: var(--mood); }
.btn--ghost {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 13px;
  padding: 6px 12px;
}

.mood-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.mood-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 28px;
  width: 64px;
  padding: 8px 0;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--panel-2);
  cursor: pointer;
  transition: all 0.15s;
}
.mood-opt span { font-size: 11px; color: var(--muted); }
.mood-opt:hover { transform: translateY(-3px); }
.mood-opt.is-active { border-color: var(--mood); background: rgba(255, 122, 193, 0.14); box-shadow: 0 6px 16px rgba(255, 122, 193, 0.25); }

/* ---------- health ---------- */
.health { display: flex; gap: 24px; align-items: center; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.health__ring {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--activity) calc(var(--p, 0) * 1%), rgba(255, 255, 255, 0.08) 0);
  transition: background 0.8s ease;
  flex-shrink: 0;
}
.health__ring.is-ok { background: conic-gradient(var(--activity) calc(var(--p, 0) * 1%), rgba(255, 255, 255, 0.08) 0); box-shadow: 0 0 26px rgba(94, 224, 138, 0.25); }
.health__ring.is-warn { background: conic-gradient(#ff7a5e calc(var(--p, 0) * 1%), rgba(255, 255, 255, 0.08) 0); box-shadow: 0 0 26px rgba(255, 122, 94, 0.25); }
.health__inner {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: var(--panel-2);
  display: grid;
  place-items: center;
  text-align: center;
  line-height: 1.15;
}
.health__inner b { font-size: 24px; }
.health__inner span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.health__list { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 240px; display: grid; gap: 9px; }
.health__list li {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 14px;
}
.health__list .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ---------- charts ---------- */
.charts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.chart-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 8px;
}
.chart-card h3 { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.chart-card canvas { width: 100%; height: 150px; display: block; }

/* ---------- history ---------- */
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.history li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  animation: rise 0.3s ease both;
}
.history .h-ico { font-size: 20px; }
.history .h-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.history .h-title { font-size: 15px; font-weight: 600; }
.history .h-note { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history .h-when { font-size: 12px; color: var(--muted); white-space: nowrap; }
.history .h-del {
  border: none;
  background: transparent;
  color: var(--danger);
  font-size: 17px;
  cursor: pointer;
  border-radius: 8px;
  padding: 4px 8px;
  transition: background 0.15s;
}
.history .h-del:hover { background: rgba(255, 107, 107, 0.15); }
.pill {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  color: #17131f;
  font-weight: 700;
  white-space: nowrap;
}
.pill--food { background: var(--food); }
.pill--water { background: var(--water); }
.pill--activity { background: var(--activity); }
.pill--mood { background: var(--mood); }

.empty { color: var(--muted); text-align: center; padding: 18px; background: var(--panel); border-radius: var(--radius); border: 1px dashed var(--line); }
.foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 30px; }

/* ---------- настройки: цели и профиль ---------- */
.goals {
  display: flex;
  gap: 14px;
  align-items: end;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.goals__title { flex: 1 0 100%; font-size: 14px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.goals__hint { flex: 1 0 100%; margin: 0; font-size: 13px; color: var(--muted); }
.goals .field { min-width: 130px; }
.btn--goals { background: var(--activity); }
.btn--skip { flex: 1; }

/* ---------- модалка профиля ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 8, 16, 0.72);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.25s ease both;
}
.modal[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal__card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(160deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px 24px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  animation: pop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(24px) scale(0.94); } to { opacity: 1; transform: none; } }
.modal__cat { font-size: 54px; animation: catBounce 3.4s ease-in-out infinite; }
.modal__card h3 { margin: 8px 0 4px; font-size: 22px; }
.modal__sub { margin: 0 0 18px; font-size: 14px; color: var(--muted); }
#formProfile { display: grid; gap: 12px; text-align: left; }
#formProfile .field input { width: 100%; }
.btn--profile { background: var(--accent); color: #17131f; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 90px);
  background: #12b886;
  color: #08301f;
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 999px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.4);
  z-index: 50;
  pointer-events: none;
}
.toast.is-show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .charts { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr; }
  .topbar__name { font-size: 18px; width: 130px; }
  .health { justify-content: center; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
