:root {
  --bg: #0d1117;
  --card: #161b22;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #238636;
  --warn: #d29922;
  --danger: #f85149;
  
  /* Цвета WHOOP */
  --recovery-green: #3fb950;
  --recovery-yellow: #d29922;
  --recovery-red: #f85149;
  --sleep-blue: #58a6ff;
  
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent; /* Убирает синий квадрат при клике на iOS */
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* Анимация появления экранов */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease-out forwards;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top, 12px));
  border-bottom: 1px solid rgba(48, 54, 61, 0.5); /* Более мягкая линия */
  position: sticky;
  top: 0;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(12px); /* Усилен блюр (как в iOS) */
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
}

.topbar h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.main {
  padding: 16px;
  padding-bottom: calc(88px + var(--safe-area-bottom));
  max-width: 520px;
  margin: 0 auto;
}

.card {
  background: var(--card);
  border: 1px solid #30363d;
  border-radius: 16px; /* Более скругленные углы */
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); /* Мягкая тень */
  transition: transform 0.1s ease;
}

/* Эффект нажатия на карточку (если она кликабельна) */
.card.clickable:active {
  transform: scale(0.98);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric-big {
  font-size: 2.5rem; /* Сделал цифры еще больше и выразительнее */
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}

/* Цвета метрик */
.metric-green { color: var(--recovery-green); }
.metric-yellow { color: var(--recovery-yellow); }
.metric-red { color: var(--recovery-red); }
.metric-blue { color: var(--sleep-blue); }

.sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  appearance: none;
  border: 1px solid #30363d;
  background: #21262d;
  color: var(--text);
  padding: 14px 16px; /* Увеличил зону нажатия */
  border-radius: 12px;
  font-size: 1rem;
  width: 100%;
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 500;
}

/* Эффект нажатия для кнопок */
.btn:active {
  transform: scale(0.97);
  opacity: 0.8;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(35, 134, 54, 0.2);
}

.btn-danger {
  background: rgba(248, 81, 73, 0.1);
  border-color: rgba(248, 81, 73, 0.3);
  color: var(--danger);
}

.btn-danger:active {
  background: rgba(248, 81, 73, 0.2);
}

.btn-ghost {
  width: auto;
  padding: 8px 14px;
  font-size: 0.85rem;
  background: transparent;
  border: none;
  color: var(--sleep-blue);
  font-weight: 600;
}

.btn-ghost:active {
  background: rgba(88, 166, 255, 0.1);
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: rgba(22, 27, 34, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(48, 54, 61, 0.5);
  padding-bottom: var(--safe-area-bottom);
  z-index: 20;
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 4px 8px;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.tabbar a svg {
  width: 24px;
  height: 24px;
  margin-bottom: 4px;
  fill: currentColor;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.tabbar a:active svg {
  transform: scale(0.85);
}

.tabbar a.active {
  color: var(--text);
}

.tabbar a.active svg {
  color: var(--sleep-blue); /* Активная иконка синяя */
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list li {
  padding: 10px 0;
  border-bottom: 1px solid #30363d;
  font-size: 0.95rem;
}

.list li:last-child {
  border-bottom: none;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: #21262d;
  color: var(--muted);
}

.rec-warn {
  border-left: 3px solid var(--warn);
  padding-left: 10px;
  margin: 8px 0;
}

.rec-ok {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  margin: 8px 0;
}

.rec-info {
  border-left: 3px solid #58a6ff;
  padding-left: 10px;
  margin: 8px 0;
}

.skeleton {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, #21262d 25%, #30363d 50%, #21262d 75%);
  background-size: 200% 100%;
  animation: sk 1.2s ease-in-out infinite;
  margin: 8px 0;
}

@keyframes sk {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(72px + var(--safe-area-bottom));
  background: #21262d;
  border: 1px solid #30363d;
  padding: 12px 14px;
  border-radius: 10px;
  z-index: 50;
}

.hidden {
  display: none !important;
}

.center {
  text-align: center;
}

.muted {
  color: var(--muted);
}
