:root {
  /* Палитра бота (card_renderer.py) */
  --bg-deep: #0f1c3c;
  --bg-card: rgba(15, 28, 60, 0.78);
  --bg-card-hover: rgba(22, 38, 72, 0.88);
  --gold: #ffcf5c;
  --gold-soft: rgba(255, 207, 92, 0.18);
  --gold-border: rgba(255, 207, 92, 0.32);
  --silver: #c8d4e8;
  --text: #f5f7fc;
  --muted: #aab9d2;
  --success: #8ae282;
  --danger: #f58282;
  --radius: 18px;
  --nav-h: 76px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Manrope', system-ui, sans-serif;
  --scroll-progress: 0;
  --bg-scale: 1;
  --bg-y: 0px;
}

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

html, body {
  height: 100%;
  font-family: var(--font-body);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: #0a0a0c url('/assets/site/background-mobile.png') center top / cover no-repeat;
  transform: scale(var(--bg-scale)) translateY(var(--bg-y));
  will-change: transform;
}

@media (min-width: 768px) {
  .app-bg {
    background-image: url('/assets/site/background-desktop.png');
  }
}

.app-overlay {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(6, 8, 14, 0.25) 0%, rgba(6, 8, 14, 0.55) 38%, rgba(8, 12, 22, 0.92) 72%, rgba(8, 12, 22, 0.97) 100%);
}

body.auth-open .app-overlay {
  background:
    linear-gradient(
      180deg,
      rgba(6, 8, 14, calc(0.05 + var(--scroll-progress) * 0.15)) 0%,
      rgba(6, 8, 14, calc(0.25 + var(--scroll-progress) * 0.35)) 40%,
      rgba(8, 12, 22, calc(0.85 + var(--scroll-progress) * 0.1)) 75%,
      rgba(8, 12, 22, 0.98) 100%
    );
}

a { color: var(--gold); }
.hidden { display: none !important; }

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.gold-line {
  height: 2px;
  width: 64px;
  margin: 10px auto 16px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  border-radius: 2px;
}

.install-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(90deg, rgba(15, 28, 60, 0.95), rgba(30, 45, 80, 0.95));
  border-bottom: 1px solid var(--gold-border);
  font-size: 14px;
  font-weight: 600;
}
.install-banner .btn-sm { margin-left: auto; }

#screen-auth {
  display: block;
  padding: 0;
  overflow: hidden;
  height: 100dvh;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  background: var(--bg-card);
  backdrop-filter: blur(18px);
  border: 1px solid var(--gold-border);
  border-radius: 24px;
  padding: 28px 24px 32px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.auth-card h1 {
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.subtitle {
  text-align: center;
  color: var(--muted);
  margin: 8px 0 20px;
  font-size: 14px;
}

.tabs { display: flex; gap: 8px; margin-bottom: 20px; position: relative; z-index: 2; }
.tab {
  flex: 1;
  padding: 11px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.tab.active {
  background: linear-gradient(135deg, var(--gold), #e6b84a);
  color: var(--bg-deep);
  border-color: transparent;
}

.form-panel { display: none; flex-direction: column; gap: 14px; }
.form-panel.active { display: flex; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.hint { font-weight: 400; font-size: 11px; }

input, select {
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font: inherit;
  outline: none;
}
input:focus, select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.error { color: var(--danger); font-size: 13px; margin-top: 12px; text-align: center; }

.btn {
  padding: 13px 20px;
  border: none;
  border-radius: 12px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--gold), #e8bf55);
  color: var(--bg-deep);
  width: 100%;
  box-shadow: 0 8px 24px rgba(255, 207, 92, 0.22);
}
.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 8px;
  background: var(--gold);
  color: var(--bg-deep);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--silver);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font: inherit;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px 8px;
  padding-top: max(14px, env(safe-area-inset-top));
  border-bottom: 1px solid rgba(255, 207, 92, 0.12);
  background: rgba(8, 12, 22, 0.55);
  backdrop-filter: blur(12px);
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-logo {
  width: 42px; height: 42px; border-radius: 12px;
  object-fit: cover; border: 1px solid var(--gold-border);
}
.topbar-title {
  font-family: var(--font-display);
  font-weight: 700; font-size: 1.05rem;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.topbar-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px calc(var(--nav-h) + var(--safe-b) + 16px);
}

.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

h2, h3 { font-family: var(--font-display); letter-spacing: 0.04em; }
h2 { font-size: 1.45rem; margin-bottom: 6px; text-transform: uppercase; }
h3 { font-size: 1.05rem; margin-bottom: 12px; }
.muted { color: var(--muted); font-size: 14px; margin-bottom: 16px; line-height: 1.5; }

.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 24px; right: 24px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-border), transparent);
}
.card.highlight {
  border-color: var(--gold-border);
  background: linear-gradient(145deg, rgba(255, 207, 92, 0.1), rgba(15, 28, 60, 0.82));
}

.vip-card-inner { display: flex; gap: 14px; align-items: flex-start; }
.vip-badge-img {
  width: 56px; height: 56px; border-radius: 14px;
  object-fit: cover; border: 1px solid var(--gold-border);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.stat-box {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 16px 8px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.stat-box .val {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gold);
}
.stat-box .lbl { font-size: 11px; color: var(--muted); margin-top: 6px; font-weight: 600; }

.quick-links {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.quick-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
button.quick-link {
  appearance: none;
  -webkit-appearance: none;
}

.sport-tabs, .form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.sport-tab {
  flex: 1;
  min-width: 90px;
  padding: 11px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.sport-tab.active {
  border-color: var(--gold);
  background: var(--gold-soft);
  color: var(--gold);
}

.form-inline input[type="date"],
.form-inline input[type="number"] { flex: 1; min-width: 100px; }
.form-inline .btn-primary { width: auto; flex: 1; min-width: 120px; }

.row-between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.row-between h3 { margin: 0; }

.diary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.diary-meta { font-size: 13px; color: var(--muted); }
.diary-dist { font-weight: 800; color: var(--gold); font-family: var(--font-display); }

.btn-delete {
  background: rgba(245, 130, 130, 0.12);
  color: var(--danger);
  border: 1px solid rgba(245, 130, 130, 0.25);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.cards-list { display: flex; flex-direction: column; gap: 12px; }
.lesson-card, .ach-card {
  display: flex;
  gap: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  text-decoration: none;
  color: inherit;
}
.lesson-num {
  width: 72px; height: 72px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold);
  background: rgba(255, 207, 92, 0.08);
  border: 1px solid var(--gold-border);
}
.ach-card img { width: 72px; height: 72px; border-radius: 14px; object-fit: cover; }
.ach-card.locked { opacity: 0.55; }
.ach-card.obtained { border-color: var(--gold-border); }

.badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.badge.ok { background: rgba(138, 226, 130, 0.15); color: var(--success); }
.badge.no { background: rgba(245, 130, 130, 0.12); color: var(--danger); }

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  background: rgba(8, 12, 22, 0.88);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--gold-border);
  z-index: 100;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.nav-item span { font-size: 21px; }
.nav-item.active { color: var(--gold); }

.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 28, 60, 0.95);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  z-index: 300;
  border: 1px solid var(--gold-border);
  max-width: 90vw;
  text-align: center;
}

.empty { text-align: center; color: var(--muted); padding: 28px 16px; }
.profile-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 2px solid var(--gold-border);
  margin-bottom: 12px;
  object-fit: cover;
}

.sync-banner {
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 207, 92, 0.35);
  background: rgba(255, 207, 92, 0.1);
  font-size: 14px;
  line-height: 1.5;
}

.sync-banner strong { color: var(--gold); }

.sync-banner .sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.sync-banner.ok {
  border-color: rgba(138, 226, 130, 0.35);
  background: rgba(138, 226, 130, 0.08);
}

@media (min-width: 768px) {
  .content { max-width: 760px; margin: 0 auto; width: 100%; }
  .bottom-nav { max-width: 760px; left: 50%; transform: translateX(-50%); border-radius: 22px 22px 0 0; }
}
