:root {
  --bg: #0a0e14;
  --card: #141a23;
  --card-2: #1b2330;
  --text: #f2f5f8;
  --muted: #8b97a7;
  --green: #16ec06;
  --yellow: #ffde00;
  --red: #ff0026;
  --blue: #5b8cff;
  --teal: #1ad6c4;
  --line: #232c3a;
}

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

body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background: #05070b;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  /* учитываем «безопасную зону» iPhone (часы/батарея/вырез), чтобы шапка не пряталась */
  padding: 16px;
  padding-top: max(16px, calc(env(safe-area-inset-top) + 10px));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* Телефонный «холст», чтобы прототип был похож на мобильное приложение */
.phone {
  width: 100%;
  max-width: 440px;
  background: var(--bg);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--line);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 12px;
  gap: 10px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 14px var(--green);
  flex: 0 0 auto;
}
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: -0.2px; }
.brand-tag { font-size: 11px; color: var(--muted); margin-top: 1px; }

.lang-select {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  max-width: 150px;
}
.lang-select:focus { outline: 2px solid var(--green); }
.lang-select option { background: var(--card); color: var(--text); }

.statusbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px 14px;
  flex-wrap: wrap;
}
.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 222, 0, 0.12);
  color: var(--yellow);
}
.badge.live { background: rgba(22, 236, 6, 0.12); color: var(--green); }
.greeting { font-size: 13px; color: var(--muted); flex: 1; }
.connect-btn {
  border: 0;
  background: var(--green);
  color: #06210a;
  font-weight: 800;
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
}
.connect-btn.signout { background: var(--card-2); color: var(--text); }

.demo-banner {
  margin: 0 18px 14px;
  padding: 11px 13px;
  background: rgba(91, 140, 255, 0.1);
  border: 1px solid rgba(91, 140, 255, 0.25);
  border-radius: 12px;
  font-size: 12px;
  color: #b9ccff;
  line-height: 1.4;
}
.demo-banner.hidden { display: none; }

.viewtoggle {
  display: flex;
  gap: 4px;
  margin: 0 18px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
}
.viewtoggle button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  padding: 9px;
  border-radius: 9px;
  cursor: pointer;
  font-family: inherit;
}
.viewtoggle button.active { background: var(--card-2); color: var(--text); }

/* Верхняя сводка: три кольца как на главном экране оригинала */
.summary {
  display: flex;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 10px;
}
.summary-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.summary .ring { width: 96px; height: 96px; }
.summary .ring-value { font-size: 23px; }
.summary .ring-unit { font-size: 11px; margin-top: 4px; }
.summary-label { font-size: 12px; color: var(--muted); font-weight: 600; text-align: center; }
.summary-row { display: flex; gap: 8px; margin-top: 6px; }
.summary-row .summary-item { gap: 6px; }

/* Обзор за период */
#overview { display: none; flex-direction: column; gap: 14px; }
#dashboard.overview .day-only { display: none; }
#dashboard.overview #overview { display: flex; }
.overview-coach { margin-top: 14px; }

.datenav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 18px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
}
.datenav-btn {
  width: 44px;
  height: 38px;
  border: 0;
  border-radius: 9px;
  background: var(--card-2);
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}
.datenav-btn:disabled { opacity: 0.3; cursor: default; }
.datenav-label {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  text-transform: capitalize;
}

main { padding: 0 14px 8px; display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--card);
  border-radius: 18px;
  padding: 18px;
  border: 1px solid var(--line);
}
.card-head { margin-bottom: 14px; }
.card.coach {
  background: linear-gradient(160deg, rgba(124, 58, 237, 0.18), rgba(22, 236, 6, 0.06)), var(--card);
  border-color: rgba(124, 58, 237, 0.4);
}
.coach-body {
  font-size: 14px;
  line-height: 1.55;
  color: #e9ecf2;
  white-space: pre-wrap;
}
.coach-body .coach-loading { color: var(--muted); font-style: italic; }
.coach-body .coach-note { color: var(--muted); font-size: 12.5px; }

/* Strain Coach */
.coach-target { display: flex; align-items: center; gap: 16px; }
.ct-ring {
  width: 88px; height: 88px; flex: 0 0 auto;
  border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 4px solid var(--teal);
}
.ct-ring.green { border-color: var(--green); }
.ct-ring.yellow { border-color: var(--yellow); }
.ct-ring.red { border-color: var(--red); }
.ct-num { font-size: 20px; font-weight: 800; }
.ct-cap { font-size: 11px; color: var(--muted); }
.ct-advice { font-size: 14px; font-weight: 600; line-height: 1.4; }

/* Планировщик сна */
.planner { display: flex; align-items: center; gap: 16px; }
.planner-main { display: flex; flex-direction: column; }
.planner-time { font-size: 30px; font-weight: 800; letter-spacing: -1px; }
.planner-cap { font-size: 11px; color: var(--muted); }
.planner-note { font-size: 13px; color: var(--muted); line-height: 1.4; }

/* Монитор здоровья */
.health-list { display: flex; flex-direction: column; gap: 2px; }
.health-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.health-row:last-child { border-bottom: 0; }
.h-label { font-size: 13px; }
.h-val { font-size: 15px; font-weight: 700; }
.h-status { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.h-status.normal { background: rgba(22, 236, 6, 0.14); color: var(--green); }
.h-status.elevated { background: rgba(255, 222, 0, 0.14); color: var(--yellow); }
.h-status.low { background: rgba(255, 0, 38, 0.14); color: #ff6b80; }
.h-base { display: block; font-size: 10px; color: var(--muted); }

/* Тренировки */
.workouts-list { display: flex; flex-direction: column; gap: 12px; }
.wo-none { font-size: 13px; color: var(--muted); }
.wo-item { background: var(--card-2); border-radius: 12px; padding: 12px; }
.wo-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.wo-emoji { font-size: 24px; }
.wo-strain { font-size: 20px; font-weight: 800; }
.wo-strain-cap { font-size: 11px; color: var(--muted); margin-left: auto; }
.wo-stats { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.wo-stats b { color: var(--text); font-weight: 700; }
.zonebar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--bg); }
.zonebar span { display: block; height: 100%; }

/* Дневник */
.journal-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.jchip {
  border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  border-radius: 999px; padding: 8px 13px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.jchip.on { background: rgba(124, 58, 237, 0.28); border-color: rgba(124, 58, 237, 0.65); }
.journal-saved { font-size: 12px; color: var(--green); margin-top: 10px; min-height: 14px; }

/* Дыхательная практика */
.breath-area { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 8px 0; }
.breath-circle {
  width: 130px; height: 130px; border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, rgba(26, 214, 196, 0.4), rgba(91, 140, 255, 0.12));
  border: 2px solid var(--teal);
  display: flex; align-items: center; justify-content: center;
  transform: scale(0.82);
  transition: transform 4s ease-in-out;
  box-shadow: 0 0 30px rgba(26, 214, 196, 0.25);
}
.breath-circle span { font-size: 15px; font-weight: 700; color: var(--text); }
.breath-btn {
  border: 0; background: var(--green); color: #06210a; font-weight: 800;
  font-size: 14px; padding: 11px 28px; border-radius: 12px; cursor: pointer; font-family: inherit;
}
.breath-btn.stop { background: var(--card-2); color: var(--text); }

/* Возраст организма */
.age-body { display: flex; align-items: center; gap: 16px; }
.age-num { display: flex; align-items: baseline; gap: 4px; }
.age-num span:first-child { font-size: 44px; font-weight: 800; letter-spacing: -1px; }
.age-yrs { font-size: 15px; color: var(--muted); font-weight: 700; }
.age-info { display: flex; flex-direction: column; gap: 4px; }
.age-vo2 { font-size: 12px; color: var(--muted); }
.age-delta { font-size: 14px; font-weight: 700; color: var(--green); }
.age-controls { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.age-sex { display: flex; background: var(--card-2); border-radius: 9px; padding: 3px; gap: 2px; }
.age-sex button {
  border: 0; background: transparent; color: var(--muted);
  font-weight: 700; font-size: 13px; padding: 7px 14px; border-radius: 7px; cursor: pointer; font-family: inherit;
}
.age-sex button.active { background: var(--card); color: var(--text); }
.age-controls input {
  flex: 1; background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 9px 12px; font-size: 14px; font-family: inherit; min-width: 0;
}
.age-note { font-size: 11px; color: var(--muted); margin-top: 10px; line-height: 1.4; }

/* Селектор периода в Обзоре */
.period-sel { display: flex; gap: 4px; background: var(--card-2); border-radius: 10px; padding: 3px; margin-top: 10px; }
.period-sel button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  font-weight: 700; font-size: 12px; padding: 7px; border-radius: 8px; cursor: pointer; font-family: inherit;
}
.period-sel button.active { background: var(--card); color: var(--text); }

.card-head h2 { font-size: 18px; font-weight: 800; letter-spacing: -0.3px; }
.card-head p { font-size: 12px; color: var(--muted); margin-top: 2px; }

.ring-row { display: flex; align-items: center; gap: 18px; }

.ring { position: relative; width: 128px; height: 128px; flex: 0 0 auto; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--card-2); stroke-width: 10; }
.ring-fg {
  fill: none;
  stroke: var(--green);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset 0.8s ease;
}
.ring.blue .ring-fg { stroke: var(--blue); }
.ring.teal .ring-fg { stroke: var(--teal); }
.ring.yellow .ring-fg { stroke: var(--yellow); }
.ring.red .ring-fg { stroke: var(--red); }

.ring-center {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  gap: 1px;
}
.ring-value { font-size: 34px; font-weight: 800; letter-spacing: -1px; }
.ring-unit { font-size: 15px; font-weight: 700; color: var(--muted); margin-top: 8px; }
.ring-note { font-size: 13px; color: var(--text); line-height: 1.4; font-weight: 600; }

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.metric {
  background: var(--card-2);
  border-radius: 12px;
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.m-label { font-size: 11px; color: var(--muted); }
.m-value { font-size: 17px; font-weight: 700; }

.big-stats { display: flex; flex-direction: column; gap: 12px; }
.big-stats > div { display: flex; flex-direction: column; }
.bs-value { font-size: 21px; font-weight: 800; letter-spacing: -0.5px; }
.bs-label { font-size: 11px; color: var(--muted); }

.stages-title { font-size: 12px; color: var(--muted); margin: 16px 0 8px; font-weight: 600; }
.stages { display: flex; flex-direction: column; gap: 8px; }
.stage-row { display: flex; align-items: center; gap: 10px; }
.stage-name { font-size: 12px; width: 96px; color: var(--text); }
.stage-bar { flex: 1; height: 8px; background: var(--card-2); border-radius: 999px; overflow: hidden; display: block; }
.stage-fill { display: block; height: 100%; border-radius: 999px; min-width: 3px; }
.stage-fill.light { background: #6f86d6; }
.stage-fill.deep { background: #3b56b0; }
.stage-fill.rem { background: #1ad6c4; }
.stage-fill.awake { background: #56607a; }
.stage-time { font-size: 12px; color: var(--muted); width: 56px; text-align: right; }

.trend-chart { margin-bottom: 22px; }
.trend-chart:last-child { margin-bottom: 0; }
.trend-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.trend-label { font-size: 13px; color: var(--text); font-weight: 700; }
.trend-avg { font-size: 12px; color: var(--muted); }

.chart { display: flex; gap: 8px; }
.chart-scale {
  width: 26px;
  height: 84px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: right;
  font-size: 10px;
  color: var(--muted);
}
.chart-main { flex: 1; }
.chart-plot { position: relative; height: 84px; margin-top: 14px; }
.chart-line { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--line); }
.chart-line span {
  position: absolute; right: 0; top: -7px;
  font-size: 9px; color: var(--muted);
  background: var(--card); padding: 0 3px; border-radius: 3px;
}
.chart-cols { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 6px; }
.chart-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.chart-val { font-size: 10px; font-weight: 700; color: var(--text); margin-bottom: 3px; line-height: 1; }
.chart-bar { width: 100%; border-radius: 5px 5px 0 0; min-height: 3px; }
.chart-bar.green { background: linear-gradient(var(--green), #0f8f06); }
.chart-bar.yellow { background: linear-gradient(var(--yellow), #b89e00); }
.chart-bar.red { background: linear-gradient(var(--red), #b3001b); }
.chart-bar.teal { background: linear-gradient(var(--teal), #0e9488); }
.chart-bar.sleep { background: linear-gradient(var(--blue), #2f54b0); }
.chart-bar.empty { background: var(--card-2); }
.chart-days { display: flex; gap: 6px; margin-top: 5px; }
.chart-day { flex: 1; text-align: center; font-size: 10px; color: var(--muted); text-transform: capitalize; }
.chart-day.today { color: var(--text); font-weight: 700; }

.footer {
  padding: 18px;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
  border-top: 1px solid var(--line);
  margin-top: 8px;
}
