:root {
  color-scheme: light;
  --hue: 332;
  --accent: hsl(var(--hue) 86% 58%);
  --accent-2: hsl(calc(var(--hue) + 35) 92% 62%);
  --accent-text: #ffffff;
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(29, 29, 31, 0.12);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b0f;
  --surface: rgba(28, 28, 34, 0.78);
  --surface-solid: #1c1c22;
  --ink: #f5f5f7;
  --muted: #a1a1aa;
  --line: rgba(255, 255, 255, 0.12);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 0%, hsl(var(--hue) 90% 65% / 0.18), transparent 28rem),
    radial-gradient(circle at 86% 12%, hsl(calc(var(--hue) + 55) 92% 62% / 0.14), transparent 30rem),
    linear-gradient(180deg, var(--surface-solid), var(--bg));
}

button,
input {
  font: inherit;
}

button,
a {
  color: inherit;
}

button,
.login,
.primary,
.secondary {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

button:hover,
.login:hover,
.primary:hover,
.secondary:hover {
  transform: translateY(-1px);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 58px;
}

.topbar {
  position: relative;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
  letter-spacing: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 42px;
  line-height: 1;
}

.brand-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border-radius: 10px;
  color: var(--ink);
  background: transparent;
  font-size: 42px;
  font-weight: 800;
  line-height: 1;
}

.brand-button img {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: block;
  border-radius: 50%;
  box-shadow: 0 10px 24px hsl(var(--hue) 80% 45% / 0.2);
}

h2 {
  margin-bottom: 8px;
  font-size: 28px;
}

h3 {
  margin-bottom: 6px;
  font-size: 17px;
}

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

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.lang-switch {
  position: relative;
}

.lang-current {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.05);
}

.lang-current span:first-child {
  font-size: 18px;
}

.lang-current span:last-child {
  font-size: 12px;
  font-weight: 800;
}

.lang-menu {
  position: absolute;
  z-index: 10000;
  top: calc(100% + 8px);
  right: 0;
  width: 190px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface-solid) 94%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.lang-menu[hidden] {
  display: none !important;
}

.lang-menu button {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: 28px 34px 1fr;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 13px;
  background: transparent;
  text-align: left;
}

.lang-menu button.active {
  color: var(--accent-text);
  background: var(--accent);
}

.lang-menu em {
  color: inherit;
  font-style: normal;
  opacity: 0.82;
}

.login,
.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 26px hsl(var(--hue) 80% 45% / 0.22);
}

.secondary {
  min-height: 44px;
  padding: 0 18px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
}

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 20px;
}

.icon-button[title="Настройки"] {
  font-size: 18px;
}

.logout-icon {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.search {
  position: relative;
  width: min(430px, 100vw - 32px);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.search input {
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 0 14px;
  color: var(--ink);
  background: transparent;
}

.search button[type="submit"] {
  min-height: 40px;
  padding: 0 16px;
  color: var(--accent-text);
  background: var(--accent);
  box-shadow: 0 8px 20px hsl(var(--hue) 80% 45% / 0.18);
}

.search-popover {
  position: fixed;
  z-index: 9999;
  max-height: 278px;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: color-mix(in srgb, var(--surface-solid) 92%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  pointer-events: auto;
}

.search-popover[hidden] {
  display: none !important;
}

.search-popover button {
  flex: 0 0 auto;
  width: 100%;
  height: 46px;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  background: transparent;
  text-align: left;
}

.search-hint {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
}

.search-popover button:empty {
  display: none;
}

.search-popover img {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 50%;
}

.search-popover span {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.player-strip,
.focus-card,
.workout-start,
.workout-card,
.setting-card,
.empty {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.player-strip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 150px;
  padding: 22px;
  border-radius: 28px;
  overflow: hidden;
}

.player-strip > *:not(.country-flag-bg) {
  position: relative;
  z-index: 1;
}

.country-flag-bg {
  position: absolute;
  inset: -34px -28px -34px auto;
  z-index: 0;
  width: min(520px, 58%);
  opacity: 0.16;
  background-position: center;
  background-size: cover;
  filter: blur(8px) saturate(1.18);
  pointer-events: none;
  transform: scale(1.05);
  transition: background-image 0.25s ease, opacity 0.25s ease, transform 0.25s ease;
  mask-image: linear-gradient(90deg, transparent 0%, black 32%, black 100%);
}

.country-flag-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--surface) 0%, transparent 45%);
}

.country-line {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.avatar-wrap {
  width: 94px;
  height: 94px;
  flex: 0 0 94px;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.avatar-wrap img,
.record img,
.map-card img,
.workout-card img,
.cover-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-wrap img {
  display: none;
}

.cover-fallback {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.chips,
.tag-row,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip,
.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: hsl(var(--hue) 84% 58% / 0.1);
}

.chip {
  padding: 7px 11px;
  font-size: 13px;
}

.creator-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 11px;
  border: 1px solid hsl(var(--hue) 84% 58% / 0.38);
  border-radius: 999px;
  color: var(--accent-text);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 18px hsl(var(--hue) 80% 45% / 0.16);
  font-size: 12px;
  text-decoration: none;
}

.creator-badge span {
  opacity: 0.82;
}

.creator-badge strong {
  font-size: 12px;
}

.badge-static {
  cursor: default;
  user-select: none;
}

.badge-static:hover {
  transform: none;
}

.tag {
  padding: 6px 9px;
  color: var(--ink);
  font-size: 12px;
}

.main-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
}

.main-tab {
  min-height: 46px;
  border-radius: 16px;
  color: var(--muted);
  background: transparent;
}

.main-tab.active {
  color: var(--accent-text);
  background: var(--accent);
  box-shadow: 0 8px 18px hsl(var(--hue) 80% 45% / 0.16);
}

.search-popover button:hover,
.search-popover button:focus-visible {
  color: var(--ink);
  background: rgba(127, 127, 140, 0.14);
}

.view {
  min-height: 360px;
}

.grid,
.map-grid,
.records,
.settings-grid {
  display: grid;
  gap: 12px;
}

.metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric,
.progression-metric,
.record,
.map-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.05);
}

.metric {
  min-height: 116px;
  padding: 18px;
}

.metric strong {
  display: block;
  margin: 10px 0 6px;
  font-size: 28px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.progression-hero,
.progression-panel {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.progression-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
  padding: 22px;
}

.progression-count {
  flex: 0 0 auto;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: hsl(var(--hue) 84% 58% / 0.1);
  font-size: 13px;
  font-weight: 700;
}

.progression-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 12px;
}

.progression-metric {
  min-height: 120px;
  padding: 18px;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
}

.progression-metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.progression-metric strong {
  display: block;
  margin: 10px 0 8px;
  font-size: 28px;
}

.progression-metric.active {
  border-color: hsl(var(--hue) 84% 58% / 0.46);
  background: hsl(var(--hue) 84% 58% / 0.13);
}

.progression-delta {
  display: inline-flex;
  width: fit-content;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(127, 127, 140, 0.12);
  font-size: 12px;
  font-weight: 800;
}

.progression-delta.good {
  color: #137333;
  background: rgba(30, 150, 76, 0.14);
}

.progression-delta.bad {
  color: #b3261e;
  background: rgba(211, 47, 47, 0.12);
}

.progression-panel {
  padding: 22px;
}

.progression-panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 8px;
}

.progression-panel-head h2 {
  margin-bottom: 0;
}

.progression-chart-wrap {
  position: relative;
  min-height: 320px;
}

.progression-chart {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-area {
  fill: url("#progressionFill");
  stroke: none;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 5;
}

.chart-point {
  fill: var(--surface-solid);
  stroke: var(--accent);
  stroke-width: 4;
  transition: r 0.16s ease, filter 0.16s ease;
}

.chart-point:hover {
  r: 8;
  filter: drop-shadow(0 7px 12px hsl(var(--hue) 80% 45% / 0.24));
}

.chart-scale {
  display: flex;
  justify-content: space-between;
  margin-top: -6px;
  color: var(--muted);
  font-size: 12px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin: 28px 0 12px;
}

.records {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.record {
  min-height: 134px;
  display: grid;
  grid-template-columns: 168px 1fr;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}

.record > div {
  padding: 14px;
}

.record p {
  margin-bottom: 8px;
  line-height: 1.35;
}

.focus-card,
.workout-start {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
  padding: 22px;
  border-radius: 28px;
}

.map-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.map-grid.compact .map-card {
  min-height: 320px;
}

.map-card {
  min-height: 370px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}

.map-card img {
  height: 132px;
}

.map-card .cover-fallback {
  height: 132px;
}

.map-body {
  padding: 16px;
}

.why {
  color: var(--muted);
  line-height: 1.45;
}

.workout-start {
  min-height: 340px;
}

.workout-categories {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
}

.workout-category {
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 17px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.workout-category span {
  color: inherit;
  font-weight: 700;
}

.workout-category small {
  color: inherit;
  opacity: 0.78;
}

.workout-category.active {
  color: var(--accent-text);
  background: var(--accent);
  box-shadow: 0 8px 18px hsl(var(--hue) 80% 45% / 0.16);
}

.big {
  min-width: 210px;
  min-height: 54px;
}

.workout-card {
  display: grid;
  grid-template-columns: minmax(280px, 42%) 1fr;
  min-height: 470px;
  overflow: hidden;
  border-radius: 30px;
}

.workout-card img {
  display: block;
}

.workout-info {
  padding: 30px;
  align-self: center;
}

.tag-row.large .tag {
  padding: 8px 11px;
  font-size: 14px;
}

.button-row {
  margin-top: 24px;
}

.load-more {
  display: flex;
  width: fit-content;
  margin: 14px auto 0;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.setting-card {
  min-height: 260px;
  padding: 24px;
  border-radius: 28px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 28px;
}

.switch-row input {
  width: 56px;
  height: 32px;
  accent-color: var(--accent);
}

.hue {
  width: 100%;
  margin-top: 30px;
  accent-color: var(--accent);
}

.color-preview {
  height: 92px;
  margin-top: 20px;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.action-card {
  min-height: 190px;
}

.settings-action,
.settings-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  font-weight: 800;
  text-decoration: none;
}

.settings-action {
  width: 100%;
  margin-top: 24px;
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  cursor: pointer;
}

.settings-panel {
  margin-top: 14px;
}

.settings-link {
  width: 100%;
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--surface);
}

.modal {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(12px);
}

.modal-panel {
  position: relative;
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 44px));
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--surface-solid);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.24);
}

.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.empty {
  padding: 24px;
  border-radius: 24px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .topbar,
  .focus-card,
  .progression-hero,
  .workout-start {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: stretch;
  }

  .search {
    width: 100%;
  }

  .metrics,
  .progression-metrics,
  .map-grid,
  .records,
  .settings-grid,
  .workout-categories {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workout-card {
    grid-template-columns: 1fr;
  }

  .workout-card img {
    height: 260px;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  h1 {
    font-size: 34px;
  }

  .brand-button {
    font-size: 34px;
  }

  .brand-button img {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .player-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .main-tabs,
  .metrics,
  .progression-metrics,
  .map-grid,
  .records,
  .settings-grid,
  .workout-categories {
    grid-template-columns: 1fr;
  }

  .record {
    grid-template-columns: 1fr;
  }

.record img,
.record .cover-fallback {
    height: 140px;
  }
}
