:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-card2: #1c2128;
  --accent: #00e676;
  --accent2: #00bcd4;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --border: #30363d;
  --danger: #f85149;
  --warning: #d29922;
  --success: #3fb950;
  --nav-h: 64px;
  --r: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

#app { height: 100vh; width: 100%; position: relative; overflow: hidden; }

/* SECTIONS */
.section {
  position: absolute;
  top: 0; left: 0; right: 0;
  bottom: var(--nav-h);
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity .25s, transform .25s;
  -webkit-overflow-scrolling: touch;
}
.section.active { opacity: 1; pointer-events: all; transform: translateY(0); }
.section::-webkit-scrollbar { width: 0; }
.section-inner { padding: 16px 16px 24px; }

/* MAP special */
#sec-map { display: flex; flex-direction: column; }
#leaflet-map { flex: 1; min-height: 260px; }
.map-find-bar { padding: 12px 16px 8px; background: var(--bg); z-index: 1; }
.gym-list { padding: 4px 16px 10px; max-height: 160px; overflow-y: auto; }
.gym-list::-webkit-scrollbar { width: 0; }

/* BOTTOM NAV */
#bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .2s;
  font-size: 8px;
  padding: 4px 1px;
}
.nav-btn svg { width: 22px; height: 22px; fill: currentColor; }
.nav-btn.active { color: var(--accent); }

/* SECTION HEADER */
.section-header { margin-bottom: 16px; }
.section-header h2 { font-size: 22px; font-weight: 700; }
.subsection-title { font-size: 15px; font-weight: 600; color: var(--text-muted); margin: 20px 0 10px; }

/* HOME */
.greeting-card {
  background: linear-gradient(135deg, #0d2b1f, #162032);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.greeting-sub { font-size: 12px; color: var(--text-muted); }
.greeting-card h1 { font-size: 22px; font-weight: 800; color: var(--accent); margin-top: 2px; }
.greeting-icon { font-size: 40px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
@media (max-width: 340px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 6px;
  text-align: center;
}
.stat-icon { font-size: 18px; margin-bottom: 4px; }
.stat-value { font-size: 17px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.tip-card {
  background: linear-gradient(135deg, #0d1f2b, #162032);
  border: 1px solid var(--accent2);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 14px;
  font-size: 13px;
  line-height: 1.55;
}
.tip-card::before {
  content: "💡 Совет дня\A";
  white-space: pre;
  font-weight: 700;
  color: var(--accent2);
  font-size: 11px;
}

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* BUTTONS */
.btn-primary {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--r);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .2s, transform .1s;
  width: 100%;
}
.btn-primary:active { transform: scale(.97); opacity: .9; }

.btn-secondary {
  background: var(--bg-card2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
  width: 100%;
}
.btn-secondary:active { background: var(--border); }
.full-width { width: 100%; }

/* PROFILE */
.profile-avatar { text-align: center; margin-bottom: 20px; }
.avatar-placeholder {
  width: 72px; height: 72px;
  background: var(--bg-card2);
  border: 2px solid var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin: 0 auto 8px;
}
.profile-name { font-weight: 600; font-size: 15px; }

.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 4px 0;
  margin-bottom: 16px;
}
.form-row {
  display: flex; align-items: center;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.form-row:last-child { border-bottom: none; }
.form-row label { flex: 1; font-size: 14px; color: var(--text-muted); }
.form-row input,
.form-row select {
  flex: 1;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--text);
  font-size: 14px;
  text-align: right;
}
.form-row select { text-align: left; }
.form-row input:focus,
.form-row select:focus { outline: none; border-color: var(--accent); }

.gender-toggle { display: flex; gap: 4px; }
.gender-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card2);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
}
.gender-btn.active { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 700; }

.bmi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 16px;
  text-align: center;
}
.bmi-title { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .5px; }
.bmi-value { font-size: 48px; font-weight: 800; color: var(--accent); line-height: 1; }
.bmi-bar-wrap { margin: 14px 0 6px; }
.bmi-bar {
  height: 8px;
  background: linear-gradient(to right, #2196F3 0%, #4CAF50 30%, #FFC107 55%, #FF5722 75%, #B71C1C 100%);
  border-radius: 4px;
  position: relative;
  margin-bottom: 6px;
}
.bmi-indicator {
  width: 12px; height: 12px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: -2px;
  transform: translateX(-50%);
  box-shadow: 0 0 0 2px var(--bg);
  transition: left .5s;
}
.bmi-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-muted); }
.bmi-status { font-size: 14px; font-weight: 600; margin: 8px 0 4px; }
.tdee-value { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* FILTERS */
.filter-tabs {
  display: flex; gap: 6px;
  margin-bottom: 10px;
  overflow-x: auto; padding-bottom: 4px;
}
.filter-tabs::-webkit-scrollbar { height: 0; }
.filter-btn {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.filter-btn.active { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 700; }

.type-filter {
  display: flex; gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto; padding-bottom: 4px;
}
.type-filter::-webkit-scrollbar { height: 0; }
.chip {
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-card2);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.chip.active { background: var(--accent2); color: #000; border-color: var(--accent2); font-weight: 600; }

/* WORKOUT CARDS */
.cards-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.workout-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
  cursor: pointer;
  transition: border-color .2s, transform .1s;
}
.workout-card:active { transform: scale(.97); border-color: var(--accent); }
.wc-emoji { font-size: 28px; margin-bottom: 8px; }
.wc-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; line-height: 1.3; }
.wc-meta { font-size: 11px; color: var(--text-muted); }
.wc-level {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  margin-top: 6px;
}
.level-beginner { background: #1a3d2b; color: #3fb950; }
.level-intermediate { background: #2d2000; color: #d29922; }
.level-advanced { background: #3d1a1a; color: #f85149; }

/* NUTRITION */
.macro-card {
  background: linear-gradient(135deg, #0d2b1f, #162032);
  border: 1px solid var(--accent);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 16px;
}
.macro-title { font-size: 11px; color: var(--text-muted); margin-bottom: 12px; text-transform: uppercase; letter-spacing: .5px; }
.macros-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.macro-val { font-size: 22px; font-weight: 800; color: var(--accent); }
.macro-lbl { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.macro-hint { font-size: 12px; color: var(--text-muted); margin-top: 12px; text-align: center; }

.tip-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.tip-item-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.tip-item-emoji { font-size: 22px; }
.tip-item-title { font-size: 14px; font-weight: 600; }
.tip-item-text { font-size: 13px; color: var(--text-muted); line-height: 1.55; }

/* MAP */
.gym-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.gym-item:last-child { border-bottom: none; }
.gym-dist { color: var(--accent); font-weight: 600; min-width: 52px; font-size: 12px; text-align: right; }

/* TRACKER */
.tracker-main { display: flex; flex-direction: column; align-items: center; padding: 4px 0; }
.step-ring { position: relative; width: 180px; height: 180px; margin-bottom: 20px; }
.ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--bg-card2); stroke-width: 10; }
.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 314;
  stroke-dashoffset: 314;
  transition: stroke-dashoffset .5s;
}
.step-count-display {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.step-count { font-size: 32px; font-weight: 800; color: var(--accent); }
.step-goal { font-size: 12px; color: var(--text-muted); }

.tracker-stats { display: flex; gap: 28px; margin-bottom: 20px; }
.t-stat { text-align: center; }
.t-stat-val { font-size: 20px; font-weight: 700; display: block; }
.t-stat-lbl { font-size: 11px; color: var(--text-muted); }

.tracker-controls { display: flex; gap: 10px; margin-bottom: 16px; width: 100%; max-width: 280px; }
.tracker-controls .btn-primary,
.tracker-controls .btn-secondary { flex: 1; }

.perm-notice {
  background: var(--bg-card);
  border: 1px solid var(--warning);
  border-radius: var(--r);
  padding: 14px;
  text-align: center;
  margin: 4px 0 16px;
  width: 100%;
}
.perm-notice p { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }

.step-chart { display: flex; align-items: flex-end; gap: 6px; height: 80px; width: 100%; }
.bar-wrap {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 4px; height: 100%; justify-content: flex-end;
}
.bar { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 4px; opacity: .6; transition: height .3s; }
.bar.today { opacity: 1; background: var(--accent2); }
.bar-label { font-size: 9px; color: var(--text-muted); }

/* GUIDES */
.sport-selector { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.sport-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 6px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  line-height: 1.4;
  transition: border-color .2s, color .2s;
}
.sport-btn.active { border-color: var(--accent); color: var(--accent); background: #0d2b1f; }

.guide-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 10px;
}
.guide-section-title {
  font-size: 11px; font-weight: 700; color: var(--accent);
  margin-bottom: 10px; text-transform: uppercase; letter-spacing: .6px;
}
.guide-item {
  display: flex; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px; line-height: 1.45;
}
.guide-item:last-child { border-bottom: none; }
.guide-num { color: var(--accent); font-weight: 700; min-width: 18px; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 200;
  display: flex; align-items: flex-end;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card);
  border-radius: var(--r) var(--r) 0 0;
  padding: 20px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .3s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-close {
  float: right; background: none; border: none;
  color: var(--text-muted); font-size: 20px; cursor: pointer;
  padding: 0 0 12px 12px;
}
.modal-workout-emoji { font-size: 48px; margin-bottom: 10px; }
.modal-workout-title { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.modal-workout-meta { color: var(--text-muted); font-size: 13px; margin-bottom: 12px; }
.exercise-list { list-style: none; }
.exercise-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.exercise-item:last-child { border-bottom: none; }
.ex-num {
  width: 24px; height: 24px;
  background: var(--accent); color: #000;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.ex-detail { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* TOAST */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--bg-card2);
  border: 1px solid var(--accent);
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 13px; color: var(--accent); font-weight: 600;
  z-index: 300;
  opacity: 0;
  transition: opacity .3s, transform .3s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
